tree-sitter/tree-sitter-ruby

heredoc_body should not be declared as an extra

mjambon opened this issue · 2 comments

I'm not sure why heredoc_body is declared as an extra i.e. a node that can occur anywhere, like a comment.

If it occurred in a grammar rule, such as after heredoc_beginning, then could have it in the typed CST we generate with ocaml-tree-sitter.

The rule for heredoc bodies is that they start on the next line after a heredoc start, no matter what is going on syntactically. I don't really think there's a good way to model them in the grammar besides including them as an extra.

See the corpus tests for examples of the different ways that they can combine with syntactic constructs.

oh. Great examples. That makes a ton of sense.

I guess a solution for ocaml-tree-sitter is to make a first pass on the tree to pair the heredoc_beginning with the next heredoc_body, or something like this.