README file for Programming Assignment 5 (Java edition) ======================================================= Your directory should now contain the following files: ASTConstants.java -> [course dir]/src/PA5J/ASTConstants.java ASTLexer.java -> [course dir]/src/PA5J/ASTLexer.java ASTParser.java -> [course dir]/src/PA5J/ASTParser.java AbstractSymbol.java -> [course dir]/src/PA5J/AbstractSymbol.java AbstractTable.java -> [course dir]/src/PA5J/AbstractTable.java BoolConst.java Cgen.java -> [course dir]/src/PA5J/Cgen.java CgenClassTable.java CgenNode.java CgenSupport.java ClassTable.java -> [course dir]/src/PA5J/ClassTable.java Flags.java -> [course dir]/src/PA5J/Flags.java IdSymbol.java -> [course dir]/src/PA5J/IdSymbol.java IdTable.java -> [course dir]/src/PA5J/IdTable.java IntSymbol.java IntTable.java -> [course dir]/src/PA5J/IntTable.java ListNode.java -> [course dir]/src/PA5J/ListNode.java Makefile -> [course dir]/assignments/PA5J/Makefile README StringSymbol.java StringTable.java -> [course dir]/src/PA5J/StringTable.java SymbolTable.java -> [course dir]/src/PA5J/SymbolTable.java SymtabExample.java -> [course dir]/src/PA5J/SymtabExample.java TokenConstants.java -> [course dir]/src/PA5J/TokenConstants.java TreeConstants.java TreeNode.java -> [course dir]/src/PA5J/TreeNode.java Utilities.java -> [course dir]/src/PA5J/Utilities.java cool-tree.aps -> [course dir]/src/PA5J/cool-tree.aps cool-tree.java example.cl The Makefile contains targets for compiling and running your program, as well as handing it in. DO NOT MODIFY. In example.cl you should write a correct Cool program which tests as many aspects of the code generator as possible. It should pass your code generator, and running spim on the generated output should run the program correctly. CgenClassTable.java CgenNode.java are the skeleton files for the code generator. These skeletons are much larger than the ones for previous assignments. The skeletons provides three components of the code generator: - functions to build the inheritance graph; (we supply this in case you didn't get this working for PA4) - functions to emit global data and constants; You should work to understand this code, and it will help you write the rest of the code generator. TreeNode.java and ListNode.java contain definitions used by the tree package. DO NOT MODIFY. cool-tree.java specifies and give an implementation of Cool ASTs (see the README for PA3 and the "Cool Tour"). In this assignment, you will need to complete the code generating methods for all Cool expression nodes. BoolConst.java, IntSymbol.java, and StringSymbol.java are used to manage constants in Cool programs. You will need to complete the method for generating constant definitions in each of these classes. CgenSupport.java is general support code for the code generator. You can add functions and constants as you see fit, but do not modify anything that's already there. This class also serves as a placeholder for a bunch of constants as well as functions to emit spim instructions (we supply these to save you some tedious coding). TreeConstants.java defined some useful symbol constants. You may add some of your own, if you wish. ASTLexer.java, ASTParser.java, and ASTConstants.java implement a lexer and a parser for reading text representation of ASTs from console in the format produced by the parser phase. DO NOT MODIFY. Cgen.java supplies the driver for the compiler. You should not modify this code. The script mycoolc can pass any of the standard flags to the code generator; for this assignment, -c (code generator debug) may be useful as it sets a global variable cgen_debug to true (1). If you want your code generator to print debug information when the option is set, write your debug code in the following format: if (cgen_debug) { ... } SymbolTable.java contains a symbol table implementation. Read the comments in the file and look at the example in SymtabExample.java. You are not required to use this code, but you may find it useful. DO NOT MODIFY. Instructions ------------ To compile your compiler and code generator type: % make cgen To test your compiler, type: % ./mycoolc [-o output filename] <file1.cl> <file2.cl> ... This command parses all the cool files given on the command line, passes them through the semantic checker, and then hands the program AST to your code generator. To run your compiler on the file example.cl, type: % make dotest To run the produced code: % spim -file file1.s /* or the output filename you chose */ Instructions for turning in the assignment will be posted on the course web page. GOOD LUCK!