Trouble defining comments in Liquid templating language #3012
Unanswered
hankthetank27
asked this question in
Q&A
Replies: 1 comment 1 reply
-
What about using a regex like this |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm new to tree sitter, and have been working on implementing a forked grammar for the Liquid HTML templating language. I've had reasonable success defining many of the language constructs, but have encountered a lot of trouble with the comments.
In the language you declare a comment if the following way:
I'd like to implement it by consuming all charters between the tags, something like this...
...which clearly does not work correctly because once tree sitter encounters any
_tag_delimiter_open
token afterrepeat(/./)
, it consumes it and subsequently errors on identifying any non"endcomment"
token.For example:
I've tried several approaches regarding fixes, including wrapping the
"endcomment"
token and its delimiters as a token with a higher precedence, and trying do replicate something similar to how the Ruby tree sitter grammar handles multi-line comments (which quickly became very unwieldy with trying to handle the delimiter options and spaces) to no avail.Would implementing a scanner be the best approach to cracking this? I'm open to any suggestions or ideas as I don't really know what I'm doing too well :p
Beta Was this translation helpful? Give feedback.
All reactions