CSE 109 Progam 6 Due 10:45 PM 10 5 April 2012 (Late Collection dates: 10:45 PM 12 7, 8 April) This programming assignment is the second last step in which we create a program to assemble StomASM programs into STOM code. For this assignment I ask you to write a program that parses StomASM programs. PLEASE READ OVER THE WHOLE ASSIGNMENT BEFORE STARTING. Your program should read the command line, expecting the name of an input file and the name of an output file. The input file should consist of what purports to be an StomAMS program. It then should parse the program, either reporting a successful parse or diagnosing a syntax error and quitting, storing the results of the parse in the output file (and sending appropriate messages to the screen). You should develop the class Parse. Its use in main() might look something like: ifstream in; ofstream out; ...... ...... Parse p(in,out); p.fullParse(); //calls Parse::parse() twice in.close(); out.close(); Part of the parse involves determining whether a reference to a line label by some goto instruction is legitimate. Therefore, your program should actually parse the program twice (WHILE PARSING TWICE IS NOT NECESSARY FOR THIS ASSIGNMENT, IT IS CRUCIAL FOR THE NEXT ASSIGNMENT). The two parses (or passes) should be the same except that on the first pass the line labels should be stored in a table (unless there is a duplicate line label, which is an error), while on the second pass the line labels referred to in jump statements should be checked against the line labelss stored in the table on the first pass. On the first pass variables and literal ints (ones that appear in expressions like 200*45*x) should be put in a table. Thus you should write a method parse() and call it twice, keeping track of which pass you are on. (VERY IMPORTANT: your last program in this sequence will be required to generate code. This means that jump statements have to know to which memory location in the STOM to branch. Thus the table should be used in the next assignment to store that information. This means that your Parse class should have instances of Tree.) To submit your assignment, create a subdirectory of /cse109.121 called p6 (that is, from your root directory cse109.121/p6) for doing your work. Finally, indicate you wish the assignment to be collected by executing the unix command "touch DONE", which will create a file of 0 bytes named DONE. Then all files in the subdirectory p6 (but not in subdirectories of the subdirectory p6) will be collected. I will test your program using a Makefile that you provide to compile your code. Note: This assignment depends on classes Lex, Word, Node< , >, and Tree< , >, developed in earlier assignments. It would be best if you used your versions of these files, but you can use the object files lex.o, word.o, and the files table.t, node.t, word.h, and lex.h To aid you I have stored these files in /proj/csc109/p6. If you use them, it is VERY IMPORTANT that you use them as I direct. Remember, you don't want to aggravate me. Your makefile should have the target "clean:' It should have three lines (in the given order): rm -f *~ *.o p6 cp /proj/csc109/p6/word.o word.o cp /proj/csc109/p6/lex.o lex.o Note: I will store some test files in /proj/csc109/p6. I will use these files, and perhaps others, to test your program. Note: You should compare the behavior of your program to the behavior of stomasm, my solution to this assignment. Note: I WILL NOT BE ABLE TO PROVIDE THE FILES parse.h and parse.cc when you do the next assignment. Thus, you must get p6 running in order to do p7. After the due date for this assignment, if your class Parse is not functioning well, I will help you get it functioning properly. Note: As pointed out above, it will be useful to have a table for storing the line labels and the corresponding memory locations of the lines of STOM code that will be generated in the next assignment. It will also be useful to have a table for storing the names of the StomASM variables and their corresponding memory locations in STOM. Once again I remind you to avoid unfair collaboration. To understand what is meant by "unfair collaboration" read the syllabus again.