Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Context free grammars, LL and LR parsing Consider the following simple context free grammars: Grammar G1 G +AS A A+ Ab Grammar G2: GAS

image text in transcribed

1. Context free grammars, LL and LR parsing Consider the following simple context free grammars: Grammar G1 G +AS A A+ Ab Grammar G2: GAS A + A Abb The start symbols are G, the nonterminals are G and A, and the terminal symbols are b and $ (end of file). Note that these grammars generate the same language: strings consisting of even numbers of b symbols (including zero of them). a. Attempt to show a shift-reduce parse of the input string bbbb for a parser for grammar G1. Show the contents of the stack, the input, and the actions in the style of Figure 3.18 on Page 58 but without the subscripts for the parse states). Indicate any conflicts and describe why they are conflicts. Is G LR(1)? Is it LR(0)? b. Attempt to show a shift-reduce parse of the input string bbbb for a parser for grammar G2. Show the contents of the stack, the input, and the actions in the style of Figure 3.18 on Page 58 but without the subscripts for the parse states). Indicate any conflicts and describe why they are conflicts. Is G2 LR(1)? Is it LR(O)? c. Indicate whether G and G2 are LL(1). You don't need to construct their LL(1) parse tables, you can argue from other properties. d. Of the language classes we have discussed in class, what is the smallest category into which L(G1) fits? Justify your answer. (Hint: This is a trick

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

Database Systems For Advanced Applications 17th International Conference Dasfaa 2012 Busan South Korea April 2012 Proceedings Part 1 Lncs 7238

Authors: Sang-goo Lee ,Zhiyong Peng ,Xiaofang Zhou ,Yang-Sae Moon ,Rainer Unland ,Jaesoo Yoo

2012 Edition

364229037X, 978-3642290374

More Books

Students also viewed these Databases questions