You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Parser fails to parse a heredoc that includes the delimiter in the body #124
considers the DOC inside the body of the string to be the heredoc delimiter, despite not being on its own line.
A naive update to the grammar would be to add \n\s* in front of the final (?P=heredoc_trim). This however breaks the grammar for the empty heredoc:
foo = <<BAR
BAR
where a single \n between the two lines is consumed by the \n after the leading delimiter: <<(?P<heredoc>[a-zA-Z][a-zA-Z0-9._-]+)\n.
Since lark doesn't support regexp "lookbehinds", a more elaborate solution would be to rewrite the grammar and transformer to:
The parser to not consume the \n after the leading delimiter; use a lookahead instead:
<<(?P<heredoc>[a-zA-Z][a-zA-Z0-9._-]+)\n -->
<<(?P<heredoc>[a-zA-Z][a-zA-Z0-9._-]+)(?=\n)
This would leave an extra \n for the final delimiter in the empty string case. With the current transformer, this would also leave the leading \n in the string body (and consume the final one which is currently being trimmed by the transformer), so the transformer will also have to change to remove one leading \n from the string.
This sounds like it could be more pretty, so maybe there's a better way to achieve this.
Activity
kkozik-amplify commentedon Mar 19, 2025
This was fixed in #194 and will be released in the next version.