Due: Friday, March 26 Grammar

Due: Friday, April 2 Lexer

Due: Friday, April 16 Parser

Due: Friday, April 30 AST's

Assignment #1

Tea BNF

10 points

Due Friday, March 26

Part 1 Tea grammar

Tea is a subset of Java. Tea programs consist of simple type definitions followed by executable statements. We will implementing the executable statements.

Executable statements can be assignment statements, if-then-else, while, dowhile, and for loops.

Expressions can be logical expressions, or numerical expressions as discussed in class.

Expression Operators can be and, or, !, ||, &&, !=, ==, >, <, >=, <=, +, -, *, /, %.

Names begin with a letter and are followed by any number of letters, digits and underscores.

    In what follows, ()'s (unbolded) are used for grouping; bolded and italicized words are tokens. {}'s (unbolded) mean 1 or more and [ ] (unbolded) mean optional - 0 or 1.

     
     program         -- > method_declaration 

    method_declaration -- > type name ( ) { statement_block }

    type -- > void | variable_type

    variable_type --> int

    statement_block -- > ...

(a) List the tokens and assign them to classes.

(b) Use EBNF to continue the grammar for statement_block. You should have a complete (initial) tea grammar when you are done. In the following 2 assignments, you will be implementing (a corrected version of) this grammar.

Unlike the example grammar for java, you must indicate precedence for expressions (as we did for arithmetic expressions with E --> E + T, etc.)

(c) 1 point will be allocated to documentation. This is the beginning of a larger project. You need to describe the overall project, create a Table of Contents (listing the rest of the assignments etc.), describe the tools you downloaded (See Part 2), etc. Neatness counts!

Part 2 Accessing Java and the Java Compiler Tools You will need javacc for the next assignment.

You should download the tools. It is not necessary to know much (if any) java to use the tools, so don't run off and learn java...

For Assignment 2, you just need to run javacc.

You do not need to run these for this week's project, but do download them.

To install the Java Development Kit, and to learn more about Java, go to my electronic documents course. (You don't have to do the labs!)

Send questions and comments to: Karen Lemone