tree-sitter / tree-sitter-ocaml

OCaml grammar for tree-sitter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

conversion_specification are not recognzed within quoted strings

undu opened this issue · comments

Quoted string don't contain escape sequences, but they can contain conversion specifications, they should be added. For validation purposes an example should be added to https://github.com/tree-sitter/tree-sitter-ocaml/blob/master/ocaml/corpus/expressions.txt

That would indeed be nice, but I'm not sure it's possible. Quoted strings are parsed by an external scanner because there is no other way to check that the opening and closing id's match. But external scanners can only return terminal symbols, so they can't contain anything else.

In Ruby, the external scanner parses strings' start and end delimiters as separate tokens, and in between it stores the delimiters as state. If we wanted to, we could do the same thing here. I'm not sure if it's worth the complexity, but possible.