whitequark / parser

A Ruby parser.
Other
1.57k stars 197 forks source link

Heredocs spanning other content #1017

Open kddnewton opened 1 month ago

kddnewton commented 1 month ago

First of all, let me say I'm sorry for reporting this at all. This is some ridiculous syntax.

<<-A; %Q[h\
g
A
h]

This should be two expressions: "g" and "hh". In an AST, it would look like:

s(:begin,
  s(:str, "g\n"),
  s(:dstr,
    s(:str, "h"),
    s(:str, "h")))

But this gem is duplicating part of the string, resulting in:

s(:begin,
  s(:str, "g\n"),
  s(:dstr,
    s(:str, "hg\n"),
    s(:str, "h")))

I assume because it's not skipping past the heredoc contents.