Question: Answer the two questions listed below click the link for the picture first. Draw number 1 and 2 out using the parse tree View the

Answer the two questions listed below click the link for the picture first.

Draw number 1 and 2 out using the parse tree

View the image first

https://ibb.co/mgOhRR

1. Given the expression grammar as following, draw the parse tree for the expressions (terminal, nonterminal) (20 points)

expr expr + term | expr - term | term term term * factor | term / factor | factor factor digit | ( expr )

digit 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9

a) 4-2+2/8

b) (3-2)*(8+5)/3

2. Given the statement grammar as following, draw the parse tree for the statements (terminal, nonterminal) (20 points)

stmt id = expr; | if expr then stmt | if expr then stmt else stmt |

while expr do stmt |{stmts} stmts stmts stmt | id a|b|c||z a) { a=expr; b=expr; } b) { x=expr; if expr then { a=expr; while expr do { b=expr; } } }

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!