Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please help me to get the answer. thank you! 5. (20) Parsing. Consider the CFG for in the slides for parsing (around P16). Trace the

image text in transcribed

image text in transcribed

image text in transcribed

please help me to get the answer. thank you! 5. (20) Parsing. Consider the CFG for in the slides for parsing (around P16). Trace the table driven parser on the following input program, as done in the class discussion: sum := A + B write sum. LL(1): example grammar 1 1 1 1. $$ 2. - | 3. id : = read id | write 4. 5. | E 6. 7. - | E 8. + ( ) | id | number 9. - + | - 10. + * / Top-of-stack nonterminal id Current input token write : = ( ) number read + - * 1 program stmt_list stmt expr term_tail term factor_tail factor add_op mult_op 14 16 - 17 - - 18 19 1. program + stmt_list $$ {id, read, write, $$} 2. stmt_list + stmt stmt_list {id, read, write} 3. stmt_list + {$$} 4. stmt id := expr {id} 5. stmt + read id {read} 6. stmt write expr {write} 7. expr + term term_tail {(, id, number} 8. term_tail add_op term term_tail {+, -} 9. term_tail +{), id, read, write, $$} 10. term + factor factor_tail {(, id, number} 11. factor_tail + mult_op factor factor_tail {*,/} 12. factor_tail e{+, -, ), id, read, write, $$} 13. factor + ( expr ) {(} 14. factor id {id} 15. factor + number {number} 16. add op ++{+} 17. add_op 7-{-} 18. mult_op *{*} 19. mult_op +/{7} please help me to get the answer. thank you! 5. (20) Parsing. Consider the CFG for in the slides for parsing (around P16). Trace the table driven parser on the following input program, as done in the class discussion: sum := A + B write sum. LL(1): example grammar 1 1 1 1. $$ 2. - | 3. id : = read id | write 4. 5. | E 6. 7. - | E 8. + ( ) | id | number 9. - + | - 10. + * / Top-of-stack nonterminal id Current input token write : = ( ) number read + - * 1 program stmt_list stmt expr term_tail term factor_tail factor add_op mult_op 14 16 - 17 - - 18 19 1. program + stmt_list $$ {id, read, write, $$} 2. stmt_list + stmt stmt_list {id, read, write} 3. stmt_list + {$$} 4. stmt id := expr {id} 5. stmt + read id {read} 6. stmt write expr {write} 7. expr + term term_tail {(, id, number} 8. term_tail add_op term term_tail {+, -} 9. term_tail +{), id, read, write, $$} 10. term + factor factor_tail {(, id, number} 11. factor_tail + mult_op factor factor_tail {*,/} 12. factor_tail e{+, -, ), id, read, write, $$} 13. factor + ( expr ) {(} 14. factor id {id} 15. factor + number {number} 16. add op ++{+} 17. add_op 7-{-} 18. mult_op *{*} 19. mult_op +/{7}

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

Step: 3

blur-text-image

Ace Your Homework with AI

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

Get Started

Recommended Textbook for

Big Data, Mining, And Analytics Components Of Strategic Decision Making

Authors: Stephan Kudyba

1st Edition

1466568704, 9781466568709

More Books

Students also viewed these Databases questions