To downaload J2SE (Java 2 Standard Edition) connect to the Oracle Java Download page (http://www.oracle.com/technetwork/java/javase/downloads/index.html).
At the time of writing, the last versione is 7 update 3 (7u3). Click on Download in the JDK column and follow the instructions. Among the various packages, select the one for the Linux operating system, distributed as a compressed file (tar.gz extension).
Supposing you have downloaded the file jdk-7u3-linux-x64.tar.gz,
move the archive into your home directory and decompress the archive into
the same directory: mv jdk-7u3-linux-x64.tar.gz ~ cd ~ tar xvfz jdk-7u3-linux-x64.tar.gz
The Java environment is now installed in your home directory, i.e. ~/jdk1.7.0_03.
3 - JFlex Installation
Create a folder, tooljava in the proposed installation procedure, where installing JFlex and Cup. To create the folder, move to the folder where you want create it: cd ~
create the folder with the command: mkdir tooljava
move the JFlex installation file into that folder: mv jflex-1.4.1.tar.gz ~/tooljava or mv jflex-1.4.1.zip ~/tooljava
To install JFlex, simply decompress the file jflex-1.4.1.tar.gz or
jflex-1.4.1.zip into the directory previously created.
Move to the folder: cd tooljava
For the .tar.gz extension execute the command: tar xvfz jflex-1.4.1.tar.gz (x=extract; v=verbose; f=file; z=zipped)
otherwise, for the .zip extension, execute: unzip jflex-1.4.1.zip
4 - Cup Installation
The Cup installation is similar to the JFlex one.
Move to the installation folder of JFlex and Cup: cd ~/tooljava
Create a folder where Cup will be installed: mkdir cup
Move the Cup installation file java_cup_v10k.tar.gz into the folder: mv java_cup_v10k.tar.gz ~/tooljava/cup
Enter the folder: cd cup
Decompress the installation file: tar xvfz java_cup_v10k.tar.gz
Execute the installation script: ./INSTALL
Note: the installation script is written for the csh shell. If you are using a different shell, follow the instructions in the next section to
complete the installation process.
5 - Environment Configuration
Before running the installed programs the Linux Shell environment variables must be configured. This guide refers to the tcsh shell.
In the case you are using a different shell, the shell tcsh can be launched with the command: ./tcsh
Edit a text file called, for example, compilers_environment and add the following lines: #!/bin/tcsh -f
Each time you want run Java, JFlex or CUP it is necessary to setup the environment variables using the command: source compilers_environment
To verify that the programs have been correctly installed, run Jflex from the sheel: jflex
A graphical window should be opened.
Launch Cup writing into the shell: java java_cup/Main
the shell output will be:
Parsing specification from standard input...
6 - Cup DrawTree installation
A modified version of Java CUP allows to graphically represent the derivation tree during the parsing processes. The package can be downloaded here as a tar.gz compressed archive.
The installation procedure is pretty much the same of the normal CUP distribution:
Decompress the downloaded file in the same folder where JFlex/CUP were installed: tar xvfz java_cup_v10k_drawTree.tgz
Modify the environment configuration file created in the previous step substituting the CLASSPATH variable with: setenv CLASSPATH .:/home/skenz/tooljava/java_cup_v10k_drawTree
The last step is required for avoiding conflicts with the standard CUP installation. A parser with the support for the derivation tree drawing can be generated launching CUP with the command: java java_cup.MainDrawTree parser.cup