
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Instructions for cs 426 students on how to complete the third machine problem of the compiler construction course, which involves generating working jasmine code from an input program using a provided parser. Students have the option to use their own parser or the sample parser, and are asked to generate code for a subset of the grammar. The document also outlines the required functions for user input and output in the generated code.
Typology: Assignments
1 / 1
This page cannot be seen from the preview
Don't miss anything!

Due: November 7, 2006 The goal of this assignment is to generate working jasmine code from any input program in the language defined from your grammar. To start, you have a choice: You may use your parser from MP2, or you may use the sample parser we have constructed. It may be found at https://netfiles.uiuc.edu/hoefling/www/index.html. There is a README on that site to help you get the parser running, and Javadocs for all the code provided. If you really like your MP2 parser or don't want to learn Java, use your MP2 parser. Otherwise, it is suggested that you start with the sample parser. It already has a built in symbol table, and a structure which should be easy to generate code from. Also, if there are any problems found in the sample parser, they will not be your responsibility to fix (please post to the newsgroup ASAP if any are found). There are a couple things to note when using the sample parser: the grammar is not exactly the same as the one provided in MP2. There is a file inside of the main directory, “grammar” which describes the grammar used for the sample parser, or you may look through the actual file used to generate the parser. You are only asked to generate code for the subset of the grammar provided with MP2, but generating code for the complete grammar of the sample parser should not be much harder. To get an idea of the structure you may use to generate code, take a look at the visitor files in the sample parser, particularly PrintVisitor.java. This class prints C code starting from an input AST. Generating code will be similar in format to this operation. When you output the jasmine code, you will want to output the jasmine code to a file, and keep an internal representation of the code in a Control Flow Graph. (This will make your life a lot easier when we start to optimize this code). Beyond the code for the language, there are a few functions we want you to allow for. We need a way to take in user input and print output to the console in our language. When generating code assume that the following functions are preset in the language:
int read( ) - reads an integer from standard input and returns it. float read( ) – reads a floating point number from standard input and returns it.
void print(int) – prints the parameter integer to standard output. void print(float) – prints the parameter floating point number to standard output. void print(String_Literal) – prints the parameter string literal to standard output.
You will need to specially generate code for each of these functions when generating the code for a function call.
Look to the links provided in MP1 for documentation on the JVM for help generating the jasmine code.
Handin Instructions : please send the instructor and the TA a tar file containing all files to make your compiler work (including the parser). Please provide a README file containing any special instructions you have for your parser. Furthermore, you should include the programs you wrote to test your code generator. The quality of your test suite will be an important component of the grade for this MP.