Skip to content

Why is the lambda being parsed as an identifier instead of a keyword in this grammar? #3386

Closed Answered by amaanq
LaBatata101 asked this question in Q&A
Discussion options

You must be logged in to vote

I think the problem in this case lies with how you've implicitly defined lexical precedence between _top_level_identifier and _id.

It's mentioned in the docs but it's not something that's immediately obvious, but when you place two terminals (e.g. patterns formed from a regex or literals formed from a string) one after the other, tree-sitter will assign the first one a higher lexical precedence, and in this case we're talking about _top_level_identifier being higher than _id. Then, you happen to make _id the word token, meaning that tree-sitter will attempt to lex these whenever tokens like 'lambda' are valid too - and here comes the problem. We are trying to see if either the word _id or…

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@LaBatata101
Comment options

@amaanq
Comment options

@LaBatata101
Comment options

@amaanq
Comment options

@LaBatata101
Comment options

Answer selected by LaBatata101
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