Instructions to Install JLex on the CS Servers
Want all the instructions in one code block without the explanations? Check out the appendix.
Before Starting
You may want to create a separate "2140" directory for this class:
mkdir -p 2140
cd 2140
Make sure you download the following two files:
You can download files on the CS servers by running wget url
, where url
is replaced with the url of the file you want to download.
So, to download these two files, you can run:
wget http://jlu.myweb.cs.uwindsor.ca/214/Main.java
wget http://jlu.myweb.cs.uwindsor.ca/214/simple.lex
Instructions
- Create a "JLex" directory (case sensitive!):
mkdir -p JLex
- Move "Main.java" (attached) into the JLex directory
mv Main.java JLex
- cd into the JLex directory
cd JLex
- Compile "Main.java"
javac Main.java
- Move back to the parent directory
cd ..
- JLex is now installed! You can now run the scanner generator.
The general method to do this is to run:java JLex.Main lexFileName
, replacinglexFileName
with the name of your lex file.
We'll use the sample lex filesimple.lex
, courtesy of Dr. Jianguo Lu, which we downloaded earlier.
To run this file, simply type:
java JLex.Main simple.lex
- You should now see a new file generated, called
lexFileName.java
, or in this casesimple.lex.java
. We must now compile it, by typing:
javac simple.lex.java
- A new file,
MyLexer.class
should have been created (note, if using a lex file other thansimple.lex
, this file may be named something different). We can now run the lexer by running:
java MyLexer
That's it!
Now try typing stuff on your keyboard and see how the lexer responds. Try typing "int" or typing some words, like "hello" and "world".
Appendix
All the commands in one block
mkdir -p 2140
cd 2140
wget http://jlu.myweb.cs.uwindsor.ca/214/Main.java
wget http://jlu.myweb.cs.uwindsor.ca/214/simple.lex
mkdir -p JLex
mv Main.java JLex
cd JLex
javac Main.java
cd ..
java JLex.Main simple.lex
javac simple.lex.java
java MyLexer