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:
mvn install:install-file -Dfile=pcat-solution.jar -DgroupId=edu.uta.pcat -DartifactId=pcat-solution -Dversion=0.1 -Dpackaging=jar
mvn clean install
scala lib/pcat.jar 4 tests/hanoi.pcat
scala pcat-solution.jar 4 tests/hanoi.pcat
You can learn more about Scala at:
Most students develop their project on the Eclipse IDE. It is not required. If you want to develop the project on Eclipse, you need to download the Bundle of the Scala IDE for Eclipse. The Scala Eclipse IDE 4.5.0 supports Scala 2.10 and 2.11. You should only use Scala 2.11. You need also to install CUP on Eclipse: go to Help/Install New Software... Then add the URL http://www2.in.tum.de/projects/cup/eclipse and install CUP. To create the project on Eclipse, do File → New → Scala Project. On "Project name:" put pcat, unclick the "Use default location", and put the location of your pcat directory. Push Next and then Finish. Right-click on the project name, and select Configure → Convert to Maven Project. To build it, Right-click on pom.xml and select Run as → Maven clean and then Maven install. To run it, Right-click on project pcat and select Run as → Run Configuration, right-click on "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 setting some flags in src/main/scala/edu/uta/pcat/PCAT.scala to use the solution classes. For example, if you messed up Project #4, then in Project #5 you can set the use_project_4_solution in src/main/scala/edu/uta/pcat/PCAT.scala to true. This will force the scala compiler to get the TypeCheck classes from pcat-solution.jar. Note that you can always go back and update your old projects, which is more 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:
scala pcat-solution.jar 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/15/2017 by Leonidas Fegaras