Search code examples
bnf

Modifying the BNF grammar to allow new binary operation


I am going through the concept BNF. I got to know how to draw the syntax trees and finding the ambiguous grammar. I came to know that the grammar can be modified and the new binary operation(&) an be added to the existing grammar with implied precedence. I have searched alot to find how to do that but I am left with no clue.. I have the following grammar

E::= E+T|T
T::= T*F|F
F::='('E')'|a|b|c

Can anyone give me some insight on this


Solution

  • E::= E+A|A
    A::= A&T|T
    T::= T*F|F
    F::='('E')'|a|b|c