Closed alcides closed 4 years ago
You are giving _PIPE
a high priority, so ||
is parsed as _PIPE _PIPE
. That is intended behavior. Why is this a problem?
Also, not using lexer='standard'
also fixes this problem.
I believed the disambiguation was through the longest sequence first and only then the priority.
I wanted _PIPE rule in order for where to have higher priority than word, but i wanted "||" to have higher priority than "|" in that particular context.
I have fixed my problem, but maybe this behaviour should be clear in the documentation. Most other parsing tools prioritize length over relative priority.
Yes, Lark does that too. You have to take three extra steps to convince Lark to not parse this correctly:
standard
lexer instead of the default contextual
, which almost never is a good idea (Slower performance, and these kind of problems)Why are you using the standard
lexer?
No reason at all. Probably because I thought it was the default (standard has a very defaulty name).
Describe the bug
Using "|" and "||" as terminals in lark rules works well independently.
However, when one defined "|" as a TOKEN, the following "||" in the rule stops working. I do not believe it is a grammar problem, as I have shown this to occur in the very simple hello world grammar below.
To Reproduce
The following code:
Returns this output: