You should do this project alone. The course project is to construct a compiler for a small programming language, called PCAT. It will involve: lexical analysis, parsing, semantic analysis (type-checking), and code generation for a MIPS architecture. The project is to be completed in six stages spaced throughout the term.
Start working on programming assignments as soon as they are handed out. Do not wait till the day before the deadline. You will see that assignments take much more time when you work on them under pressure than when you are more relaxed. Remember that there is a severe penalty for late submissions. Design carefully before you code. Writing a well-designed piece of code is always easier than starting with some code that "almost works" and adding patches to make it "really work".
A major part of this project is to implement a full compiler for a subset of Pascal, called PCAT, designed by Andrew Tolmach at Portland State University. The paper that describes the language can be retrieved from pcat04.pdf.
You will do this project on your PC using the programming language Scala. Any PC (Windows, Mac OS X, Linux, etc) will be fine. To install the project on your PC, you do the following:
run 4 tests/hanoi.pcat
solution 4 tests/hanoi.pcat
You can learn more about Scala at:
If you like, you may develop projects 3-6 on the Eclipse IDE (projects 1 and 2 cannot be done on Eclipse). If you don't have Eclipse on your PC, you can download the Bundle of the Scala IDE for Eclipse. Otherwise, if you already have Eclipse, go to "Install New Software..." on Eclipse, enter the latest Scala repo URL in "Work with:", and install the Scala IDE for Eclipse. For eclipse to work, it must use the same scala library as the one you downloaded: eg, if you installed scala 2.11 on your PC, you must install 2.11 on eclipse too (not 2.10). To create the project on Eclipse (after you unpack it), do File → New → Project... → Scala Wizards → Scala Project. On "Project name:" put pcat and on "Location:" put the location of your pcat directory. Push Next. On "Libraries" use "Add External Jars..." to add the System.jar and use "Add Library" to add the Scala Library. Note that, in order for your scala files to compile, you need to generate the scanner and parser first. Right-click on project pcat and select Run → Run Configuration, highlight "Scala Application" and push the New button on top left. Use "Name:" pcat, in Main menu set "Project:" pcat, "Main class:" edu.uta.pcat.PCAT, in Arguments menu set "Program arguments:" 4 tests/hanoi.pcat (or whatever phase and test file you want), and finally, push Run to run it.
Programs will be graded according to their correctness, style, and readability. Programs should behave as specified in the assignment handouts. Bad data should be handled gracefully; your program should never have run-time errors, such as using an out-of-bounds index. Special cases should be handled correctly. Unnecessarily inefficient algorithms or constructs should be avoided; however, efficiency should never be pursued at the expense of clarity or simplicity. Programs should be well documented, modular, and flexible, i.e. easy to modify. Indentation should reflect program structure. Use meaningful identifiers. Don't use side effects during the semantic actions of a parser. The grader should be able to understand the program without undue strain. I will provide some test programs, but these programs will not test your compiler exhaustively. It is your responsibility to test every statement in your program by some piece of test data. Thorough testing is essential to establish the reliability of your code. Don't add fancy features until the required work is completely debugged. A correctly working simple program is worth much more (both in this class and in actual practice) than a fancy program with bugs.
Project assignments must be done individually. No copying is permitted. Cheating involves giving assistance to or receiving assistance from other students or from other individuals, copying material from the web, etc. The punishment for cheating is a zero in the assignment and will be subject to the university's academic dishonesty policy. If you have any questions regarding an assignment, see the instructor or teaching assistant.
The projects and their due days are listed below. The due time of each project is the midnight of the indicated due day. You will hand-in your project source code electronically. You may hand-in your source files as many times as you want; only the last one will be taken into account. Details of what do you need to hand-in (and how) can be found by clicking on the appropriate project name. Projects will be marked 20 points off per day. So, there is no point submitting a project more than 4 days late! No further extensions will be allowed. This penalty cannot be waived, unless there was a case of illness or other substantial impediment beyond your control, with proof in documents from the school.
If you mess up a project phase, you can still do the next project phases by removing the appropriate file name from your pcat directory. That way, the missing classes will be copied from the Solution.jar, rather than compiled from your source file. For example, if you messed up Project #4, then in Project #5 you can remove the file TypeCheck.scala, which will force the scala compiler to get the TypeCheck classes from Solution.jar. Note that you can always go back and update your old projects, which is preferable from using the solution, because you will have a better control over your own programs. You can run the solution PCAT compiler over a test PCAT file, say tests/tsort.pcat, using the command:
solution 6 tests/tsort.pcatinside your project directory. This will run the PCAT compiler over tests/tsort.pcat using the solution jar and will generate the MIPS code tests/tsort.s. The goal of this project is to build a compiler for PCAT that behaves the same as the solution PCAT compiler.
Last modified: 01/20/2015 by Leonidas Fegaras