Replies: 1 comment 1 reply
-
Yes, it does the same thing regardless of the arity of the sequence. In general, precedence tells Tree-sitter to always prefer to try parsing one rule over another. When using it, you often need to clearly understand when Tree-sitter would need to decide between the different conflicting options. The decision may be required earlier than you realize, causing the parser to commit too early to one alternative or another. One tool that can be helpful in debugging this is running |
Beta Was this translation helpful? Give feedback.
-
My question is from my previous question: #781.
Basically I defined comma expression like
x=1,x
, and equality comparison expression likex=x
, and I want comma expression have lower precedence, thus parsingx=1,x=x
as(x=1),(x=x)
, instead of(x=1,x)=x
:but it gives following error when parsing
x=1,x=x
:Finally my solution was separating
expression_comma
into 2 rules, as described in my comment, but I still don't know why I must do so.My question is: does
prec
work withseq
whose arity is greater than 3, or to put it in another way, does it work with a structure other than "operand-operator-operand"? If yes, What's wrong in my case?Thanks.
Beta Was this translation helpful? Give feedback.
All reactions