{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

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

Info icon This 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
Image of page 1

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

View Full Document Right Arrow Icon
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 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 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

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern