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.
(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 CUPCalcFor non-graphic test, perform the command
java parser
To compile the parser from the CUP-source file "CUPCalc.cup", perform the command
makeIt firstly calls CUP, that creates the files "parser.java" and "sym.java".
java java_cup.Main < CUPCalc.cupThen (in case of no errors) it compiles the resulting Java-file:
javac parser.javaIt creates the file parser.class (and some other).
Also the "make" command compiles the "CUPCalc" applet.