elixir-lang / tree-sitter-elixir

Elixir grammar for tree-sitter
https://elixir-lang.org/tree-sitter-elixir
Apache License 2.0
245 stars 24 forks source link

Ignore heredoc end delimiter unless in a new line #28

Closed jonatanklosko closed 2 years ago

jonatanklosko commented 2 years ago

Given

"""
hey """
"""

we currently treat the second """ as end delimiter, which is not correct.

This PR essentially adds a constraint, such that when parsing heredoc content, we recognise end delimiter only when it goes in a new line (with optional leading whitespace).

As a side effect, we now don't distinguish escaped newlines (\<enter>) inside heredocs, otherwise we wouldn't treat \<enter>""" as end delimiter. I tried a number of things and I don't see any solution with reasonable complexity. In practice this means we won't highlight \ in this particular case, which seems fine to me.