Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(20) Parsing Consider the CFG for in the slides (of L6) for parsing (Page 16), and an input program sum := A + B write

image text in transcribed

image text in transcribed

image text in transcribed

(20) Parsing Consider the CFG for in the slides (of L6) for parsing (Page 16), and an input program sum := A + B write sum. (a) Trace the table driven parser as done in the class discussion. You can use a table for tracing as we did in L6 slides. (b) Trace the recursive descent parser (starting from the main function in P29 of L6 slides). You may write the function call sequences (and changes of global variable input_token) in executing the parser on the input program as shown below. If any function is missing, you can create your own following the problem decomposi- tion method we used during class. Note. To design the recursive descent parser, the best way is still the use of problem decomposition method following each pro- duction. This tracing just help you to see that it does work. program () | --stmt_list() // input_token: sum | ----stmt () // input_token: ? -stmt_list() // input_token: ? | --match ($$) outputs true/false which is returned LL(1): example grammar 1. $ $ 2. 3. id : = | read id | write 4. + E 6. * 7. | 8. ( ) | id | number 9. 10. - Main function input_token: current token of the input program. A global variable main () { // get the first token input_token = scan () ; return (program () ); } 29 (20) Parsing Consider the CFG for in the slides (of L6) for parsing (Page 16), and an input program sum := A + B write sum. (a) Trace the table driven parser as done in the class discussion. You can use a table for tracing as we did in L6 slides. (b) Trace the recursive descent parser (starting from the main function in P29 of L6 slides). You may write the function call sequences (and changes of global variable input_token) in executing the parser on the input program as shown below. If any function is missing, you can create your own following the problem decomposi- tion method we used during class. Note. To design the recursive descent parser, the best way is still the use of problem decomposition method following each pro- duction. This tracing just help you to see that it does work. program () | --stmt_list() // input_token: sum | ----stmt () // input_token: ? -stmt_list() // input_token: ? | --match ($$) outputs true/false which is returned LL(1): example grammar 1. $ $ 2. 3. id : = | read id | write 4. + E 6. * 7. | 8. ( ) | id | number 9. 10. - Main function input_token: current token of the input program. A global variable main () { // get the first token input_token = scan () ; return (program () ); } 29

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

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2018 Dublin Ireland September 10 14 2018 Proceedings Part 1 Lnai 11051

Authors: Michele Berlingerio ,Francesco Bonchi ,Thomas Gartner ,Neil Hurley ,Georgiana Ifrim

1st Edition

3030109240, 978-3030109240

More Books

Students also viewed these Databases questions

Question

Question What is a Roth 401(k) feature?

Answered: 1 week ago

Question

Question Can employees make contributions to a profit sharing plan?

Answered: 1 week ago