Due 11:59pm Wednesday Sept 30
Implement a parser for the Mojo language using JavaCC.
Once you have this working you will then use your parser to construct an abstract syntax tree (AST) for the input program.
Source code to get started with is available in the /homes/cs352/Fall15 directory. To copy the skeleton code into your project directory, start in your project directory and do:
cp /homes/cs352/Fall15/project2.tar.gz ./ tar -xvf project2.tar.gz
The files are actually configured as an Eclipse project, so you can also import the project into Eclipse at your convenience. The bin subdirectory is where your .class files will be generated, and the src subdirectory is where you will place your .java files. You may make new .java files or use the included ones at your convenience. We have included a Makefile which targets the included .java files and cleans up the automatically generated javacc files in the src/mojo/parse directory.
All commands below will assume that you have first set your current directory
bin subdirectory using the command:
The framework for building the AST (and printing out the results) is available
mojo/Absyn.java. You do not need to edit this file, but you
will be building the AST from the classes in this file. Note that the Abstract Syntax Tree implemented in Absyn.java utilizes the popular Visitor design pattern (see CS307).
You can run the parser and print out the AST it builds using the command:
java mojo.Absyn file.mj
Before starting this project, familiarize yourself with Chapters 3 & 4 of the textbook. In addition to the lectures, this will give you a solid foundation for starting your parser.
You should turn in just your JavaCC file (Parser.jj), which implements your scanner, using the turnin command available on CS Unix machines.
To turn in your project, make sure that you are in the directory that contains your Parser.jj file. Then type the following:
turnin -c cs352 -p project2 Parser.jj
To verify your turned-in work, do:
turnin -c cs352 -p project2 -v
We will create a set of test cases, and then compare the output of your solution to our reference implementation. Grading test cases are intended to test separable functionality of your parser.
To use the test cases yourself, go into your project's bin folder and then do the following:
cp /homes/cs352/Fall15/project2/p2tests.tar.gz ./ tar -vxf p2tests.tar.gzWith the p2tests folder in your bin folder, go into p2tests to look at the tests. Run them individually or by using the s1.sh file. Expected output is in the output directory.
There will be a reconciliation period after initial grading when you will be able to compare outputs of your parser with those of the reference implementation, and you may then offer simple fixes for the TAs to apply to your implementation to improve your grade. These fixes will be accepted only at the discretion of the TAs and the instructor (we will judge what "simple" means!)
The reconciliation period is only intended for you to be able to fix simple problems that you may have mistakenly overlooked. Thus, you must make sure to test your implementation thoroughly.