This is the second of a series whose first article appeared in the April, 1999 issue of Linux Gazette. [see: Compiler Construction Tools, Part I ]. The traditional example, the calculator, is provided in Part III, which is intended as a companion to this part and also appears in this issue.
0.0 Background
The JFlex and CUP software packages come with installation instructions. These are well written and straightforward. Nevertheless this document was written to give a very specific installation scenario. In the author's experience, this specificity can be useful to certain new users who find the generality and flexibility of less specific installation instructions somewhat difficult upon first exposure. The downside is that this specificity takes away flexibility.
These instructions are intended for use with a Linux box, with bash as the default shell and with the tcsh also installed, but not as default. It is assumed that the user has a version of jdk (Java Development Kit), or some equivalent, installed already. If not, you can find such at www.blackdown.org/. In the system used by the author, the compressed tarball of jdk1.1.5-v5-glibc.tar.gz from blackdown was downloaded into /usr/lib and exploded there.
The author would appreciate corrections and constructive suggestions. He can be contacted at: [email protected]
1.0 System Preparation
Note that the specific choices made in this section are arbitrary. For starters, it is assumed that you have logged into your home directory, say, /home/jsmith. All paths will be relative to that position within the file hierarchy. Make new directories as follows:
> mkdir javatools
> mkdir javatools/CUP
Next revise your .bash_profile and .bashrc files to have the needed java CLASSPATH etc. Here are some example lines:
JAVB=/usr/lib/jdk1.1
JAVT=/home/jsmith/javatools
CLASSPATH=./:$JAVB/lib/classes.zip:$JAVT/JFlex/lib/JFlex.jar:$JAVT/CUP
PATH=$PATH:$JAVB/bin:$JAVT/JFlex/bin
export PATH CLASSPATH
Note: The directory /usr/lib/jdk1.1 is meant to denote the site of the java files exploded from the blackdown tarball. In the author's case it was a symbolic link to /usr/lib/jdk1.1.5v5-980311/.
For these changes to take effect you must log out and log back in.
2.0 JFlex
2.1 Obtaining JFlex
JFlex is available from www.informatik.tu-muenchen.de/~kleing/jflex/index.html#Download
in a tar.gz format. At this writing the file name was 'jflex-1.2.tar.gz'.
This tarball includes an extensive manual with its own installation instructions.
2.2 A Specific Installation Scenario
2.3 Testing the Installation
This is a sample
input file for the
standalone example
scanner.
Have a
nice day!
3.0 CUP
3.1 Obtaining CUP
CUP is available from www.cs.princeton.edu/~appel/modern/java/.
There you'll find the needed source code (compressed tarball) and a user
manual. The manual can be downloaded in html to provide an on-line manual
or in a form (e.g. postscript) suitable for printing. The next section
deals with downloading the source file.
Note: The above website also contains an alternative to JFlex, called
JLex.
3.2 A Specific Installation Scenario for CUP with test
4.0 What Next?
The manuals downloaded with JFlex and CUP provide enough information so that users can get up and running.
Compiler Construction Tools Part I, April 1998