hw6 - Problem 3 – LR Grammars Prove that the right end of...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
CS 415 Compilers: Problem Set 6 Due date: Wednesday, April 7, 2010, before recitation Problem 1 – LR(1) Parsing 1 S’ ::= S 2 S ::= L = R 3 | R 4 L ::= * R 5 | id 6 R ::= L 1. Compute the canonical collection of sets of LR (1) items 2. Construct the LR (1) parse table 3. Is the grammar LR (1) or not? Justify your answer. 4. If the grammar is LR (1), show the behavior of the LR (1) parser on input *id = id , i.e., show stack content, current input, and selected action for each move of the machine. Problem 2 – LR(0) Grammars Show that the above grammar (Problem 1) is not LR(0). Note that it is sufficient to show one state where there is a conflict (Hint: you don’t need to enumerate all states).
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Problem 3 – LR Grammars Prove that the right end of the current handle has to be at the same position as the previous handle, or to the right of the previous handle. Without loss of generality, assume that a reduction for a rule for non-terminal A has just been performed, i.e., we successfully derived the right sentential form X 1 X 2 . . . X n A y ⇒ * R xy where xy is the input word, A is a non-terminal, and X 1 . . . X n are symbols (terminal or non-terminal). You need to show that the right end of the next handle must be to the right of non-terminal A. Hint: Use proof by contradiction....
View Full Document

This note was uploaded on 10/29/2010 for the course CS 198:415 taught by Professor Kremer,u. during the Spring '10 term at Rutgers.

Ask a homework question - tutors are online