Menu

(Solved) : Consider Following Bnf Grammar Arithmetic Expressions Incorporates Unary Operator E Term Q27384134 . . .

. Consider the following BNF grammar for arithmetic expressions,which incorporates the unary “−” operator:

< E > → < term > | < term > + < E >

< term > → < primary > | < primary > * <term >

< primary > → < id > | “(” < E > “)” | − <primary >

1- Give the parse tree for each of the following:

x + y * z

( x + y ) * z

x + y + z

x * y * z

x + − y * − z

− ( x + y ) * z

2- According to this grammar, are the + and * operatorsleft-associative or right-associative, which?

3- Expand this grammar to incorporate the binary subtraction anddivision operators “−” and “/” with their proper precedence.

Expert Answer


Answer to Consider Following Bnf Grammar Arithmetic Expressions Incorporates Unary Operator E Term Q27384134 . . .

OR