homework2

homework2 - Homework 2 CSC 4101, Fall 2011 Due: 30...

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

View Full Document Right Arrow Icon
Homework 2 CSC 4101, Fall 2011 Due: 30 September 2011 1. (10 pts) Consider the following grammar for variable and class declarations in Java: <Decl> -> <VarDecl> | <ClassDecl> <VarDecl> -> <Modifiers> <Type> <VarDec> SEM <ClassDecl> -> <Modifiers> CLASS ID LBRACE <DeclList> RBRACE <DeclList> -> <Decl> | <DeclList> <Decl> <VarDec> -> ID | ID ASSIGN <Exp> | <VarDec> COMMA ID | <VarDec> COMMA ID ASSIGN <Exp> Indicate any problems in this grammar that prevent it from being parsed by a recursive-descent parser with one token lookahead. Transform this grammar into a form that can be parsed with a recursive-descent parser with one token lookahead. Make as few changes to the grammar as possible. Do not use Extended BNF. 1
Background image of page 1

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

View Full DocumentRight Arrow Icon
2. (10 pts) Consider the following grammar S -> A M M -> S | A -> a E | b A A E -> a B | b A | B -> b E | a B B Show a derivation for the string ‘ a b a a ’. Start with S => A M => . . . and in each step replace one nonterminal by the right-hand side of a grammar rule until you end up
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 12/31/2011 for the course CSC 4101 taught by Professor Kraft,d during the Fall '08 term at LSU.

Page1 / 4

homework2 - Homework 2 CSC 4101, Fall 2011 Due: 30...

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

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