Ex#5: Given the following grammar for a simple assignment
statements.
<assign> --> <id> = <expr>
<id> --> A | B | C
<exp> --> <id> + <expr> | <id> *
<expr> | (<expr>) | <id>
Show a leftmost derivation and a parse tree of the following
statement:
A = A *(B + (C * A))
LEFT MOST DERIVATION
<assign>
<id> = <expr>
A = <expr>
A = <id> * <expr>
A = A * <expr>
A = A * (<expr>)
A = A * (<id> + <expr>)
A = A * (B + <expr>)
A = A * (B + (<expr>))
A = A * (B + (<id> * <expr> ))
A = A * (B + (C * <expr> ))
A = A * (B + (C * <id>))
A = A * (B + (C * A))
PARSE TREE
PLEASE UP VOTE
Get Answers For Free
Most questions answered within 1 hours.