Closed jjalowie closed 1 year ago
The problem isn't with Lark.
You forgot to account for the whitespace, so the parser failed to match struct_def.
The following grammar works as expected (there is no need to specify priority):
start: (struct_def | other)*
other: OTHER
OTHER: /[^\\n]+/
STRUCT: "struct"
struct_def: STRUCT CNAME
%import common.CNAME
%import common.WS
%ignore WS
Thanks!
What is your question?
I have the following grammar:
Why does everything get matched as
other
despite setting a higher priority forstruct_def
?If you're having trouble with your code or grammar
Python code reproduction:
The above code produces the following output:
I would expect the
struct qwerty
input text to be parsed asstruct_def STRUCT qwerty
.Explain what you're trying to do, and what is obstructing your progress.
I'm trying to write a parse of
struct
s for a C-like language. I want to ignore everything except forstruct
definitions. I don't understand why theother
rule is fired before thestruct_def
rule.