Question

Show a complete bottom-up parse, including the parse stack contents, input string, and action for the string below using the parse table

String: (id+id) * id

Grammar(language) :

E -> E + T |E * T | T

T -> (E) | id

Parse table:

R-reduce S-Shift - Error id S4 S5 S6 S7 Accept R1 R1 R1 R1 4 S4 S5 R6 R6 R6 R6 S4 S5 10 7 S4 S5 S6 R2 R3 R5 S7 R2 R3 R5 S11 R2 R3 R5 8 R2 R3 R5 10 Firsrt(T) = {c, id Follow(E) S,+,*.)) First(E)[c, id) Follow(T)-($,+,*

Then show a rightmost derivation for the string above and show how the bottom up parse correctly finds all of the handles.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

It seems one accidental mistake in The Table given by you. In row I3, It will be R4 instead of R1.

I have provided modified table below(bolden)

R-reduce S-Shift - Error id S4 S5 S7 Accept S6 R4 R4 R4 R4 4 S4 S5 R6 R6 R6 R6 S4 S5 10 7 S4 S5 S6 R2 R3 R5 S7 R2 R3 R5 S11 R

The following is the answer

Bottom up Parsing with given parsing table

Configuration of stack content and input string

   Stack                                                  InputString

I1 x1S1 x2S2..xmSm                       ai ai+1..    am$

                                                I1: initial Items,

x1: symbols   Sm: state , ai: symbols in input string

Parsing rule:

Check the entries in Action Table.

  1. If ACTION[sm,ai]=Shift N, then make a shift move , the configuration will be as below

I1 x1S1 x2S2..xmSm aiN                ai+1..    am$

  1. If ACTION[sm,ai]=Reduce a->? ,then make a reduce move, Configuration will be as below

I1 x1S1 x2S2..xmSm xm-rSm-rAN              ai ai+1..    am$

Where r=len[?],   A=Production head

N: entry in the GOTO[sm-r,A]                   

  1. If ACTION[sm,ai]=ACCEPT, ,parsing completed successfully.
  2. If ACTION[sm,ai]=EROR,   the string cannot be parsed

TAC ACTION Shift 4 shift 5 Reduce by R6 ieT->id Reduce by R4 le E->T Shift 6 shift 5 Reduce by T->id Reduce by E->E+T shift 1

2 ナナブブ

Add a comment
Know the answer?
Add Answer to:
Show a complete bottom-up parse, including the parse stack contents, input string, and action for the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Name: 3. (10 points) Given grammar: <program> → <stmts> Page: 2 <term> → <var> 1 const...

    Name: 3. (10 points) Given grammar: <program> → <stmts> Page: 2 <term> → <var> 1 const 1), write down derivation of: c-5+a 2) What are terminals and what are non-terminals in the grammar? 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 below. (10 points) 4. Grammar State id S4 4. T F 5. F (E) R2 S7 R4 R4 R2İR2 Parse...

  • (20 pts) Create an LR(O) parse table for the following grammar. Show all steps (creating closures,...

    (20 pts) Create an LR(O) parse table for the following grammar. Show all steps (creating closures, the DFA, the transition table, and finally the parse table): E->E+T E*T T T->(E) | id Show a complete bottom-up parse, including the parse stack contents, input string, and action for the string below using the parse table you created (id + id) * id Show a rightmost derivation for the string above, and show how the bottom-up parse you completed correctly finds all...

  • 1.Use the action/goto table for the grammar below (where the productions are as numbered) to parse...

    1.Use the action/goto table for the grammar below (where the productions are as numbered) to parse the incorrect input string:       ( 2 ( ) ) 5 ) 6 ) When the syntax error is detected, a) what does the stack look like, b) what was the last action and c) what is the lookahead? 1: R->S 2.S->(L)L 3.S-> ε 4.L->int L 5. L->S state ( ) int $ S L 0 s2 r3 r3 1 1 acc 2 s2...

  • Stack Operation 10. (10 pts.) Show the contents of the stack and affected registers at the two marked points in the exe...

    Stack Operation 10. (10 pts.) Show the contents of the stack and affected registers at the two marked points in the execution of the followin code. Assume RO-0, R1-1, R2-2, R3-3, R4-4, R5-5, and R6-6. The initial value for stack pointer (prior to executing this code block) is given as SP-0x20001000 PUSH R2,R3) ADD R4, R1, Re ;<---A POP R5, R6) ADD R5, R5, R4 ADD R6, R6, R5 PUSH (R4-R6); SUBS Re, RO,R1-B a) Show the contents of Stack,...

  • Step 6 is the answer of below question (20 pts) Create an LR(O) parse table for...

    Step 6 is the answer of below question (20 pts) Create an LR(O) parse table for the following grammar. Show all steps (creating closures, the DFA, the transition table, and finally the parse table): E->E+TE*TIT T->(E) | id (20 pts) Show a complete bottom-up parse, including the parse stack contents, input string, and action for the string below using the parse table you created in step 6. Think about how I went through this in class. (id + id) *...

  • PLEASE SHOW ALL WORK AND TO FOLLOW DIRECTIONS. PLEASE USE PSPICE. STUDENT ID= 7220849 2. Using...

    PLEASE SHOW ALL WORK AND TO FOLLOW DIRECTIONS. PLEASE USE PSPICE. STUDENT ID= 7220849 2. Using a DC Sweep analysis to generate a table of values in the .OUT file: See Circuit 2 below: Let R1 through R6 equivalent to the digits 1 through 6 in your StudentID in k12 (use 10 k22 for a digit of 0). • For example, if your StudentID is 9870654 then R1 =9 kN, R2 =8 kN, R3 = 7kN, R4 = 10KN, R5...

  • PLEASE SHOW ALL WORK AND TO USE PSPICE AND FOLLOW ALL DIRECTIONS. STUDENT ID=378564 Assignment: 1....

    PLEASE SHOW ALL WORK AND TO USE PSPICE AND FOLLOW ALL DIRECTIONS. STUDENT ID=378564 Assignment: 1. For the Circuit 1 shown below: A. Analyze the circuit by hand as described in the textbook. B. Analyze the circuit using PSPICE as follows: Use a Bias Point analysis to find the quantities found in part A above. Be sure to add text to the schematic as indicated in the Sample Report. Adjust the placement of each value on the schematic so that...

  • Note: The question needs to be answered in "C Programming Languange ". And after the question fin...

    Note: The question needs to be answered in "C Programming Languange ". And after the question find 3 pages for needed informations. Spring CE4717 Language Processors Q1. Consider the following LEx program. return R1 return R2 return R3 return R4 return R5; return R6; IA-2a-z)[A-Za-z0-9]- -2 10-91+ 10-9a-EA-FI Ihi] [01] [01] 이삐 t Vtin) int main (void) int tcode; do f tcode -yylex()i printf ("token type td \"%s\"\n", tcode, yytext); ) while (tcode)i return 0; i. Explain the steps needed...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT