Question

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>?

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top