Question: expr -> expr addop term | term addop -> + | - term -> term mulop factor | factor mulop -> * factor -> (expr)
expr -> expr addop term | term
addop -> + | -
term -> term mulop factor | factor
mulop -> *
factor -> (expr) | num
Consider the grammar above and the token string: num+num*(num+num)
a. Show a leftmost derivation of the string.
b. Show a rightmost derivation of the string.
c. Show the parse tree (not an Abstract Syntax Tree) corresponding to the leftmost derivation you gave in part (a).
d. Would the parse tree corresponding to a rightmost derivation be the same as you came up with in part (c)? Why or Why not?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
