The 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 MIPS architecture. Domain 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.
Platform and Tools 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:
If you do not have Java on your PC, install Java SE 8 JDK. Setup the JAVA_HOME variable. On Microsoft Windows 8/10, click Start, then Control Panel, then System, then Advanced, then Environment Variables. Insert a new System variable JAVA_HOME to be C:\Java\jdk1.8.0_111 (change the version to match). Install Apache maven from https://maven.apache.org/install.html. Install Scala 2.11.* from http://www.scala-lang.org/download/ (do not install Scala 2.12.*). Change your PATH. On Microsoft Windows 8/10, click Start, then Control Panel, then System, then Advanced, then Environment Variables. Edit the System variable Path and insert C:\Java\jdk1.8.0_111\bin, C:\apache-maven-3.3.9\bin, and C:\Program Files (x86)\scala\bin at the top (change the versions to match). Download the zipped project source files pcat.zip and unzip it. The source files in the pcat directory contain minimal code. Your goal for this project is to add more code to these files to make them function according to the specs. The pcat directory also contains the jar file pcat-solution.jar, which is the solution of the project. You may use it to compare the output of your program with the solution output. Install the solution into your system: Open a Command Prompt, go to the pcat directory, and do: mvn install:install-file -Dfile=pcat-solution.jar -DgroupId=edu.uta.pcat -DartifactId=pcat-solution -Dversion=0.1 -Dpackaging=jar The last project (#6) is optional (extra credit) for undergraduate students. In project #6, you will need to install the MIPS code simulator, called SPIM, to run the assembly code generated by your compiler (instructions will be given in Project #6). To compile the pcat sources, go to the pcat directory, and do: mvn clean install To run, for example, project #4 on the test file tests/hanoi.pcat, run the script: scala lib/pcat.jar 4 tests/hanoi.pcat To run the solution for the same example: scala pcat-solution.jar 4 tests/hanoi.pcat You can learn more about Scala at:
Scala Overview A Scala Tutorial for Java Programmers A Tour of Scala Scala by Example The Scala Language Specification Scala API You may use the first two links only. The other links should be used as a reference only. Developing your Project on Eclipse (Optional) 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.