Question

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 r3 s4 r3 5 3
3 s6
4 s2 r3 s4 r3 5 7
5 r5 r5
6 s2 r3 s4 r3 5 8
7 r4 r4
8 r2 r2
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Explanation For given Solution:

In step number 1 , stack content is $I0, where $ indicates stack start symbol and I0 is initial state.In table(Action/Goto), On state I0 if input symbol is ( , shift action occur and symbol shift into stack.

All shift actions in this manner only.

In step number 4 there is no ymbol on RHS of production so just place S into stack and if I2 gets S in gototablegoes to I5, so put I5.

In state number 16 when we reducing there are 4 symbols on RHS of production so remove 8(4multiply by 2)symbols from stack.

For complete solution see the images.

have to parse the third (21))5%) (21))526), t shift to (12 15) ) 61(1 214 (121 1s )54 リー 2101, 24117, redue S-E vedute Sa (1)

See step number 16. Here I7 and input ) , reduce by production number4. i.e L->int L

Now Stack content would be $I0(I2LI3)I6LI8

Now reduce by second production , After reduction stack contend would be $I0I1 .

For I1 and ) , there is no entry in table means error

Add a comment
Know the answer?
Add Answer to:
1.Use the action/goto table for the grammar below (where the productions are as numbered) to parse...
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
  • Show a complete bottom-up parse, including the parse stack contents, input string, and action for the...

    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: Then show a rightmost derivation for the string above and show how the bottom up parse correctly finds all of the handles. R-reduce S-Shift - Error id S4 S5 S6 S7 Accept R1 R1 R1...

  • 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...

  • Need help with Programming Language plz. (15) Consider this grammar and given table: S -(L) L-L,S L-S rocess the string (a, (a, a)) using the table and showing the steps for processing ach input....

    Need help with Programming Language plz. (15) Consider this grammar and given table: S -(L) L-L,S L-S rocess the string (a, (a, a)) using the table and showing the steps for processing ach input. Remember that each imput string has an implied at the end of it. Be sure o show all work to get full credit for the question Goto Action State a S3 S2 S3 S2 12 12 r3 S6 S7 r4 r4 S3 S2 r3 r3 r3...

  • Use the program listing below to answer the questions that follow. Note that this is not...

    Use the program listing below to answer the questions that follow. Note that this is not a working program. The intent of the assignment is for you to apply your knowledge of structural testing to answer the accompanying testing questions. 1. public static void main(String[] args) { 2. double a1 = 1.0; 3. double a2 = 2.0; 4. double a3 = 3.0; 5. if (cl) { 6. r1 = rate * 1.1; 7. r2 = rate * 2.1; 8. }...

  • (10] Eliminate left recursion from the grammar A Ba |Aa c B Bb | Ab 1...

    (10] Eliminate left recursion from the grammar A Ba |Aa c B Bb | Ab 1 d A Ad IB A BA ASJAE Consider the following grammar G: S'S S (S)S|e fa) (10] Construct the collection of the sets of LR(0) items (b) [5] When constructing the action table of SLR parser of G what are the rules to determine the parsing actions? That is, what is the rule for a shift action at state /? What is the rule...

  • Implement the following statements using MS430 assembly instructions. You may use more than one, ...

    Implement the following statements using MS430 assembly instructions. You may use more than one, but you should minimize the number of instructions required. You can use both native and emulated instructions. Use hex notation for all numbers 1. (a) Move the word located in register R14 to R15 (b) Increment the word in R6 by 2. (c) Perform a bitwise ANDing of the word located at address 0x0240 with the datum in R15, placing the results in R15. (d) Rotate...

  • Which part of this program is used for input one context free grammar? And if you...

    Which part of this program is used for input one context free grammar? And if you want to give another different context free grammar, how to do that? code: #include<stdio.h> #include<stdlib.h> #include<string.h> #define MaxVtNum 20 #define MaxVnNum 20 #define MaxPLength 20 #define MaxSTLength 50 char stack[20]={'#','E'}; char input[MaxSTLength]; char termin[MaxVtNum]={'i','+','*','(',')','#'}; char non_termin[MaxVnNum]={'E','G','T','H','F'}; struct product{ char left; char right[MaxPLength]; int length; }; struct product E,T,G,G1,H,H1,F,F1; struct product M[MaxVnNum][MaxVtNum]; int flag=1; int top=1; int l; void print_stack(){ } } } } }...

  • 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...

  • 5. Consider the SPIM code below. globl main .text main: ori $t1, $0, 10 ori $t2,...

    5. Consider the SPIM code below. globl main .text main: ori $t1, $0, 10 ori $t2, $0, 11 add $t3, $t1,$t2 move $t4, $t3 The following image shows a screen shot of QtSPIM page when this program is loaded, and executed in step-by step fashion. Current instruction is highlighted. Data Text x Text Regs Int Regs [16] Int Regs [16] PC = 400028 EPC 0 Cause = 0 BadAddr = 0 Status = 3000ff10 HI LO = 0 = 0...

  • ASSIGNMENT 7: FINANCIAL ACCOUNTING Note: 1. Value Added Tax (VAT) must be ignored 2. Use the form...

    All questions need to be answered please. From questions 1 to question 5. ASSIGNMENT 7: FINANCIAL ACCOUNTING Note: 1. Value Added Tax (VAT) must be ignored 2. Use the formats contained in your study guide to answer questions 2 to 5 (20) QUESTION 1 REQUIRED For each of the following questions, write down only the letter of the correct answer e.g. 1.6 C. Do not shovw any calculations. 1.1 he following information relates to an item of inventory sold by...

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