hw5 - ] = 3 MaxDepth[ ((a, a, a), (a, a)) ] = 2 YOU CAN USE...

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

View Full Document Right Arrow Icon
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 ::= , AC | 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)))
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: ] = 3 MaxDepth[ ((a, a, a), (a, a)) ] = 2 YOU CAN USE YOUR FAVORITE PROGRAMMING LANGUAGE FROM THE FOLLOWING OPTIONS: Java, C, C ++ , or Scheme You will need to submit your program and a ReadMe le that describes how to recom-pile and run your program. Your program has to run on the ilab cluster. In addition to the code, please submit a printout of your code. We will post the exact submission procedure on our news group (Sakai). Problem 2 1. LL(2) grammars allow predictive parsering with a lookahead of two tokens. Give a formal denition of an LL(2) grammar. (Hint: you will need to modify the denition of FIRST and FOLLOW sets). 2. Give a grammar that is LL(2), but not LL(1). Prove your claim formally. 3. Describe the class of programming languages that can be recognized by LL(0) gram-mars....
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.

Page1 / 2

hw5 - ] = 3 MaxDepth[ ((a, a, a), (a, a)) ] = 2 YOU CAN USE...

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