How to remove ambiguity in EBNF Instaparse grammar

151 views Asked by At

How can i prevent that the "," literal in the structure rule is parsed as a operator in the following EBNF grammar for Instaparse?

Grammar:

structure = atom <"("> term ("," term)* <")"> 
term = atom | number | structure | variable | "(" term ")" | term operator term
operator = "," | ";" | "\\=" | "=="
1

There are 1 answers

0
Uran On

Using the comma as a separator and as an operator like you do makes comma context sensitive which Ebnf on its own can't deal with.