Closed aha79 closed 1 year ago
This is probably happening just because of the default priority of terminals adjusting slightly due to different hashes in each run. (and maybe with the additional complication of interacting with shift/reduce collisions)
The real problem seems to me that SETCHAR
and PATTCHAR
can match the same character, and there is no way for LALR to know which one to choose. I recommend that you either set their priorities explicitly (like SETCHAR.10
), or use the Earley parser.
Thank you for your prompt response.
I was (perhaps incorrectly) assuming that inside the "[" atom* "]"
only the SETCHAR terminal is expected and hence only this token generated by the lexer.
I solved it this way
XCHAR: /[^\^\$\\\.\+\?\*\(\)\[\]\{\}\|\-]/
pattchar: XCHAR
| "-"
setchar: XCHAR
| /[\^\$\.\+\?\*\(\)\[\{\}\|]/
which is perfectly fine for me.
inside the "[" atom* "]" only the SETCHAR terminal is expected
Lark can do that to some degree with LALR, but not perfectly. I think that they're both included because they are both in the FOLLOW set of null_escape
.
Describe the bug
Identical grammar gives "UnexpectedToken" error.
To Reproduce
Consider the following code
Raises error
However when I change to
no exception is generated.
Also when I omit the star in first rule, i.e.
main: char
no error is generated. However this changes the grammar of course.I have no idea why this is the case, but I suspect this must be some kind of bug.
I use version 1.1.5.