Skip to content

[question] Is this a bug? I can't seem to skip over an optional block #1665

Closed Answered by maxbrunsfeld
Claudenw asked this question in Q&A
Discussion options

You must be logged in to vote

You have user as its own distinct token in your grammar:

        user : $ => token( user ),

But that means that you're asking the lexer to distinguish between a user token and any other usage of qname. The lexer doesn't have enough information to do that: it's just matching regular expressions. When two different tokens both match the same sequence of characters, the lexer has very limited options for how to decide between the two: see the documentation about conflicting tokens: https://tree-sitter.github.io/tree-sitter/creating-parsers#conflicting-tokens.

In your case, the lexer is probably picking the keyspace rule semi-arbitrarily, because it is listed first in the grammar.

You should …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Claudenw
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #1664 on February 25, 2022 00:50.