Interpreter, V1

We discussed a working interpreter for expressions in class. In this assignment you will start with this set of classes and expand it to support the minimal language whose syntax is shown below.


Objectives


Grammar

The basic unit of this language is a statement. Statements will be scanned, parsed and evaluated one at a time. It is not safe to make any assumptions about whitespace.

A program in this language is a sequence of statements. So the start symbol is <statement>.

    < statement> -> < assignExpr>;

    <assignExpr>  -> <var> = <expr> 
    <expr>  -> <term> {[+ | -] <term> }* 
    <term>   -> <primary>  {[* | /] <primary>}* 
    <primary>  -> <var> | <number>  
                    | (<expr>) | - <primary> 

Specification

The existing java files ( documentation) can be copied from the ~tcole/teaching/cs354/handouts/i1/ directory on onyx. Before you do anything else, take the time to read through the code for these classes and make sure you understand how they work. It does not make sense to try to modify existing code until you understand what it is doing to begin with.

Modify and add to the classes of the existing interpreter to add the following functionality:


Testing

Download or copy from the directory on onyx the following files:

Create a new subdirectory called myTests and write at least 3 test files that you can use to test the added functionality of your interpreter. Part of your score will be based on your test files so try to provide tests for everything you added.

FYI: testProg is a shell script written in bash. You should be able to tell what it does by reading the file in an editor or listing it to the screen with the cat command.


Documentation

Use javadoc comments to document your Environment class and all the methods that you added or modified in the existing classes. You should also include a file called README that tells me what the files you've submitted are, explains your test files and provides any other information I need to know to grade your program. If you are trying for extra credit, tell me what to look for.


Submission

Required files

Put all the required filed for the assignment in a single directory, change to that directory and submit using the following command:

submit tcole cs354 i1