Answered step by step
Verified Expert Solution
Question
1 Approved Answer
please help me with this homework problem, and please explain how to do it 1. Context free grammars, LL and LR parsing Consider the following
please help me with this homework problem, and please explain how to do it
1. Context free grammars, LL and LR parsing Consider the following simple context free grammars Grammar Gi Grammar G2 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 G1 LR(1)? Is it LR(O)? (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 t LR(0)? (c) Indicate whether Gi and G2 are LL(1). You don't need to construct their LL(1) parse tables, but you may argue from other properties. (d) Of the language classes we have discussed in class, what is the smallest category into which L (G) fits? Justify your answer. [Hint: This is a trickStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started