Homework 4
Lisp Evaluator (Part 2)
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:

This should be an extension of Lab 4, however the main method will now be in the class you create for this assignment, and not in Lisp.java.

Objective

Write a class called Parser which will be responsible for parsing compound s-expressions into atomic s-expressions.

Your class must do the following:

Hints

A good strategy is to parse the file character by character, and build up the s-expression as a String. Done this way, you have 4 cases to consider:

In addition, you might find the following methods useful:

Example Dialog
Using this input file

        Enter the name of a lisp file
        test.lisp
        6
        8
        16
    
Finally:

Upload the .java file to the dropbox