I need to convert the following grammar to EBNF:
<assign> -> <id> = <expr>
<id> -> A|B|C
<expr> -> <expr> + <expr>
|<expr> * <expr>
|<expr> * <expr>
|( <expr> )
|<id>
The progress I’ve currently made is below:
<assign> -> <id> = <expr>
<id> = (A | B | C)
<expr> -> <id> {(+ | * ) <expr>} | ‘(‘ <expr> ‘)’
Is it best to eliminate all recursion if using EBNF? Is there even a way to accomplish it using only <id> in <expr>?
How about this:
No left recursion, and
*takes precedence over+, but not over( ... ).