You should do this project alone. The course project is to construct a compiler for a small programming language, called SPL. 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".
The goal of this project is to implement a full compiler for a simple programming language, called SPL. The language description is available at SPL.pdf.
You will do this project on your PC using the programming language Scala. You may use any PC (Windows, Mac OS X, Linux, etc). To install the project on your PC, you do the following:
mvn install:install-file -Dfile=spl-solution.jar -DgroupId=edu.uta.spl -DartifactId=spl-solution -Dversion=0.1 -Dpackaging=jar
mvn clean install
scala lib/spl.jar 4 tests/hanoi.spl
scala spl-solution.jar 4 tests/hanoi.spl
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 the CUP plugin 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 spl, unclick the "Use default location", and put the location of your spl directory. Push Next and then Finish. Right-click on the project name, and select Configure → Convert to Maven Project. You may also need to go to the Scala menu and select the Scala installation (2.11) and restart the presentation compiler. 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 spl and select Run as → Run Configuration, right-click on "Scala Application" and push the New button on top left. Use "Name:" spl, in Main menu set "Project:" spl, "Main class:" edu.uta.spl.SPL, in Arguments menu set "Program arguments:" 4 tests/hanoi.spl (or whatever phase and test file you want), and finally, push Run to run it.
Instead of Eclipse, you can install IntelliJ IDEA with Scala and Maven already pre-installed from the Scala home. Otherwise, if you already have Intellij IDEA, go to Preferences, then to Plugins and install the "Scala" and "Maven Integration" plugins by clicking on "Install JetBrains plugin...". Optionally, you may also install the CUP plugin (not easy to install). Then you click on New and then on "Project from Existing Sources..." and select the spl directory (you import it as a Maven project). Every time you change the spl.lex or spl.cup, you need to right-click on the project, select Maven, then "Generate Sources and Update Folders". After this, you can Build your project.
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/spl/SPL.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/spl/SPL.scala to true. This will force the scala compiler to get the TypeCheck classes from spl-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 SPL compiler over a test SPL file, say tests/tsort.spl, using the command:
scala spl-solution.jar 6 tests/tsort.splinside your project directory. This will run the SPL compiler over tests/tsort.spl using the solution jar and will generate the MIPS code tests/tsort.s. The goal of this project is to build a compiler for SPL that behaves the same as the solution SPL compiler.
Last modified: 01/23/2018 by Leonidas Fegaras