hw2 - without the subscripts for the parse states)....

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
HW 2: Syntax Analysis CSC 4351, Spring 2011 Due: 28 February 2011 1. Context free grammars, LL and LR parsing Consider the following simple context free grammars: Grammar G 1 Grammar G 2 G A $ G A $ A ǫ A ǫ A bAb 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 G 1 . 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 1 LR(1)? Is it LR(0)? (b) Attempt to show a shift-reduce parse of the input string bbbb for a parser for grammar G 2 . Show the contents of the stack, the input, and the actions (in the style of Figure 3.18 on Page 58 but
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: without the subscripts for the parse states). Indicate any conflicts and describe why they are conflicts. Is G 2 LR(1)? Is it LR(0)? (c) Indicate whether G 1 and G 2 are LL(1). You dont 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 1 ) fits? Justify your answer. [Hint: This is a trick question!] 1 2. LL Parsing Given the following grammar: S uBDz B Bv B w D EF E y E F x F (a) Calculate nullable, FIRST, and FOLLOW for this grammar. (b) Construct the LL(1) parsing table and give evidence that this grammar is not LL(1). (c) Modify the grammar as little as possible to make an LL(1) grammar that accepts the same language. 2...
View Full Document

Page1 / 2

hw2 - without the subscripts for the parse states)....

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online