This project consists of implementing a simple compiler for the so called LITTLE programming language. The LITTLE language is a toy programming language designed solely for this course and it's based (however different!) on the MICRO language described in the course text book.
Aurangzeb (orangzeb 'at' purdue 'dot' edu) will be grading the projects and answering questions. His office hours are Thursdays 1:30 - 2:30 pm and Fridays 2:30 - 3:30 pm in EE 207 (computer lab).
Grading policy: All the points from the first 7 steps add up to 700 points (plus 10 bonus points from step0) and are worth total 30% of the project's total grade. The final step is worth 70% of the project's grade. Preliminary steps (step0 - step7) will be tested against published testcases. Final step (step8) will be tested agains published as well as hidden testcases.
We will compiler your compiler by running:
make clean; make compiler
Submit all source files and libraries necessary to build your compiler. Do not submit generated ANTLR-generated .java or Flex/Bison-generated .c/.cpp files. Submit the original source files and ensure that the Makefile calls ANTLR, Flex, Bison, etc. as part of its build process.
This is how we will test your compiler in Java (assuming that test.micro is the testcase):
java -cp lib/antlr.jar:classes/ Micro [path to test.micro] > [output file]
This is how we will test your compiler in C/C++ (assuming that test.micro is the testcase):
./Micro [path to test.micro] > [output file]
Note that the input is being read in from a file passed as a command line argument, not redirected from STDIN, while the output is being redirected from STDOUT. If you are using a different language than C/C++ or Java, include a shell script in your submission called "Micro" that provides the same usage interface as in the C/C++ case above
We will be testing your project on the ecegrid machines (ecegrid.ecn.purdue.edu), so please make sure that your projects compile and run on those systems!
See this page for the necessary directory structure for your project (step1 onward).
Submit each step using the turnin command. Instructions for using turnin are available here.
Copying the source code from your classmates or internet is strictly prohibited. Your projects will be checked for plagiarism. Any violation to the honor code will result in a zero for the project. Violators will also be reported to the department. If you keep your code on some online repository (such as github), make sure to keep the repository private so others do not copy from your code without you knowing about it. That said, you can consult your peers for conceptual help and you may look for examples of how to use your parser generator tool (ANTLR/Bison/etc.) and do certain things with it, online.
It is extremely important to carefully read the documentation of your relevant scanner/parser generator.
Here are some sources:
Documentation:(Please carefully read and apply what you learn. This should be the first step. E.g. note that parser rules start with a small case letter and lexer rules and tokens start with an upper case letter.)
Antlr4 API/Java Doc:(You will need this to know how to create objects of generated code, e.g. a lexer object and make them do stuff.)
Some articles for additional help:
Some grammar files:(caution: these files implement full-scale grammars and use most of the features of Antlr so you may find some parts of them hard to understand, but they may be helpful especially if you have mastered the documentation)
Source code of the examples provided in the book "The Definitive ANTLR 4 Reference":
Documentation: (This is for version 2.5.37, we have version 2.5.35 so it should almost be the same)
Feel free to search for other tutorials online.