Due: October 5
In this course you will be developing an interpretor for a high-level
language, called HL, which manipulates numbers and polynomials
In this assignment you will be using JavaCC to build HL's scanner.
This should familiarize you with the use of compiler generators
and the scanning process.
Before you start your assignment,
you will need to set up the environment under which you will be working.
You can develop your assignment on whatever platform you prefer.
However, we will only test it on the moons,
so you should verify your work on this platform before submitting it in order not to lose grades for
In all cases, you will need to do the following:
- Create a directory where you will do your work.
- Copy the 3 following files to that directory:
- You can start your work with this skeleton version of
- This Makefile will be used to compile your program.
You can learn about the make program
by typing "man make" on elara or from the
GNU Make Manual.
- The makefile will link your assignment with
This program is a fairly standard main file to test javacc scanners.
Do not modify this file as we will be using the one posted here to test and grade your scanner.
- If you are developing in UNIX on the command line,
you can use the makefile to recompile and test your scanner.
You will need to modify it though when you add the two new classes.
If you are working in an IDE, you will need to set it up yourself.
You may want to look at the makefile for the sequence of actions and flags.
- Compile everything (make will do this if you are working in UNIX on the command line) once to make sure that your compilation settings are correct. This will also generate additional files that you can modify later
Once you have set up the environment, and verified that it runs smoothly,
you can start your assignment.
Testing your Assignment
- Upload your HL.jj, Token.java, BooleanToken.java,IntegerToken.java, DecimalToken.java, and StringToken.java to elara in a new directory on the moons.
makefile to that directory.
- run make in that directory to check that your program compiles properly.
- Once it compiles properly,
- copy the 2 scripts in the Handouts directory to your source directory and
change their perms to make them executable.
runtests runs all the tests in order.
and t runs one test at a time. Take a look at runtests to see how to use t.
- create a subdirectory of your source directory called "Test" and copy all the files in this
Test directory into your Test subdirectory.
- Each test is called testX.hl where X is the type of token being tested.
- The file containing the expected result for testX.hl is called X.results
- Run runtests. If your program passes a test, you will only see the name of that test.
If it doesn't, you will see all the cases where your result differs from the expected result.
You can then fix your program and retest it for that specific test using the script t.
Submitting your Assignment
Once you have verified that your source does compile and run properly on elara:
- zip up your
HL.jj, Token.java, BooleanToken.java,IntegerToken.java, DecimalToken.java, IdentifirToken.java and StringToken.java files into a file called A1.zip
- Submit electronically A1.zip
- Print, fill out, and hand in the marking sheet (
or pdf format).
- CPS710 Material
The following provide overviews of scanning with Javacc and are good places to get started because they have enough information to help you produce
a very basic JavaCC file that detects the simple tokens and skips whitespace.
JavaCC [tm]: TokenManager MiniTutorial
gives a good overview of how JavaCC handles tokens and how to write
a JavaCC program.
Compiler Construction also gives a
good overview: read the Lexical Analysis section.
The comment section will get you properly started with comments.
- Chapter 2 of the JavaCC textbook by Tom Copeland are quite thorough.
- Specific References
How to submit the assignment
- Submit electronically HL.jj, Token.java, BooleanToken.java,IdentiferToken.java
IntegerToken.java, DecimalToken.java, and StringToken.java
- Print, fill out, and hand in the marking sheet(
This page is maintained by
Tuesday, 20-Sep-2016 12:02:34 EDT