Guide on how to install Java, Jflex and CUP in the macOS operating system.
THIS GUIDE FOR NOW WAS CHECKED ONLY BY ONE STUDENT, AS A CONSEQUENCE IF YOU FOUND ERRORS OR SOME PASSAGES THAT CAN BE SIMPLIFIED, PLEASE LET ME KNOW BY SENDING AND EMAIL.
The Oracle JDK can be downloaded at the following address https://www.oracle.com/java/technologies/javase-downloads.html, choosing the one marked as Windows x64 Installer (at the moment of this guide the recommended version to download is jdk-15.0.2_osx-x64_bin.tar.gz
).
To install Java a possible guide is the following:
cd mkdir -p compilers cd compilers
jdk-15.0.2_osx-x64_bin.tar.gz
.tar xvfz jdk-15.0.2_osx-x64_bin.tar.gz
To install JFlex and CUP follow the following steps:
brew install jflex
java_cup_v11_draw_tree
(that you can find in this zip file) inside compilers
, in order to have the path /home/skenz/compilers/java_cup_v11_draw_tree
.cd java_cup_v11_draw_tree/java_cup
javac *.java runtime/*.java ../StdDraw.java
Before running CUP and Jflex, environment variables must be configured.
To set the environment variables, open in your home directory the file .zshrc
(the .zshrc
file is executed by the shell each time you open a terminal and usually it is used to configure a shell):
cd touch .zshrc open .zshrc
After opening the .zshrc
file, add on its top the following lines:
PATH=$PATH:.:/Users/skenz/compilers/java_cup_v11_draw_tree/java_cup/:/Users/skenz/compilers/jflex-1.8.2/bin export PATH CLASSPATH=.:/Users/skenz/compilers/java_cup_v11_draw_tree/ export CLASSPATH
Note: to make active the new environment variables you must reopen a new shell. Remember that both $PATH
and $CLASSPATH
environmental variables have to contain the .
(dot) that represents the current directory.
To verify that the programs have been installed correctly, open a command prompt (cmd) and enter:
jflex
A graphical window should be opened.
For CUP you can type into the command prompt:
java java_cup.Main
and if it is correctly installed you see nothing in the terminal. To stop it you can press CTRL-c
.
The installed CUP version contains also the functionality to draw into the screen the parse tree (this version was made especially for this course). To check this part you can type into the command prompt:
java java_cup.MainDrawTree
and if it is correctly installed you see nothing in the terminal. To stop it you can press CTRL-c
.
jflex scanner.jflex java java_cup.MainDrawTree parser.cup javac *.java java Main example_expr.txt