rendered paste body main : (decl )* main_def ;
decl : #(i:INT ( init )* );// { code.println("TEST1: " + i.toString()); } ;
init { String i = null; }
// : #(INIT c:IDENT ) {code.println( pFD() + "\tli\t$v1," + i + "\n\tsw\t$v1," + table.getFullName(c) ); }
: #(INIT a:IDENT i=expr ) {code.println( pFD() + table.getFullName(a) + ":\n\t.word\t" + i); }
| b:IDENT {code.println(pFiD() + table.getFullName(b) + ":\n\t.space\t4"); }
;
// iwm comment included so diff stops complaining!
main_def : {code.println("#labcompile last changed 18:07 20th March 2007\n#Ian Moor iwm@doc.ic.ac.uk\n\t.text\n\t.globl\tmain\nmain:"); firstData = true; firstiData = true;} #(MAIN block)
{
// Print all the data at the end of the program (like labcompile :-))
code.println(pFC() + "\tli\t$v0,10\n\tsyscall\n\t.data");
for (int i = 0; i < sdata.size(); i++) {
code.println("S" + i + ": .asciiz" + "\t" + "" + sdata.get(i).toString() + "");
// cool, sdata.get(i).toString() is already enclosed in ".
}
};
block :
#(DECLBLOCK
{ table.pushScope(); } // This action tells the symbol table a new scope is entered
(decl)+ (statement)*)
{ table.popScope(); }
|
#(LBRACKET (statement )* )
;