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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!