Lab 4
Lisp Evaluator (Part 1)
Description

LISP (List Processing) is a family of programming languages where the program is composed solely of linked lists.

Each list in any Lisp dialect is surrounded by parentheses, with the elements delimited by spaces (and ordered from left to right). The first element is assumed to be the function, and the remaining elements are the parameters to this function. A list of this form is also called an s-expression.

For example:
(+ 1 2 3)
Is a simple program in Lisp which would evaluate to 6

An atomic list is a list that contains no other lists. Your goal is to implement addition, multiplication, and subtraction over atomic lists according to the specified interface.

Preliminaries:
  1. Download the parsing library here
  2. After creating your project in eclipse, click 'Project' in the toolbar and open 'Properties'
  3. Click 'Java Build Path' on the left, then click the 'Libraries' tab.
  4. Click 'Add External Jars', then add the jar file you downloaded from step 1.

Note: If you are compiling from the command line (i.e. not Eclipse), you can have javac locate the library by properly setting the CLASSPATH:
export CLASSPATH="path/to/jar:."

Objective

Write a class called Lisp which will be responsible for evaluating expressions in a simple variant of LISP.

Your class must do the following:

Hints

In addition, you might find the following methods useful:

Example Dialog

    Welcome to the simple lisp evaluator.
    Enter an s-expression or type (exit) to quit.

    -> (+ 1 2)
    3

    -> (- 1 (+ 1 2) (* 3 4))
    -14

    -> (- 0 1)
    -1

    -> (- 0 1 1 1)
    -3

    -> (+ 1 2 3 4)
    10

    -> (exit)
    Goodbye
    
Finally:

Upload the .java file to the dropbox