Simple Calcuator, Written in CUP

This simple example uses CUP -- the Java-version of unix "yacc" utility for generation of parsers.

Simple calculator evaluates any expression, that contains real number, ariphmetic operations and parenthesys.

You should run some Java-enabled browser to see the applet.

(If you do not see anything above, then probably your browser does not support JDK 1.1. You need some JDK 1.1 compartible browser -- Netscape 4.5, MSIE 4.0, HotJava 1.2, etc.)

There are two tests of the parser: the first, graphic test, is the applet "CUPCalc" that you see above. The second, non graphic, test is contained in the parser code, in the method "main". Both tests evaluate any ariphmetic expression. To run the graphic test, perform the command

    java CUPCalc
For non-graphic test, perform the command
    java parser

To compile the parser from the CUP-source file "CUPCalc.cup", perform the command

    make
It firstly calls CUP, that creates the files "parser.java" and "sym.java".
    java java_cup.Main < CUPCalc.cup
Then (in case of no errors) it compiles the resulting Java-file:
    javac parser.java
It creates the file parser.class (and some other).

Also the "make" command compiles the "CUPCalc" applet.