{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# hw5 - = 3 MaxDepth(a a a(a a = 2 YOU CAN USE YOUR FAVORITE...

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

CS 415 Compilers: Problem Set 5 Due date: Wednesday, March 10, 2010, before recitation Problem 1 Consider the following grammar with start symbol A. 1 A ::= ( B ) | 2 a 3 B ::= A C 3 C ::= , A C | 4 epsilon 1. Compute the FIRST and FOLLOW sets for the grammar. 2. Compute the LL(1) parse table for the resulting grammar. Is the grammar LL(1) or not? Justify your answer. 3. If the resulting grammar is LL(1), show the behavior of the LL(1) skeleton parser (EAC Figure 3.8, p.106, or lecture 11, page 13) as a sequence of states [stack content, remaining input, next action to be taken] on sentence (a , (a, a)) (see lecture 11, page 14 and 15). 4. If the resulting grammar is LL(1), write a recursive descent parser for it. Insert code into the recursive descent parser such that the parser returns the maximal nesting depth of a items in the list. Examples: MaxDepth[ (a, a) ] = 1 MaxDepth[ (a, (a, (a, a)))

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.