Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Show a complete parse, including the parse stack contents, input string, and action for the string id+(id * id) using the grammar and parse table

Show a complete parse, including the parse stack contents, input string, and action for the string id+(id * id) using the grammar and parse table in Section 4.5.3 of Sebesta.

image text in transcribed

1. E -> E + T 2. E -> T 3. T -> T * F 4. T -> F 5. F -> (E) 6. F -> id

Example: id+id*id

image text in transcribed

Action Goto State Id + ( ) A E T F 0 S5 S4 1 2 3 1 S6 accept 2 R2 S7 R2 R2 3 R4 R4 R4 R4 4 SS S4 8 N 3 5 R6 R6 R6 R6 6 SS S4 9 3 7 SS S4 10 8 S6 S11 9 R1 S7 R1 R1 10 R3 R3 R3 R3 11 R5 RS R5 R5 Stack Action 0 Oids 03 OT2 OEI OE 1+6 0E1+6id5 0E1+6F3 OE1+6 T9 OE 1+6T947 0E1+6T9+7id5 0E1+6T947F10 OE1+6T9 OEI Input id + id * id s + id id $ + id id $ + id id $ + id id $ id * id s * id $ * id $ *id $ id S S S S S Shift 5 Reduce 6 (use GOTOCO,F) Reduce 4 (use GOTO[O, T) Reduce 2 (use GOTO'O, E) Shift 6 Shift 5 Reduce 6 (use GOTO[6, F) Reduce 4 (use GOTO[6,T]) Shift 7 Shift 5 Reduce 6 (use GOTO[7, F1) Reduce 3 (use GOTO[6, T)) Reduce 1 (use GOTOPO, ED) Accept

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions