Assignment #1

Tea BNF

5 points

Due Monday, January 19

Part 1 Tea grammar

Tea is a subset of Java. Initially, Tea programs will consist of simple type definitions followed by 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.

(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.

Solution

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

You can either download the tools or go to your WPI account on an alpha (Bert, Ernie, Reno etc.) and run java there and JavaCC from Theo's account: /cs/users/tvd/JavaCC. (cd to subdirectory bin. For Assignment 2, you just need to run javacc).

You do not need to run these for this week's project.

To download, you need the install tool from cs/users/tvd. It's the only .class file there, and is called JavaCC0_7.class . To install: type java JavaCC0_7. Follow the on screen instructions.

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