I have the following basic BNF grammar:
<A> --> <id> = <E>
<id> --> A | B | C | D | F
<E> --> <E> + <T> | <T>
<T> --> <T> * <F> | <F>
<F> --> <E> | <id>
Operator (*) should have higher precedence over (+). However, see this statement:
A = A + B + C + D * F
The leftmost derivation (and parse tree) indicate the opposite! i.e., (+) has higher precedence than (*) since it will show up lower in the parse tree!
What am I missing here?
<F> --> ( <E> ) | <id>
in order to allow parenthesised expressions. As written, your grammar is highly ambiguous. $\endgroup$