Compilers and Interpreters: Assignment 8
November 24, 2008
In this assignment, you will build a compiler for the Mini-Triangle language
through the use of ANTLR. The language is as described in our textbook except for the following:
- Operators in expressions have different precedence. The syntax is already implemented in the files given to you.
- A program can contain a sequence of commands instead of a single command. This is also the way we've done it in the provided files.
You may obtain up to 10 points of extra credit by implementing extra features that
are not required in this assignements. Examples of what you could be doing:
- Meaningful error reporting and recovery
- Procedure and function declarations. This could be global with no parameters,
or could have nested declarations, have one parameter, or an arbitrary number.
- One dimensional arrays
- A new type (set, enum, one you invent)
Make sure that TAM primitive routines can be called from a Mini-Triangle program.
It will probably be useful to include code taken from the Triangle compiler available with
our textbook. Please attribute the sections to the proper source. Useful files are
Instruction.java and Machine.java in the TAM directory. You will probably want to
reorganize the declarations into your own file. Also look at saveObjectProgram inside
Encoder.java. It creates an object file. The object file can be executed with the
interpreter, or you can look at it using the disassembler.
Due Wednesday, December 10, midnight. In order to have enough time to grade,
late submission may or may not be considered.
If you plan a late submission, submit your partial work before the deadline.
To submit, E-mail (with CS 4352 Assignment 8 on the subject line)
to the instructor (longpre @ utep.edu)
and to the teaching assistant
(nskanagala @ gmail.com):
- a compressed file with the directory containing all appropriate files
- a README file within this directory with:
- directions to compile and run your compiler (especially if different from
the provide make.bat file)
- a description of what you've done to deserve extra credit (if any)
- some Mini-Triangle programs you used to test your compiler
- anything that you have not implemented correctly yet, with an explanation
of what would need to be done.