JCalc
JCalc is an attempt to implement a fast, extensible scientific
calculator/expression evaluator in Java. It is intended to be included in
other Java programs, but a simple command-line client is included as part of
the package.
JCalc is fully programmable, and supports compilation. It is intended that
only the core mathematical functions are implemented internally, and that most
of the functionality is supplied by compiled JCalc scripts.
To this end,
JCalc reads the file `boot/boot.jc' on start-up. This is expected to load
further scripts, to implement the functions required. At present only basic
logarithmic and trigonometric functions are defined, but adding new functions
is not difficult (see the file boot/trig.jct for examples).
Installation
Copy the file `jcalc.jar' to a convenient place (e.g., /usr/lib).
Modify the script `jcalc' to be appropriate for your system, and
copy it to somewhere in the PATH.
Building
You should not need to do this unless you want to modify the core
functionality. In particular, you will not need to do this to add new
variables, constants or functions to the program.
To build the classes from scratch you will need up-to-date versions of
jjtree and javacc, available from java.sun.com. This distribution contains a
shell script called `build' which builds the complete system into a single
JAR called `jcalc.jar'. With this JAR on the CLASSPATH, you can run the
command-line client like this:
java com.web_tomorrow.jcalc.CmdLine [options]
You will almost certainly have to customise the build script for your
system. The steps in building the JAR are as follows:
1. Generate parse-tree node by running jjtree on jcalc.jjt
2. Generate the parser by running javacc on jcalc.jj
3. Compile all the generated Java classes, and the supporting classes
4. Run the newly-generated jcalc on the script `bootcompile.jct',
which compiles the boot scripts. Feel free to add to and modify these
scripts to implement additional functions. Look at, for example,
`boot/trig.jct' for the syntax of the `define' function
5. Package the classes and the compiled boot scripts into the JAR.
Note that extending the function library requires only steps 4 and 5.
For more information, see the
README file. For a detailed description, unpack the
JAR archive and refer to the file `overview.html' and the
javadoc documentation in the `doc' directory.
Download JAR file
©1994-2003 Kevin Boone, all rights reserved