summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIru Cai <mytbk920423@gmail.com>2014-10-08 21:15:43 +0800
committerIru Cai <mytbk920423@gmail.com>2014-10-08 21:15:43 +0800
commit748308e11e6791284b302f61e5bc0d99a0957b6a (patch)
tree31b88d40d043f39d54ab90393656300656aaa209
downloadminijava-748308e11e6791284b302f61e5bc0d99a0957b6a.tar.xz
First commit
-rw-r--r--src/Main.java7
-rw-r--r--src/kanga/JavaCharStream.java587
-rw-r--r--src/kanga/KangaParser.java986
-rw-r--r--src/kanga/KangaParserConstants.java178
-rw-r--r--src/kanga/KangaParserTokenManager.java1101
-rw-r--r--src/kanga/ParseException.java191
-rw-r--r--src/kanga/Token.java80
-rw-r--r--src/kanga/TokenMgrError.java132
-rw-r--r--src/kanga/kanga2mips/Main.java32
-rw-r--r--src/kanga/syntaxtree/ALoadStmt.java43
-rw-r--r--src/kanga/syntaxtree/AStoreStmt.java43
-rw-r--r--src/kanga/syntaxtree/BinOp.java37
-rw-r--r--src/kanga/syntaxtree/CJumpStmt.java43
-rw-r--r--src/kanga/syntaxtree/CallStmt.java39
-rw-r--r--src/kanga/syntaxtree/ErrorStmt.java35
-rw-r--r--src/kanga/syntaxtree/Exp.java33
-rw-r--r--src/kanga/syntaxtree/Goal.java87
-rw-r--r--src/kanga/syntaxtree/HAllocate.java39
-rw-r--r--src/kanga/syntaxtree/HLoadStmt.java47
-rw-r--r--src/kanga/syntaxtree/HStoreStmt.java47
-rw-r--r--src/kanga/syntaxtree/IntegerLiteral.java31
-rw-r--r--src/kanga/syntaxtree/JumpStmt.java39
-rw-r--r--src/kanga/syntaxtree/Label.java31
-rw-r--r--src/kanga/syntaxtree/MoveStmt.java43
-rw-r--r--src/kanga/syntaxtree/NoOpStmt.java35
-rw-r--r--src/kanga/syntaxtree/Node.java16
-rw-r--r--src/kanga/syntaxtree/NodeChoice.java36
-rw-r--r--src/kanga/syntaxtree/NodeList.java45
-rw-r--r--src/kanga/syntaxtree/NodeListInterface.java22
-rw-r--r--src/kanga/syntaxtree/NodeListOptional.java46
-rw-r--r--src/kanga/syntaxtree/NodeOptional.java41
-rw-r--r--src/kanga/syntaxtree/NodeSequence.java46
-rw-r--r--src/kanga/syntaxtree/NodeToken.java88
-rw-r--r--src/kanga/syntaxtree/Operator.java34
-rw-r--r--src/kanga/syntaxtree/PassArgStmt.java43
-rw-r--r--src/kanga/syntaxtree/PrintStmt.java39
-rw-r--r--src/kanga/syntaxtree/Procedure.java79
-rw-r--r--src/kanga/syntaxtree/Reg.java54
-rw-r--r--src/kanga/syntaxtree/SimpleExp.java33
-rw-r--r--src/kanga/syntaxtree/SpilledArg.java39
-rw-r--r--src/kanga/syntaxtree/Stmt.java42
-rw-r--r--src/kanga/syntaxtree/StmtList.java31
-rw-r--r--src/kanga/visitor/DepthFirstVisitor.java385
-rw-r--r--src/kanga/visitor/GJDepthFirst.java455
-rw-r--r--src/kanga/visitor/GJNoArguDepthFirst.java455
-rw-r--r--src/kanga/visitor/GJNoArguVisitor.java271
-rw-r--r--src/kanga/visitor/GJVisitor.java270
-rw-r--r--src/kanga/visitor/GJVoidDepthFirst.java395
-rw-r--r--src/kanga/visitor/GJVoidVisitor.java271
-rw-r--r--src/kanga/visitor/Visitor.java271
-rw-r--r--src/minijava/JavaCharStream.java587
-rw-r--r--src/minijava/MiniJavaParser.java1947
-rw-r--r--src/minijava/MiniJavaParserConstants.java102
-rw-r--r--src/minijava/MiniJavaParserTokenManager.java1232
-rw-r--r--src/minijava/ParseException.java191
-rw-r--r--src/minijava/Token.java80
-rw-r--r--src/minijava/TokenMgrError.java132
-rw-r--r--src/minijava/minijava2piglet/Main.java37
-rw-r--r--src/minijava/symboltable/MClass.java44
-rw-r--r--src/minijava/symboltable/MClasses.java31
-rw-r--r--src/minijava/symboltable/MIdentifier.java17
-rw-r--r--src/minijava/symboltable/MMethod.java11
-rw-r--r--src/minijava/symboltable/MMethodList.java24
-rw-r--r--src/minijava/symboltable/MType.java43
-rw-r--r--src/minijava/symboltable/MVarList.java24
-rw-r--r--src/minijava/symboltable/MVariable.java11
-rw-r--r--src/minijava/syntaxtree/AllocationExpression.java47
-rw-r--r--src/minijava/syntaxtree/AndExpression.java43
-rw-r--r--src/minijava/syntaxtree/ArrayAllocationExpression.java51
-rw-r--r--src/minijava/syntaxtree/ArrayAssignmentStatement.java59
-rw-r--r--src/minijava/syntaxtree/ArrayLength.java43
-rw-r--r--src/minijava/syntaxtree/ArrayLookup.java47
-rw-r--r--src/minijava/syntaxtree/ArrayType.java43
-rw-r--r--src/minijava/syntaxtree/AssignmentStatement.java47
-rw-r--r--src/minijava/syntaxtree/Block.java43
-rw-r--r--src/minijava/syntaxtree/BooleanType.java35
-rw-r--r--src/minijava/syntaxtree/BracketExpression.java43
-rw-r--r--src/minijava/syntaxtree/ClassDeclaration.java55
-rw-r--r--src/minijava/syntaxtree/ClassExtendsDeclaration.java63
-rw-r--r--src/minijava/syntaxtree/CompareExpression.java43
-rw-r--r--src/minijava/syntaxtree/Expression.java39
-rw-r--r--src/minijava/syntaxtree/ExpressionList.java34
-rw-r--r--src/minijava/syntaxtree/ExpressionRest.java39
-rw-r--r--src/minijava/syntaxtree/FalseLiteral.java35
-rw-r--r--src/minijava/syntaxtree/FormalParameter.java34
-rw-r--r--src/minijava/syntaxtree/FormalParameterList.java34
-rw-r--r--src/minijava/syntaxtree/FormalParameterRest.java39
-rw-r--r--src/minijava/syntaxtree/Goal.java43
-rw-r--r--src/minijava/syntaxtree/Identifier.java31
-rw-r--r--src/minijava/syntaxtree/IfStatement.java59
-rw-r--r--src/minijava/syntaxtree/IntegerLiteral.java31
-rw-r--r--src/minijava/syntaxtree/IntegerType.java35
-rw-r--r--src/minijava/syntaxtree/MainClass.java99
-rw-r--r--src/minijava/syntaxtree/MessageSend.java55
-rw-r--r--src/minijava/syntaxtree/MethodDeclaration.java83
-rw-r--r--src/minijava/syntaxtree/MinusExpression.java43
-rw-r--r--src/minijava/syntaxtree/Node.java16
-rw-r--r--src/minijava/syntaxtree/NodeChoice.java36
-rw-r--r--src/minijava/syntaxtree/NodeList.java45
-rw-r--r--src/minijava/syntaxtree/NodeListInterface.java22
-rw-r--r--src/minijava/syntaxtree/NodeListOptional.java46
-rw-r--r--src/minijava/syntaxtree/NodeOptional.java41
-rw-r--r--src/minijava/syntaxtree/NodeSequence.java46
-rw-r--r--src/minijava/syntaxtree/NodeToken.java88
-rw-r--r--src/minijava/syntaxtree/NotExpression.java39
-rw-r--r--src/minijava/syntaxtree/PlusExpression.java43
-rw-r--r--src/minijava/syntaxtree/PrimaryExpression.java39
-rw-r--r--src/minijava/syntaxtree/PrintStatement.java51
-rw-r--r--src/minijava/syntaxtree/Statement.java36
-rw-r--r--src/minijava/syntaxtree/ThisExpression.java35
-rw-r--r--src/minijava/syntaxtree/TimesExpression.java43
-rw-r--r--src/minijava/syntaxtree/TrueLiteral.java35
-rw-r--r--src/minijava/syntaxtree/Type.java34
-rw-r--r--src/minijava/syntaxtree/TypeDeclaration.java32
-rw-r--r--src/minijava/syntaxtree/VarDeclaration.java43
-rw-r--r--src/minijava/syntaxtree/WhileStatement.java51
-rw-r--r--src/minijava/typecheck/Main.java42
-rw-r--r--src/minijava/typecheck/PrintError.java24
-rw-r--r--src/minijava/visitor/BuildSymbolTableVisitor.java732
-rw-r--r--src/minijava/visitor/DepthFirstVisitor.java623
-rw-r--r--src/minijava/visitor/GJDepthFirst.java727
-rw-r--r--src/minijava/visitor/GJNoArguDepthFirst.java727
-rw-r--r--src/minijava/visitor/GJNoArguVisitor.java416
-rw-r--r--src/minijava/visitor/GJVisitor.java415
-rw-r--r--src/minijava/visitor/GJVoidDepthFirst.java633
-rw-r--r--src/minijava/visitor/GJVoidVisitor.java416
-rw-r--r--src/minijava/visitor/Visitor.java416
-rw-r--r--src/piglet/JavaCharStream.java587
-rw-r--r--src/piglet/ParseException.java192
-rw-r--r--src/piglet/PigletParser.java676
-rw-r--r--src/piglet/PigletParserConstants.java106
-rw-r--r--src/piglet/PigletParserTokenManager.java925
-rw-r--r--src/piglet/Token.java80
-rw-r--r--src/piglet/TokenMgrError.java132
-rw-r--r--src/piglet/piglet2spiglet/Main.java38
-rw-r--r--src/piglet/syntaxtree/BinOp.java37
-rw-r--r--src/piglet/syntaxtree/CJumpStmt.java43
-rw-r--r--src/piglet/syntaxtree/Call.java51
-rw-r--r--src/piglet/syntaxtree/ErrorStmt.java35
-rw-r--r--src/piglet/syntaxtree/Exp.java37
-rw-r--r--src/piglet/syntaxtree/Goal.java51
-rw-r--r--src/piglet/syntaxtree/HAllocate.java39
-rw-r--r--src/piglet/syntaxtree/HLoadStmt.java47
-rw-r--r--src/piglet/syntaxtree/HStoreStmt.java47
-rw-r--r--src/piglet/syntaxtree/IntegerLiteral.java31
-rw-r--r--src/piglet/syntaxtree/JumpStmt.java39
-rw-r--r--src/piglet/syntaxtree/Label.java31
-rw-r--r--src/piglet/syntaxtree/MoveStmt.java43
-rw-r--r--src/piglet/syntaxtree/NoOpStmt.java35
-rw-r--r--src/piglet/syntaxtree/Node.java16
-rw-r--r--src/piglet/syntaxtree/NodeChoice.java36
-rw-r--r--src/piglet/syntaxtree/NodeList.java45
-rw-r--r--src/piglet/syntaxtree/NodeListInterface.java22
-rw-r--r--src/piglet/syntaxtree/NodeListOptional.java46
-rw-r--r--src/piglet/syntaxtree/NodeOptional.java41
-rw-r--r--src/piglet/syntaxtree/NodeSequence.java46
-rw-r--r--src/piglet/syntaxtree/NodeToken.java88
-rw-r--r--src/piglet/syntaxtree/Operator.java34
-rw-r--r--src/piglet/syntaxtree/PrintStmt.java39
-rw-r--r--src/piglet/syntaxtree/Procedure.java51
-rw-r--r--src/piglet/syntaxtree/Stmt.java38
-rw-r--r--src/piglet/syntaxtree/StmtExp.java51
-rw-r--r--src/piglet/syntaxtree/StmtList.java31
-rw-r--r--src/piglet/syntaxtree/Temp.java39
-rw-r--r--src/piglet/visitor/DepthFirstVisitor.java298
-rw-r--r--src/piglet/visitor/GJDepthFirst.java360
-rw-r--r--src/piglet/visitor/GJNoArguDepthFirst.java360
-rw-r--r--src/piglet/visitor/GJNoArguVisitor.java207
-rw-r--r--src/piglet/visitor/GJVisitor.java206
-rw-r--r--src/piglet/visitor/GJVoidDepthFirst.java308
-rw-r--r--src/piglet/visitor/GJVoidVisitor.java207
-rw-r--r--src/piglet/visitor/Visitor.java207
-rw-r--r--src/spiglet/JavaCharStream.java587
-rw-r--r--src/spiglet/ParseException.java191
-rw-r--r--src/spiglet/SpigletParser.java682
-rw-r--r--src/spiglet/SpigletParserConstants.java106
-rw-r--r--src/spiglet/SpigletParserTokenManager.java924
-rw-r--r--src/spiglet/Token.java80
-rw-r--r--src/spiglet/TokenMgrError.java132
-rw-r--r--src/spiglet/spiglet2kanga/Main.java39
-rw-r--r--src/spiglet/syntaxtree/BinOp.java37
-rw-r--r--src/spiglet/syntaxtree/CJumpStmt.java43
-rw-r--r--src/spiglet/syntaxtree/Call.java51
-rw-r--r--src/spiglet/syntaxtree/ErrorStmt.java35
-rw-r--r--src/spiglet/syntaxtree/Exp.java34
-rw-r--r--src/spiglet/syntaxtree/Goal.java51
-rw-r--r--src/spiglet/syntaxtree/HAllocate.java39
-rw-r--r--src/spiglet/syntaxtree/HLoadStmt.java47
-rw-r--r--src/spiglet/syntaxtree/HStoreStmt.java47
-rw-r--r--src/spiglet/syntaxtree/IntegerLiteral.java31
-rw-r--r--src/spiglet/syntaxtree/JumpStmt.java39
-rw-r--r--src/spiglet/syntaxtree/Label.java31
-rw-r--r--src/spiglet/syntaxtree/MoveStmt.java43
-rw-r--r--src/spiglet/syntaxtree/NoOpStmt.java35
-rw-r--r--src/spiglet/syntaxtree/Node.java16
-rw-r--r--src/spiglet/syntaxtree/NodeChoice.java36
-rw-r--r--src/spiglet/syntaxtree/NodeList.java45
-rw-r--r--src/spiglet/syntaxtree/NodeListInterface.java22
-rw-r--r--src/spiglet/syntaxtree/NodeListOptional.java46
-rw-r--r--src/spiglet/syntaxtree/NodeOptional.java41
-rw-r--r--src/spiglet/syntaxtree/NodeSequence.java46
-rw-r--r--src/spiglet/syntaxtree/NodeToken.java88
-rw-r--r--src/spiglet/syntaxtree/Operator.java34
-rw-r--r--src/spiglet/syntaxtree/PrintStmt.java39
-rw-r--r--src/spiglet/syntaxtree/Procedure.java51
-rw-r--r--src/spiglet/syntaxtree/SimpleExp.java33
-rw-r--r--src/spiglet/syntaxtree/Stmt.java38
-rw-r--r--src/spiglet/syntaxtree/StmtExp.java51
-rw-r--r--src/spiglet/syntaxtree/StmtList.java31
-rw-r--r--src/spiglet/syntaxtree/Temp.java39
-rw-r--r--src/spiglet/visitor/DepthFirstVisitor.java305
-rw-r--r--src/spiglet/visitor/GJDepthFirst.java369
-rw-r--r--src/spiglet/visitor/GJNoArguDepthFirst.java369
-rw-r--r--src/spiglet/visitor/GJNoArguVisitor.java212
-rw-r--r--src/spiglet/visitor/GJVisitor.java211
-rw-r--r--src/spiglet/visitor/GJVoidDepthFirst.java315
-rw-r--r--src/spiglet/visitor/GJVoidVisitor.java212
-rw-r--r--src/spiglet/visitor/Visitor.java212
218 files changed, 31616 insertions, 0 deletions
diff --git a/src/Main.java b/src/Main.java
new file mode 100644
index 0000000..461b6f0
--- /dev/null
+++ b/src/Main.java
@@ -0,0 +1,7 @@
+public class Main {
+
+ public static void main(String[] args) {
+
+
+ }
+}
diff --git a/src/kanga/JavaCharStream.java b/src/kanga/JavaCharStream.java
new file mode 100644
index 0000000..209c2a0
--- /dev/null
+++ b/src/kanga/JavaCharStream.java
@@ -0,0 +1,587 @@
+package kanga;
+/* Generated By:JavaCC: Do not edit this line. JavaCharStream.java Version 4.0 */
+/**
+ * An implementation of interface CharStream, where the stream is assumed to
+ * contain only ASCII characters (with java-like unicode escape processing).
+ */
+
+public class JavaCharStream
+{
+ public static final boolean staticFlag = true;
+ static final int hexval(char c) throws java.io.IOException {
+ switch(c)
+ {
+ case '0' :
+ return 0;
+ case '1' :
+ return 1;
+ case '2' :
+ return 2;
+ case '3' :
+ return 3;
+ case '4' :
+ return 4;
+ case '5' :
+ return 5;
+ case '6' :
+ return 6;
+ case '7' :
+ return 7;
+ case '8' :
+ return 8;
+ case '9' :
+ return 9;
+
+ case 'a' :
+ case 'A' :
+ return 10;
+ case 'b' :
+ case 'B' :
+ return 11;
+ case 'c' :
+ case 'C' :
+ return 12;
+ case 'd' :
+ case 'D' :
+ return 13;
+ case 'e' :
+ case 'E' :
+ return 14;
+ case 'f' :
+ case 'F' :
+ return 15;
+ }
+
+ throw new java.io.IOException(); // Should never come here
+ }
+
+ static public int bufpos = -1;
+ static int bufsize;
+ static int available;
+ static int tokenBegin;
+ static protected int bufline[];
+ static protected int bufcolumn[];
+
+ static protected int column = 0;
+ static protected int line = 1;
+
+ static protected boolean prevCharIsCR = false;
+ static protected boolean prevCharIsLF = false;
+
+ static protected java.io.Reader inputStream;
+
+ static protected char[] nextCharBuf;
+ static protected char[] buffer;
+ static protected int maxNextCharInd = 0;
+ static protected int nextCharInd = -1;
+ static protected int inBuf = 0;
+ static protected int tabSize = 8;
+
+ static protected void setTabSize(int i) { tabSize = i; }
+ static protected int getTabSize(int i) { return tabSize; }
+
+ static protected void ExpandBuff(boolean wrapAround)
+ {
+ char[] newbuffer = new char[bufsize + 2048];
+ int newbufline[] = new int[bufsize + 2048];
+ int newbufcolumn[] = new int[bufsize + 2048];
+
+ try
+ {
+ if (wrapAround)
+ {
+ System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin);
+ System.arraycopy(buffer, 0, newbuffer,
+ bufsize - tokenBegin, bufpos);
+ buffer = newbuffer;
+
+ System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin);
+ System.arraycopy(bufline, 0, newbufline, bufsize - tokenBegin, bufpos);
+ bufline = newbufline;
+
+ System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin);
+ System.arraycopy(bufcolumn, 0, newbufcolumn, bufsize - tokenBegin, bufpos);
+ bufcolumn = newbufcolumn;
+
+ bufpos += (bufsize - tokenBegin);
+ }
+ else
+ {
+ System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin);
+ buffer = newbuffer;
+
+ System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin);
+ bufline = newbufline;
+
+ System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin);
+ bufcolumn = newbufcolumn;
+
+ bufpos -= tokenBegin;
+ }
+ }
+ catch (Throwable t)
+ {
+ throw new Error(t.getMessage());
+ }
+
+ available = (bufsize += 2048);
+ tokenBegin = 0;
+ }
+
+ static protected void FillBuff() throws java.io.IOException
+ {
+ int i;
+ if (maxNextCharInd == 4096)
+ maxNextCharInd = nextCharInd = 0;
+
+ try {
+ if ((i = inputStream.read(nextCharBuf, maxNextCharInd,
+ 4096 - maxNextCharInd)) == -1)
+ {
+ inputStream.close();
+ throw new java.io.IOException();
+ }
+ else
+ maxNextCharInd += i;
+ return;
+ }
+ catch(java.io.IOException e) {
+ if (bufpos != 0)
+ {
+ --bufpos;
+ backup(0);
+ }
+ else
+ {
+ bufline[bufpos] = line;
+ bufcolumn[bufpos] = column;
+ }
+ throw e;
+ }
+ }
+
+ static protected char ReadByte() throws java.io.IOException
+ {
+ if (++nextCharInd >= maxNextCharInd)
+ FillBuff();
+
+ return nextCharBuf[nextCharInd];
+ }
+
+ static public char BeginToken() throws java.io.IOException
+ {
+ if (inBuf > 0)
+ {
+ --inBuf;
+
+ if (++bufpos == bufsize)
+ bufpos = 0;
+
+ tokenBegin = bufpos;
+ return buffer[bufpos];
+ }
+
+ tokenBegin = 0;
+ bufpos = -1;
+
+ return readChar();
+ }
+
+ static protected void AdjustBuffSize()
+ {
+ if (available == bufsize)
+ {
+ if (tokenBegin > 2048)
+ {
+ bufpos = 0;
+ available = tokenBegin;
+ }
+ else
+ ExpandBuff(false);
+ }
+ else if (available > tokenBegin)
+ available = bufsize;
+ else if ((tokenBegin - available) < 2048)
+ ExpandBuff(true);
+ else
+ available = tokenBegin;
+ }
+
+ static protected void UpdateLineColumn(char c)
+ {
+ column++;
+
+ if (prevCharIsLF)
+ {
+ prevCharIsLF = false;
+ line += (column = 1);
+ }
+ else if (prevCharIsCR)
+ {
+ prevCharIsCR = false;
+ if (c == '\n')
+ {
+ prevCharIsLF = true;
+ }
+ else
+ line += (column = 1);
+ }
+
+ switch (c)
+ {
+ case '\r' :
+ prevCharIsCR = true;
+ break;
+ case '\n' :
+ prevCharIsLF = true;
+ break;
+ case '\t' :
+ column--;
+ column += (tabSize - (column % tabSize));
+ break;
+ default :
+ break;
+ }
+
+ bufline[bufpos] = line;
+ bufcolumn[bufpos] = column;
+ }
+
+ static public char readChar() throws java.io.IOException
+ {
+ if (inBuf > 0)
+ {
+ --inBuf;
+
+ if (++bufpos == bufsize)
+ bufpos = 0;
+
+ return buffer[bufpos];
+ }
+
+ char c;
+
+ if (++bufpos == available)
+ AdjustBuffSize();
+
+ if ((buffer[bufpos] = c = ReadByte()) == '\\')
+ {
+ UpdateLineColumn(c);
+
+ int backSlashCnt = 1;
+
+ for (;;) // Read all the backslashes
+ {
+ if (++bufpos == available)
+ AdjustBuffSize();
+
+ try
+ {
+ if ((buffer[bufpos] = c = ReadByte()) != '\\')
+ {
+ UpdateLineColumn(c);
+ // found a non-backslash char.
+ if ((c == 'u') && ((backSlashCnt & 1) == 1))
+ {
+ if (--bufpos < 0)
+ bufpos = bufsize - 1;
+
+ break;
+ }
+
+ backup(backSlashCnt);
+ return '\\';
+ }
+ }
+ catch(java.io.IOException e)
+ {
+ if (backSlashCnt > 1)
+ backup(backSlashCnt);
+
+ return '\\';
+ }
+
+ UpdateLineColumn(c);
+ backSlashCnt++;
+ }
+
+ // Here, we have seen an odd number of backslash's followed by a 'u'
+ try
+ {
+ while ((c = ReadByte()) == 'u')
+ ++column;
+
+ buffer[bufpos] = c = (char)(hexval(c) << 12 |
+ hexval(ReadByte()) << 8 |
+ hexval(ReadByte()) << 4 |
+ hexval(ReadByte()));
+
+ column += 4;
+ }
+ catch(java.io.IOException e)
+ {
+ throw new Error("Invalid escape character at line " + line +
+ " column " + column + ".");
+ }
+
+ if (backSlashCnt == 1)
+ return c;
+ else
+ {
+ backup(backSlashCnt - 1);
+ return '\\';
+ }
+ }
+ else
+ {
+ UpdateLineColumn(c);
+ return (c);
+ }
+ }
+
+ /**
+ * @deprecated
+ * @see #getEndColumn
+ */
+
+ static public int getColumn() {
+ return bufcolumn[bufpos];
+ }
+
+ /**
+ * @deprecated
+ * @see #getEndLine
+ */
+
+ static public int getLine() {
+ return bufline[bufpos];
+ }
+
+ static public int getEndColumn() {
+ return bufcolumn[bufpos];
+ }
+
+ static public int getEndLine() {
+ return bufline[bufpos];
+ }
+
+ static public int getBeginColumn() {
+ return bufcolumn[tokenBegin];
+ }
+
+ static public int getBeginLine() {
+ return bufline[tokenBegin];
+ }
+
+ static public void backup(int amount) {
+
+ inBuf += amount;
+ if ((bufpos -= amount) < 0)
+ bufpos += bufsize;
+ }
+
+ public JavaCharStream(java.io.Reader dstream,
+ int startline, int startcolumn, int buffersize)
+ {
+ if (inputStream != null)
+ throw new Error("\n ERROR: Second call to the constructor of a static JavaCharStream. You must\n" +
+ " either use ReInit() or set the JavaCC option STATIC to false\n" +
+ " during the generation of this class.");
+ inputStream = dstream;
+ line = startline;
+ column = startcolumn - 1;
+
+ available = bufsize = buffersize;
+ buffer = new char[buffersize];
+ bufline = new int[buffersize];
+ bufcolumn = new int[buffersize];
+ nextCharBuf = new char[4096];
+ }
+
+ public JavaCharStream(java.io.Reader dstream,
+ int startline, int startcolumn)
+ {
+ this(dstream, startline, startcolumn, 4096);
+ }
+
+ public JavaCharStream(java.io.Reader dstream)
+ {
+ this(dstream, 1, 1, 4096);
+ }
+ public void ReInit(java.io.Reader dstream,
+ int startline, int startcolumn, int buffersize)
+ {
+ inputStream = dstream;
+ line = startline;
+ column = startcolumn - 1;
+
+ if (buffer == null || buffersize != buffer.length)
+ {
+ available = bufsize = buffersize;
+ buffer = new char[buffersize];
+ bufline = new int[buffersize];
+ bufcolumn = new int[buffersize];
+ nextCharBuf = new char[4096];
+ }
+ prevCharIsLF = prevCharIsCR = false;
+ tokenBegin = inBuf = maxNextCharInd = 0;
+ nextCharInd = bufpos = -1;
+ }
+
+ public void ReInit(java.io.Reader dstream,
+ int startline, int startcolumn)
+ {
+ ReInit(dstream, startline, startcolumn, 4096);
+ }
+
+ public void ReInit(java.io.Reader dstream)
+ {
+ ReInit(dstream, 1, 1, 4096);
+ }
+ public JavaCharStream(java.io.InputStream dstream, String encoding, int startline,
+ int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException
+ {
+ this(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize);
+ }
+
+ public JavaCharStream(java.io.InputStream dstream, int startline,
+ int startcolumn, int buffersize)
+ {
+ this(new java.io.InputStreamReader(dstream), startline, startcolumn, 4096);
+ }
+
+ public JavaCharStream(java.io.InputStream dstream, String encoding, int startline,
+ int startcolumn) throws java.io.UnsupportedEncodingException
+ {
+ this(dstream, encoding, startline, startcolumn, 4096);
+ }
+
+ public JavaCharStream(java.io.InputStream dstream, int startline,
+ int startcolumn)
+ {
+ this(dstream, startline, startcolumn, 4096);
+ }
+
+ public JavaCharStream(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException
+ {
+ this(dstream, encoding, 1, 1, 4096);
+ }
+
+ public JavaCharStream(java.io.InputStream dstream)
+ {
+ this(dstream, 1, 1, 4096);
+ }
+
+ public void ReInit(java.io.InputStream dstream, String encoding, int startline,
+ int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException
+ {
+ ReInit(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize);
+ }
+
+ public void ReInit(java.io.InputStream dstream, int startline,
+ int startcolumn, int buffersize)
+ {
+ ReInit(new java.io.InputStreamReader(dstream), startline, startcolumn, buffersize);
+ }
+ public void ReInit(java.io.InputStream dstream, String encoding, int startline,
+ int startcolumn) throws java.io.UnsupportedEncodingException
+ {
+ ReInit(dstream, encoding, startline, startcolumn, 4096);
+ }
+ public void ReInit(java.io.InputStream dstream, int startline,
+ int startcolumn)
+ {
+ ReInit(dstream, startline, startcolumn, 4096);
+ }
+ public void ReInit(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException
+ {
+ ReInit(dstream, encoding, 1, 1, 4096);
+ }
+
+ public void ReInit(java.io.InputStream dstream)
+ {
+ ReInit(dstream, 1, 1, 4096);
+ }
+
+ static public String GetImage()
+ {
+ if (bufpos >= tokenBegin)
+ return new String(buffer, tokenBegin, bufpos - tokenBegin + 1);
+ else
+ return new String(buffer, tokenBegin, bufsize - tokenBegin) +
+ new String(buffer, 0, bufpos + 1);
+ }
+
+ static public char[] GetSuffix(int len)
+ {
+ char[] ret = new char[len];
+
+ if ((bufpos + 1) >= len)
+ System.arraycopy(buffer, bufpos - len + 1, ret, 0, len);
+ else
+ {
+ System.arraycopy(buffer, bufsize - (len - bufpos - 1), ret, 0,
+ len - bufpos - 1);
+ System.arraycopy(buffer, 0, ret, len - bufpos - 1, bufpos + 1);
+ }
+
+ return ret;
+ }
+
+ static public void Done()
+ {
+ nextCharBuf = null;
+ buffer = null;
+ bufline = null;
+ bufcolumn = null;
+ }
+
+ /**
+ * Method to adjust line and column numbers for the start of a token.
+ */
+ static public void adjustBeginLineColumn(int newLine, int newCol)
+ {
+ int start = tokenBegin;
+ int len;
+
+ if (bufpos >= tokenBegin)
+ {
+ len = bufpos - tokenBegin + inBuf + 1;
+ }
+ else
+ {
+ len = bufsize - tokenBegin + bufpos + 1 + inBuf;
+ }
+
+ int i = 0, j = 0, k = 0;
+ int nextColDiff = 0, columnDiff = 0;
+
+ while (i < len &&
+ bufline[j = start % bufsize] == bufline[k = ++start % bufsize])
+ {
+ bufline[j] = newLine;
+ nextColDiff = columnDiff + bufcolumn[k] - bufcolumn[j];
+ bufcolumn[j] = newCol + columnDiff;
+ columnDiff = nextColDiff;
+ i++;
+ }
+
+ if (i < len)
+ {
+ bufline[j] = newLine++;
+ bufcolumn[j] = newCol + columnDiff;
+
+ while (i++ < len)
+ {
+ if (bufline[j = start % bufsize] != bufline[++start % bufsize])
+ bufline[j] = newLine++;
+ else
+ bufline[j] = newLine;
+ }
+ }
+
+ line = bufline[j];
+ column = bufcolumn[j];
+ }
+
+}
diff --git a/src/kanga/KangaParser.java b/src/kanga/KangaParser.java
new file mode 100644
index 0000000..a476c1c
--- /dev/null
+++ b/src/kanga/KangaParser.java
@@ -0,0 +1,986 @@
+package kanga;
+/* Generated By:JavaCC: Do not edit this line. KangaParser.java */
+import kanga.syntaxtree.ALoadStmt;
+import kanga.syntaxtree.AStoreStmt;
+import kanga.syntaxtree.BinOp;
+import kanga.syntaxtree.CJumpStmt;
+import kanga.syntaxtree.CallStmt;
+import kanga.syntaxtree.ErrorStmt;
+import kanga.syntaxtree.Exp;
+import kanga.syntaxtree.Goal;
+import kanga.syntaxtree.HAllocate;
+import kanga.syntaxtree.HLoadStmt;
+import kanga.syntaxtree.HStoreStmt;
+import kanga.syntaxtree.IntegerLiteral;
+import kanga.syntaxtree.JumpStmt;
+import kanga.syntaxtree.Label;
+import kanga.syntaxtree.MoveStmt;
+import kanga.syntaxtree.NoOpStmt;
+import kanga.syntaxtree.NodeChoice;
+import kanga.syntaxtree.NodeListOptional;
+import kanga.syntaxtree.NodeOptional;
+import kanga.syntaxtree.NodeSequence;
+import kanga.syntaxtree.NodeToken;
+import kanga.syntaxtree.Operator;
+import kanga.syntaxtree.PassArgStmt;
+import kanga.syntaxtree.PrintStmt;
+import kanga.syntaxtree.Procedure;
+import kanga.syntaxtree.Reg;
+import kanga.syntaxtree.SimpleExp;
+import kanga.syntaxtree.SpilledArg;
+import kanga.syntaxtree.Stmt;
+import kanga.syntaxtree.StmtList;
+
+
+public class KangaParser implements KangaParserConstants {
+
+ static final public Goal Goal() throws ParseException {
+ NodeToken n0;
+ Token n1;
+ NodeToken n2;
+ Token n3;
+ IntegerLiteral n4;
+ NodeToken n5;
+ Token n6;
+ NodeToken n7;
+ Token n8;
+ IntegerLiteral n9;
+ NodeToken n10;
+ Token n11;
+ NodeToken n12;
+ Token n13;
+ IntegerLiteral n14;
+ NodeToken n15;
+ Token n16;
+ StmtList n17;
+ NodeToken n18;
+ Token n19;
+ NodeListOptional n20 = new NodeListOptional();
+ Procedure n21;
+ NodeToken n22;
+ Token n23;
+ n1 = jj_consume_token(MAIN);
+ n0 = JTBToolkit.makeNodeToken(n1);
+ n3 = jj_consume_token(LSQPAREN);
+ n2 = JTBToolkit.makeNodeToken(n3);
+ n4 = IntegerLiteral();
+ n6 = jj_consume_token(RSQPAREN);
+ n5 = JTBToolkit.makeNodeToken(n6);
+ n8 = jj_consume_token(LSQPAREN);
+ n7 = JTBToolkit.makeNodeToken(n8);
+ n9 = IntegerLiteral();
+ n11 = jj_consume_token(RSQPAREN);
+ n10 = JTBToolkit.makeNodeToken(n11);
+ n13 = jj_consume_token(LSQPAREN);
+ n12 = JTBToolkit.makeNodeToken(n13);
+ n14 = IntegerLiteral();
+ n16 = jj_consume_token(RSQPAREN);
+ n15 = JTBToolkit.makeNodeToken(n16);
+ n17 = StmtList();
+ n19 = jj_consume_token(END);
+ n18 = JTBToolkit.makeNodeToken(n19);
+ label_1:
+ while (true) {
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case IDENTIFIER:
+ ;
+ break;
+ default:
+ jj_la1[0] = jj_gen;
+ break label_1;
+ }
+ n21 = Procedure();
+ n20.addNode(n21);
+ }
+ n20.nodes.trimToSize();
+ n23 = jj_consume_token(0);
+ n23.beginColumn++; n23.endColumn++;
+ n22 = JTBToolkit.makeNodeToken(n23);
+ {if (true) return new Goal(n0,n2,n4,n5,n7,n9,n10,n12,n14,n15,n17,n18,n20,n22);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public StmtList StmtList() throws ParseException {
+ NodeListOptional n0 = new NodeListOptional();
+ NodeSequence n1;
+ NodeOptional n2;
+ Label n3;
+ Stmt n4;
+ label_2:
+ while (true) {
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case NOOP:
+ case MOVE:
+ case CALL:
+ case ERROR:
+ case PRINT:
+ case JUMP:
+ case CJUMP:
+ case HSTORE:
+ case HLOAD:
+ case ALOAD:
+ case ASTORE:
+ case PASSARG:
+ case IDENTIFIER:
+ ;
+ break;
+ default:
+ jj_la1[1] = jj_gen;
+ break label_2;
+ }
+ n2 = new NodeOptional();
+ n1 = new NodeSequence(2);
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case IDENTIFIER:
+ n3 = Label();
+ n2.addNode(n3);
+ break;
+ default:
+ jj_la1[2] = jj_gen;
+ ;
+ }
+ n1.addNode(n2);
+ n4 = Stmt();
+ n1.addNode(n4);
+ n0.addNode(n1);
+ }
+ n0.nodes.trimToSize();
+ {if (true) return new StmtList(n0);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public Procedure Procedure() throws ParseException {
+ Label n0;
+ NodeToken n1;
+ Token n2;
+ IntegerLiteral n3;
+ NodeToken n4;
+ Token n5;
+ NodeToken n6;
+ Token n7;
+ IntegerLiteral n8;
+ NodeToken n9;
+ Token n10;
+ NodeToken n11;
+ Token n12;
+ IntegerLiteral n13;
+ NodeToken n14;
+ Token n15;
+ StmtList n16;
+ NodeToken n17;
+ Token n18;
+ n0 = Label();
+ n2 = jj_consume_token(LSQPAREN);
+ n1 = JTBToolkit.makeNodeToken(n2);
+ n3 = IntegerLiteral();
+ n5 = jj_consume_token(RSQPAREN);
+ n4 = JTBToolkit.makeNodeToken(n5);
+ n7 = jj_consume_token(LSQPAREN);
+ n6 = JTBToolkit.makeNodeToken(n7);
+ n8 = IntegerLiteral();
+ n10 = jj_consume_token(RSQPAREN);
+ n9 = JTBToolkit.makeNodeToken(n10);
+ n12 = jj_consume_token(LSQPAREN);
+ n11 = JTBToolkit.makeNodeToken(n12);
+ n13 = IntegerLiteral();
+ n15 = jj_consume_token(RSQPAREN);
+ n14 = JTBToolkit.makeNodeToken(n15);
+ n16 = StmtList();
+ n18 = jj_consume_token(END);
+ n17 = JTBToolkit.makeNodeToken(n18);
+ {if (true) return new Procedure(n0,n1,n3,n4,n6,n8,n9,n11,n13,n14,n16,n17);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public Stmt Stmt() throws ParseException {
+ NodeChoice n0;
+ NoOpStmt n1;
+ ErrorStmt n2;
+ CJumpStmt n3;
+ JumpStmt n4;
+ HStoreStmt n5;
+ HLoadStmt n6;
+ MoveStmt n7;
+ PrintStmt n8;
+ ALoadStmt n9;
+ AStoreStmt n10;
+ PassArgStmt n11;
+ CallStmt n12;
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case NOOP:
+ n1 = NoOpStmt();
+ n0 = new NodeChoice(n1, 0);
+ break;
+ case ERROR:
+ n2 = ErrorStmt();
+ n0 = new NodeChoice(n2, 1);
+ break;
+ case CJUMP:
+ n3 = CJumpStmt();
+ n0 = new NodeChoice(n3, 2);
+ break;
+ case JUMP:
+ n4 = JumpStmt();
+ n0 = new NodeChoice(n4, 3);
+ break;
+ case HSTORE:
+ n5 = HStoreStmt();
+ n0 = new NodeChoice(n5, 4);
+ break;
+ case HLOAD:
+ n6 = HLoadStmt();
+ n0 = new NodeChoice(n6, 5);
+ break;
+ case MOVE:
+ n7 = MoveStmt();
+ n0 = new NodeChoice(n7, 6);
+ break;
+ case PRINT:
+ n8 = PrintStmt();
+ n0 = new NodeChoice(n8, 7);
+ break;
+ case ALOAD:
+ n9 = ALoadStmt();
+ n0 = new NodeChoice(n9, 8);
+ break;
+ case ASTORE:
+ n10 = AStoreStmt();
+ n0 = new NodeChoice(n10, 9);
+ break;
+ case PASSARG:
+ n11 = PassArgStmt();
+ n0 = new NodeChoice(n11, 10);
+ break;
+ case CALL:
+ n12 = CallStmt();
+ n0 = new NodeChoice(n12, 11);
+ break;
+ default:
+ jj_la1[3] = jj_gen;
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ {if (true) return new Stmt(n0);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public NoOpStmt NoOpStmt() throws ParseException {
+ NodeToken n0;
+ Token n1;
+ n1 = jj_consume_token(NOOP);
+ n0 = JTBToolkit.makeNodeToken(n1);
+ {if (true) return new NoOpStmt(n0);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public ErrorStmt ErrorStmt() throws ParseException {
+ NodeToken n0;
+ Token n1;
+ n1 = jj_consume_token(ERROR);
+ n0 = JTBToolkit.makeNodeToken(n1);
+ {if (true) return new ErrorStmt(n0);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public CJumpStmt CJumpStmt() throws ParseException {
+ NodeToken n0;
+ Token n1;
+ Reg n2;
+ Label n3;
+ n1 = jj_consume_token(CJUMP);
+ n0 = JTBToolkit.makeNodeToken(n1);
+ n2 = Reg();
+ n3 = Label();
+ {if (true) return new CJumpStmt(n0,n2,n3);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public JumpStmt JumpStmt() throws ParseException {
+ NodeToken n0;
+ Token n1;
+ Label n2;
+ n1 = jj_consume_token(JUMP);
+ n0 = JTBToolkit.makeNodeToken(n1);
+ n2 = Label();
+ {if (true) return new JumpStmt(n0,n2);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public HStoreStmt HStoreStmt() throws ParseException {
+ NodeToken n0;
+ Token n1;
+ Reg n2;
+ IntegerLiteral n3;
+ Reg n4;
+ n1 = jj_consume_token(HSTORE);
+ n0 = JTBToolkit.makeNodeToken(n1);
+ n2 = Reg();
+ n3 = IntegerLiteral();
+ n4 = Reg();
+ {if (true) return new HStoreStmt(n0,n2,n3,n4);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public HLoadStmt HLoadStmt() throws ParseException {
+ NodeToken n0;
+ Token n1;
+ Reg n2;
+ Reg n3;
+ IntegerLiteral n4;
+ n1 = jj_consume_token(HLOAD);
+ n0 = JTBToolkit.makeNodeToken(n1);
+ n2 = Reg();
+ n3 = Reg();
+ n4 = IntegerLiteral();
+ {if (true) return new HLoadStmt(n0,n2,n3,n4);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public MoveStmt MoveStmt() throws ParseException {
+ NodeToken n0;
+ Token n1;
+ Reg n2;
+ Exp n3;
+ n1 = jj_consume_token(MOVE);
+ n0 = JTBToolkit.makeNodeToken(n1);
+ n2 = Reg();
+ n3 = Exp();
+ {if (true) return new MoveStmt(n0,n2,n3);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public PrintStmt PrintStmt() throws ParseException {
+ NodeToken n0;
+ Token n1;
+ SimpleExp n2;
+ n1 = jj_consume_token(PRINT);
+ n0 = JTBToolkit.makeNodeToken(n1);
+ n2 = SimpleExp();
+ {if (true) return new PrintStmt(n0,n2);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public ALoadStmt ALoadStmt() throws ParseException {
+ NodeToken n0;
+ Token n1;
+ Reg n2;
+ SpilledArg n3;
+ n1 = jj_consume_token(ALOAD);
+ n0 = JTBToolkit.makeNodeToken(n1);
+ n2 = Reg();
+ n3 = SpilledArg();
+ {if (true) return new ALoadStmt(n0,n2,n3);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public AStoreStmt AStoreStmt() throws ParseException {
+ NodeToken n0;
+ Token n1;
+ SpilledArg n2;
+ Reg n3;
+ n1 = jj_consume_token(ASTORE);
+ n0 = JTBToolkit.makeNodeToken(n1);
+ n2 = SpilledArg();
+ n3 = Reg();
+ {if (true) return new AStoreStmt(n0,n2,n3);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public PassArgStmt PassArgStmt() throws ParseException {
+ NodeToken n0;
+ Token n1;
+ IntegerLiteral n2;
+ Reg n3;
+ n1 = jj_consume_token(PASSARG);
+ n0 = JTBToolkit.makeNodeToken(n1);
+ n2 = IntegerLiteral();
+ n3 = Reg();
+ {if (true) return new PassArgStmt(n0,n2,n3);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public CallStmt CallStmt() throws ParseException {
+ NodeToken n0;
+ Token n1;
+ SimpleExp n2;
+ n1 = jj_consume_token(CALL);
+ n0 = JTBToolkit.makeNodeToken(n1);
+ n2 = SimpleExp();
+ {if (true) return new CallStmt(n0,n2);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public Exp Exp() throws ParseException {
+ NodeChoice n0;
+ HAllocate n1;
+ BinOp n2;
+ SimpleExp n3;
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case HALLOCATE:
+ n1 = HAllocate();
+ n0 = new NodeChoice(n1, 0);
+ break;
+ case LT:
+ case PLUS:
+ case MINUS:
+ case TIMES:
+ n2 = BinOp();
+ n0 = new NodeChoice(n2, 1);
+ break;
+ case v0:
+ case v1:
+ case a0:
+ case a1:
+ case a2:
+ case a3:
+ case t0:
+ case t1:
+ case t2:
+ case t3:
+ case t4:
+ case t5:
+ case t6:
+ case t7:
+ case s0:
+ case s1:
+ case s2:
+ case s3:
+ case s4:
+ case s5:
+ case s6:
+ case s7:
+ case t8:
+ case t9:
+ case INTEGER_LITERAL:
+ case IDENTIFIER:
+ n3 = SimpleExp();
+ n0 = new NodeChoice(n3, 2);
+ break;
+ default:
+ jj_la1[4] = jj_gen;
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ {if (true) return new Exp(n0);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public HAllocate HAllocate() throws ParseException {
+ NodeToken n0;
+ Token n1;
+ SimpleExp n2;
+ n1 = jj_consume_token(HALLOCATE);
+ n0 = JTBToolkit.makeNodeToken(n1);
+ n2 = SimpleExp();
+ {if (true) return new HAllocate(n0,n2);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public BinOp BinOp() throws ParseException {
+ Operator n0;
+ Reg n1;
+ SimpleExp n2;
+ n0 = Operator();
+ n1 = Reg();
+ n2 = SimpleExp();
+ {if (true) return new BinOp(n0,n1,n2);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public Operator Operator() throws ParseException {
+ NodeChoice n0;
+ NodeToken n1;
+ Token n2;
+ NodeToken n3;
+ Token n4;
+ NodeToken n5;
+ Token n6;
+ NodeToken n7;
+ Token n8;
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case LT:
+ n2 = jj_consume_token(LT);
+ n1 = JTBToolkit.makeNodeToken(n2);
+ n0 = new NodeChoice(n1, 0);
+ break;
+ case PLUS:
+ n4 = jj_consume_token(PLUS);
+ n3 = JTBToolkit.makeNodeToken(n4);
+ n0 = new NodeChoice(n3, 1);
+ break;
+ case MINUS:
+ n6 = jj_consume_token(MINUS);
+ n5 = JTBToolkit.makeNodeToken(n6);
+ n0 = new NodeChoice(n5, 2);
+ break;
+ case TIMES:
+ n8 = jj_consume_token(TIMES);
+ n7 = JTBToolkit.makeNodeToken(n8);
+ n0 = new NodeChoice(n7, 3);
+ break;
+ default:
+ jj_la1[5] = jj_gen;
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ {if (true) return new Operator(n0);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public SpilledArg SpilledArg() throws ParseException {
+ NodeToken n0;
+ Token n1;
+ IntegerLiteral n2;
+ n1 = jj_consume_token(SPILLEDARG);
+ n0 = JTBToolkit.makeNodeToken(n1);
+ n2 = IntegerLiteral();
+ {if (true) return new SpilledArg(n0,n2);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public SimpleExp SimpleExp() throws ParseException {
+ NodeChoice n0;
+ Reg n1;
+ IntegerLiteral n2;
+ Label n3;
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case v0:
+ case v1:
+ case a0:
+ case a1:
+ case a2:
+ case a3:
+ case t0:
+ case t1:
+ case t2:
+ case t3:
+ case t4:
+ case t5:
+ case t6:
+ case t7:
+ case s0:
+ case s1:
+ case s2:
+ case s3:
+ case s4:
+ case s5:
+ case s6:
+ case s7:
+ case t8:
+ case t9:
+ n1 = Reg();
+ n0 = new NodeChoice(n1, 0);
+ break;
+ case INTEGER_LITERAL:
+ n2 = IntegerLiteral();
+ n0 = new NodeChoice(n2, 1);
+ break;
+ case IDENTIFIER:
+ n3 = Label();
+ n0 = new NodeChoice(n3, 2);
+ break;
+ default:
+ jj_la1[6] = jj_gen;
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ {if (true) return new SimpleExp(n0);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public Reg Reg() throws ParseException {
+ NodeChoice n0;
+ NodeToken n1;
+ Token n2;
+ NodeToken n3;
+ Token n4;
+ NodeToken n5;
+ Token n6;
+ NodeToken n7;
+ Token n8;
+ NodeToken n9;
+ Token n10;
+ NodeToken n11;
+ Token n12;
+ NodeToken n13;
+ Token n14;
+ NodeToken n15;
+ Token n16;
+ NodeToken n17;
+ Token n18;
+ NodeToken n19;
+ Token n20;
+ NodeToken n21;
+ Token n22;
+ NodeToken n23;
+ Token n24;
+ NodeToken n25;
+ Token n26;
+ NodeToken n27;
+ Token n28;
+ NodeToken n29;
+ Token n30;
+ NodeToken n31;
+ Token n32;
+ NodeToken n33;
+ Token n34;
+ NodeToken n35;
+ Token n36;
+ NodeToken n37;
+ Token n38;
+ NodeToken n39;
+ Token n40;
+ NodeToken n41;
+ Token n42;
+ NodeToken n43;
+ Token n44;
+ NodeToken n45;
+ Token n46;
+ NodeToken n47;
+ Token n48;
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case a0:
+ n2 = jj_consume_token(a0);
+ n1 = JTBToolkit.makeNodeToken(n2);
+ n0 = new NodeChoice(n1, 0);
+ break;
+ case a1:
+ n4 = jj_consume_token(a1);
+ n3 = JTBToolkit.makeNodeToken(n4);
+ n0 = new NodeChoice(n3, 1);
+ break;
+ case a2:
+ n6 = jj_consume_token(a2);
+ n5 = JTBToolkit.makeNodeToken(n6);
+ n0 = new NodeChoice(n5, 2);
+ break;
+ case a3:
+ n8 = jj_consume_token(a3);
+ n7 = JTBToolkit.makeNodeToken(n8);
+ n0 = new NodeChoice(n7, 3);
+ break;
+ case t0:
+ n10 = jj_consume_token(t0);
+ n9 = JTBToolkit.makeNodeToken(n10);
+ n0 = new NodeChoice(n9, 4);
+ break;
+ case t1:
+ n12 = jj_consume_token(t1);
+ n11 = JTBToolkit.makeNodeToken(n12);
+ n0 = new NodeChoice(n11, 5);
+ break;
+ case t2:
+ n14 = jj_consume_token(t2);
+ n13 = JTBToolkit.makeNodeToken(n14);
+ n0 = new NodeChoice(n13, 6);
+ break;
+ case t3:
+ n16 = jj_consume_token(t3);
+ n15 = JTBToolkit.makeNodeToken(n16);
+ n0 = new NodeChoice(n15, 7);
+ break;
+ case t4:
+ n18 = jj_consume_token(t4);
+ n17 = JTBToolkit.makeNodeToken(n18);
+ n0 = new NodeChoice(n17, 8);
+ break;
+ case t5:
+ n20 = jj_consume_token(t5);
+ n19 = JTBToolkit.makeNodeToken(n20);
+ n0 = new NodeChoice(n19, 9);
+ break;
+ case t6:
+ n22 = jj_consume_token(t6);
+ n21 = JTBToolkit.makeNodeToken(n22);
+ n0 = new NodeChoice(n21, 10);
+ break;
+ case t7:
+ n24 = jj_consume_token(t7);
+ n23 = JTBToolkit.makeNodeToken(n24);
+ n0 = new NodeChoice(n23, 11);
+ break;
+ case s0:
+ n26 = jj_consume_token(s0);
+ n25 = JTBToolkit.makeNodeToken(n26);
+ n0 = new NodeChoice(n25, 12);
+ break;
+ case s1:
+ n28 = jj_consume_token(s1);
+ n27 = JTBToolkit.makeNodeToken(n28);
+ n0 = new NodeChoice(n27, 13);
+ break;
+ case s2:
+ n30 = jj_consume_token(s2);
+ n29 = JTBToolkit.makeNodeToken(n30);
+ n0 = new NodeChoice(n29, 14);
+ break;
+ case s3:
+ n32 = jj_consume_token(s3);
+ n31 = JTBToolkit.makeNodeToken(n32);
+ n0 = new NodeChoice(n31, 15);
+ break;
+ case s4:
+ n34 = jj_consume_token(s4);
+ n33 = JTBToolkit.makeNodeToken(n34);
+ n0 = new NodeChoice(n33, 16);
+ break;
+ case s5:
+ n36 = jj_consume_token(s5);
+ n35 = JTBToolkit.makeNodeToken(n36);
+ n0 = new NodeChoice(n35, 17);
+ break;
+ case s6:
+ n38 = jj_consume_token(s6);
+ n37 = JTBToolkit.makeNodeToken(n38);
+ n0 = new NodeChoice(n37, 18);
+ break;
+ case s7:
+ n40 = jj_consume_token(s7);
+ n39 = JTBToolkit.makeNodeToken(n40);
+ n0 = new NodeChoice(n39, 19);
+ break;
+ case t8:
+ n42 = jj_consume_token(t8);
+ n41 = JTBToolkit.makeNodeToken(n42);
+ n0 = new NodeChoice(n41, 20);
+ break;
+ case t9:
+ n44 = jj_consume_token(t9);
+ n43 = JTBToolkit.makeNodeToken(n44);
+ n0 = new NodeChoice(n43, 21);
+ break;
+ case v0:
+ n46 = jj_consume_token(v0);
+ n45 = JTBToolkit.makeNodeToken(n46);
+ n0 = new NodeChoice(n45, 22);
+ break;
+ case v1:
+ n48 = jj_consume_token(v1);
+ n47 = JTBToolkit.makeNodeToken(n48);
+ n0 = new NodeChoice(n47, 23);
+ break;
+ default:
+ jj_la1[7] = jj_gen;
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ {if (true) return new Reg(n0);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public IntegerLiteral IntegerLiteral() throws ParseException {
+ NodeToken n0;
+ Token n1;
+ n1 = jj_consume_token(INTEGER_LITERAL);
+ n0 = JTBToolkit.makeNodeToken(n1);
+ {if (true) return new IntegerLiteral(n0);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public Label Label() throws ParseException {
+ NodeToken n0;
+ Token n1;
+ n1 = jj_consume_token(IDENTIFIER);
+ n0 = JTBToolkit.makeNodeToken(n1);
+ {if (true) return new Label(n0);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static private boolean jj_initialized_once = false;
+ static public KangaParserTokenManager token_source;
+ static JavaCharStream jj_input_stream;
+ static public Token token, jj_nt;
+ static private int jj_ntk;
+ static private int jj_gen;
+ static final private int[] jj_la1 = new int[8];
+ static private int[] jj_la1_0;
+ static private int[] jj_la1_1;
+ static private int[] jj_la1_2;
+ static {
+ jj_la1_0();
+ jj_la1_1();
+ jj_la1_2();
+ }
+ private static void jj_la1_0() {
+ jj_la1_0 = new int[] {0x0,0x0,0x0,0x0,0x48c10000,0x8c10000,0x0,0x0,};
+ }
+ private static void jj_la1_1() {
+ jj_la1_1 = new int[] {0x0,0x7f3e,0x0,0x7f3e,0xfff00000,0x0,0xfff00000,0xfff00000,};
+ }
+ private static void jj_la1_2() {
+ jj_la1_2 = new int[] {0x80000,0x80000,0x80000,0x0,0xc0fff,0x0,0xc0fff,0xfff,};
+ }
+
+ public KangaParser(java.io.InputStream stream) {
+ this(stream, null);
+ }
+ public KangaParser(java.io.InputStream stream, String encoding) {
+ if (jj_initialized_once) {
+ System.out.println("ERROR: Second call to constructor of static parser. You must");
+ System.out.println(" either use ReInit() or set the JavaCC option STATIC to false");
+ System.out.println(" during parser generation.");
+ throw new Error();
+ }
+ jj_initialized_once = true;
+ try { jj_input_stream = new JavaCharStream(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); }
+ token_source = new KangaParserTokenManager(jj_input_stream);
+ token = new Token();
+ jj_ntk = -1;
+ jj_gen = 0;
+ for (int i = 0; i < 8; i++) jj_la1[i] = -1;
+ }
+
+ static public void ReInit(java.io.InputStream stream) {
+ ReInit(stream, null);
+ }
+ static public void ReInit(java.io.InputStream stream, String encoding) {
+ try { jj_input_stream.ReInit(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); }
+ token_source.ReInit(jj_input_stream);
+ token = new Token();
+ jj_ntk = -1;
+ jj_gen = 0;
+ for (int i = 0; i < 8; i++) jj_la1[i] = -1;
+ }
+
+ public KangaParser(java.io.Reader stream) {
+ if (jj_initialized_once) {
+ System.out.println("ERROR: Second call to constructor of static parser. You must");
+ System.out.println(" either use ReInit() or set the JavaCC option STATIC to false");
+ System.out.println(" during parser generation.");
+ throw new Error();
+ }
+ jj_initialized_once = true;
+ jj_input_stream = new JavaCharStream(stream, 1, 1);
+ token_source = new KangaParserTokenManager(jj_input_stream);
+ token = new Token();
+ jj_ntk = -1;
+ jj_gen = 0;
+ for (int i = 0; i < 8; i++) jj_la1[i] = -1;
+ }
+
+ static public void ReInit(java.io.Reader stream) {
+ jj_input_stream.ReInit(stream, 1, 1);
+ token_source.ReInit(jj_input_stream);
+ token = new Token();
+ jj_ntk = -1;
+ jj_gen = 0;
+ for (int i = 0; i < 8; i++) jj_la1[i] = -1;
+ }
+
+ public KangaParser(KangaParserTokenManager tm) {
+ if (jj_initialized_once) {
+ System.out.println("ERROR: Second call to constructor of static parser. You must");
+ System.out.println(" either use ReInit() or set the JavaCC option STATIC to false");
+ System.out.println(" during parser generation.");
+ throw new Error();
+ }
+ jj_initialized_once = true;
+ token_source = tm;
+ token = new Token();
+ jj_ntk = -1;
+ jj_gen = 0;
+ for (int i = 0; i < 8; i++) jj_la1[i] = -1;
+ }
+
+ public void ReInit(KangaParserTokenManager tm) {
+ token_source = tm;
+ token = new Token();
+ jj_ntk = -1;
+ jj_gen = 0;
+ for (int i = 0; i < 8; i++) jj_la1[i] = -1;
+ }
+
+ static final private Token jj_consume_token(int kind) throws ParseException {
+ Token oldToken;
+ if ((oldToken = token).next != null) token = token.next;
+ else token = token.next = token_source.getNextToken();
+ jj_ntk = -1;
+ if (token.kind == kind) {
+ jj_gen++;
+ return token;
+ }
+ token = oldToken;
+ jj_kind = kind;
+ throw generateParseException();
+ }
+
+ static final public Token getNextToken() {
+ if (token.next != null) token = token.next;
+ else token = token.next = token_source.getNextToken();
+ jj_ntk = -1;
+ jj_gen++;
+ return token;
+ }
+
+ static final public Token getToken(int index) {
+ Token t = token;
+ for (int i = 0; i < index; i++) {
+ if (t.next != null) t = t.next;
+ else t = t.next = token_source.getNextToken();
+ }
+ return t;
+ }
+
+ static final private int jj_ntk() {
+ if ((jj_nt=token.next) == null)
+ return (jj_ntk = (token.next=token_source.getNextToken()).kind);
+ else
+ return (jj_ntk = jj_nt.kind);
+ }
+
+ static private java.util.Vector jj_expentries = new java.util.Vector();
+ static private int[] jj_expentry;
+ static private int jj_kind = -1;
+
+ static public ParseException generateParseException() {
+ jj_expentries.removeAllElements();
+ boolean[] la1tokens = new boolean[86];
+ for (int i = 0; i < 86; i++) {
+ la1tokens[i] = false;
+ }
+ if (jj_kind >= 0) {
+ la1tokens[jj_kind] = true;
+ jj_kind = -1;
+ }
+ for (int i = 0; i < 8; i++) {
+ if (jj_la1[i] == jj_gen) {
+ for (int j = 0; j < 32; j++) {
+ if ((jj_la1_0[i] & (1<<j)) != 0) {
+ la1tokens[j] = true;
+ }
+ if ((jj_la1_1[i] & (1<<j)) != 0) {
+ la1tokens[32+j] = true;
+ }
+ if ((jj_la1_2[i] & (1<<j)) != 0) {
+ la1tokens[64+j] = true;
+ }
+ }
+ }
+ }
+ for (int i = 0; i < 86; i++) {
+ if (la1tokens[i]) {
+ jj_expentry = new int[1];
+ jj_expentry[0] = i;
+ jj_expentries.addElement(jj_expentry);
+ }
+ }
+ int[][] exptokseq = new int[jj_expentries.size()][];
+ for (int i = 0; i < jj_expentries.size(); i++) {
+ exptokseq[i] = (int[])jj_expentries.elementAt(i);
+ }
+ return new ParseException(token, exptokseq, tokenImage);
+ }
+
+ static final public void enable_tracing() {
+ }
+
+ static final public void disable_tracing() {
+ }
+
+}
+
+class JTBToolkit {
+ static NodeToken makeNodeToken(Token t) {
+ return new NodeToken(t.image.intern(), t.kind, t.beginLine, t.beginColumn, t.endLine, t.endColumn);
+ }
+}
diff --git a/src/kanga/KangaParserConstants.java b/src/kanga/KangaParserConstants.java
new file mode 100644
index 0000000..c36a5e6
--- /dev/null
+++ b/src/kanga/KangaParserConstants.java
@@ -0,0 +1,178 @@
+package kanga;
+/* Generated By:JavaCC: Do not edit this line. KangaParserConstants.java */
+public interface KangaParserConstants {
+
+ int EOF = 0;
+ int SINGLE_LINE_COMMENT = 6;
+ int FORMAL_COMMENT = 7;
+ int MULTI_LINE_COMMENT = 8;
+ int LPAREN = 9;
+ int RPAREN = 10;
+ int LBRACE = 11;
+ int RBRACE = 12;
+ int LSQPAREN = 13;
+ int RSQPAREN = 14;
+ int DOT = 15;
+ int LT = 16;
+ int LE = 17;
+ int GT = 18;
+ int GE = 19;
+ int NE = 20;
+ int EQ = 21;
+ int PLUS = 22;
+ int MINUS = 23;
+ int AND = 24;
+ int OR = 25;
+ int NOT = 26;
+ int TIMES = 27;
+ int MAIN = 28;
+ int CODE = 29;
+ int HALLOCATE = 30;
+ int SPILLEDARG = 31;
+ int END = 32;
+ int NOOP = 33;
+ int MOVE = 34;
+ int CALL = 35;
+ int ERROR = 36;
+ int PRINT = 37;
+ int BEGIN = 38;
+ int RETURN = 39;
+ int JUMP = 40;
+ int CJUMP = 41;
+ int HSTORE = 42;
+ int HLOAD = 43;
+ int ALOAD = 44;
+ int ASTORE = 45;
+ int PASSARG = 46;
+ int MEM = 47;
+ int TEMP = 48;
+ int ARG = 49;
+ int ZERO = 50;
+ int at = 51;
+ int v0 = 52;
+ int v1 = 53;
+ int a0 = 54;
+ int a1 = 55;
+ int a2 = 56;
+ int a3 = 57;
+ int t0 = 58;
+ int t1 = 59;
+ int t2 = 60;
+ int t3 = 61;
+ int t4 = 62;
+ int t5 = 63;
+ int t6 = 64;
+ int t7 = 65;
+ int s0 = 66;
+ int s1 = 67;
+ int s2 = 68;
+ int s3 = 69;
+ int s4 = 70;
+ int s5 = 71;
+ int s6 = 72;
+ int s7 = 73;
+ int t8 = 74;
+ int t9 = 75;
+ int k0 = 76;
+ int k1 = 77;
+ int gp = 78;
+ int sp = 79;
+ int fp = 80;
+ int ra = 81;
+ int INTEGER_LITERAL = 82;
+ int IDENTIFIER = 83;
+ int LETTER = 84;
+ int DIGIT = 85;
+
+ int DEFAULT = 0;
+
+ String[] tokenImage = {
+ "<EOF>",
+ "\" \"",
+ "\"\\t\"",
+ "\"\\n\"",
+ "\"\\r\"",
+ "\"\\f\"",
+ "<SINGLE_LINE_COMMENT>",
+ "<FORMAL_COMMENT>",
+ "<MULTI_LINE_COMMENT>",
+ "\"(\"",
+ "\")\"",
+ "\"{\"",
+ "\"}\"",
+ "\"[\"",
+ "\"]\"",
+ "\".\"",
+ "\"LT\"",
+ "\"LE\"",
+ "\"GT\"",
+ "\"GE\"",
+ "\"NE\"",
+ "\"EQ\"",
+ "\"PLUS\"",
+ "\"MINUS\"",
+ "\"AND\"",
+ "\"OR\"",
+ "\"NOT\"",
+ "\"TIMES\"",
+ "\"MAIN\"",
+ "\"CODE\"",
+ "\"HALLOCATE\"",
+ "\"SPILLEDARG\"",
+ "\"END\"",
+ "\"NOOP\"",
+ "\"MOVE\"",
+ "\"CALL\"",
+ "\"ERROR\"",
+ "\"PRINT\"",
+ "\"BEGIN\"",
+ "\"RETURN\"",
+ "\"JUMP\"",
+ "\"CJUMP\"",
+ "\"HSTORE\"",
+ "\"HLOAD\"",
+ "\"ALOAD\"",
+ "\"ASTORE\"",
+ "\"PASSARG\"",
+ "\"MEM\"",
+ "\"TEMP\"",
+ "\"ARG\"",
+ "\"zero\"",
+ "\"at\"",
+ "\"v0\"",
+ "\"v1\"",
+ "\"a0\"",
+ "\"a1\"",
+ "\"a2\"",
+ "\"a3\"",
+ "\"t0\"",
+ "\"t1\"",
+ "\"t2\"",
+ "\"t3\"",
+ "\"t4\"",
+ "\"t5\"",
+ "\"t6\"",
+ "\"t7\"",
+ "\"s0\"",
+ "\"s1\"",
+ "\"s2\"",
+ "\"s3\"",
+ "\"s4\"",
+ "\"s5\"",
+ "\"s6\"",
+ "\"s7\"",
+ "\"t8\"",
+ "\"t9\"",
+ "\"k0\"",
+ "\"k1\"",
+ "\"gp\"",
+ "\"sp\"",
+ "\"fp\"",
+ "\"ra\"",
+ "<INTEGER_LITERAL>",
+ "<IDENTIFIER>",
+ "<LETTER>",
+ "<DIGIT>",
+ };
+
+}
diff --git a/src/kanga/KangaParserTokenManager.java b/src/kanga/KangaParserTokenManager.java
new file mode 100644
index 0000000..d4f231d
--- /dev/null
+++ b/src/kanga/KangaParserTokenManager.java
@@ -0,0 +1,1101 @@
+package kanga;
+/* Generated By:JavaCC: Do not edit this line. KangaParserTokenManager.java */
+
+public class KangaParserTokenManager implements KangaParserConstants
+{
+ public static java.io.PrintStream debugStream = System.out;
+ public static void setDebugStream(java.io.PrintStream ds) { debugStream = ds; }
+private static final int jjStopStringLiteralDfa_0(int pos, long active0, long active1)
+{
+ switch (pos)
+ {
+ case 0:
+ if ((active0 & 0xffffffffffff0000L) != 0L || (active1 & 0x3ffffL) != 0L)
+ {
+ jjmatchedKind = 83;
+ return 4;
+ }
+ return -1;
+ case 1:
+ if ((active0 & 0xfff80000023f0000L) != 0L || (active1 & 0x3ffffL) != 0L)
+ return 4;
+ if ((active0 & 0x7fffffdc00000L) != 0L)
+ {
+ jjmatchedKind = 83;
+ jjmatchedPos = 1;
+ return 4;
+ }
+ return -1;
+ case 2:
+ if ((active0 & 0x2800105000000L) != 0L)
+ return 4;
+ if ((active0 & 0x57ffef8c00000L) != 0L)
+ {
+ jjmatchedKind = 83;
+ jjmatchedPos = 2;
+ return 4;
+ }
+ return -1;
+ case 3:
+ if ((active0 & 0x5010e30400000L) != 0L)
+ return 4;
+ if ((active0 & 0x7ef0c8800000L) != 0L)
+ {
+ jjmatchedKind = 83;
+ jjmatchedPos = 3;
+ return 4;
+ }
+ return -1;
+ case 4:
+ if ((active0 & 0x1a7008800000L) != 0L)
+ return 4;
+ if ((active0 & 0x6480c0000000L) != 0L)
+ {
+ jjmatchedKind = 83;
+ jjmatchedPos = 4;
+ return 4;
+ }
+ return -1;
+ case 5:
+ if ((active0 & 0x248000000000L) != 0L)
+ return 4;
+ if ((active0 & 0x4000c0000000L) != 0L)
+ {
+ jjmatchedKind = 83;
+ jjmatchedPos = 5;
+ return 4;
+ }
+ return -1;
+ case 6:
+ if ((active0 & 0x400000000000L) != 0L)
+ return 4;
+ if ((active0 & 0xc0000000L) != 0L)
+ {
+ jjmatchedKind = 83;
+ jjmatchedPos = 6;
+ return 4;
+ }
+ return -1;
+ case 7:
+ if ((active0 & 0xc0000000L) != 0L)
+ {
+ jjmatchedKind = 83;
+ jjmatchedPos = 7;
+ return 4;
+ }
+ return -1;
+ case 8:
+ if ((active0 & 0x40000000L) != 0L)
+ return 4;
+ if ((active0 & 0x80000000L) != 0L)
+ {
+ jjmatchedKind = 83;
+ jjmatchedPos = 8;
+ return 4;
+ }
+ return -1;
+ default :
+ return -1;
+ }
+}
+private static final int jjStartNfa_0(int pos, long active0, long active1)
+{
+ return jjMoveNfa_0(jjStopStringLiteralDfa_0(pos, active0, active1), pos + 1);
+}
+static private final int jjStopAtPos(int pos, int kind)
+{
+ jjmatchedKind = kind;
+ jjmatchedPos = pos;
+ return pos + 1;
+}
+static private final int jjStartNfaWithStates_0(int pos, int kind, int state)
+{
+ jjmatchedKind = kind;
+ jjmatchedPos = pos;
+ try { curChar = input_stream.readChar(); }
+ catch(java.io.IOException e) { return pos + 1; }
+ return jjMoveNfa_0(state, pos + 1);
+}
+static private final int jjMoveStringLiteralDfa0_0()
+{
+ switch(curChar)
+ {
+ case 40:
+ return jjStopAtPos(0, 9);
+ case 41:
+ return jjStopAtPos(0, 10);
+ case 46:
+ return jjStopAtPos(0, 15);
+ case 65:
+ return jjMoveStringLiteralDfa1_0(0x2300001000000L, 0x0L);
+ case 66:
+ return jjMoveStringLiteralDfa1_0(0x4000000000L, 0x0L);
+ case 67:
+ return jjMoveStringLiteralDfa1_0(0x20820000000L, 0x0L);
+ case 69:
+ return jjMoveStringLiteralDfa1_0(0x1100200000L, 0x0L);
+ case 71:
+ return jjMoveStringLiteralDfa1_0(0xc0000L, 0x0L);
+ case 72:
+ return jjMoveStringLiteralDfa1_0(0xc0040000000L, 0x0L);
+ case 74:
+ return jjMoveStringLiteralDfa1_0(0x10000000000L, 0x0L);
+ case 76:
+ return jjMoveStringLiteralDfa1_0(0x30000L, 0x0L);
+ case 77:
+ return jjMoveStringLiteralDfa1_0(0x800410800000L, 0x0L);
+ case 78:
+ return jjMoveStringLiteralDfa1_0(0x204100000L, 0x0L);
+ case 79:
+ return jjMoveStringLiteralDfa1_0(0x2000000L, 0x0L);
+ case 80:
+ return jjMoveStringLiteralDfa1_0(0x402000400000L, 0x0L);
+ case 82:
+ return jjMoveStringLiteralDfa1_0(0x8000000000L, 0x0L);
+ case 83:
+ return jjMoveStringLiteralDfa1_0(0x80000000L, 0x0L);
+ case 84:
+ return jjMoveStringLiteralDfa1_0(0x1000008000000L, 0x0L);
+ case 91:
+ return jjStopAtPos(0, 13);
+ case 93:
+ return jjStopAtPos(0, 14);
+ case 97:
+ return jjMoveStringLiteralDfa1_0(0x3c8000000000000L, 0x0L);
+ case 102:
+ return jjMoveStringLiteralDfa1_0(0x0L, 0x10000L);
+ case 103:
+ return jjMoveStringLiteralDfa1_0(0x0L, 0x4000L);
+ case 107:
+ return jjMoveStringLiteralDfa1_0(0x0L, 0x3000L);
+ case 114:
+ return jjMoveStringLiteralDfa1_0(0x0L, 0x20000L);
+ case 115:
+ return jjMoveStringLiteralDfa1_0(0x0L, 0x83fcL);
+ case 116:
+ return jjMoveStringLiteralDfa1_0(0xfc00000000000000L, 0xc03L);
+ case 118:
+ return jjMoveStringLiteralDfa1_0(0x30000000000000L, 0x0L);
+ case 122:
+ return jjMoveStringLiteralDfa1_0(0x4000000000000L, 0x0L);
+ case 123:
+ return jjStopAtPos(0, 11);
+ case 125:
+ return jjStopAtPos(0, 12);
+ default :
+ return jjMoveNfa_0(0, 0);
+ }
+}
+static private final int jjMoveStringLiteralDfa1_0(long active0, long active1)
+{
+ try { curChar = input_stream.readChar(); }
+ catch(java.io.IOException e) {
+ jjStopStringLiteralDfa_0(0, active0, active1);
+ return 1;
+ }
+ switch(curChar)
+ {
+ case 48:
+ if ((active0 & 0x10000000000000L) != 0L)
+ return jjStartNfaWithStates_0(1, 52, 4);
+ else if ((active0 & 0x40000000000000L) != 0L)
+ return jjStartNfaWithStates_0(1, 54, 4);
+ else if ((active0 & 0x400000000000000L) != 0L)
+ return jjStartNfaWithStates_0(1, 58, 4);
+ else if ((active1 & 0x4L) != 0L)
+ return jjStartNfaWithStates_0(1, 66, 4);
+ else if ((active1 & 0x1000L) != 0L)
+ return jjStartNfaWithStates_0(1, 76, 4);
+ break;
+ case 49:
+ if ((active0 & 0x20000000000000L) != 0L)
+ return jjStartNfaWithStates_0(1, 53, 4);
+ else if ((active0 & 0x80000000000000L) != 0L)
+ return jjStartNfaWithStates_0(1, 55, 4);
+ else if ((active0 & 0x800000000000000L) != 0L)
+ return jjStartNfaWithStates_0(1, 59, 4);
+ else if ((active1 & 0x8L) != 0L)
+ return jjStartNfaWithStates_0(1, 67, 4);
+ else if ((active1 & 0x2000L) != 0L)
+ return jjStartNfaWithStates_0(1, 77, 4);
+ break;
+ case 50:
+ if ((active0 & 0x100000000000000L) != 0L)
+ return jjStartNfaWithStates_0(1, 56, 4);
+ else if ((active0 & 0x1000000000000000L) != 0L)
+ return jjStartNfaWithStates_0(1, 60, 4);
+ else if ((active1 & 0x10L) != 0L)
+ return jjStartNfaWithStates_0(1, 68, 4);
+ break;
+ case 51:
+ if ((active0 & 0x200000000000000L) != 0L)
+ return jjStartNfaWithStates_0(1, 57, 4);
+ else if ((active0 & 0x2000000000000000L) != 0L)
+ return jjStartNfaWithStates_0(1, 61, 4);
+ else if ((active1 & 0x20L) != 0L)
+ return jjStartNfaWithStates_0(1, 69, 4);
+ break;
+ case 52:
+ if ((active0 & 0x4000000000000000L) != 0L)
+ return jjStartNfaWithStates_0(1, 62, 4);
+ else if ((active1 & 0x40L) != 0L)
+ return jjStartNfaWithStates_0(1, 70, 4);
+ break;
+ case 53:
+ if ((active0 & 0x8000000000000000L) != 0L)
+ return jjStartNfaWithStates_0(1, 63, 4);
+ else if ((active1 & 0x80L) != 0L)
+ return jjStartNfaWithStates_0(1, 71, 4);
+ break;
+ case 54:
+ if ((active1 & 0x1L) != 0L)
+ return jjStartNfaWithStates_0(1, 64, 4);
+ else if ((active1 & 0x100L) != 0L)
+ return jjStartNfaWithStates_0(1, 72, 4);
+ break;
+ case 55:
+ if ((active1 & 0x2L) != 0L)
+ return jjStartNfaWithStates_0(1, 65, 4);
+ else if ((active1 & 0x200L) != 0L)
+ return jjStartNfaWithStates_0(1, 73, 4);
+ break;
+ case 56:
+ if ((active1 & 0x400L) != 0L)
+ return jjStartNfaWithStates_0(1, 74, 4);
+ break;
+ case 57:
+ if ((active1 & 0x800L) != 0L)
+ return jjStartNfaWithStates_0(1, 75, 4);
+ break;
+ case 65:
+ return jjMoveStringLiteralDfa2_0(active0, 0x400850000000L, active1, 0L);
+ case 69:
+ if ((active0 & 0x20000L) != 0L)
+ return jjStartNfaWithStates_0(1, 17, 4);
+ else if ((active0 & 0x80000L) != 0L)
+ return jjStartNfaWithStates_0(1, 19, 4);
+ else if ((active0 & 0x100000L) != 0L)
+ return jjStartNfaWithStates_0(1, 20, 4);
+ return jjMoveStringLiteralDfa2_0(active0, 0x180c000000000L, active1, 0L);
+ case 73:
+ return jjMoveStringLiteralDfa2_0(active0, 0x8800000L, active1, 0L);
+ case 74:
+ return jjMoveStringLiteralDfa2_0(active0, 0x20000000000L, active1, 0L);
+ case 76:
+ return jjMoveStringLiteralDfa2_0(active0, 0x180000400000L, active1, 0L);
+ case 78:
+ return jjMoveStringLiteralDfa2_0(active0, 0x101000000L, active1, 0L);
+ case 79:
+ return jjMoveStringLiteralDfa2_0(active0, 0x624000000L, active1, 0L);
+ case 80:
+ return jjMoveStringLiteralDfa2_0(active0, 0x80000000L, active1, 0L);
+ case 81:
+ if ((active0 & 0x200000L) != 0L)
+ return jjStartNfaWithStates_0(1, 21, 4);
+ break;
+ case 82:
+ if ((active0 & 0x2000000L) != 0L)
+ return jjStartNfaWithStates_0(1, 25, 4);
+ return jjMoveStringLiteralDfa2_0(active0, 0x2003000000000L, active1, 0L);
+ case 83:
+ return jjMoveStringLiteralDfa2_0(active0, 0x240000000000L, active1, 0L);
+ case 84:
+ if ((active0 & 0x10000L) != 0L)
+ return jjStartNfaWithStates_0(1, 16, 4);
+ else if ((active0 & 0x40000L) != 0L)
+ return jjStartNfaWithStates_0(1, 18, 4);
+ break;
+ case 85:
+ return jjMoveStringLiteralDfa2_0(active0, 0x10000000000L, active1, 0L);
+ case 97:
+ if ((active1 & 0x20000L) != 0L)
+ return jjStartNfaWithStates_0(1, 81, 4);
+ break;
+ case 101:
+ return jjMoveStringLiteralDfa2_0(active0, 0x4000000000000L, active1, 0L);
+ case 112:
+ if ((active1 & 0x4000L) != 0L)
+ return jjStartNfaWithStates_0(1, 78, 4);
+ else if ((active1 & 0x8000L) != 0L)
+ return jjStartNfaWithStates_0(1, 79, 4);
+ else if ((active1 & 0x10000L) != 0L)
+ return jjStartNfaWithStates_0(1, 80, 4);
+ break;
+ case 116:
+ if ((active0 & 0x8000000000000L) != 0L)
+ return jjStartNfaWithStates_0(1, 51, 4);
+ break;
+ default :
+ break;
+ }
+ return jjStartNfa_0(0, active0, active1);
+}
+static private final int jjMoveStringLiteralDfa2_0(long old0, long active0, long old1, long active1)
+{
+ if (((active0 &= old0) | (active1 &= old1)) == 0L)
+ return jjStartNfa_0(0, old0, old1);
+ try { curChar = input_stream.readChar(); }
+ catch(java.io.IOException e) {
+ jjStopStringLiteralDfa_0(1, active0, 0L);
+ return 2;
+ }
+ switch(curChar)
+ {
+ case 68:
+ if ((active0 & 0x1000000L) != 0L)
+ return jjStartNfaWithStates_0(2, 24, 4);
+ else if ((active0 & 0x100000000L) != 0L)
+ return jjStartNfaWithStates_0(2, 32, 4);
+ return jjMoveStringLiteralDfa3_0(active0, 0x20000000L);
+ case 71:
+ if ((active0 & 0x2000000000000L) != 0L)
+ return jjStartNfaWithStates_0(2, 49, 4);
+ return jjMoveStringLiteralDfa3_0(active0, 0x4000000000L);
+ case 73:
+ return jjMoveStringLiteralDfa3_0(active0, 0x2090000000L);
+ case 76:
+ return jjMoveStringLiteralDfa3_0(active0, 0x840000000L);
+ case 77:
+ if ((active0 & 0x800000000000L) != 0L)
+ return jjStartNfaWithStates_0(2, 47, 4);
+ return jjMoveStringLiteralDfa3_0(active0, 0x1010008000000L);
+ case 78:
+ return jjMoveStringLiteralDfa3_0(active0, 0x800000L);
+ case 79:
+ return jjMoveStringLiteralDfa3_0(active0, 0x180200000000L);
+ case 82:
+ return jjMoveStringLiteralDfa3_0(active0, 0x1000000000L);
+ case 83:
+ return jjMoveStringLiteralDfa3_0(active0, 0x400000000000L);
+ case 84:
+ if ((active0 & 0x4000000L) != 0L)
+ return jjStartNfaWithStates_0(2, 26, 4);
+ return jjMoveStringLiteralDfa3_0(active0, 0x248000000000L);
+ case 85:
+ return jjMoveStringLiteralDfa3_0(active0, 0x20000400000L);
+ case 86:
+ return jjMoveStringLiteralDfa3_0(active0, 0x400000000L);
+ case 114:
+ return jjMoveStringLiteralDfa3_0(active0, 0x4000000000000L);
+ default :
+ break;
+ }
+ return jjStartNfa_0(1, active0, 0L);
+}
+static private final int jjMoveStringLiteralDfa3_0(long old0, long active0)
+{
+ if (((active0 &= old0)) == 0L)
+ return jjStartNfa_0(1, old0, 0L);
+ try { curChar = input_stream.readChar(); }
+ catch(java.io.IOException e) {
+ jjStopStringLiteralDfa_0(2, active0, 0L);
+ return 3;
+ }
+ switch(curChar)
+ {
+ case 65:
+ return jjMoveStringLiteralDfa4_0(active0, 0x180000000000L);
+ case 69:
+ if ((active0 & 0x20000000L) != 0L)
+ return jjStartNfaWithStates_0(3, 29, 4);
+ else if ((active0 & 0x400000000L) != 0L)
+ return jjStartNfaWithStates_0(3, 34, 4);
+ return jjMoveStringLiteralDfa4_0(active0, 0x8000000L);
+ case 73:
+ return jjMoveStringLiteralDfa4_0(active0, 0x4000000000L);
+ case 76:
+ if ((active0 & 0x800000000L) != 0L)
+ return jjStartNfaWithStates_0(3, 35, 4);
+ return jjMoveStringLiteralDfa4_0(active0, 0xc0000000L);
+ case 77:
+ return jjMoveStringLiteralDfa4_0(active0, 0x20000000000L);
+ case 78:
+ if ((active0 & 0x10000000L) != 0L)
+ return jjStartNfaWithStates_0(3, 28, 4);
+ return jjMoveStringLiteralDfa4_0(active0, 0x2000000000L);
+ case 79:
+ return jjMoveStringLiteralDfa4_0(active0, 0x241000000000L);
+ case 80:
+ if ((active0 & 0x200000000L) != 0L)
+ return jjStartNfaWithStates_0(3, 33, 4);
+ else if ((active0 & 0x10000000000L) != 0L)
+ return jjStartNfaWithStates_0(3, 40, 4);
+ else if ((active0 & 0x1000000000000L) != 0L)
+ return jjStartNfaWithStates_0(3, 48, 4);
+ break;
+ case 83:
+ if ((active0 & 0x400000L) != 0L)
+ return jjStartNfaWithStates_0(3, 22, 4);
+ return jjMoveStringLiteralDfa4_0(active0, 0x400000000000L);
+ case 85:
+ return jjMoveStringLiteralDfa4_0(active0, 0x8000800000L);
+ case 111:
+ if ((active0 & 0x4000000000000L) != 0L)
+ return jjStartNfaWithStates_0(3, 50, 4);
+ break;
+ default :
+ break;
+ }
+ return jjStartNfa_0(2, active0, 0L);
+}
+static private final int jjMoveStringLiteralDfa4_0(long old0, long active0)
+{
+ if (((active0 &= old0)) == 0L)
+ return jjStartNfa_0(2, old0, 0L);
+ try { curChar = input_stream.readChar(); }
+ catch(java.io.IOException e) {
+ jjStopStringLiteralDfa_0(3, active0, 0L);
+ return 4;
+ }
+ switch(curChar)
+ {
+ case 65:
+ return jjMoveStringLiteralDfa5_0(active0, 0x400000000000L);
+ case 68:
+ if ((active0 & 0x80000000000L) != 0L)
+ return jjStartNfaWithStates_0(4, 43, 4);
+ else if ((active0 & 0x100000000000L) != 0L)
+ return jjStartNfaWithStates_0(4, 44, 4);
+ break;
+ case 76:
+ return jjMoveStringLiteralDfa5_0(active0, 0x80000000L);
+ case 78:
+ if ((active0 & 0x4000000000L) != 0L)
+ return jjStartNfaWithStates_0(4, 38, 4);
+ break;
+ case 79:
+ return jjMoveStringLiteralDfa5_0(active0, 0x40000000L);
+ case 80:
+ if ((active0 & 0x20000000000L) != 0L)
+ return jjStartNfaWithStates_0(4, 41, 4);
+ break;
+ case 82:
+ if ((active0 & 0x1000000000L) != 0L)
+ return jjStartNfaWithStates_0(4, 36, 4);
+ return jjMoveStringLiteralDfa5_0(active0, 0x248000000000L);
+ case 83:
+ if ((active0 & 0x800000L) != 0L)
+ return jjStartNfaWithStates_0(4, 23, 4);
+ else if ((active0 & 0x8000000L) != 0L)
+ return jjStartNfaWithStates_0(4, 27, 4);
+ break;
+ case 84:
+ if ((active0 & 0x2000000000L) != 0L)
+ return jjStartNfaWithStates_0(4, 37, 4);
+ break;
+ default :
+ break;
+ }
+ return jjStartNfa_0(3, active0, 0L);
+}
+static private final int jjMoveStringLiteralDfa5_0(long old0, long active0)
+{
+ if (((active0 &= old0)) == 0L)
+ return jjStartNfa_0(3, old0, 0L);
+ try { curChar = input_stream.readChar(); }
+ catch(java.io.IOException e) {
+ jjStopStringLiteralDfa_0(4, active0, 0L);
+ return 5;
+ }
+ switch(curChar)
+ {
+ case 67:
+ return jjMoveStringLiteralDfa6_0(active0, 0x40000000L);
+ case 69:
+ if ((active0 & 0x40000000000L) != 0L)
+ return jjStartNfaWithStates_0(5, 42, 4);
+ else if ((active0 & 0x200000000000L) != 0L)
+ return jjStartNfaWithStates_0(5, 45, 4);
+ return jjMoveStringLiteralDfa6_0(active0, 0x80000000L);
+ case 78:
+ if ((active0 & 0x8000000000L) != 0L)
+ return jjStartNfaWithStates_0(5, 39, 4);
+ break;
+ case 82:
+ return jjMoveStringLiteralDfa6_0(active0, 0x400000000000L);
+ default :
+ break;
+ }
+ return jjStartNfa_0(4, active0, 0L);
+}
+static private final int jjMoveStringLiteralDfa6_0(long old0, long active0)
+{
+ if (((active0 &= old0)) == 0L)
+ return jjStartNfa_0(4, old0, 0L);
+ try { curChar = input_stream.readChar(); }
+ catch(java.io.IOException e) {
+ jjStopStringLiteralDfa_0(5, active0, 0L);
+ return 6;
+ }
+ switch(curChar)
+ {
+ case 65:
+ return jjMoveStringLiteralDfa7_0(active0, 0x40000000L);
+ case 68:
+ return jjMoveStringLiteralDfa7_0(active0, 0x80000000L);
+ case 71:
+ if ((active0 & 0x400000000000L) != 0L)
+ return jjStartNfaWithStates_0(6, 46, 4);
+ break;
+ default :
+ break;
+ }
+ return jjStartNfa_0(5, active0, 0L);
+}
+static private final int jjMoveStringLiteralDfa7_0(long old0, long active0)
+{
+ if (((active0 &= old0)) == 0L)
+ return jjStartNfa_0(5, old0, 0L);
+ try { curChar = input_stream.readChar(); }
+ catch(java.io.IOException e) {
+ jjStopStringLiteralDfa_0(6, active0, 0L);
+ return 7;
+ }
+ switch(curChar)
+ {
+ case 65:
+ return jjMoveStringLiteralDfa8_0(active0, 0x80000000L);
+ case 84:
+ return jjMoveStringLiteralDfa8_0(active0, 0x40000000L);
+ default :
+ break;
+ }
+ return jjStartNfa_0(6, active0, 0L);
+}
+static private final int jjMoveStringLiteralDfa8_0(long old0, long active0)
+{
+ if (((active0 &= old0)) == 0L)
+ return jjStartNfa_0(6, old0, 0L);
+ try { curChar = input_stream.readChar(); }
+ catch(java.io.IOException e) {
+ jjStopStringLiteralDfa_0(7, active0, 0L);
+ return 8;
+ }
+ switch(curChar)
+ {
+ case 69:
+ if ((active0 & 0x40000000L) != 0L)
+ return jjStartNfaWithStates_0(8, 30, 4);
+ break;
+ case 82:
+ return jjMoveStringLiteralDfa9_0(active0, 0x80000000L);
+ default :
+ break;
+ }
+ return jjStartNfa_0(7, active0, 0L);
+}
+static private final int jjMoveStringLiteralDfa9_0(long old0, long active0)
+{
+ if (((active0 &= old0)) == 0L)
+ return jjStartNfa_0(7, old0, 0L);
+ try { curChar = input_stream.readChar(); }
+ catch(java.io.IOException e) {
+ jjStopStringLiteralDfa_0(8, active0, 0L);
+ return 9;
+ }
+ switch(curChar)
+ {
+ case 71:
+ if ((active0 & 0x80000000L) != 0L)
+ return jjStartNfaWithStates_0(9, 31, 4);
+ break;
+ default :
+ break;
+ }
+ return jjStartNfa_0(8, active0, 0L);
+}
+static private final void jjCheckNAdd(int state)
+{
+ if (jjrounds[state] != jjround)
+ {
+ jjstateSet[jjnewStateCnt++] = state;
+ jjrounds[state] = jjround;
+ }
+}
+static private final void jjAddStates(int start, int end)
+{
+ do {
+ jjstateSet[jjnewStateCnt++] = jjnextStates[start];
+ } while (start++ != end);
+}
+static private final void jjCheckNAddTwoStates(int state1, int state2)
+{
+ jjCheckNAdd(state1);
+ jjCheckNAdd(state2);
+}
+static private final void jjCheckNAddStates(int start, int end)
+{
+ do {
+ jjCheckNAdd(jjnextStates[start]);
+ } while (start++ != end);
+}
+static private final void jjCheckNAddStates(int start)
+{
+ jjCheckNAdd(jjnextStates[start]);
+ jjCheckNAdd(jjnextStates[start + 1]);
+}
+static final long[] jjbitVec0 = {
+ 0x1ff00000fffffffeL, 0xffffffffffffc000L, 0xffffffffL, 0x600000000000000L
+};
+static final long[] jjbitVec2 = {
+ 0x0L, 0x0L, 0x0L, 0xff7fffffff7fffffL
+};
+static final long[] jjbitVec3 = {
+ 0x0L, 0xffffffffffffffffL, 0xffffffffffffffffL, 0xffffffffffffffffL
+};
+static final long[] jjbitVec4 = {
+ 0xffffffffffffffffL, 0xffffffffffffffffL, 0xffffL, 0x0L
+};
+static final long[] jjbitVec5 = {
+ 0xffffffffffffffffL, 0xffffffffffffffffL, 0x0L, 0x0L
+};
+static final long[] jjbitVec6 = {
+ 0x3fffffffffffL, 0x0L, 0x0L, 0x0L
+};
+static final long[] jjbitVec7 = {
+ 0xfffffffffffffffeL, 0xffffffffffffffffL, 0xffffffffffffffffL, 0xffffffffffffffffL
+};
+static final long[] jjbitVec8 = {
+ 0x0L, 0x0L, 0xffffffffffffffffL, 0xffffffffffffffffL
+};
+static private final int jjMoveNfa_0(int startState, int curPos)
+{
+ int[] nextStates;
+ int startsAt = 0;
+ jjnewStateCnt = 24;
+ int i = 1;
+ jjstateSet[0] = startState;
+ int j, kind = 0x7fffffff;
+ for (;;)
+ {
+ if (++jjround == 0x7fffffff)
+ ReInitRounds();
+ if (curChar < 64)
+ {
+ long l = 1L << curChar;
+ MatchLoop: do
+ {
+ switch(jjstateSet[--i])
+ {
+ case 0:
+ if ((0x3fe000000000000L & l) != 0L)
+ {
+ if (kind > 82)
+ kind = 82;
+ jjCheckNAdd(1);
+ }
+ else if (curChar == 47)
+ jjAddStates(0, 2);
+ else if (curChar == 36)
+ {
+ if (kind > 83)
+ kind = 83;
+ jjCheckNAdd(4);
+ }
+ else if (curChar == 48)
+ {
+ if (kind > 82)
+ kind = 82;
+ }
+ break;
+ case 1:
+ if ((0x3ff000000000000L & l) == 0L)
+ break;
+ if (kind > 82)
+ kind = 82;
+ jjCheckNAdd(1);
+ break;
+ case 2:
+ if (curChar == 48 && kind > 82)
+ kind = 82;
+ break;
+ case 3:
+ if (curChar != 36)
+ break;
+ if (kind > 83)
+ kind = 83;
+ jjCheckNAdd(4);
+ break;
+ case 4:
+ if ((0x3ff001000000000L & l) == 0L)
+ break;
+ if (kind > 83)
+ kind = 83;
+ jjCheckNAdd(4);
+ break;
+ case 5:
+ if (curChar == 47)
+ jjAddStates(0, 2);
+ break;
+ case 6:
+ if (curChar == 47)
+ jjCheckNAddStates(3, 5);
+ break;
+ case 7:
+ if ((0xffffffffffffdbffL & l) != 0L)
+ jjCheckNAddStates(3, 5);
+ break;
+ case 8:
+ if ((0x2400L & l) != 0L && kind > 6)
+ kind = 6;
+ break;
+ case 9:
+ if (curChar == 10 && kind > 6)
+ kind = 6;
+ break;
+ case 10:
+ if (curChar == 13)
+ jjstateSet[jjnewStateCnt++] = 9;
+ break;
+ case 11:
+ if (curChar == 42)
+ jjCheckNAddTwoStates(12, 13);
+ break;
+ case 12:
+ if ((0xfffffbffffffffffL & l) != 0L)
+ jjCheckNAddTwoStates(12, 13);
+ break;
+ case 13:
+ if (curChar == 42)
+ jjCheckNAddStates(6, 8);
+ break;
+ case 14:
+ if ((0xffff7bffffffffffL & l) != 0L)
+ jjCheckNAddTwoStates(15, 13);
+ break;
+ case 15:
+ if ((0xfffffbffffffffffL & l) != 0L)
+ jjCheckNAddTwoStates(15, 13);
+ break;
+ case 16:
+ if (curChar == 47 && kind > 7)
+ kind = 7;
+ break;
+ case 17:
+ if (curChar == 42)
+ jjstateSet[jjnewStateCnt++] = 11;
+ break;
+ case 18:
+ if (curChar == 42)
+ jjCheckNAddTwoStates(19, 20);
+ break;
+ case 19:
+ if ((0xfffffbffffffffffL & l) != 0L)
+ jjCheckNAddTwoStates(19, 20);
+ break;
+ case 20:
+ if (curChar == 42)
+ jjCheckNAddStates(9, 11);
+ break;
+ case 21:
+ if ((0xffff7bffffffffffL & l) != 0L)
+ jjCheckNAddTwoStates(22, 20);
+ break;
+ case 22:
+ if ((0xfffffbffffffffffL & l) != 0L)
+ jjCheckNAddTwoStates(22, 20);
+ break;
+ case 23:
+ if (curChar == 47 && kind > 8)
+ kind = 8;
+ break;
+ default : break;
+ }
+ } while(i != startsAt);
+ }
+ else if (curChar < 128)
+ {
+ long l = 1L << (curChar & 077);
+ MatchLoop: do
+ {
+ switch(jjstateSet[--i])
+ {
+ case 0:
+ case 4:
+ if ((0x7fffffe87fffffeL & l) == 0L)
+ break;
+ if (kind > 83)
+ kind = 83;
+ jjCheckNAdd(4);
+ break;
+ case 7:
+ jjAddStates(3, 5);
+ break;
+ case 12:
+ jjCheckNAddTwoStates(12, 13);
+ break;
+ case 14:
+ case 15:
+ jjCheckNAddTwoStates(15, 13);
+ break;
+ case 19:
+ jjCheckNAddTwoStates(19, 20);
+ break;
+ case 21:
+ case 22:
+ jjCheckNAddTwoStates(22, 20);
+ break;
+ default : break;
+ }
+ } while(i != startsAt);
+ }
+ else
+ {
+ int hiByte = (int)(curChar >> 8);
+ int i1 = hiByte >> 6;
+ long l1 = 1L << (hiByte & 077);
+ int i2 = (curChar & 0xff) >> 6;
+ long l2 = 1L << (curChar & 077);
+ MatchLoop: do
+ {
+ switch(jjstateSet[--i])
+ {
+ case 0:
+ case 4:
+ if (!jjCanMove_0(hiByte, i1, i2, l1, l2))
+ break;
+ if (kind > 83)
+ kind = 83;
+ jjCheckNAdd(4);
+ break;
+ case 7:
+ if (jjCanMove_1(hiByte, i1, i2, l1, l2))
+ jjAddStates(3, 5);
+ break;
+ case 12:
+ if (jjCanMove_1(hiByte, i1, i2, l1, l2))
+ jjCheckNAddTwoStates(12, 13);
+ break;
+ case 14:
+ case 15:
+ if (jjCanMove_1(hiByte, i1, i2, l1, l2))
+ jjCheckNAddTwoStates(15, 13);
+ break;
+ case 19:
+ if (jjCanMove_1(hiByte, i1, i2, l1, l2))
+ jjCheckNAddTwoStates(19, 20);
+ break;
+ case 21:
+ case 22:
+ if (jjCanMove_1(hiByte, i1, i2, l1, l2))
+ jjCheckNAddTwoStates(22, 20);
+ break;
+ default : break;
+ }
+ } while(i != startsAt);
+ }
+ if (kind != 0x7fffffff)
+ {
+ jjmatchedKind = kind;
+ jjmatchedPos = curPos;
+ kind = 0x7fffffff;
+ }
+ ++curPos;
+ if ((i = jjnewStateCnt) == (startsAt = 24 - (jjnewStateCnt = startsAt)))
+ return curPos;
+ try { curChar = input_stream.readChar(); }
+ catch(java.io.IOException e) { return curPos; }
+ }
+}
+static final int[] jjnextStates = {
+ 6, 17, 18, 7, 8, 10, 13, 14, 16, 20, 21, 23,
+};
+private static final boolean jjCanMove_0(int hiByte, int i1, int i2, long l1, long l2)
+{
+ switch(hiByte)
+ {
+ case 0:
+ return ((jjbitVec2[i2] & l2) != 0L);
+ case 48:
+ return ((jjbitVec3[i2] & l2) != 0L);
+ case 49:
+ return ((jjbitVec4[i2] & l2) != 0L);
+ case 51:
+ return ((jjbitVec5[i2] & l2) != 0L);
+ case 61:
+ return ((jjbitVec6[i2] & l2) != 0L);
+ default :
+ if ((jjbitVec0[i1] & l1) != 0L)
+ return true;
+ return false;
+ }
+}
+private static final boolean jjCanMove_1(int hiByte, int i1, int i2, long l1, long l2)
+{
+ switch(hiByte)
+ {
+ case 0:
+ return ((jjbitVec8[i2] & l2) != 0L);
+ default :
+ if ((jjbitVec7[i1] & l1) != 0L)
+ return true;
+ return false;
+ }
+}
+public static final String[] jjstrLiteralImages = {
+"", null, null, null, null, null, null, null, null, "\50", "\51", "\173",
+"\175", "\133", "\135", "\56", "\114\124", "\114\105", "\107\124", "\107\105",
+"\116\105", "\105\121", "\120\114\125\123", "\115\111\116\125\123", "\101\116\104",
+"\117\122", "\116\117\124", "\124\111\115\105\123", "\115\101\111\116",
+"\103\117\104\105", "\110\101\114\114\117\103\101\124\105",
+"\123\120\111\114\114\105\104\101\122\107", "\105\116\104", "\116\117\117\120", "\115\117\126\105", "\103\101\114\114",
+"\105\122\122\117\122", "\120\122\111\116\124", "\102\105\107\111\116", "\122\105\124\125\122\116",
+"\112\125\115\120", "\103\112\125\115\120", "\110\123\124\117\122\105", "\110\114\117\101\104",
+"\101\114\117\101\104", "\101\123\124\117\122\105", "\120\101\123\123\101\122\107", "\115\105\115",
+"\124\105\115\120", "\101\122\107", "\172\145\162\157", "\141\164", "\166\60", "\166\61",
+"\141\60", "\141\61", "\141\62", "\141\63", "\164\60", "\164\61", "\164\62", "\164\63",
+"\164\64", "\164\65", "\164\66", "\164\67", "\163\60", "\163\61", "\163\62", "\163\63",
+"\163\64", "\163\65", "\163\66", "\163\67", "\164\70", "\164\71", "\153\60", "\153\61",
+"\147\160", "\163\160", "\146\160", "\162\141", null, null, null, null, };
+public static final String[] lexStateNames = {
+ "DEFAULT",
+};
+static final long[] jjtoToken = {
+ 0xfffffffffffffe01L, 0xfffffL,
+};
+static final long[] jjtoSkip = {
+ 0x1feL, 0x0L,
+};
+static final long[] jjtoSpecial = {
+ 0x1c0L, 0x0L,
+};
+static protected JavaCharStream input_stream;
+static private final int[] jjrounds = new int[24];
+static private final int[] jjstateSet = new int[48];
+static protected char curChar;
+public KangaParserTokenManager(JavaCharStream stream){
+ if (input_stream != null)
+ throw new TokenMgrError("ERROR: Second call to constructor of static lexer. You must use ReInit() to initialize the static variables.", TokenMgrError.STATIC_LEXER_ERROR);
+ input_stream = stream;
+}
+public KangaParserTokenManager(JavaCharStream stream, int lexState){
+ this(stream);
+ SwitchTo(lexState);
+}
+static public void ReInit(JavaCharStream stream)
+{
+ jjmatchedPos = jjnewStateCnt = 0;
+ curLexState = defaultLexState;
+ input_stream = stream;
+ ReInitRounds();
+}
+static private final void ReInitRounds()
+{
+ int i;
+ jjround = 0x80000001;
+ for (i = 24; i-- > 0;)
+ jjrounds[i] = 0x80000000;
+}
+static public void ReInit(JavaCharStream stream, int lexState)
+{
+ ReInit(stream);
+ SwitchTo(lexState);
+}
+static public void SwitchTo(int lexState)
+{
+ if (lexState >= 1 || lexState < 0)
+ throw new TokenMgrError("Error: Ignoring invalid lexical state : " + lexState + ". State unchanged.", TokenMgrError.INVALID_LEXICAL_STATE);
+ else
+ curLexState = lexState;
+}
+
+static protected Token jjFillToken()
+{
+ Token t = Token.newToken(jjmatchedKind);
+ t.kind = jjmatchedKind;
+ String im = jjstrLiteralImages[jjmatchedKind];
+ t.image = (im == null) ? input_stream.GetImage() : im;
+ t.beginLine = input_stream.getBeginLine();
+ t.beginColumn = input_stream.getBeginColumn();
+ t.endLine = input_stream.getEndLine();
+ t.endColumn = input_stream.getEndColumn();
+ return t;
+}
+
+static int curLexState = 0;
+static int defaultLexState = 0;
+static int jjnewStateCnt;
+static int jjround;
+static int jjmatchedPos;
+static int jjmatchedKind;
+
+public static Token getNextToken()
+{
+ int kind;
+ Token specialToken = null;
+ Token matchedToken;
+ int curPos = 0;
+
+ EOFLoop :
+ for (;;)
+ {
+ try
+ {
+ curChar = input_stream.BeginToken();
+ }
+ catch(java.io.IOException e)
+ {
+ jjmatchedKind = 0;
+ matchedToken = jjFillToken();
+ matchedToken.specialToken = specialToken;
+ return matchedToken;
+ }
+
+ try { input_stream.backup(0);
+ while (curChar <= 32 && (0x100003600L & (1L << curChar)) != 0L)
+ curChar = input_stream.BeginToken();
+ }
+ catch (java.io.IOException e1) { continue EOFLoop; }
+ jjmatchedKind = 0x7fffffff;
+ jjmatchedPos = 0;
+ curPos = jjMoveStringLiteralDfa0_0();
+ if (jjmatchedKind != 0x7fffffff)
+ {
+ if (jjmatchedPos + 1 < curPos)
+ input_stream.backup(curPos - jjmatchedPos - 1);
+ if ((jjtoToken[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L)
+ {
+ matchedToken = jjFillToken();
+ matchedToken.specialToken = specialToken;
+ return matchedToken;
+ }
+ else
+ {
+ if ((jjtoSpecial[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L)
+ {
+ matchedToken = jjFillToken();
+ if (specialToken == null)
+ specialToken = matchedToken;
+ else
+ {
+ matchedToken.specialToken = specialToken;
+ specialToken = (specialToken.next = matchedToken);
+ }
+ }
+ continue EOFLoop;
+ }
+ }
+ int error_line = input_stream.getEndLine();
+ int error_column = input_stream.getEndColumn();
+ String error_after = null;
+ boolean EOFSeen = false;
+ try { input_stream.readChar(); input_stream.backup(1); }
+ catch (java.io.IOException e1) {
+ EOFSeen = true;
+ error_after = curPos <= 1 ? "" : input_stream.GetImage();
+ if (curChar == '\n' || curChar == '\r') {
+ error_line++;
+ error_column = 0;
+ }
+ else
+ error_column++;
+ }
+ if (!EOFSeen) {
+ input_stream.backup(1);
+ error_after = curPos <= 1 ? "" : input_stream.GetImage();
+ }
+ throw new TokenMgrError(EOFSeen, curLexState, error_line, error_column, error_after, curChar, TokenMgrError.LEXICAL_ERROR);
+ }
+}
+
+}
diff --git a/src/kanga/ParseException.java b/src/kanga/ParseException.java
new file mode 100644
index 0000000..a30b1e4
--- /dev/null
+++ b/src/kanga/ParseException.java
@@ -0,0 +1,191 @@
+package kanga;
+/* Generated By:JavaCC: Do not edit this line. ParseException.java Version 3.0 */
+/**
+ * This exception is thrown when parse errors are encountered.
+ * You can explicitly create objects of this exception type by
+ * calling the method generateParseException in the generated
+ * parser.
+ *
+ * You can modify this class to customize your error reporting
+ * mechanisms so long as you retain the public fields.
+ */
+public class ParseException extends Exception {
+
+ /**
+ * This constructor is used by the method "generateParseException"
+ * in the generated parser. Calling this constructor generates
+ * a new object of this type with the fields "currentToken",
+ * "expectedTokenSequences", and "tokenImage" set. The boolean
+ * flag "specialConstructor" is also set to true to indicate that
+ * this constructor was used to create this object.
+ * This constructor calls its super class with the empty string
+ * to force the "toString" method of parent class "Throwable" to
+ * print the error message in the form:
+ * ParseException: <result of getMessage>
+ */
+ public ParseException(Token currentTokenVal,
+ int[][] expectedTokenSequencesVal,
+ String[] tokenImageVal
+ )
+ {
+ super("");
+ specialConstructor = true;
+ currentToken = currentTokenVal;
+ expectedTokenSequences = expectedTokenSequencesVal;
+ tokenImage = tokenImageVal;
+ }
+
+ /**
+ * The following constructors are for use by you for whatever
+ * purpose you can think of. Constructing the exception in this
+ * manner makes the exception behave in the normal way - i.e., as
+ * documented in the class "Throwable". The fields "errorToken",
+ * "expectedTokenSequences", and "tokenImage" do not contain
+ * relevant information. The JavaCC generated code does not use
+ * these constructors.
+ */
+
+ public ParseException() {
+ super();
+ specialConstructor = false;
+ }
+
+ public ParseException(String message) {
+ super(message);
+ specialConstructor = false;
+ }
+
+ /**
+ * This variable determines which constructor was used to create
+ * this object and thereby affects the semantics of the
+ * "getMessage" method (see below).
+ */
+ protected boolean specialConstructor;
+
+ /**
+ * This is the last token that has been consumed successfully. If
+ * this object has been created due to a parse error, the token
+ * followng this token will (therefore) be the first error token.
+ */
+ public Token currentToken;
+
+ /**
+ * Each entry in this array is an array of integers. Each array
+ * of integers represents a sequence of tokens (by their ordinal
+ * values) that is expected at this point of the parse.
+ */
+ public int[][] expectedTokenSequences;
+
+ /**
+ * This is a reference to the "tokenImage" array of the generated
+ * parser within which the parse error occurred. This array is
+ * defined in the generated ...Constants interface.
+ */
+ public String[] tokenImage;
+
+ /**
+ * This method has the standard behavior when this object has been
+ * created using the standard constructors. Otherwise, it uses
+ * "currentToken" and "expectedTokenSequences" to generate a parse
+ * error message and returns it. If this object has been created
+ * due to a parse error, and you do not catch it (it gets thrown
+ * from the parser), then this method is called during the printing
+ * of the final stack trace, and hence the correct error message
+ * gets displayed.
+ */
+ public String getMessage() {
+ if (!specialConstructor) {
+ return super.getMessage();
+ }
+ StringBuffer expected = new StringBuffer();
+ int maxSize = 0;
+ for (int i = 0; i < expectedTokenSequences.length; i++) {
+ if (maxSize < expectedTokenSequences[i].length) {
+ maxSize = expectedTokenSequences[i].length;
+ }
+ for (int j = 0; j < expectedTokenSequences[i].length; j++) {
+ expected.append(tokenImage[expectedTokenSequences[i][j]]).append(" ");
+ }
+ if (expectedTokenSequences[i][expectedTokenSequences[i].length - 1] != 0) {
+ expected.append("...");
+ }
+ expected.append(eol).append(" ");
+ }
+ String retval = "Encountered \"";
+ Token tok = currentToken.next;
+ for (int i = 0; i < maxSize; i++) {
+ if (i != 0) retval += " ";
+ if (tok.kind == 0) {
+ retval += tokenImage[0];
+ break;
+ }
+ retval += add_escapes(tok.image);
+ tok = tok.next;
+ }
+ retval += "\" at line " + currentToken.next.beginLine + ", column " + currentToken.next.beginColumn;
+ retval += "." + eol;
+ if (expectedTokenSequences.length == 1) {
+ retval += "Was expecting:" + eol + " ";
+ } else {
+ retval += "Was expecting one of:" + eol + " ";
+ }
+ retval += expected.toString();
+ return retval;
+ }
+
+ /**
+ * The end of line string for this machine.
+ */
+ protected String eol = System.getProperty("line.separator", "\n");
+
+ /**
+ * Used to convert raw characters to their escaped version
+ * when these raw version cannot be used as part of an ASCII
+ * string literal.
+ */
+ protected String add_escapes(String str) {
+ StringBuffer retval = new StringBuffer();
+ char ch;
+ for (int i = 0; i < str.length(); i++) {
+ switch (str.charAt(i))
+ {
+ case 0 :
+ continue;
+ case '\b':
+ retval.append("\\b");
+ continue;
+ case '\t':
+ retval.append("\\t");
+ continue;
+ case '\n':
+ retval.append("\\n");
+ continue;
+ case '\f':
+ retval.append("\\f");
+ continue;
+ case '\r':
+ retval.append("\\r");
+ continue;
+ case '\"':
+ retval.append("\\\"");
+ continue;
+ case '\'':
+ retval.append("\\\'");
+ continue;
+ case '\\':
+ retval.append("\\\\");
+ continue;
+ default:
+ if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) {
+ String s = "0000" + Integer.toString(ch, 16);
+ retval.append("\\u" + s.substring(s.length() - 4, s.length()));
+ } else {
+ retval.append(ch);
+ }
+ continue;
+ }
+ }
+ return retval.toString();
+ }
+
+}
diff --git a/src/kanga/Token.java b/src/kanga/Token.java
new file mode 100644
index 0000000..3a89e75
--- /dev/null
+++ b/src/kanga/Token.java
@@ -0,0 +1,80 @@
+package kanga;
+/* Generated By:JavaCC: Do not edit this line. Token.java Version 3.0 */
+/**
+ * Describes the input token stream.
+ */
+
+public class Token {
+
+ /**
+ * An integer that describes the kind of this token. This numbering
+ * system is determined by JavaCCParser, and a table of these numbers is
+ * stored in the file ...Constants.java.
+ */
+ public int kind;
+
+ /**
+ * beginLine and beginColumn describe the position of the first character
+ * of this token; endLine and endColumn describe the position of the
+ * last character of this token.
+ */
+ public int beginLine, beginColumn, endLine, endColumn;
+
+ /**
+ * The string image of the token.
+ */
+ public String image;
+
+ /**
+ * A reference to the next regular (non-special) token from the input
+ * stream. If this is the last token from the input stream, or if the
+ * token manager has not read tokens beyond this one, this field is
+ * set to null. This is true only if this token is also a regular
+ * token. Otherwise, see below for a description of the contents of
+ * this field.
+ */
+ public Token next;
+
+ /**
+ * This field is used to access special tokens that occur prior to this
+ * token, but after the immediately preceding regular (non-special) token.
+ * If there are no such special tokens, this field is set to null.
+ * When there are more than one such special token, this field refers
+ * to the last of these special tokens, which in turn refers to the next
+ * previous special token through its specialToken field, and so on
+ * until the first special token (whose specialToken field is null).
+ * The next fields of special tokens refer to other special tokens that
+ * immediately follow it (without an intervening regular token). If there
+ * is no such token, this field is null.
+ */
+ public Token specialToken;
+
+ /**
+ * Returns the image.
+ */
+ public String toString()
+ {
+ return image;
+ }
+
+ /**
+ * Returns a new Token object, by default. However, if you want, you
+ * can create and return subclass objects based on the value of ofKind.
+ * Simply add the cases to the switch for all those special cases.
+ * For example, if you have a subclass of Token called IDToken that
+ * you want to create if ofKind is ID, simlpy add something like :
+ *
+ * case MyParserConstants.ID : return new IDToken();
+ *
+ * to the following switch statement. Then you can cast matchedToken
+ * variable to the appropriate type and use it in your lexical actions.
+ */
+ public static final Token newToken(int ofKind)
+ {
+ switch(ofKind)
+ {
+ default : return new Token();
+ }
+ }
+
+}
diff --git a/src/kanga/TokenMgrError.java b/src/kanga/TokenMgrError.java
new file mode 100644
index 0000000..b30ccec
--- /dev/null
+++ b/src/kanga/TokenMgrError.java
@@ -0,0 +1,132 @@
+package kanga;
+/* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 3.0 */
+public class TokenMgrError extends Error
+{
+ /*
+ * Ordinals for various reasons why an Error of this type can be thrown.
+ */
+
+ /**
+ * Lexical error occured.
+ */
+ static final int LEXICAL_ERROR = 0;
+
+ /**
+ * An attempt wass made to create a second instance of a static token manager.
+ */
+ static final int STATIC_LEXER_ERROR = 1;
+
+ /**
+ * Tried to change to an invalid lexical state.
+ */
+ static final int INVALID_LEXICAL_STATE = 2;
+
+ /**
+ * Detected (and bailed out of) an infinite loop in the token manager.
+ */
+ static final int LOOP_DETECTED = 3;
+
+ /**
+ * Indicates the reason why the exception is thrown. It will have
+ * one of the above 4 values.
+ */
+ int errorCode;
+
+ /**
+ * Replaces unprintable characters by their espaced (or unicode escaped)
+ * equivalents in the given string
+ */
+ protected static final String addEscapes(String str) {
+ StringBuffer retval = new StringBuffer();
+ char ch;
+ for (int i = 0; i < str.length(); i++) {
+ switch (str.charAt(i))
+ {
+ case 0 :
+ continue;
+ case '\b':
+ retval.append("\\b");
+ continue;
+ case '\t':
+ retval.append("\\t");
+ continue;
+ case '\n':
+ retval.append("\\n");
+ continue;
+ case '\f':
+ retval.append("\\f");
+ continue;
+ case '\r':
+ retval.append("\\r");
+ continue;
+ case '\"':
+ retval.append("\\\"");
+ continue;
+ case '\'':
+ retval.append("\\\'");
+ continue;
+ case '\\':
+ retval.append("\\\\");
+ continue;
+ default:
+ if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) {
+ String s = "0000" + Integer.toString(ch, 16);
+ retval.append("\\u" + s.substring(s.length() - 4, s.length()));
+ } else {
+ retval.append(ch);
+ }
+ continue;
+ }
+ }
+ return retval.toString();
+ }
+
+ /**
+ * Returns a detailed message for the Error when it is thrown by the
+ * token manager to indicate a lexical error.
+ * Parameters :
+ * EOFSeen : indicates if EOF caused the lexicl error
+ * curLexState : lexical state in which this error occured
+ * errorLine : line number when the error occured
+ * errorColumn : column number when the error occured
+ * errorAfter : prefix that was seen before this error occured
+ * curchar : the offending character
+ * Note: You can customize the lexical error message by modifying this method.
+ */
+ protected static String LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar) {
+ return("Lexical error at line " +
+ errorLine + ", column " +
+ errorColumn + ". Encountered: " +
+ (EOFSeen ? "<EOF> " : ("\"" + addEscapes(String.valueOf(curChar)) + "\"") + " (" + (int)curChar + "), ") +
+ "after : \"" + addEscapes(errorAfter) + "\"");
+ }
+
+ /**
+ * You can also modify the body of this method to customize your error messages.
+ * For example, cases like LOOP_DETECTED and INVALID_LEXICAL_STATE are not
+ * of end-users concern, so you can return something like :
+ *
+ * "Internal Error : Please file a bug report .... "
+ *
+ * from this method for such cases in the release version of your parser.
+ */
+ public String getMessage() {
+ return super.getMessage();
+ }
+
+ /*
+ * Constructors of various flavors follow.
+ */
+
+ public TokenMgrError() {
+ }
+
+ public TokenMgrError(String message, int reason) {
+ super(message);
+ errorCode = reason;
+ }
+
+ public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar, int reason) {
+ this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason);
+ }
+}
diff --git a/src/kanga/kanga2mips/Main.java b/src/kanga/kanga2mips/Main.java
new file mode 100644
index 0000000..7b5a49c
--- /dev/null
+++ b/src/kanga/kanga2mips/Main.java
@@ -0,0 +1,32 @@
+package kanga.kanga2mips;
+
+import kanga.KangaParser;
+import kanga.ParseException;
+import kanga.TokenMgrError;
+import kanga.syntaxtree.Node;
+import kanga.visitor.GJDepthFirst;
+
+public class Main {
+
+ public static void main(String[] args) {
+ try {
+ Node root = new KangaParser(System.in).Goal();
+ /*
+ * TODO: Implement your own Visitors and other classes.
+ */
+ GJDepthFirst v = new GJDepthFirst<Object, Object>() {
+ };
+ // Traverse the Abstract Grammar Tree
+ root.accept(v, null);
+ } catch (TokenMgrError e) {
+ // Handle Lexical Errors
+ e.printStackTrace();
+ } catch (ParseException e) {
+ // Handle Grammar Errors
+ e.printStackTrace();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ }
+} \ No newline at end of file
diff --git a/src/kanga/syntaxtree/ALoadStmt.java b/src/kanga/syntaxtree/ALoadStmt.java
new file mode 100644
index 0000000..e3959b0
--- /dev/null
+++ b/src/kanga/syntaxtree/ALoadStmt.java
@@ -0,0 +1,43 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package kanga.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "ALOAD"
+ * f1 -> Reg()
+ * f2 -> SpilledArg()
+ */
+public class ALoadStmt implements Node {
+ public NodeToken f0;
+ public Reg f1;
+ public SpilledArg f2;
+
+ public ALoadStmt(NodeToken n0, Reg n1, SpilledArg n2) {
+ f0 = n0;
+ f1 = n1;
+ f2 = n2;
+ }
+
+ public ALoadStmt(Reg n0, SpilledArg n1) {
+ f0 = new NodeToken("ALOAD");
+ f1 = n0;
+ f2 = n1;
+ }
+
+ public void accept(kanga.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(kanga.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(kanga.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(kanga.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/kanga/syntaxtree/AStoreStmt.java b/src/kanga/syntaxtree/AStoreStmt.java
new file mode 100644
index 0000000..fb90f0c
--- /dev/null
+++ b/src/kanga/syntaxtree/AStoreStmt.java
@@ -0,0 +1,43 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package kanga.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "ASTORE"
+ * f1 -> SpilledArg()
+ * f2 -> Reg()
+ */
+public class AStoreStmt implements Node {
+ public NodeToken f0;
+ public SpilledArg f1;
+ public Reg f2;
+
+ public AStoreStmt(NodeToken n0, SpilledArg n1, Reg n2) {
+ f0 = n0;
+ f1 = n1;
+ f2 = n2;
+ }
+
+ public AStoreStmt(SpilledArg n0, Reg n1) {
+ f0 = new NodeToken("ASTORE");
+ f1 = n0;
+ f2 = n1;
+ }
+
+ public void accept(kanga.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(kanga.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(kanga.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(kanga.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/kanga/syntaxtree/BinOp.java b/src/kanga/syntaxtree/BinOp.java
new file mode 100644
index 0000000..73a9876
--- /dev/null
+++ b/src/kanga/syntaxtree/BinOp.java
@@ -0,0 +1,37 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package kanga.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> Operator()
+ * f1 -> Reg()
+ * f2 -> SimpleExp()
+ */
+public class BinOp implements Node {
+ public Operator f0;
+ public Reg f1;
+ public SimpleExp f2;
+
+ public BinOp(Operator n0, Reg n1, SimpleExp n2) {
+ f0 = n0;
+ f1 = n1;
+ f2 = n2;
+ }
+
+ public void accept(kanga.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(kanga.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(kanga.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(kanga.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/kanga/syntaxtree/CJumpStmt.java b/src/kanga/syntaxtree/CJumpStmt.java
new file mode 100644
index 0000000..3f89bf8
--- /dev/null
+++ b/src/kanga/syntaxtree/CJumpStmt.java
@@ -0,0 +1,43 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package kanga.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "CJUMP"
+ * f1 -> Reg()
+ * f2 -> Label()
+ */
+public class CJumpStmt implements Node {
+ public NodeToken f0;
+ public Reg f1;
+ public Label f2;
+
+ public CJumpStmt(NodeToken n0, Reg n1, Label n2) {
+ f0 = n0;
+ f1 = n1;
+ f2 = n2;
+ }
+
+ public CJumpStmt(Reg n0, Label n1) {
+ f0 = new NodeToken("CJUMP");
+ f1 = n0;
+ f2 = n1;
+ }
+
+ public void accept(kanga.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(kanga.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(kanga.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(kanga.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/kanga/syntaxtree/CallStmt.java b/src/kanga/syntaxtree/CallStmt.java
new file mode 100644
index 0000000..2f50353
--- /dev/null
+++ b/src/kanga/syntaxtree/CallStmt.java
@@ -0,0 +1,39 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package kanga.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "CALL"
+ * f1 -> SimpleExp()
+ */
+public class CallStmt implements Node {
+ public NodeToken f0;
+ public SimpleExp f1;
+
+ public CallStmt(NodeToken n0, SimpleExp n1) {
+ f0 = n0;
+ f1 = n1;
+ }
+
+ public CallStmt(SimpleExp n0) {
+ f0 = new NodeToken("CALL");
+ f1 = n0;
+ }
+
+ public void accept(kanga.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(kanga.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(kanga.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(kanga.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/kanga/syntaxtree/ErrorStmt.java b/src/kanga/syntaxtree/ErrorStmt.java
new file mode 100644
index 0000000..b6a5b97
--- /dev/null
+++ b/src/kanga/syntaxtree/ErrorStmt.java
@@ -0,0 +1,35 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package kanga.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "ERROR"
+ */
+public class ErrorStmt implements Node {
+ public NodeToken f0;
+
+ public ErrorStmt(NodeToken n0) {
+ f0 = n0;
+ }
+
+ public ErrorStmt() {
+ f0 = new NodeToken("ERROR");
+ }
+
+ public void accept(kanga.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(kanga.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(kanga.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(kanga.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/kanga/syntaxtree/Exp.java b/src/kanga/syntaxtree/Exp.java
new file mode 100644
index 0000000..634327b
--- /dev/null
+++ b/src/kanga/syntaxtree/Exp.java
@@ -0,0 +1,33 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package kanga.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> HAllocate()
+ * | BinOp()
+ * | SimpleExp()
+ */
+public class Exp implements Node {
+ public NodeChoice f0;
+
+ public Exp(NodeChoice n0) {
+ f0 = n0;
+ }
+
+ public void accept(kanga.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(kanga.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(kanga.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(kanga.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/kanga/syntaxtree/Goal.java b/src/kanga/syntaxtree/Goal.java
new file mode 100644
index 0000000..541376e
--- /dev/null
+++ b/src/kanga/syntaxtree/Goal.java
@@ -0,0 +1,87 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package kanga.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "MAIN"
+ * f1 -> "["
+ * f2 -> IntegerLiteral()
+ * f3 -> "]"
+ * f4 -> "["
+ * f5 -> IntegerLiteral()
+ * f6 -> "]"
+ * f7 -> "["
+ * f8 -> IntegerLiteral()
+ * f9 -> "]"
+ * f10 -> StmtList()
+ * f11 -> "END"
+ * f12 -> ( Procedure() )*
+ * f13 -> <EOF>
+ */
+public class Goal implements Node {
+ public NodeToken f0;
+ public NodeToken f1;
+ public IntegerLiteral f2;
+ public NodeToken f3;
+ public NodeToken f4;
+ public IntegerLiteral f5;
+ public NodeToken f6;
+ public NodeToken f7;
+ public IntegerLiteral f8;
+ public NodeToken f9;
+ public StmtList f10;
+ public NodeToken f11;
+ public NodeListOptional f12;
+ public NodeToken f13;
+
+ public Goal(NodeToken n0, NodeToken n1, IntegerLiteral n2, NodeToken n3, NodeToken n4, IntegerLiteral n5, NodeToken n6, NodeToken n7, IntegerLiteral n8, NodeToken n9, StmtList n10, NodeToken n11, NodeListOptional n12, NodeToken n13) {
+ f0 = n0;
+ f1 = n1;
+ f2 = n2;
+ f3 = n3;
+ f4 = n4;
+ f5 = n5;
+ f6 = n6;
+ f7 = n7;
+ f8 = n8;
+ f9 = n9;
+ f10 = n10;
+ f11 = n11;
+ f12 = n12;
+ f13 = n13;
+ }
+
+ public Goal(IntegerLiteral n0, IntegerLiteral n1, IntegerLiteral n2, StmtList n3, NodeListOptional n4) {
+ f0 = new NodeToken("MAIN");
+ f1 = new NodeToken("[");
+ f2 = n0;
+ f3 = new NodeToken("]");
+ f4 = new NodeToken("[");
+ f5 = n1;
+ f6 = new NodeToken("]");
+ f7 = new NodeToken("[");
+ f8 = n2;
+ f9 = new NodeToken("]");
+ f10 = n3;
+ f11 = new NodeToken("END");
+ f12 = n4;
+ f13 = new NodeToken("");
+ }
+
+ public void accept(kanga.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(kanga.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(kanga.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(kanga.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/kanga/syntaxtree/HAllocate.java b/src/kanga/syntaxtree/HAllocate.java
new file mode 100644
index 0000000..97fd8bd
--- /dev/null
+++ b/src/kanga/syntaxtree/HAllocate.java
@@ -0,0 +1,39 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package kanga.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "HALLOCATE"
+ * f1 -> SimpleExp()
+ */
+public class HAllocate implements Node {
+ public NodeToken f0;
+ public SimpleExp f1;
+
+ public HAllocate(NodeToken n0, SimpleExp n1) {
+ f0 = n0;
+ f1 = n1;
+ }
+
+ public HAllocate(SimpleExp n0) {
+ f0 = new NodeToken("HALLOCATE");
+ f1 = n0;
+ }
+
+ public void accept(kanga.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(kanga.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(kanga.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(kanga.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/kanga/syntaxtree/HLoadStmt.java b/src/kanga/syntaxtree/HLoadStmt.java
new file mode 100644
index 0000000..5185583
--- /dev/null
+++ b/src/kanga/syntaxtree/HLoadStmt.java
@@ -0,0 +1,47 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package kanga.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "HLOAD"
+ * f1 -> Reg()
+ * f2 -> Reg()
+ * f3 -> IntegerLiteral()
+ */
+public class HLoadStmt implements Node {
+ public NodeToken f0;
+ public Reg f1;
+ public Reg f2;
+ public IntegerLiteral f3;
+
+ public HLoadStmt(NodeToken n0, Reg n1, Reg n2, IntegerLiteral n3) {
+ f0 = n0;
+ f1 = n1;
+ f2 = n2;
+ f3 = n3;
+ }
+
+ public HLoadStmt(Reg n0, Reg n1, IntegerLiteral n2) {
+ f0 = new NodeToken("HLOAD");
+ f1 = n0;
+ f2 = n1;
+ f3 = n2;
+ }
+
+ public void accept(kanga.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(kanga.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(kanga.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(kanga.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/kanga/syntaxtree/HStoreStmt.java b/src/kanga/syntaxtree/HStoreStmt.java
new file mode 100644
index 0000000..074eb9c
--- /dev/null
+++ b/src/kanga/syntaxtree/HStoreStmt.java
@@ -0,0 +1,47 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package kanga.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "HSTORE"
+ * f1 -> Reg()
+ * f2 -> IntegerLiteral()
+ * f3 -> Reg()
+ */
+public class HStoreStmt implements Node {
+ public NodeToken f0;
+ public Reg f1;
+ public IntegerLiteral f2;
+ public Reg f3;
+
+ public HStoreStmt(NodeToken n0, Reg n1, IntegerLiteral n2, Reg n3) {
+ f0 = n0;
+ f1 = n1;
+ f2 = n2;
+ f3 = n3;
+ }
+
+ public HStoreStmt(Reg n0, IntegerLiteral n1, Reg n2) {
+ f0 = new NodeToken("HSTORE");
+ f1 = n0;
+ f2 = n1;
+ f3 = n2;
+ }
+
+ public void accept(kanga.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(kanga.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(kanga.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(kanga.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/kanga/syntaxtree/IntegerLiteral.java b/src/kanga/syntaxtree/IntegerLiteral.java
new file mode 100644
index 0000000..9359606
--- /dev/null
+++ b/src/kanga/syntaxtree/IntegerLiteral.java
@@ -0,0 +1,31 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package kanga.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> <INTEGER_LITERAL>
+ */
+public class IntegerLiteral implements Node {
+ public NodeToken f0;
+
+ public IntegerLiteral(NodeToken n0) {
+ f0 = n0;
+ }
+
+ public void accept(kanga.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(kanga.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(kanga.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(kanga.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/kanga/syntaxtree/JumpStmt.java b/src/kanga/syntaxtree/JumpStmt.java
new file mode 100644
index 0000000..6ef09f4
--- /dev/null
+++ b/src/kanga/syntaxtree/JumpStmt.java
@@ -0,0 +1,39 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package kanga.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "JUMP"
+ * f1 -> Label()
+ */
+public class JumpStmt implements Node {
+ public NodeToken f0;
+ public Label f1;
+
+ public JumpStmt(NodeToken n0, Label n1) {
+ f0 = n0;
+ f1 = n1;
+ }
+
+ public JumpStmt(Label n0) {
+ f0 = new NodeToken("JUMP");
+ f1 = n0;
+ }
+
+ public void accept(kanga.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(kanga.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(kanga.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(kanga.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/kanga/syntaxtree/Label.java b/src/kanga/syntaxtree/Label.java
new file mode 100644
index 0000000..a2bc07c
--- /dev/null
+++ b/src/kanga/syntaxtree/Label.java
@@ -0,0 +1,31 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package kanga.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> <IDENTIFIER>
+ */
+public class Label implements Node {
+ public NodeToken f0;
+
+ public Label(NodeToken n0) {
+ f0 = n0;
+ }
+
+ public void accept(kanga.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(kanga.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(kanga.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(kanga.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/kanga/syntaxtree/MoveStmt.java b/src/kanga/syntaxtree/MoveStmt.java
new file mode 100644
index 0000000..88a1f87
--- /dev/null
+++ b/src/kanga/syntaxtree/MoveStmt.java
@@ -0,0 +1,43 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package kanga.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "MOVE"
+ * f1 -> Reg()
+ * f2 -> Exp()
+ */
+public class MoveStmt implements Node {
+ public NodeToken f0;
+ public Reg f1;
+ public Exp f2;
+
+ public MoveStmt(NodeToken n0, Reg n1, Exp n2) {
+ f0 = n0;
+ f1 = n1;
+ f2 = n2;
+ }
+
+ public MoveStmt(Reg n0, Exp n1) {
+ f0 = new NodeToken("MOVE");
+ f1 = n0;
+ f2 = n1;
+ }
+
+ public void accept(kanga.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(kanga.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(kanga.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(kanga.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/kanga/syntaxtree/NoOpStmt.java b/src/kanga/syntaxtree/NoOpStmt.java
new file mode 100644
index 0000000..8b722b2
--- /dev/null
+++ b/src/kanga/syntaxtree/NoOpStmt.java
@@ -0,0 +1,35 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package kanga.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "NOOP"
+ */
+public class NoOpStmt implements Node {
+ public NodeToken f0;
+
+ public NoOpStmt(NodeToken n0) {
+ f0 = n0;
+ }
+
+ public NoOpStmt() {
+ f0 = new NodeToken("NOOP");
+ }
+
+ public void accept(kanga.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(kanga.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(kanga.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(kanga.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/kanga/syntaxtree/Node.java b/src/kanga/syntaxtree/Node.java
new file mode 100644
index 0000000..945ac77
--- /dev/null
+++ b/src/kanga/syntaxtree/Node.java
@@ -0,0 +1,16 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package kanga.syntaxtree;
+
+/**
+ * The interface which all syntax tree classes must implement.
+ */
+public interface Node extends java.io.Serializable {
+ public void accept(kanga.visitor.Visitor v);
+ public <R,A> R accept(kanga.visitor.GJVisitor<R,A> v, A argu);
+ public <R> R accept(kanga.visitor.GJNoArguVisitor<R> v);
+ public <A> void accept(kanga.visitor.GJVoidVisitor<A> v, A argu);
+}
+
diff --git a/src/kanga/syntaxtree/NodeChoice.java b/src/kanga/syntaxtree/NodeChoice.java
new file mode 100644
index 0000000..4230240
--- /dev/null
+++ b/src/kanga/syntaxtree/NodeChoice.java
@@ -0,0 +1,36 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package kanga.syntaxtree;
+
+/**
+ * Represents a grammar choice, e.g. ( A | B )
+ */
+public class NodeChoice implements Node {
+ public NodeChoice(Node node) {
+ this(node, -1);
+ }
+
+ public NodeChoice(Node node, int whichChoice) {
+ choice = node;
+ which = whichChoice;
+ }
+
+ public void accept(kanga.visitor.Visitor v) {
+ choice.accept(v);
+ }
+ public <R,A> R accept(kanga.visitor.GJVisitor<R,A> v, A argu) {
+ return choice.accept(v,argu);
+ }
+ public <R> R accept(kanga.visitor.GJNoArguVisitor<R> v) {
+ return choice.accept(v);
+ }
+ public <A> void accept(kanga.visitor.GJVoidVisitor<A> v, A argu) {
+ choice.accept(v,argu);
+ }
+
+ public Node choice;
+ public int which;
+}
+
diff --git a/src/kanga/syntaxtree/NodeList.java b/src/kanga/syntaxtree/NodeList.java
new file mode 100644
index 0000000..050a920
--- /dev/null
+++ b/src/kanga/syntaxtree/NodeList.java
@@ -0,0 +1,45 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package kanga.syntaxtree;
+
+import java.util.Enumeration;
+import java.util.Vector;
+
+/**
+ * Represents a grammar list, e.g. ( A )+
+ */
+public class NodeList implements NodeListInterface {
+ public NodeList() {
+ nodes = new Vector<Node>();
+ }
+
+ public NodeList(Node firstNode) {
+ nodes = new Vector<Node>();
+ addNode(firstNode);
+ }
+
+ public void addNode(Node n) {
+ nodes.addElement(n);
+ }
+
+ public Enumeration<Node> elements() { return nodes.elements(); }
+ public Node elementAt(int i) { return nodes.elementAt(i); }
+ public int size() { return nodes.size(); }
+ public void accept(kanga.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(kanga.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(kanga.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(kanga.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+
+ public Vector<Node> nodes;
+}
+
diff --git a/src/kanga/syntaxtree/NodeListInterface.java b/src/kanga/syntaxtree/NodeListInterface.java
new file mode 100644
index 0000000..e09eb36
--- /dev/null
+++ b/src/kanga/syntaxtree/NodeListInterface.java
@@ -0,0 +1,22 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package kanga.syntaxtree;
+
+/**
+ * The interface which NodeList, NodeListOptional, and NodeSequence
+ * implement.
+ */
+public interface NodeListInterface extends Node {
+ public void addNode(Node n);
+ public Node elementAt(int i);
+ public java.util.Enumeration<Node> elements();
+ public int size();
+
+ public void accept(kanga.visitor.Visitor v);
+ public <R,A> R accept(kanga.visitor.GJVisitor<R,A> v, A argu);
+ public <R> R accept(kanga.visitor.GJNoArguVisitor<R> v);
+ public <A> void accept(kanga.visitor.GJVoidVisitor<A> v, A argu);
+}
+
diff --git a/src/kanga/syntaxtree/NodeListOptional.java b/src/kanga/syntaxtree/NodeListOptional.java
new file mode 100644
index 0000000..7d0581d
--- /dev/null
+++ b/src/kanga/syntaxtree/NodeListOptional.java
@@ -0,0 +1,46 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package kanga.syntaxtree;
+
+import java.util.Enumeration;
+import java.util.Vector;
+
+/**
+ * Represents an optional grammar list, e.g. ( A )*
+ */
+public class NodeListOptional implements NodeListInterface {
+ public NodeListOptional() {
+ nodes = new Vector<Node>();
+ }
+
+ public NodeListOptional(Node firstNode) {
+ nodes = new Vector<Node>();
+ addNode(firstNode);
+ }
+
+ public void addNode(Node n) {
+ nodes.addElement(n);
+ }
+
+ public Enumeration<Node> elements() { return nodes.elements(); }
+ public Node elementAt(int i) { return nodes.elementAt(i); }
+ public int size() { return nodes.size(); }
+ public boolean present() { return nodes.size() != 0; }
+ public void accept(kanga.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(kanga.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(kanga.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(kanga.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+
+ public Vector<Node> nodes;
+}
+
diff --git a/src/kanga/syntaxtree/NodeOptional.java b/src/kanga/syntaxtree/NodeOptional.java
new file mode 100644
index 0000000..5f60850
--- /dev/null
+++ b/src/kanga/syntaxtree/NodeOptional.java
@@ -0,0 +1,41 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package kanga.syntaxtree;
+
+/**
+ * Represents an grammar optional node, e.g. ( A )? or [ A ]
+ */
+public class NodeOptional implements Node {
+ public NodeOptional() {
+ node = null;
+ }
+
+ public NodeOptional(Node n) {
+ addNode(n);
+ }
+
+ public void addNode(Node n) {
+ if ( node != null) // Oh oh!
+ throw new Error("Attempt to set optional node twice");
+
+ node = n;
+ }
+ public void accept(kanga.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(kanga.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(kanga.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(kanga.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+ public boolean present() { return node != null; }
+
+ public Node node;
+}
+
diff --git a/src/kanga/syntaxtree/NodeSequence.java b/src/kanga/syntaxtree/NodeSequence.java
new file mode 100644
index 0000000..4b55d11
--- /dev/null
+++ b/src/kanga/syntaxtree/NodeSequence.java
@@ -0,0 +1,46 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package kanga.syntaxtree;
+
+import java.util.Enumeration;
+import java.util.Vector;
+
+/**
+ * Represents a sequence of nodes nested within a choice, list,
+ * optional list, or optional, e.g. ( A B )+ or [ C D E ]
+ */
+public class NodeSequence implements NodeListInterface {
+ public NodeSequence(int n) {
+ nodes = new Vector<Node>(n);
+ }
+
+ public NodeSequence(Node firstNode) {
+ nodes = new Vector<Node>();
+ addNode(firstNode);
+ }
+
+ public void addNode(Node n) {
+ nodes.addElement(n);
+ }
+
+ public Node elementAt(int i) { return nodes.elementAt(i); }
+ public Enumeration<Node> elements() { return nodes.elements(); }
+ public int size() { return nodes.size(); }
+ public void accept(kanga.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(kanga.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(kanga.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(kanga.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+
+ public Vector<Node> nodes;
+}
+
diff --git a/src/kanga/syntaxtree/NodeToken.java b/src/kanga/syntaxtree/NodeToken.java
new file mode 100644
index 0000000..840b92d
--- /dev/null
+++ b/src/kanga/syntaxtree/NodeToken.java
@@ -0,0 +1,88 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package kanga.syntaxtree;
+
+import java.util.Enumeration;
+import java.util.Vector;
+/**
+ * Represents a single token in the grammar. If the "-tk" option
+ * is used, also contains a Vector of preceding special tokens.
+ */
+public class NodeToken implements Node {
+ public NodeToken(String s) {
+ this(s, -1, -1, -1, -1, -1); }
+
+ public NodeToken(String s, int kind, int beginLine, int beginColumn, int endLine, int endColumn) {
+ tokenImage = s;
+ specialTokens = null;
+ this.kind = kind;
+ this.beginLine = beginLine;
+ this.beginColumn = beginColumn;
+ this.endLine = endLine;
+ this.endColumn = endColumn;
+ }
+
+ public NodeToken getSpecialAt(int i) {
+ if ( specialTokens == null )
+ throw new java.util.NoSuchElementException("No specials in token");
+ return specialTokens.elementAt(i);
+ }
+
+ public int numSpecials() {
+ if ( specialTokens == null ) return 0;
+ return specialTokens.size();
+ }
+
+ public void addSpecial(NodeToken s) {
+ if ( specialTokens == null ) specialTokens = new Vector<NodeToken>();
+ specialTokens.addElement(s);
+ }
+
+ public void trimSpecials() {
+ if ( specialTokens == null ) return;
+ specialTokens.trimToSize();
+ }
+
+ public String toString() { return tokenImage; }
+
+ public String withSpecials() {
+ if ( specialTokens == null )
+ return tokenImage;
+
+ StringBuffer buf = new StringBuffer();
+
+ for ( Enumeration<NodeToken> e = specialTokens.elements(); e.hasMoreElements(); )
+ buf.append(e.nextElement().toString());
+
+ buf.append(tokenImage);
+ return buf.toString();
+ }
+
+ public void accept(kanga.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(kanga.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(kanga.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(kanga.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+
+ public String tokenImage;
+
+ // Stores a list of NodeTokens
+ public Vector<NodeToken> specialTokens;
+
+ // -1 for these ints means no position info is available.
+ public int beginLine, beginColumn, endLine, endColumn;
+
+ // Equal to the JavaCC token "kind" integer.
+ // -1 if not available.
+ public int kind;
+}
+
diff --git a/src/kanga/syntaxtree/Operator.java b/src/kanga/syntaxtree/Operator.java
new file mode 100644
index 0000000..3bb8c0c
--- /dev/null
+++ b/src/kanga/syntaxtree/Operator.java
@@ -0,0 +1,34 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package kanga.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "LT"
+ * | "PLUS"
+ * | "MINUS"
+ * | "TIMES"
+ */
+public class Operator implements Node {
+ public NodeChoice f0;
+
+ public Operator(NodeChoice n0) {
+ f0 = n0;
+ }
+
+ public void accept(kanga.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(kanga.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(kanga.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(kanga.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/kanga/syntaxtree/PassArgStmt.java b/src/kanga/syntaxtree/PassArgStmt.java
new file mode 100644
index 0000000..ac7671d
--- /dev/null
+++ b/src/kanga/syntaxtree/PassArgStmt.java
@@ -0,0 +1,43 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package kanga.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "PASSARG"
+ * f1 -> IntegerLiteral()
+ * f2 -> Reg()
+ */
+public class PassArgStmt implements Node {
+ public NodeToken f0;
+ public IntegerLiteral f1;
+ public Reg f2;
+
+ public PassArgStmt(NodeToken n0, IntegerLiteral n1, Reg n2) {
+ f0 = n0;
+ f1 = n1;
+ f2 = n2;
+ }
+
+ public PassArgStmt(IntegerLiteral n0, Reg n1) {
+ f0 = new NodeToken("PASSARG");
+ f1 = n0;
+ f2 = n1;
+ }
+
+ public void accept(kanga.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(kanga.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(kanga.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(kanga.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/kanga/syntaxtree/PrintStmt.java b/src/kanga/syntaxtree/PrintStmt.java
new file mode 100644
index 0000000..40f5f6e
--- /dev/null
+++ b/src/kanga/syntaxtree/PrintStmt.java
@@ -0,0 +1,39 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package kanga.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "PRINT"
+ * f1 -> SimpleExp()
+ */
+public class PrintStmt implements Node {
+ public NodeToken f0;
+ public SimpleExp f1;
+
+ public PrintStmt(NodeToken n0, SimpleExp n1) {
+ f0 = n0;
+ f1 = n1;
+ }
+
+ public PrintStmt(SimpleExp n0) {
+ f0 = new NodeToken("PRINT");
+ f1 = n0;
+ }
+
+ public void accept(kanga.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(kanga.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(kanga.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(kanga.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/kanga/syntaxtree/Procedure.java b/src/kanga/syntaxtree/Procedure.java
new file mode 100644
index 0000000..08f8abd
--- /dev/null
+++ b/src/kanga/syntaxtree/Procedure.java
@@ -0,0 +1,79 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package kanga.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> Label()
+ * f1 -> "["
+ * f2 -> IntegerLiteral()
+ * f3 -> "]"
+ * f4 -> "["
+ * f5 -> IntegerLiteral()
+ * f6 -> "]"
+ * f7 -> "["
+ * f8 -> IntegerLiteral()
+ * f9 -> "]"
+ * f10 -> StmtList()
+ * f11 -> "END"
+ */
+public class Procedure implements Node {
+ public Label f0;
+ public NodeToken f1;
+ public IntegerLiteral f2;
+ public NodeToken f3;
+ public NodeToken f4;
+ public IntegerLiteral f5;
+ public NodeToken f6;
+ public NodeToken f7;
+ public IntegerLiteral f8;
+ public NodeToken f9;
+ public StmtList f10;
+ public NodeToken f11;
+
+ public Procedure(Label n0, NodeToken n1, IntegerLiteral n2, NodeToken n3, NodeToken n4, IntegerLiteral n5, NodeToken n6, NodeToken n7, IntegerLiteral n8, NodeToken n9, StmtList n10, NodeToken n11) {
+ f0 = n0;
+ f1 = n1;
+ f2 = n2;
+ f3 = n3;
+ f4 = n4;
+ f5 = n5;
+ f6 = n6;
+ f7 = n7;
+ f8 = n8;
+ f9 = n9;
+ f10 = n10;
+ f11 = n11;
+ }
+
+ public Procedure(Label n0, IntegerLiteral n1, IntegerLiteral n2, IntegerLiteral n3, StmtList n4) {
+ f0 = n0;
+ f1 = new NodeToken("[");
+ f2 = n1;
+ f3 = new NodeToken("]");
+ f4 = new NodeToken("[");
+ f5 = n2;
+ f6 = new NodeToken("]");
+ f7 = new NodeToken("[");
+ f8 = n3;
+ f9 = new NodeToken("]");
+ f10 = n4;
+ f11 = new NodeToken("END");
+ }
+
+ public void accept(kanga.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(kanga.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(kanga.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(kanga.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/kanga/syntaxtree/Reg.java b/src/kanga/syntaxtree/Reg.java
new file mode 100644
index 0000000..0f1bcbd
--- /dev/null
+++ b/src/kanga/syntaxtree/Reg.java
@@ -0,0 +1,54 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package kanga.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "a0"
+ * | "a1"
+ * | "a2"
+ * | "a3"
+ * | "t0"
+ * | "t1"
+ * | "t2"
+ * | "t3"
+ * | "t4"
+ * | "t5"
+ * | "t6"
+ * | "t7"
+ * | "s0"
+ * | "s1"
+ * | "s2"
+ * | "s3"
+ * | "s4"
+ * | "s5"
+ * | "s6"
+ * | "s7"
+ * | "t8"
+ * | "t9"
+ * | "v0"
+ * | "v1"
+ */
+public class Reg implements Node {
+ public NodeChoice f0;
+
+ public Reg(NodeChoice n0) {
+ f0 = n0;
+ }
+
+ public void accept(kanga.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(kanga.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(kanga.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(kanga.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/kanga/syntaxtree/SimpleExp.java b/src/kanga/syntaxtree/SimpleExp.java
new file mode 100644
index 0000000..51343aa
--- /dev/null
+++ b/src/kanga/syntaxtree/SimpleExp.java
@@ -0,0 +1,33 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package kanga.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> Reg()
+ * | IntegerLiteral()
+ * | Label()
+ */
+public class SimpleExp implements Node {
+ public NodeChoice f0;
+
+ public SimpleExp(NodeChoice n0) {
+ f0 = n0;
+ }
+
+ public void accept(kanga.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(kanga.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(kanga.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(kanga.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/kanga/syntaxtree/SpilledArg.java b/src/kanga/syntaxtree/SpilledArg.java
new file mode 100644
index 0000000..75b9416
--- /dev/null
+++ b/src/kanga/syntaxtree/SpilledArg.java
@@ -0,0 +1,39 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package kanga.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "SPILLEDARG"
+ * f1 -> IntegerLiteral()
+ */
+public class SpilledArg implements Node {
+ public NodeToken f0;
+ public IntegerLiteral f1;
+
+ public SpilledArg(NodeToken n0, IntegerLiteral n1) {
+ f0 = n0;
+ f1 = n1;
+ }
+
+ public SpilledArg(IntegerLiteral n0) {
+ f0 = new NodeToken("SPILLEDARG");
+ f1 = n0;
+ }
+
+ public void accept(kanga.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(kanga.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(kanga.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(kanga.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/kanga/syntaxtree/Stmt.java b/src/kanga/syntaxtree/Stmt.java
new file mode 100644
index 0000000..bb9b396
--- /dev/null
+++ b/src/kanga/syntaxtree/Stmt.java
@@ -0,0 +1,42 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package kanga.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> NoOpStmt()
+ * | ErrorStmt()
+ * | CJumpStmt()
+ * | JumpStmt()
+ * | HStoreStmt()
+ * | HLoadStmt()
+ * | MoveStmt()
+ * | PrintStmt()
+ * | ALoadStmt()
+ * | AStoreStmt()
+ * | PassArgStmt()
+ * | CallStmt()
+ */
+public class Stmt implements Node {
+ public NodeChoice f0;
+
+ public Stmt(NodeChoice n0) {
+ f0 = n0;
+ }
+
+ public void accept(kanga.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(kanga.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(kanga.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(kanga.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/kanga/syntaxtree/StmtList.java b/src/kanga/syntaxtree/StmtList.java
new file mode 100644
index 0000000..e8d350e
--- /dev/null
+++ b/src/kanga/syntaxtree/StmtList.java
@@ -0,0 +1,31 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package kanga.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> ( ( Label() )? Stmt() )*
+ */
+public class StmtList implements Node {
+ public NodeListOptional f0;
+
+ public StmtList(NodeListOptional n0) {
+ f0 = n0;
+ }
+
+ public void accept(kanga.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(kanga.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(kanga.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(kanga.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/kanga/visitor/DepthFirstVisitor.java b/src/kanga/visitor/DepthFirstVisitor.java
new file mode 100644
index 0000000..39d3338
--- /dev/null
+++ b/src/kanga/visitor/DepthFirstVisitor.java
@@ -0,0 +1,385 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package kanga.visitor;
+import java.util.Enumeration;
+
+import kanga.syntaxtree.ALoadStmt;
+import kanga.syntaxtree.AStoreStmt;
+import kanga.syntaxtree.BinOp;
+import kanga.syntaxtree.CJumpStmt;
+import kanga.syntaxtree.CallStmt;
+import kanga.syntaxtree.ErrorStmt;
+import kanga.syntaxtree.Exp;
+import kanga.syntaxtree.Goal;
+import kanga.syntaxtree.HAllocate;
+import kanga.syntaxtree.HLoadStmt;
+import kanga.syntaxtree.HStoreStmt;
+import kanga.syntaxtree.IntegerLiteral;
+import kanga.syntaxtree.JumpStmt;
+import kanga.syntaxtree.Label;
+import kanga.syntaxtree.MoveStmt;
+import kanga.syntaxtree.NoOpStmt;
+import kanga.syntaxtree.Node;
+import kanga.syntaxtree.NodeList;
+import kanga.syntaxtree.NodeListOptional;
+import kanga.syntaxtree.NodeOptional;
+import kanga.syntaxtree.NodeSequence;
+import kanga.syntaxtree.NodeToken;
+import kanga.syntaxtree.Operator;
+import kanga.syntaxtree.PassArgStmt;
+import kanga.syntaxtree.PrintStmt;
+import kanga.syntaxtree.Procedure;
+import kanga.syntaxtree.Reg;
+import kanga.syntaxtree.SimpleExp;
+import kanga.syntaxtree.SpilledArg;
+import kanga.syntaxtree.Stmt;
+import kanga.syntaxtree.StmtList;
+
+/**
+ * Provides default methods which visit each node in the tree in depth-first
+ * order. Your visitors may extend this class.
+ */
+public class DepthFirstVisitor implements Visitor {
+ //
+ // Auto class visitors--probably don't need to be overridden.
+ //
+ public void visit(NodeList n) {
+ for ( Enumeration<Node> e = n.elements(); e.hasMoreElements(); )
+ e.nextElement().accept(this);
+ }
+
+ public void visit(NodeListOptional n) {
+ if ( n.present() )
+ for ( Enumeration<Node> e = n.elements(); e.hasMoreElements(); )
+ e.nextElement().accept(this);
+ }
+
+ public void visit(NodeOptional n) {
+ if ( n.present() )
+ n.node.accept(this);
+ }
+
+ public void visit(NodeSequence n) {
+ for ( Enumeration<Node> e = n.elements(); e.hasMoreElements(); )
+ e.nextElement().accept(this);
+ }
+
+ public void visit(NodeToken n) { }
+
+ //
+ // User-generated visitor methods below
+ //
+
+ /**
+ * f0 -> "MAIN"
+ * f1 -> "["
+ * f2 -> IntegerLiteral()
+ * f3 -> "]"
+ * f4 -> "["
+ * f5 -> IntegerLiteral()
+ * f6 -> "]"
+ * f7 -> "["
+ * f8 -> IntegerLiteral()
+ * f9 -> "]"
+ * f10 -> StmtList()
+ * f11 -> "END"
+ * f12 -> ( Procedure() )*
+ * f13 -> <EOF>
+ */
+ public void visit(Goal n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ n.f3.accept(this);
+ n.f4.accept(this);
+ n.f5.accept(this);
+ n.f6.accept(this);
+ n.f7.accept(this);
+ n.f8.accept(this);
+ n.f9.accept(this);
+ n.f10.accept(this);
+ n.f11.accept(this);
+ n.f12.accept(this);
+ n.f13.accept(this);
+ }
+
+ /**
+ * f0 -> ( ( Label() )? Stmt() )*
+ */
+ public void visit(StmtList n) {
+ n.f0.accept(this);
+ }
+
+ /**
+ * f0 -> Label()
+ * f1 -> "["
+ * f2 -> IntegerLiteral()
+ * f3 -> "]"
+ * f4 -> "["
+ * f5 -> IntegerLiteral()
+ * f6 -> "]"
+ * f7 -> "["
+ * f8 -> IntegerLiteral()
+ * f9 -> "]"
+ * f10 -> StmtList()
+ * f11 -> "END"
+ */
+ public void visit(Procedure n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ n.f3.accept(this);
+ n.f4.accept(this);
+ n.f5.accept(this);
+ n.f6.accept(this);
+ n.f7.accept(this);
+ n.f8.accept(this);
+ n.f9.accept(this);
+ n.f10.accept(this);
+ n.f11.accept(this);
+ }
+
+ /**
+ * f0 -> NoOpStmt()
+ * | ErrorStmt()
+ * | CJumpStmt()
+ * | JumpStmt()
+ * | HStoreStmt()
+ * | HLoadStmt()
+ * | MoveStmt()
+ * | PrintStmt()
+ * | ALoadStmt()
+ * | AStoreStmt()
+ * | PassArgStmt()
+ * | CallStmt()
+ */
+ public void visit(Stmt n) {
+ n.f0.accept(this);
+ }
+
+ /**
+ * f0 -> "NOOP"
+ */
+ public void visit(NoOpStmt n) {
+ n.f0.accept(this);
+ }
+
+ /**
+ * f0 -> "ERROR"
+ */
+ public void visit(ErrorStmt n) {
+ n.f0.accept(this);
+ }
+
+ /**
+ * f0 -> "CJUMP"
+ * f1 -> Reg()
+ * f2 -> Label()
+ */
+ public void visit(CJumpStmt n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ }
+
+ /**
+ * f0 -> "JUMP"
+ * f1 -> Label()
+ */
+ public void visit(JumpStmt n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ }
+
+ /**
+ * f0 -> "HSTORE"
+ * f1 -> Reg()
+ * f2 -> IntegerLiteral()
+ * f3 -> Reg()
+ */
+ public void visit(HStoreStmt n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ n.f3.accept(this);
+ }
+
+ /**
+ * f0 -> "HLOAD"
+ * f1 -> Reg()
+ * f2 -> Reg()
+ * f3 -> IntegerLiteral()
+ */
+ public void visit(HLoadStmt n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ n.f3.accept(this);
+ }
+
+ /**
+ * f0 -> "MOVE"
+ * f1 -> Reg()
+ * f2 -> Exp()
+ */
+ public void visit(MoveStmt n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ }
+
+ /**
+ * f0 -> "PRINT"
+ * f1 -> SimpleExp()
+ */
+ public void visit(PrintStmt n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ }
+
+ /**
+ * f0 -> "ALOAD"
+ * f1 -> Reg()
+ * f2 -> SpilledArg()
+ */
+ public void visit(ALoadStmt n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ }
+
+ /**
+ * f0 -> "ASTORE"
+ * f1 -> SpilledArg()
+ * f2 -> Reg()
+ */
+ public void visit(AStoreStmt n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ }
+
+ /**
+ * f0 -> "PASSARG"
+ * f1 -> IntegerLiteral()
+ * f2 -> Reg()
+ */
+ public void visit(PassArgStmt n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ }
+
+ /**
+ * f0 -> "CALL"
+ * f1 -> SimpleExp()
+ */
+ public void visit(CallStmt n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ }
+
+ /**
+ * f0 -> HAllocate()
+ * | BinOp()
+ * | SimpleExp()
+ */
+ public void visit(Exp n) {
+ n.f0.accept(this);
+ }
+
+ /**
+ * f0 -> "HALLOCATE"
+ * f1 -> SimpleExp()
+ */
+ public void visit(HAllocate n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ }
+
+ /**
+ * f0 -> Operator()
+ * f1 -> Reg()
+ * f2 -> SimpleExp()
+ */
+ public void visit(BinOp n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ }
+
+ /**
+ * f0 -> "LT"
+ * | "PLUS"
+ * | "MINUS"
+ * | "TIMES"
+ */
+ public void visit(Operator n) {
+ n.f0.accept(this);
+ }
+
+ /**
+ * f0 -> "SPILLEDARG"
+ * f1 -> IntegerLiteral()
+ */
+ public void visit(SpilledArg n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ }
+
+ /**
+ * f0 -> Reg()
+ * | IntegerLiteral()
+ * | Label()
+ */
+ public void visit(SimpleExp n) {
+ n.f0.accept(this);
+ }
+
+ /**
+ * f0 -> "a0"
+ * | "a1"
+ * | "a2"
+ * | "a3"
+ * | "t0"
+ * | "t1"
+ * | "t2"
+ * | "t3"
+ * | "t4"
+ * | "t5"
+ * | "t6"
+ * | "t7"
+ * | "s0"
+ * | "s1"
+ * | "s2"
+ * | "s3"
+ * | "s4"
+ * | "s5"
+ * | "s6"
+ * | "s7"
+ * | "t8"
+ * | "t9"
+ * | "v0"
+ * | "v1"
+ */
+ public void visit(Reg n) {
+ n.f0.accept(this);
+ }
+
+ /**
+ * f0 -> <INTEGER_LITERAL>
+ */
+ public void visit(IntegerLiteral n) {
+ n.f0.accept(this);
+ }
+
+ /**
+ * f0 -> <IDENTIFIER>
+ */
+ public void visit(Label n) {
+ n.f0.accept(this);
+ }
+
+}
diff --git a/src/kanga/visitor/GJDepthFirst.java b/src/kanga/visitor/GJDepthFirst.java
new file mode 100644
index 0000000..53ee768
--- /dev/null
+++ b/src/kanga/visitor/GJDepthFirst.java
@@ -0,0 +1,455 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package kanga.visitor;
+import java.util.Enumeration;
+
+import kanga.syntaxtree.ALoadStmt;
+import kanga.syntaxtree.AStoreStmt;
+import kanga.syntaxtree.BinOp;
+import kanga.syntaxtree.CJumpStmt;
+import kanga.syntaxtree.CallStmt;
+import kanga.syntaxtree.ErrorStmt;
+import kanga.syntaxtree.Exp;
+import kanga.syntaxtree.Goal;
+import kanga.syntaxtree.HAllocate;
+import kanga.syntaxtree.HLoadStmt;
+import kanga.syntaxtree.HStoreStmt;
+import kanga.syntaxtree.IntegerLiteral;
+import kanga.syntaxtree.JumpStmt;
+import kanga.syntaxtree.Label;
+import kanga.syntaxtree.MoveStmt;
+import kanga.syntaxtree.NoOpStmt;
+import kanga.syntaxtree.Node;
+import kanga.syntaxtree.NodeList;
+import kanga.syntaxtree.NodeListOptional;
+import kanga.syntaxtree.NodeOptional;
+import kanga.syntaxtree.NodeSequence;
+import kanga.syntaxtree.NodeToken;
+import kanga.syntaxtree.Operator;
+import kanga.syntaxtree.PassArgStmt;
+import kanga.syntaxtree.PrintStmt;
+import kanga.syntaxtree.Procedure;
+import kanga.syntaxtree.Reg;
+import kanga.syntaxtree.SimpleExp;
+import kanga.syntaxtree.SpilledArg;
+import kanga.syntaxtree.Stmt;
+import kanga.syntaxtree.StmtList;
+
+/**
+ * Provides default methods which visit each node in the tree in depth-first
+ * order. Your visitors may extend this class.
+ */
+public class GJDepthFirst<R,A> implements GJVisitor<R,A> {
+ //
+ // Auto class visitors--probably don't need to be overridden.
+ //
+ public R visit(NodeList n, A argu) {
+ R _ret=null;
+ int _count=0;
+ for ( Enumeration<Node> e = n.elements(); e.hasMoreElements(); ) {
+ e.nextElement().accept(this,argu);
+ _count++;
+ }
+ return _ret;
+ }
+
+ public R visit(NodeListOptional n, A argu) {
+ if ( n.present() ) {
+ R _ret=null;
+ int _count=0;
+ for ( Enumeration<Node> e = n.elements(); e.hasMoreElements(); ) {
+ e.nextElement().accept(this,argu);
+ _count++;
+ }
+ return _ret;
+ }
+ else
+ return null;
+ }
+
+ public R visit(NodeOptional n, A argu) {
+ if ( n.present() )
+ return n.node.accept(this,argu);
+ else
+ return null;
+ }
+
+ public R visit(NodeSequence n, A argu) {
+ R _ret=null;
+ int _count=0;
+ for ( Enumeration<Node> e = n.elements(); e.hasMoreElements(); ) {
+ e.nextElement().accept(this,argu);
+ _count++;
+ }
+ return _ret;
+ }
+
+ public R visit(NodeToken n, A argu) { return null; }
+
+ //
+ // User-generated visitor methods below
+ //
+
+ /**
+ * f0 -> "MAIN"
+ * f1 -> "["
+ * f2 -> IntegerLiteral()
+ * f3 -> "]"
+ * f4 -> "["
+ * f5 -> IntegerLiteral()
+ * f6 -> "]"
+ * f7 -> "["
+ * f8 -> IntegerLiteral()
+ * f9 -> "]"
+ * f10 -> StmtList()
+ * f11 -> "END"
+ * f12 -> ( Procedure() )*
+ * f13 -> <EOF>
+ */
+ public R visit(Goal n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ n.f3.accept(this, argu);
+ n.f4.accept(this, argu);
+ n.f5.accept(this, argu);
+ n.f6.accept(this, argu);
+ n.f7.accept(this, argu);
+ n.f8.accept(this, argu);
+ n.f9.accept(this, argu);
+ n.f10.accept(this, argu);
+ n.f11.accept(this, argu);
+ n.f12.accept(this, argu);
+ n.f13.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> ( ( Label() )? Stmt() )*
+ */
+ public R visit(StmtList n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> Label()
+ * f1 -> "["
+ * f2 -> IntegerLiteral()
+ * f3 -> "]"
+ * f4 -> "["
+ * f5 -> IntegerLiteral()
+ * f6 -> "]"
+ * f7 -> "["
+ * f8 -> IntegerLiteral()
+ * f9 -> "]"
+ * f10 -> StmtList()
+ * f11 -> "END"
+ */
+ public R visit(Procedure n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ n.f3.accept(this, argu);
+ n.f4.accept(this, argu);
+ n.f5.accept(this, argu);
+ n.f6.accept(this, argu);
+ n.f7.accept(this, argu);
+ n.f8.accept(this, argu);
+ n.f9.accept(this, argu);
+ n.f10.accept(this, argu);
+ n.f11.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> NoOpStmt()
+ * | ErrorStmt()
+ * | CJumpStmt()
+ * | JumpStmt()
+ * | HStoreStmt()
+ * | HLoadStmt()
+ * | MoveStmt()
+ * | PrintStmt()
+ * | ALoadStmt()
+ * | AStoreStmt()
+ * | PassArgStmt()
+ * | CallStmt()
+ */
+ public R visit(Stmt n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "NOOP"
+ */
+ public R visit(NoOpStmt n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "ERROR"
+ */
+ public R visit(ErrorStmt n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "CJUMP"
+ * f1 -> Reg()
+ * f2 -> Label()
+ */
+ public R visit(CJumpStmt n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "JUMP"
+ * f1 -> Label()
+ */
+ public R visit(JumpStmt n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "HSTORE"
+ * f1 -> Reg()
+ * f2 -> IntegerLiteral()
+ * f3 -> Reg()
+ */
+ public R visit(HStoreStmt n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ n.f3.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "HLOAD"
+ * f1 -> Reg()
+ * f2 -> Reg()
+ * f3 -> IntegerLiteral()
+ */
+ public R visit(HLoadStmt n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ n.f3.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "MOVE"
+ * f1 -> Reg()
+ * f2 -> Exp()
+ */
+ public R visit(MoveStmt n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "PRINT"
+ * f1 -> SimpleExp()
+ */
+ public R visit(PrintStmt n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "ALOAD"
+ * f1 -> Reg()
+ * f2 -> SpilledArg()
+ */
+ public R visit(ALoadStmt n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "ASTORE"
+ * f1 -> SpilledArg()
+ * f2 -> Reg()
+ */
+ public R visit(AStoreStmt n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "PASSARG"
+ * f1 -> IntegerLiteral()
+ * f2 -> Reg()
+ */
+ public R visit(PassArgStmt n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "CALL"
+ * f1 -> SimpleExp()
+ */
+ public R visit(CallStmt n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> HAllocate()
+ * | BinOp()
+ * | SimpleExp()
+ */
+ public R visit(Exp n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "HALLOCATE"
+ * f1 -> SimpleExp()
+ */
+ public R visit(HAllocate n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> Operator()
+ * f1 -> Reg()
+ * f2 -> SimpleExp()
+ */
+ public R visit(BinOp n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "LT"
+ * | "PLUS"
+ * | "MINUS"
+ * | "TIMES"
+ */
+ public R visit(Operator n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "SPILLEDARG"
+ * f1 -> IntegerLiteral()
+ */
+ public R visit(SpilledArg n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> Reg()
+ * | IntegerLiteral()
+ * | Label()
+ */
+ public R visit(SimpleExp n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "a0"
+ * | "a1"
+ * | "a2"
+ * | "a3"
+ * | "t0"
+ * | "t1"
+ * | "t2"
+ * | "t3"
+ * | "t4"
+ * | "t5"
+ * | "t6"
+ * | "t7"
+ * | "s0"
+ * | "s1"
+ * | "s2"
+ * | "s3"
+ * | "s4"
+ * | "s5"
+ * | "s6"
+ * | "s7"
+ * | "t8"
+ * | "t9"
+ * | "v0"
+ * | "v1"
+ */
+ public R visit(Reg n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> <INTEGER_LITERAL>
+ */
+ public R visit(IntegerLiteral n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> <IDENTIFIER>
+ */
+ public R visit(Label n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ return _ret;
+ }
+
+}
diff --git a/src/kanga/visitor/GJNoArguDepthFirst.java b/src/kanga/visitor/GJNoArguDepthFirst.java
new file mode 100644
index 0000000..a4848c2
--- /dev/null
+++ b/src/kanga/visitor/GJNoArguDepthFirst.java
@@ -0,0 +1,455 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package kanga.visitor;
+import java.util.Enumeration;
+
+import kanga.syntaxtree.ALoadStmt;
+import kanga.syntaxtree.AStoreStmt;
+import kanga.syntaxtree.BinOp;
+import kanga.syntaxtree.CJumpStmt;
+import kanga.syntaxtree.CallStmt;
+import kanga.syntaxtree.ErrorStmt;
+import kanga.syntaxtree.Exp;
+import kanga.syntaxtree.Goal;
+import kanga.syntaxtree.HAllocate;
+import kanga.syntaxtree.HLoadStmt;
+import kanga.syntaxtree.HStoreStmt;
+import kanga.syntaxtree.IntegerLiteral;
+import kanga.syntaxtree.JumpStmt;
+import kanga.syntaxtree.Label;
+import kanga.syntaxtree.MoveStmt;
+import kanga.syntaxtree.NoOpStmt;
+import kanga.syntaxtree.Node;
+import kanga.syntaxtree.NodeList;
+import kanga.syntaxtree.NodeListOptional;
+import kanga.syntaxtree.NodeOptional;
+import kanga.syntaxtree.NodeSequence;
+import kanga.syntaxtree.NodeToken;
+import kanga.syntaxtree.Operator;
+import kanga.syntaxtree.PassArgStmt;
+import kanga.syntaxtree.PrintStmt;
+import kanga.syntaxtree.Procedure;
+import kanga.syntaxtree.Reg;
+import kanga.syntaxtree.SimpleExp;
+import kanga.syntaxtree.SpilledArg;
+import kanga.syntaxtree.Stmt;
+import kanga.syntaxtree.StmtList;
+
+/**
+ * Provides default methods which visit each node in the tree in depth-first
+ * order. Your visitors may extend this class.
+ */
+public class GJNoArguDepthFirst<R> implements GJNoArguVisitor<R> {
+ //
+ // Auto class visitors--probably don't need to be overridden.
+ //
+ public R visit(NodeList n) {
+ R _ret=null;
+ int _count=0;
+ for ( Enumeration<Node> e = n.elements(); e.hasMoreElements(); ) {
+ e.nextElement().accept(this);
+ _count++;
+ }
+ return _ret;
+ }
+
+ public R visit(NodeListOptional n) {
+ if ( n.present() ) {
+ R _ret=null;
+ int _count=0;
+ for ( Enumeration<Node> e = n.elements(); e.hasMoreElements(); ) {
+ e.nextElement().accept(this);
+ _count++;
+ }
+ return _ret;
+ }
+ else
+ return null;
+ }
+
+ public R visit(NodeOptional n) {
+ if ( n.present() )
+ return n.node.accept(this);
+ else
+ return null;
+ }
+
+ public R visit(NodeSequence n) {
+ R _ret=null;
+ int _count=0;
+ for ( Enumeration<Node> e = n.elements(); e.hasMoreElements(); ) {
+ e.nextElement().accept(this);
+ _count++;
+ }
+ return _ret;
+ }
+
+ public R visit(NodeToken n) { return null; }
+
+ //
+ // User-generated visitor methods below
+ //
+
+ /**
+ * f0 -> "MAIN"
+ * f1 -> "["
+ * f2 -> IntegerLiteral()
+ * f3 -> "]"
+ * f4 -> "["
+ * f5 -> IntegerLiteral()
+ * f6 -> "]"
+ * f7 -> "["
+ * f8 -> IntegerLiteral()
+ * f9 -> "]"
+ * f10 -> StmtList()
+ * f11 -> "END"
+ * f12 -> ( Procedure() )*
+ * f13 -> <EOF>
+ */
+ public R visit(Goal n) {
+ R _ret=null;
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ n.f3.accept(this);
+ n.f4.accept(this);
+ n.f5.accept(this);
+ n.f6.accept(this);
+ n.f7.accept(this);
+ n.f8.accept(this);
+ n.f9.accept(this);
+ n.f10.accept(this);
+ n.f11.accept(this);
+ n.f12.accept(this);
+ n.f13.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> ( ( Label() )? Stmt() )*
+ */
+ public R visit(StmtList n) {
+ R _ret=null;
+ n.f0.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> Label()
+ * f1 -> "["
+ * f2 -> IntegerLiteral()
+ * f3 -> "]"
+ * f4 -> "["
+ * f5 -> IntegerLiteral()
+ * f6 -> "]"
+ * f7 -> "["
+ * f8 -> IntegerLiteral()
+ * f9 -> "]"
+ * f10 -> StmtList()
+ * f11 -> "END"
+ */
+ public R visit(Procedure n) {
+ R _ret=null;
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ n.f3.accept(this);
+ n.f4.accept(this);
+ n.f5.accept(this);
+ n.f6.accept(this);
+ n.f7.accept(this);
+ n.f8.accept(this);
+ n.f9.accept(this);
+ n.f10.accept(this);
+ n.f11.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> NoOpStmt()
+ * | ErrorStmt()
+ * | CJumpStmt()
+ * | JumpStmt()
+ * | HStoreStmt()
+ * | HLoadStmt()
+ * | MoveStmt()
+ * | PrintStmt()
+ * | ALoadStmt()
+ * | AStoreStmt()
+ * | PassArgStmt()
+ * | CallStmt()
+ */
+ public R visit(Stmt n) {
+ R _ret=null;
+ n.f0.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "NOOP"
+ */
+ public R visit(NoOpStmt n) {
+ R _ret=null;
+ n.f0.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "ERROR"
+ */
+ public R visit(ErrorStmt n) {
+ R _ret=null;
+ n.f0.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "CJUMP"
+ * f1 -> Reg()
+ * f2 -> Label()
+ */
+ public R visit(CJumpStmt n) {
+ R _ret=null;
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "JUMP"
+ * f1 -> Label()
+ */
+ public R visit(JumpStmt n) {
+ R _ret=null;
+ n.f0.accept(this);
+ n.f1.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "HSTORE"
+ * f1 -> Reg()
+ * f2 -> IntegerLiteral()
+ * f3 -> Reg()
+ */
+ public R visit(HStoreStmt n) {
+ R _ret=null;
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ n.f3.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "HLOAD"
+ * f1 -> Reg()
+ * f2 -> Reg()
+ * f3 -> IntegerLiteral()
+ */
+ public R visit(HLoadStmt n) {
+ R _ret=null;
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ n.f3.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "MOVE"
+ * f1 -> Reg()
+ * f2 -> Exp()
+ */
+ public R visit(MoveStmt n) {
+ R _ret=null;
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "PRINT"
+ * f1 -> SimpleExp()
+ */
+ public R visit(PrintStmt n) {
+ R _ret=null;
+ n.f0.accept(this);
+ n.f1.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "ALOAD"
+ * f1 -> Reg()
+ * f2 -> SpilledArg()
+ */
+ public R visit(ALoadStmt n) {
+ R _ret=null;
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "ASTORE"
+ * f1 -> SpilledArg()
+ * f2 -> Reg()
+ */
+ public R visit(AStoreStmt n) {
+ R _ret=null;
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "PASSARG"
+ * f1 -> IntegerLiteral()
+ * f2 -> Reg()
+ */
+ public R visit(PassArgStmt n) {
+ R _ret=null;
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "CALL"
+ * f1 -> SimpleExp()
+ */
+ public R visit(CallStmt n) {
+ R _ret=null;
+ n.f0.accept(this);
+ n.f1.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> HAllocate()
+ * | BinOp()
+ * | SimpleExp()
+ */
+ public R visit(Exp n) {
+ R _ret=null;
+ n.f0.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "HALLOCATE"
+ * f1 -> SimpleExp()
+ */
+ public R visit(HAllocate n) {
+ R _ret=null;
+ n.f0.accept(this);
+ n.f1.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> Operator()
+ * f1 -> Reg()
+ * f2 -> SimpleExp()
+ */
+ public R visit(BinOp n) {
+ R _ret=null;
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "LT"
+ * | "PLUS"
+ * | "MINUS"
+ * | "TIMES"
+ */
+ public R visit(Operator n) {
+ R _ret=null;
+ n.f0.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "SPILLEDARG"
+ * f1 -> IntegerLiteral()
+ */
+ public R visit(SpilledArg n) {
+ R _ret=null;
+ n.f0.accept(this);
+ n.f1.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> Reg()
+ * | IntegerLiteral()
+ * | Label()
+ */
+ public R visit(SimpleExp n) {
+ R _ret=null;
+ n.f0.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "a0"
+ * | "a1"
+ * | "a2"
+ * | "a3"
+ * | "t0"
+ * | "t1"
+ * | "t2"
+ * | "t3"
+ * | "t4"
+ * | "t5"
+ * | "t6"
+ * | "t7"
+ * | "s0"
+ * | "s1"
+ * | "s2"
+ * | "s3"
+ * | "s4"
+ * | "s5"
+ * | "s6"
+ * | "s7"
+ * | "t8"
+ * | "t9"
+ * | "v0"
+ * | "v1"
+ */
+ public R visit(Reg n) {
+ R _ret=null;
+ n.f0.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> <INTEGER_LITERAL>
+ */
+ public R visit(IntegerLiteral n) {
+ R _ret=null;
+ n.f0.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> <IDENTIFIER>
+ */
+ public R visit(Label n) {
+ R _ret=null;
+ n.f0.accept(this);
+ return _ret;
+ }
+
+}
diff --git a/src/kanga/visitor/GJNoArguVisitor.java b/src/kanga/visitor/GJNoArguVisitor.java
new file mode 100644
index 0000000..109aafe
--- /dev/null
+++ b/src/kanga/visitor/GJNoArguVisitor.java
@@ -0,0 +1,271 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package kanga.visitor;
+import kanga.syntaxtree.ALoadStmt;
+import kanga.syntaxtree.AStoreStmt;
+import kanga.syntaxtree.BinOp;
+import kanga.syntaxtree.CJumpStmt;
+import kanga.syntaxtree.CallStmt;
+import kanga.syntaxtree.ErrorStmt;
+import kanga.syntaxtree.Exp;
+import kanga.syntaxtree.Goal;
+import kanga.syntaxtree.HAllocate;
+import kanga.syntaxtree.HLoadStmt;
+import kanga.syntaxtree.HStoreStmt;
+import kanga.syntaxtree.IntegerLiteral;
+import kanga.syntaxtree.JumpStmt;
+import kanga.syntaxtree.Label;
+import kanga.syntaxtree.MoveStmt;
+import kanga.syntaxtree.NoOpStmt;
+import kanga.syntaxtree.NodeList;
+import kanga.syntaxtree.NodeListOptional;
+import kanga.syntaxtree.NodeOptional;
+import kanga.syntaxtree.NodeSequence;
+import kanga.syntaxtree.NodeToken;
+import kanga.syntaxtree.Operator;
+import kanga.syntaxtree.PassArgStmt;
+import kanga.syntaxtree.PrintStmt;
+import kanga.syntaxtree.Procedure;
+import kanga.syntaxtree.Reg;
+import kanga.syntaxtree.SimpleExp;
+import kanga.syntaxtree.SpilledArg;
+import kanga.syntaxtree.Stmt;
+import kanga.syntaxtree.StmtList;
+
+/**
+ * All GJ visitors with no argument must implement this interface.
+ */
+
+public interface GJNoArguVisitor<R> {
+
+ //
+ // GJ Auto class visitors with no argument
+ //
+
+ public R visit(NodeList n);
+ public R visit(NodeListOptional n);
+ public R visit(NodeOptional n);
+ public R visit(NodeSequence n);
+ public R visit(NodeToken n);
+
+ //
+ // User-generated visitor methods below
+ //
+
+ /**
+ * f0 -> "MAIN"
+ * f1 -> "["
+ * f2 -> IntegerLiteral()
+ * f3 -> "]"
+ * f4 -> "["
+ * f5 -> IntegerLiteral()
+ * f6 -> "]"
+ * f7 -> "["
+ * f8 -> IntegerLiteral()
+ * f9 -> "]"
+ * f10 -> StmtList()
+ * f11 -> "END"
+ * f12 -> ( Procedure() )*
+ * f13 -> <EOF>
+ */
+ public R visit(Goal n);
+
+ /**
+ * f0 -> ( ( Label() )? Stmt() )*
+ */
+ public R visit(StmtList n);
+
+ /**
+ * f0 -> Label()
+ * f1 -> "["
+ * f2 -> IntegerLiteral()
+ * f3 -> "]"
+ * f4 -> "["
+ * f5 -> IntegerLiteral()
+ * f6 -> "]"
+ * f7 -> "["
+ * f8 -> IntegerLiteral()
+ * f9 -> "]"
+ * f10 -> StmtList()
+ * f11 -> "END"
+ */
+ public R visit(Procedure n);
+
+ /**
+ * f0 -> NoOpStmt()
+ * | ErrorStmt()
+ * | CJumpStmt()
+ * | JumpStmt()
+ * | HStoreStmt()
+ * | HLoadStmt()
+ * | MoveStmt()
+ * | PrintStmt()
+ * | ALoadStmt()
+ * | AStoreStmt()
+ * | PassArgStmt()
+ * | CallStmt()
+ */
+ public R visit(Stmt n);
+
+ /**
+ * f0 -> "NOOP"
+ */
+ public R visit(NoOpStmt n);
+
+ /**
+ * f0 -> "ERROR"
+ */
+ public R visit(ErrorStmt n);
+
+ /**
+ * f0 -> "CJUMP"
+ * f1 -> Reg()
+ * f2 -> Label()
+ */
+ public R visit(CJumpStmt n);
+
+ /**
+ * f0 -> "JUMP"
+ * f1 -> Label()
+ */
+ public R visit(JumpStmt n);
+
+ /**
+ * f0 -> "HSTORE"
+ * f1 -> Reg()
+ * f2 -> IntegerLiteral()
+ * f3 -> Reg()
+ */
+ public R visit(HStoreStmt n);
+
+ /**
+ * f0 -> "HLOAD"
+ * f1 -> Reg()
+ * f2 -> Reg()
+ * f3 -> IntegerLiteral()
+ */
+ public R visit(HLoadStmt n);
+
+ /**
+ * f0 -> "MOVE"
+ * f1 -> Reg()
+ * f2 -> Exp()
+ */
+ public R visit(MoveStmt n);
+
+ /**
+ * f0 -> "PRINT"
+ * f1 -> SimpleExp()
+ */
+ public R visit(PrintStmt n);
+
+ /**
+ * f0 -> "ALOAD"
+ * f1 -> Reg()
+ * f2 -> SpilledArg()
+ */
+ public R visit(ALoadStmt n);
+
+ /**
+ * f0 -> "ASTORE"
+ * f1 -> SpilledArg()
+ * f2 -> Reg()
+ */
+ public R visit(AStoreStmt n);
+
+ /**
+ * f0 -> "PASSARG"
+ * f1 -> IntegerLiteral()
+ * f2 -> Reg()
+ */
+ public R visit(PassArgStmt n);
+
+ /**
+ * f0 -> "CALL"
+ * f1 -> SimpleExp()
+ */
+ public R visit(CallStmt n);
+
+ /**
+ * f0 -> HAllocate()
+ * | BinOp()
+ * | SimpleExp()
+ */
+ public R visit(Exp n);
+
+ /**
+ * f0 -> "HALLOCATE"
+ * f1 -> SimpleExp()
+ */
+ public R visit(HAllocate n);
+
+ /**
+ * f0 -> Operator()
+ * f1 -> Reg()
+ * f2 -> SimpleExp()
+ */
+ public R visit(BinOp n);
+
+ /**
+ * f0 -> "LT"
+ * | "PLUS"
+ * | "MINUS"
+ * | "TIMES"
+ */
+ public R visit(Operator n);
+
+ /**
+ * f0 -> "SPILLEDARG"
+ * f1 -> IntegerLiteral()
+ */
+ public R visit(SpilledArg n);
+
+ /**
+ * f0 -> Reg()
+ * | IntegerLiteral()
+ * | Label()
+ */
+ public R visit(SimpleExp n);
+
+ /**
+ * f0 -> "a0"
+ * | "a1"
+ * | "a2"
+ * | "a3"
+ * | "t0"
+ * | "t1"
+ * | "t2"
+ * | "t3"
+ * | "t4"
+ * | "t5"
+ * | "t6"
+ * | "t7"
+ * | "s0"
+ * | "s1"
+ * | "s2"
+ * | "s3"
+ * | "s4"
+ * | "s5"
+ * | "s6"
+ * | "s7"
+ * | "t8"
+ * | "t9"
+ * | "v0"
+ * | "v1"
+ */
+ public R visit(Reg n);
+
+ /**
+ * f0 -> <INTEGER_LITERAL>
+ */
+ public R visit(IntegerLiteral n);
+
+ /**
+ * f0 -> <IDENTIFIER>
+ */
+ public R visit(Label n);
+
+}
+
diff --git a/src/kanga/visitor/GJVisitor.java b/src/kanga/visitor/GJVisitor.java
new file mode 100644
index 0000000..cdb30b3
--- /dev/null
+++ b/src/kanga/visitor/GJVisitor.java
@@ -0,0 +1,270 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package kanga.visitor;
+import kanga.syntaxtree.ALoadStmt;
+import kanga.syntaxtree.AStoreStmt;
+import kanga.syntaxtree.BinOp;
+import kanga.syntaxtree.CJumpStmt;
+import kanga.syntaxtree.CallStmt;
+import kanga.syntaxtree.ErrorStmt;
+import kanga.syntaxtree.Exp;
+import kanga.syntaxtree.Goal;
+import kanga.syntaxtree.HAllocate;
+import kanga.syntaxtree.HLoadStmt;
+import kanga.syntaxtree.HStoreStmt;
+import kanga.syntaxtree.IntegerLiteral;
+import kanga.syntaxtree.JumpStmt;
+import kanga.syntaxtree.Label;
+import kanga.syntaxtree.MoveStmt;
+import kanga.syntaxtree.NoOpStmt;
+import kanga.syntaxtree.NodeList;
+import kanga.syntaxtree.NodeListOptional;
+import kanga.syntaxtree.NodeOptional;
+import kanga.syntaxtree.NodeSequence;
+import kanga.syntaxtree.NodeToken;
+import kanga.syntaxtree.Operator;
+import kanga.syntaxtree.PassArgStmt;
+import kanga.syntaxtree.PrintStmt;
+import kanga.syntaxtree.Procedure;
+import kanga.syntaxtree.Reg;
+import kanga.syntaxtree.SimpleExp;
+import kanga.syntaxtree.SpilledArg;
+import kanga.syntaxtree.Stmt;
+import kanga.syntaxtree.StmtList;
+
+/**
+ * All GJ visitors must implement this interface.
+ */
+
+public interface GJVisitor<R,A> {
+
+ //
+ // GJ Auto class visitors
+ //
+
+ public R visit(NodeList n, A argu);
+ public R visit(NodeListOptional n, A argu);
+ public R visit(NodeOptional n, A argu);
+ public R visit(NodeSequence n, A argu);
+ public R visit(NodeToken n, A argu);
+
+ //
+ // User-generated visitor methods below
+ //
+
+ /**
+ * f0 -> "MAIN"
+ * f1 -> "["
+ * f2 -> IntegerLiteral()
+ * f3 -> "]"
+ * f4 -> "["
+ * f5 -> IntegerLiteral()
+ * f6 -> "]"
+ * f7 -> "["
+ * f8 -> IntegerLiteral()
+ * f9 -> "]"
+ * f10 -> StmtList()
+ * f11 -> "END"
+ * f12 -> ( Procedure() )*
+ * f13 -> <EOF>
+ */
+ public R visit(Goal n, A argu);
+
+ /**
+ * f0 -> ( ( Label() )? Stmt() )*
+ */
+ public R visit(StmtList n, A argu);
+
+ /**
+ * f0 -> Label()
+ * f1 -> "["
+ * f2 -> IntegerLiteral()
+ * f3 -> "]"
+ * f4 -> "["
+ * f5 -> IntegerLiteral()
+ * f6 -> "]"
+ * f7 -> "["
+ * f8 -> IntegerLiteral()
+ * f9 -> "]"
+ * f10 -> StmtList()
+ * f11 -> "END"
+ */
+ public R visit(Procedure n, A argu);
+
+ /**
+ * f0 -> NoOpStmt()
+ * | ErrorStmt()
+ * | CJumpStmt()
+ * | JumpStmt()
+ * | HStoreStmt()
+ * | HLoadStmt()
+ * | MoveStmt()
+ * | PrintStmt()
+ * | ALoadStmt()
+ * | AStoreStmt()
+ * | PassArgStmt()
+ * | CallStmt()
+ */
+ public R visit(Stmt n, A argu);
+
+ /**
+ * f0 -> "NOOP"
+ */
+ public R visit(NoOpStmt n, A argu);
+
+ /**
+ * f0 -> "ERROR"
+ */
+ public R visit(ErrorStmt n, A argu);
+
+ /**
+ * f0 -> "CJUMP"
+ * f1 -> Reg()
+ * f2 -> Label()
+ */
+ public R visit(CJumpStmt n, A argu);
+
+ /**
+ * f0 -> "JUMP"
+ * f1 -> Label()
+ */
+ public R visit(JumpStmt n, A argu);
+
+ /**
+ * f0 -> "HSTORE"
+ * f1 -> Reg()
+ * f2 -> IntegerLiteral()
+ * f3 -> Reg()
+ */
+ public R visit(HStoreStmt n, A argu);
+
+ /**
+ * f0 -> "HLOAD"
+ * f1 -> Reg()
+ * f2 -> Reg()
+ * f3 -> IntegerLiteral()
+ */
+ public R visit(HLoadStmt n, A argu);
+
+ /**
+ * f0 -> "MOVE"
+ * f1 -> Reg()
+ * f2 -> Exp()
+ */
+ public R visit(MoveStmt n, A argu);
+
+ /**
+ * f0 -> "PRINT"
+ * f1 -> SimpleExp()
+ */
+ public R visit(PrintStmt n, A argu);
+
+ /**
+ * f0 -> "ALOAD"
+ * f1 -> Reg()
+ * f2 -> SpilledArg()
+ */
+ public R visit(ALoadStmt n, A argu);
+
+ /**
+ * f0 -> "ASTORE"
+ * f1 -> SpilledArg()
+ * f2 -> Reg()
+ */
+ public R visit(AStoreStmt n, A argu);
+
+ /**
+ * f0 -> "PASSARG"
+ * f1 -> IntegerLiteral()
+ * f2 -> Reg()
+ */
+ public R visit(PassArgStmt n, A argu);
+
+ /**
+ * f0 -> "CALL"
+ * f1 -> SimpleExp()
+ */
+ public R visit(CallStmt n, A argu);
+
+ /**
+ * f0 -> HAllocate()
+ * | BinOp()
+ * | SimpleExp()
+ */
+ public R visit(Exp n, A argu);
+
+ /**
+ * f0 -> "HALLOCATE"
+ * f1 -> SimpleExp()
+ */
+ public R visit(HAllocate n, A argu);
+
+ /**
+ * f0 -> Operator()
+ * f1 -> Reg()
+ * f2 -> SimpleExp()
+ */
+ public R visit(BinOp n, A argu);
+
+ /**
+ * f0 -> "LT"
+ * | "PLUS"
+ * | "MINUS"
+ * | "TIMES"
+ */
+ public R visit(Operator n, A argu);
+
+ /**
+ * f0 -> "SPILLEDARG"
+ * f1 -> IntegerLiteral()
+ */
+ public R visit(SpilledArg n, A argu);
+
+ /**
+ * f0 -> Reg()
+ * | IntegerLiteral()
+ * | Label()
+ */
+ public R visit(SimpleExp n, A argu);
+
+ /**
+ * f0 -> "a0"
+ * | "a1"
+ * | "a2"
+ * | "a3"
+ * | "t0"
+ * | "t1"
+ * | "t2"
+ * | "t3"
+ * | "t4"
+ * | "t5"
+ * | "t6"
+ * | "t7"
+ * | "s0"
+ * | "s1"
+ * | "s2"
+ * | "s3"
+ * | "s4"
+ * | "s5"
+ * | "s6"
+ * | "s7"
+ * | "t8"
+ * | "t9"
+ * | "v0"
+ * | "v1"
+ */
+ public R visit(Reg n, A argu);
+
+ /**
+ * f0 -> <INTEGER_LITERAL>
+ */
+ public R visit(IntegerLiteral n, A argu);
+
+ /**
+ * f0 -> <IDENTIFIER>
+ */
+ public R visit(Label n, A argu);
+
+}
diff --git a/src/kanga/visitor/GJVoidDepthFirst.java b/src/kanga/visitor/GJVoidDepthFirst.java
new file mode 100644
index 0000000..8850418
--- /dev/null
+++ b/src/kanga/visitor/GJVoidDepthFirst.java
@@ -0,0 +1,395 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package kanga.visitor;
+import java.util.Enumeration;
+
+import kanga.syntaxtree.ALoadStmt;
+import kanga.syntaxtree.AStoreStmt;
+import kanga.syntaxtree.BinOp;
+import kanga.syntaxtree.CJumpStmt;
+import kanga.syntaxtree.CallStmt;
+import kanga.syntaxtree.ErrorStmt;
+import kanga.syntaxtree.Exp;
+import kanga.syntaxtree.Goal;
+import kanga.syntaxtree.HAllocate;
+import kanga.syntaxtree.HLoadStmt;
+import kanga.syntaxtree.HStoreStmt;
+import kanga.syntaxtree.IntegerLiteral;
+import kanga.syntaxtree.JumpStmt;
+import kanga.syntaxtree.Label;
+import kanga.syntaxtree.MoveStmt;
+import kanga.syntaxtree.NoOpStmt;
+import kanga.syntaxtree.Node;
+import kanga.syntaxtree.NodeList;
+import kanga.syntaxtree.NodeListOptional;
+import kanga.syntaxtree.NodeOptional;
+import kanga.syntaxtree.NodeSequence;
+import kanga.syntaxtree.NodeToken;
+import kanga.syntaxtree.Operator;
+import kanga.syntaxtree.PassArgStmt;
+import kanga.syntaxtree.PrintStmt;
+import kanga.syntaxtree.Procedure;
+import kanga.syntaxtree.Reg;
+import kanga.syntaxtree.SimpleExp;
+import kanga.syntaxtree.SpilledArg;
+import kanga.syntaxtree.Stmt;
+import kanga.syntaxtree.StmtList;
+
+/**
+ * Provides default methods which visit each node in the tree in depth-first
+ * order. Your visitors may extend this class.
+ */
+public class GJVoidDepthFirst<A> implements GJVoidVisitor<A> {
+ //
+ // Auto class visitors--probably don't need to be overridden.
+ //
+ public void visit(NodeList n, A argu) {
+ int _count=0;
+ for ( Enumeration<Node> e = n.elements(); e.hasMoreElements(); ) {
+ e.nextElement().accept(this,argu);
+ _count++;
+ }
+ }
+
+ public void visit(NodeListOptional n, A argu) {
+ if ( n.present() ) {
+ int _count=0;
+ for ( Enumeration<Node> e = n.elements(); e.hasMoreElements(); ) {
+ e.nextElement().accept(this,argu);
+ _count++;
+ }
+ }
+ }
+
+ public void visit(NodeOptional n, A argu) {
+ if ( n.present() )
+ n.node.accept(this,argu);
+ }
+
+ public void visit(NodeSequence n, A argu) {
+ int _count=0;
+ for ( Enumeration<Node> e = n.elements(); e.hasMoreElements(); ) {
+ e.nextElement().accept(this,argu);
+ _count++;
+ }
+ }
+
+ public void visit(NodeToken n, A argu) {}
+
+ //
+ // User-generated visitor methods below
+ //
+
+ /**
+ * f0 -> "MAIN"
+ * f1 -> "["
+ * f2 -> IntegerLiteral()
+ * f3 -> "]"
+ * f4 -> "["
+ * f5 -> IntegerLiteral()
+ * f6 -> "]"
+ * f7 -> "["
+ * f8 -> IntegerLiteral()
+ * f9 -> "]"
+ * f10 -> StmtList()
+ * f11 -> "END"
+ * f12 -> ( Procedure() )*
+ * f13 -> <EOF>
+ */
+ public void visit(Goal n, A argu) {
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ n.f3.accept(this, argu);
+ n.f4.accept(this, argu);
+ n.f5.accept(this, argu);
+ n.f6.accept(this, argu);
+ n.f7.accept(this, argu);
+ n.f8.accept(this, argu);
+ n.f9.accept(this, argu);
+ n.f10.accept(this, argu);
+ n.f11.accept(this, argu);
+ n.f12.accept(this, argu);
+ n.f13.accept(this, argu);
+ }
+
+ /**
+ * f0 -> ( ( Label() )? Stmt() )*
+ */
+ public void visit(StmtList n, A argu) {
+ n.f0.accept(this, argu);
+ }
+
+ /**
+ * f0 -> Label()
+ * f1 -> "["
+ * f2 -> IntegerLiteral()
+ * f3 -> "]"
+ * f4 -> "["
+ * f5 -> IntegerLiteral()
+ * f6 -> "]"
+ * f7 -> "["
+ * f8 -> IntegerLiteral()
+ * f9 -> "]"
+ * f10 -> StmtList()
+ * f11 -> "END"
+ */
+ public void visit(Procedure n, A argu) {
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ n.f3.accept(this, argu);
+ n.f4.accept(this, argu);
+ n.f5.accept(this, argu);
+ n.f6.accept(this, argu);
+ n.f7.accept(this, argu);
+ n.f8.accept(this, argu);
+ n.f9.accept(this, argu);
+ n.f10.accept(this, argu);
+ n.f11.accept(this, argu);
+ }
+
+ /**
+ * f0 -> NoOpStmt()
+ * | ErrorStmt()
+ * | CJumpStmt()
+ * | JumpStmt()
+ * | HStoreStmt()
+ * | HLoadStmt()
+ * | MoveStmt()
+ * | PrintStmt()
+ * | ALoadStmt()
+ * | AStoreStmt()
+ * | PassArgStmt()
+ * | CallStmt()
+ */
+ public void visit(Stmt n, A argu) {
+ n.f0.accept(this, argu);
+ }
+
+ /**
+ * f0 -> "NOOP"
+ */
+ public void visit(NoOpStmt n, A argu) {
+ n.f0.accept(this, argu);
+ }
+
+ /**
+ * f0 -> "ERROR"
+ */
+ public void visit(ErrorStmt n, A argu) {
+ n.f0.accept(this, argu);
+ }
+
+ /**
+ * f0 -> "CJUMP"
+ * f1 -> Reg()
+ * f2 -> Label()
+ */
+ public void visit(CJumpStmt n, A argu) {
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ }
+
+ /**
+ * f0 -> "JUMP"
+ * f1 -> Label()
+ */
+ public void visit(JumpStmt n, A argu) {
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ }
+
+ /**
+ * f0 -> "HSTORE"
+ * f1 -> Reg()
+ * f2 -> IntegerLiteral()
+ * f3 -> Reg()
+ */
+ public void visit(HStoreStmt n, A argu) {
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ n.f3.accept(this, argu);
+ }
+
+ /**
+ * f0 -> "HLOAD"
+ * f1 -> Reg()
+ * f2 -> Reg()
+ * f3 -> IntegerLiteral()
+ */
+ public void visit(HLoadStmt n, A argu) {
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ n.f3.accept(this, argu);
+ }
+
+ /**
+ * f0 -> "MOVE"
+ * f1 -> Reg()
+ * f2 -> Exp()
+ */
+ public void visit(MoveStmt n, A argu) {
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ }
+
+ /**
+ * f0 -> "PRINT"
+ * f1 -> SimpleExp()
+ */
+ public void visit(PrintStmt n, A argu) {
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ }
+
+ /**
+ * f0 -> "ALOAD"
+ * f1 -> Reg()
+ * f2 -> SpilledArg()
+ */
+ public void visit(ALoadStmt n, A argu) {
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ }
+
+ /**
+ * f0 -> "ASTORE"
+ * f1 -> SpilledArg()
+ * f2 -> Reg()
+ */
+ public void visit(AStoreStmt n, A argu) {
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ }
+
+ /**
+ * f0 -> "PASSARG"
+ * f1 -> IntegerLiteral()
+ * f2 -> Reg()
+ */
+ public void visit(PassArgStmt n, A argu) {
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ }
+
+ /**
+ * f0 -> "CALL"
+ * f1 -> SimpleExp()
+ */
+ public void visit(CallStmt n, A argu) {
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ }
+
+ /**
+ * f0 -> HAllocate()
+ * | BinOp()
+ * | SimpleExp()
+ */
+ public void visit(Exp n, A argu) {
+ n.f0.accept(this, argu);
+ }
+
+ /**
+ * f0 -> "HALLOCATE"
+ * f1 -> SimpleExp()
+ */
+ public void visit(HAllocate n, A argu) {
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ }
+
+ /**
+ * f0 -> Operator()
+ * f1 -> Reg()
+ * f2 -> SimpleExp()
+ */
+ public void visit(BinOp n, A argu) {
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ }
+
+ /**
+ * f0 -> "LT"
+ * | "PLUS"
+ * | "MINUS"
+ * | "TIMES"
+ */
+ public void visit(Operator n, A argu) {
+ n.f0.accept(this, argu);
+ }
+
+ /**
+ * f0 -> "SPILLEDARG"
+ * f1 -> IntegerLiteral()
+ */
+ public void visit(SpilledArg n, A argu) {
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ }
+
+ /**
+ * f0 -> Reg()
+ * | IntegerLiteral()
+ * | Label()
+ */
+ public void visit(SimpleExp n, A argu) {
+ n.f0.accept(this, argu);
+ }
+
+ /**
+ * f0 -> "a0"
+ * | "a1"
+ * | "a2"
+ * | "a3"
+ * | "t0"
+ * | "t1"
+ * | "t2"
+ * | "t3"
+ * | "t4"
+ * | "t5"
+ * | "t6"
+ * | "t7"
+ * | "s0"
+ * | "s1"
+ * | "s2"
+ * | "s3"
+ * | "s4"
+ * | "s5"
+ * | "s6"
+ * | "s7"
+ * | "t8"
+ * | "t9"
+ * | "v0"
+ * | "v1"
+ */
+ public void visit(Reg n, A argu) {
+ n.f0.accept(this, argu);
+ }
+
+ /**
+ * f0 -> <INTEGER_LITERAL>
+ */
+ public void visit(IntegerLiteral n, A argu) {
+ n.f0.accept(this, argu);
+ }
+
+ /**
+ * f0 -> <IDENTIFIER>
+ */
+ public void visit(Label n, A argu) {
+ n.f0.accept(this, argu);
+ }
+
+}
diff --git a/src/kanga/visitor/GJVoidVisitor.java b/src/kanga/visitor/GJVoidVisitor.java
new file mode 100644
index 0000000..ed862f1
--- /dev/null
+++ b/src/kanga/visitor/GJVoidVisitor.java
@@ -0,0 +1,271 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package kanga.visitor;
+import kanga.syntaxtree.ALoadStmt;
+import kanga.syntaxtree.AStoreStmt;
+import kanga.syntaxtree.BinOp;
+import kanga.syntaxtree.CJumpStmt;
+import kanga.syntaxtree.CallStmt;
+import kanga.syntaxtree.ErrorStmt;
+import kanga.syntaxtree.Exp;
+import kanga.syntaxtree.Goal;
+import kanga.syntaxtree.HAllocate;
+import kanga.syntaxtree.HLoadStmt;
+import kanga.syntaxtree.HStoreStmt;
+import kanga.syntaxtree.IntegerLiteral;
+import kanga.syntaxtree.JumpStmt;
+import kanga.syntaxtree.Label;
+import kanga.syntaxtree.MoveStmt;
+import kanga.syntaxtree.NoOpStmt;
+import kanga.syntaxtree.NodeList;
+import kanga.syntaxtree.NodeListOptional;
+import kanga.syntaxtree.NodeOptional;
+import kanga.syntaxtree.NodeSequence;
+import kanga.syntaxtree.NodeToken;
+import kanga.syntaxtree.Operator;
+import kanga.syntaxtree.PassArgStmt;
+import kanga.syntaxtree.PrintStmt;
+import kanga.syntaxtree.Procedure;
+import kanga.syntaxtree.Reg;
+import kanga.syntaxtree.SimpleExp;
+import kanga.syntaxtree.SpilledArg;
+import kanga.syntaxtree.Stmt;
+import kanga.syntaxtree.StmtList;
+
+/**
+ * All GJ void visitors must implement this interface.
+ */
+
+public interface GJVoidVisitor<A> {
+
+ //
+ // GJ void Auto class visitors
+ //
+
+ public void visit(NodeList n, A argu);
+ public void visit(NodeListOptional n, A argu);
+ public void visit(NodeOptional n, A argu);
+ public void visit(NodeSequence n, A argu);
+ public void visit(NodeToken n, A argu);
+
+ //
+ // User-generated visitor methods below
+ //
+
+ /**
+ * f0 -> "MAIN"
+ * f1 -> "["
+ * f2 -> IntegerLiteral()
+ * f3 -> "]"
+ * f4 -> "["
+ * f5 -> IntegerLiteral()
+ * f6 -> "]"
+ * f7 -> "["
+ * f8 -> IntegerLiteral()
+ * f9 -> "]"
+ * f10 -> StmtList()
+ * f11 -> "END"
+ * f12 -> ( Procedure() )*
+ * f13 -> <EOF>
+ */
+ public void visit(Goal n, A argu);
+
+ /**
+ * f0 -> ( ( Label() )? Stmt() )*
+ */
+ public void visit(StmtList n, A argu);
+
+ /**
+ * f0 -> Label()
+ * f1 -> "["
+ * f2 -> IntegerLiteral()
+ * f3 -> "]"
+ * f4 -> "["
+ * f5 -> IntegerLiteral()
+ * f6 -> "]"
+ * f7 -> "["
+ * f8 -> IntegerLiteral()
+ * f9 -> "]"
+ * f10 -> StmtList()
+ * f11 -> "END"
+ */
+ public void visit(Procedure n, A argu);
+
+ /**
+ * f0 -> NoOpStmt()
+ * | ErrorStmt()
+ * | CJumpStmt()
+ * | JumpStmt()
+ * | HStoreStmt()
+ * | HLoadStmt()
+ * | MoveStmt()
+ * | PrintStmt()
+ * | ALoadStmt()
+ * | AStoreStmt()
+ * | PassArgStmt()
+ * | CallStmt()
+ */
+ public void visit(Stmt n, A argu);
+
+ /**
+ * f0 -> "NOOP"
+ */
+ public void visit(NoOpStmt n, A argu);
+
+ /**
+ * f0 -> "ERROR"
+ */
+ public void visit(ErrorStmt n, A argu);
+
+ /**
+ * f0 -> "CJUMP"
+ * f1 -> Reg()
+ * f2 -> Label()
+ */
+ public void visit(CJumpStmt n, A argu);
+
+ /**
+ * f0 -> "JUMP"
+ * f1 -> Label()
+ */
+ public void visit(JumpStmt n, A argu);
+
+ /**
+ * f0 -> "HSTORE"
+ * f1 -> Reg()
+ * f2 -> IntegerLiteral()
+ * f3 -> Reg()
+ */
+ public void visit(HStoreStmt n, A argu);
+
+ /**
+ * f0 -> "HLOAD"
+ * f1 -> Reg()
+ * f2 -> Reg()
+ * f3 -> IntegerLiteral()
+ */
+ public void visit(HLoadStmt n, A argu);
+
+ /**
+ * f0 -> "MOVE"
+ * f1 -> Reg()
+ * f2 -> Exp()
+ */
+ public void visit(MoveStmt n, A argu);
+
+ /**
+ * f0 -> "PRINT"
+ * f1 -> SimpleExp()
+ */
+ public void visit(PrintStmt n, A argu);
+
+ /**
+ * f0 -> "ALOAD"
+ * f1 -> Reg()
+ * f2 -> SpilledArg()
+ */
+ public void visit(ALoadStmt n, A argu);
+
+ /**
+ * f0 -> "ASTORE"
+ * f1 -> SpilledArg()
+ * f2 -> Reg()
+ */
+ public void visit(AStoreStmt n, A argu);
+
+ /**
+ * f0 -> "PASSARG"
+ * f1 -> IntegerLiteral()
+ * f2 -> Reg()
+ */
+ public void visit(PassArgStmt n, A argu);
+
+ /**
+ * f0 -> "CALL"
+ * f1 -> SimpleExp()
+ */
+ public void visit(CallStmt n, A argu);
+
+ /**
+ * f0 -> HAllocate()
+ * | BinOp()
+ * | SimpleExp()
+ */
+ public void visit(Exp n, A argu);
+
+ /**
+ * f0 -> "HALLOCATE"
+ * f1 -> SimpleExp()
+ */
+ public void visit(HAllocate n, A argu);
+
+ /**
+ * f0 -> Operator()
+ * f1 -> Reg()
+ * f2 -> SimpleExp()
+ */
+ public void visit(BinOp n, A argu);
+
+ /**
+ * f0 -> "LT"
+ * | "PLUS"
+ * | "MINUS"
+ * | "TIMES"
+ */
+ public void visit(Operator n, A argu);
+
+ /**
+ * f0 -> "SPILLEDARG"
+ * f1 -> IntegerLiteral()
+ */
+ public void visit(SpilledArg n, A argu);
+
+ /**
+ * f0 -> Reg()
+ * | IntegerLiteral()
+ * | Label()
+ */
+ public void visit(SimpleExp n, A argu);
+
+ /**
+ * f0 -> "a0"
+ * | "a1"
+ * | "a2"
+ * | "a3"
+ * | "t0"
+ * | "t1"
+ * | "t2"
+ * | "t3"
+ * | "t4"
+ * | "t5"
+ * | "t6"
+ * | "t7"
+ * | "s0"
+ * | "s1"
+ * | "s2"
+ * | "s3"
+ * | "s4"
+ * | "s5"
+ * | "s6"
+ * | "s7"
+ * | "t8"
+ * | "t9"
+ * | "v0"
+ * | "v1"
+ */
+ public void visit(Reg n, A argu);
+
+ /**
+ * f0 -> <INTEGER_LITERAL>
+ */
+ public void visit(IntegerLiteral n, A argu);
+
+ /**
+ * f0 -> <IDENTIFIER>
+ */
+ public void visit(Label n, A argu);
+
+}
+
diff --git a/src/kanga/visitor/Visitor.java b/src/kanga/visitor/Visitor.java
new file mode 100644
index 0000000..33685bd
--- /dev/null
+++ b/src/kanga/visitor/Visitor.java
@@ -0,0 +1,271 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package kanga.visitor;
+import kanga.syntaxtree.ALoadStmt;
+import kanga.syntaxtree.AStoreStmt;
+import kanga.syntaxtree.BinOp;
+import kanga.syntaxtree.CJumpStmt;
+import kanga.syntaxtree.CallStmt;
+import kanga.syntaxtree.ErrorStmt;
+import kanga.syntaxtree.Exp;
+import kanga.syntaxtree.Goal;
+import kanga.syntaxtree.HAllocate;
+import kanga.syntaxtree.HLoadStmt;
+import kanga.syntaxtree.HStoreStmt;
+import kanga.syntaxtree.IntegerLiteral;
+import kanga.syntaxtree.JumpStmt;
+import kanga.syntaxtree.Label;
+import kanga.syntaxtree.MoveStmt;
+import kanga.syntaxtree.NoOpStmt;
+import kanga.syntaxtree.NodeList;
+import kanga.syntaxtree.NodeListOptional;
+import kanga.syntaxtree.NodeOptional;
+import kanga.syntaxtree.NodeSequence;
+import kanga.syntaxtree.NodeToken;
+import kanga.syntaxtree.Operator;
+import kanga.syntaxtree.PassArgStmt;
+import kanga.syntaxtree.PrintStmt;
+import kanga.syntaxtree.Procedure;
+import kanga.syntaxtree.Reg;
+import kanga.syntaxtree.SimpleExp;
+import kanga.syntaxtree.SpilledArg;
+import kanga.syntaxtree.Stmt;
+import kanga.syntaxtree.StmtList;
+
+/**
+ * All void visitors must implement this interface.
+ */
+
+public interface Visitor {
+
+ //
+ // void Auto class visitors
+ //
+
+ public void visit(NodeList n);
+ public void visit(NodeListOptional n);
+ public void visit(NodeOptional n);
+ public void visit(NodeSequence n);
+ public void visit(NodeToken n);
+
+ //
+ // User-generated visitor methods below
+ //
+
+ /**
+ * f0 -> "MAIN"
+ * f1 -> "["
+ * f2 -> IntegerLiteral()
+ * f3 -> "]"
+ * f4 -> "["
+ * f5 -> IntegerLiteral()
+ * f6 -> "]"
+ * f7 -> "["
+ * f8 -> IntegerLiteral()
+ * f9 -> "]"
+ * f10 -> StmtList()
+ * f11 -> "END"
+ * f12 -> ( Procedure() )*
+ * f13 -> <EOF>
+ */
+ public void visit(Goal n);
+
+ /**
+ * f0 -> ( ( Label() )? Stmt() )*
+ */
+ public void visit(StmtList n);
+
+ /**
+ * f0 -> Label()
+ * f1 -> "["
+ * f2 -> IntegerLiteral()
+ * f3 -> "]"
+ * f4 -> "["
+ * f5 -> IntegerLiteral()
+ * f6 -> "]"
+ * f7 -> "["
+ * f8 -> IntegerLiteral()
+ * f9 -> "]"
+ * f10 -> StmtList()
+ * f11 -> "END"
+ */
+ public void visit(Procedure n);
+
+ /**
+ * f0 -> NoOpStmt()
+ * | ErrorStmt()
+ * | CJumpStmt()
+ * | JumpStmt()
+ * | HStoreStmt()
+ * | HLoadStmt()
+ * | MoveStmt()
+ * | PrintStmt()
+ * | ALoadStmt()
+ * | AStoreStmt()
+ * | PassArgStmt()
+ * | CallStmt()
+ */
+ public void visit(Stmt n);
+
+ /**
+ * f0 -> "NOOP"
+ */
+ public void visit(NoOpStmt n);
+
+ /**
+ * f0 -> "ERROR"
+ */
+ public void visit(ErrorStmt n);
+
+ /**
+ * f0 -> "CJUMP"
+ * f1 -> Reg()
+ * f2 -> Label()
+ */
+ public void visit(CJumpStmt n);
+
+ /**
+ * f0 -> "JUMP"
+ * f1 -> Label()
+ */
+ public void visit(JumpStmt n);
+
+ /**
+ * f0 -> "HSTORE"
+ * f1 -> Reg()
+ * f2 -> IntegerLiteral()
+ * f3 -> Reg()
+ */
+ public void visit(HStoreStmt n);
+
+ /**
+ * f0 -> "HLOAD"
+ * f1 -> Reg()
+ * f2 -> Reg()
+ * f3 -> IntegerLiteral()
+ */
+ public void visit(HLoadStmt n);
+
+ /**
+ * f0 -> "MOVE"
+ * f1 -> Reg()
+ * f2 -> Exp()
+ */
+ public void visit(MoveStmt n);
+
+ /**
+ * f0 -> "PRINT"
+ * f1 -> SimpleExp()
+ */
+ public void visit(PrintStmt n);
+
+ /**
+ * f0 -> "ALOAD"
+ * f1 -> Reg()
+ * f2 -> SpilledArg()
+ */
+ public void visit(ALoadStmt n);
+
+ /**
+ * f0 -> "ASTORE"
+ * f1 -> SpilledArg()
+ * f2 -> Reg()
+ */
+ public void visit(AStoreStmt n);
+
+ /**
+ * f0 -> "PASSARG"
+ * f1 -> IntegerLiteral()
+ * f2 -> Reg()
+ */
+ public void visit(PassArgStmt n);
+
+ /**
+ * f0 -> "CALL"
+ * f1 -> SimpleExp()
+ */
+ public void visit(CallStmt n);
+
+ /**
+ * f0 -> HAllocate()
+ * | BinOp()
+ * | SimpleExp()
+ */
+ public void visit(Exp n);
+
+ /**
+ * f0 -> "HALLOCATE"
+ * f1 -> SimpleExp()
+ */
+ public void visit(HAllocate n);
+
+ /**
+ * f0 -> Operator()
+ * f1 -> Reg()
+ * f2 -> SimpleExp()
+ */
+ public void visit(BinOp n);
+
+ /**
+ * f0 -> "LT"
+ * | "PLUS"
+ * | "MINUS"
+ * | "TIMES"
+ */
+ public void visit(Operator n);
+
+ /**
+ * f0 -> "SPILLEDARG"
+ * f1 -> IntegerLiteral()
+ */
+ public void visit(SpilledArg n);
+
+ /**
+ * f0 -> Reg()
+ * | IntegerLiteral()
+ * | Label()
+ */
+ public void visit(SimpleExp n);
+
+ /**
+ * f0 -> "a0"
+ * | "a1"
+ * | "a2"
+ * | "a3"
+ * | "t0"
+ * | "t1"
+ * | "t2"
+ * | "t3"
+ * | "t4"
+ * | "t5"
+ * | "t6"
+ * | "t7"
+ * | "s0"
+ * | "s1"
+ * | "s2"
+ * | "s3"
+ * | "s4"
+ * | "s5"
+ * | "s6"
+ * | "s7"
+ * | "t8"
+ * | "t9"
+ * | "v0"
+ * | "v1"
+ */
+ public void visit(Reg n);
+
+ /**
+ * f0 -> <INTEGER_LITERAL>
+ */
+ public void visit(IntegerLiteral n);
+
+ /**
+ * f0 -> <IDENTIFIER>
+ */
+ public void visit(Label n);
+
+}
+
diff --git a/src/minijava/JavaCharStream.java b/src/minijava/JavaCharStream.java
new file mode 100644
index 0000000..6da1d4a
--- /dev/null
+++ b/src/minijava/JavaCharStream.java
@@ -0,0 +1,587 @@
+package minijava;
+/* Generated By:JavaCC: Do not edit this line. JavaCharStream.java Version 4.0 */
+/**
+ * An implementation of interface CharStream, where the stream is assumed to
+ * contain only ASCII characters (with java-like unicode escape processing).
+ */
+
+public class JavaCharStream
+{
+ public static final boolean staticFlag = true;
+ static final int hexval(char c) throws java.io.IOException {
+ switch(c)
+ {
+ case '0' :
+ return 0;
+ case '1' :
+ return 1;
+ case '2' :
+ return 2;
+ case '3' :
+ return 3;
+ case '4' :
+ return 4;
+ case '5' :
+ return 5;
+ case '6' :
+ return 6;
+ case '7' :
+ return 7;
+ case '8' :
+ return 8;
+ case '9' :
+ return 9;
+
+ case 'a' :
+ case 'A' :
+ return 10;
+ case 'b' :
+ case 'B' :
+ return 11;
+ case 'c' :
+ case 'C' :
+ return 12;
+ case 'd' :
+ case 'D' :
+ return 13;
+ case 'e' :
+ case 'E' :
+ return 14;
+ case 'f' :
+ case 'F' :
+ return 15;
+ }
+
+ throw new java.io.IOException(); // Should never come here
+ }
+
+ static public int bufpos = -1;
+ static int bufsize;
+ static int available;
+ static int tokenBegin;
+ static protected int bufline[];
+ static protected int bufcolumn[];
+
+ static protected int column = 0;
+ static protected int line = 1;
+
+ static protected boolean prevCharIsCR = false;
+ static protected boolean prevCharIsLF = false;
+
+ static protected java.io.Reader inputStream;
+
+ static protected char[] nextCharBuf;
+ static protected char[] buffer;
+ static protected int maxNextCharInd = 0;
+ static protected int nextCharInd = -1;
+ static protected int inBuf = 0;
+ static protected int tabSize = 8;
+
+ static protected void setTabSize(int i) { tabSize = i; }
+ static protected int getTabSize(int i) { return tabSize; }
+
+ static protected void ExpandBuff(boolean wrapAround)
+ {
+ char[] newbuffer = new char[bufsize + 2048];
+ int newbufline[] = new int[bufsize + 2048];
+ int newbufcolumn[] = new int[bufsize + 2048];
+
+ try
+ {
+ if (wrapAround)
+ {
+ System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin);
+ System.arraycopy(buffer, 0, newbuffer,
+ bufsize - tokenBegin, bufpos);
+ buffer = newbuffer;
+
+ System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin);
+ System.arraycopy(bufline, 0, newbufline, bufsize - tokenBegin, bufpos);
+ bufline = newbufline;
+
+ System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin);
+ System.arraycopy(bufcolumn, 0, newbufcolumn, bufsize - tokenBegin, bufpos);
+ bufcolumn = newbufcolumn;
+
+ bufpos += (bufsize - tokenBegin);
+ }
+ else
+ {
+ System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin);
+ buffer = newbuffer;
+
+ System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin);
+ bufline = newbufline;
+
+ System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin);
+ bufcolumn = newbufcolumn;
+
+ bufpos -= tokenBegin;
+ }
+ }
+ catch (Throwable t)
+ {
+ throw new Error(t.getMessage());
+ }
+
+ available = (bufsize += 2048);
+ tokenBegin = 0;
+ }
+
+ static protected void FillBuff() throws java.io.IOException
+ {
+ int i;
+ if (maxNextCharInd == 4096)
+ maxNextCharInd = nextCharInd = 0;
+
+ try {
+ if ((i = inputStream.read(nextCharBuf, maxNextCharInd,
+ 4096 - maxNextCharInd)) == -1)
+ {
+ inputStream.close();
+ throw new java.io.IOException();
+ }
+ else
+ maxNextCharInd += i;
+ return;
+ }
+ catch(java.io.IOException e) {
+ if (bufpos != 0)
+ {
+ --bufpos;
+ backup(0);
+ }
+ else
+ {
+ bufline[bufpos] = line;
+ bufcolumn[bufpos] = column;
+ }
+ throw e;
+ }
+ }
+
+ static protected char ReadByte() throws java.io.IOException
+ {
+ if (++nextCharInd >= maxNextCharInd)
+ FillBuff();
+
+ return nextCharBuf[nextCharInd];
+ }
+
+ static public char BeginToken() throws java.io.IOException
+ {
+ if (inBuf > 0)
+ {
+ --inBuf;
+
+ if (++bufpos == bufsize)
+ bufpos = 0;
+
+ tokenBegin = bufpos;
+ return buffer[bufpos];
+ }
+
+ tokenBegin = 0;
+ bufpos = -1;
+
+ return readChar();
+ }
+
+ static protected void AdjustBuffSize()
+ {
+ if (available == bufsize)
+ {
+ if (tokenBegin > 2048)
+ {
+ bufpos = 0;
+ available = tokenBegin;
+ }
+ else
+ ExpandBuff(false);
+ }
+ else if (available > tokenBegin)
+ available = bufsize;
+ else if ((tokenBegin - available) < 2048)
+ ExpandBuff(true);
+ else
+ available = tokenBegin;
+ }
+
+ static protected void UpdateLineColumn(char c)
+ {
+ column++;
+
+ if (prevCharIsLF)
+ {
+ prevCharIsLF = false;
+ line += (column = 1);
+ }
+ else if (prevCharIsCR)
+ {
+ prevCharIsCR = false;
+ if (c == '\n')
+ {
+ prevCharIsLF = true;
+ }
+ else
+ line += (column = 1);
+ }
+
+ switch (c)
+ {
+ case '\r' :
+ prevCharIsCR = true;
+ break;
+ case '\n' :
+ prevCharIsLF = true;
+ break;
+ case '\t' :
+ column--;
+ column += (tabSize - (column % tabSize));
+ break;
+ default :
+ break;
+ }
+
+ bufline[bufpos] = line;
+ bufcolumn[bufpos] = column;
+ }
+
+ static public char readChar() throws java.io.IOException
+ {
+ if (inBuf > 0)
+ {
+ --inBuf;
+
+ if (++bufpos == bufsize)
+ bufpos = 0;
+
+ return buffer[bufpos];
+ }
+
+ char c;
+
+ if (++bufpos == available)
+ AdjustBuffSize();
+
+ if ((buffer[bufpos] = c = ReadByte()) == '\\')
+ {
+ UpdateLineColumn(c);
+
+ int backSlashCnt = 1;
+
+ for (;;) // Read all the backslashes
+ {
+ if (++bufpos == available)
+ AdjustBuffSize();
+
+ try
+ {
+ if ((buffer[bufpos] = c = ReadByte()) != '\\')
+ {
+ UpdateLineColumn(c);
+ // found a non-backslash char.
+ if ((c == 'u') && ((backSlashCnt & 1) == 1))
+ {
+ if (--bufpos < 0)
+ bufpos = bufsize - 1;
+
+ break;
+ }
+
+ backup(backSlashCnt);
+ return '\\';
+ }
+ }
+ catch(java.io.IOException e)
+ {
+ if (backSlashCnt > 1)
+ backup(backSlashCnt);
+
+ return '\\';
+ }
+
+ UpdateLineColumn(c);
+ backSlashCnt++;
+ }
+
+ // Here, we have seen an odd number of backslash's followed by a 'u'
+ try
+ {
+ while ((c = ReadByte()) == 'u')
+ ++column;
+
+ buffer[bufpos] = c = (char)(hexval(c) << 12 |
+ hexval(ReadByte()) << 8 |
+ hexval(ReadByte()) << 4 |
+ hexval(ReadByte()));
+
+ column += 4;
+ }
+ catch(java.io.IOException e)
+ {
+ throw new Error("Invalid escape character at line " + line +
+ " column " + column + ".");
+ }
+
+ if (backSlashCnt == 1)
+ return c;
+ else
+ {
+ backup(backSlashCnt - 1);
+ return '\\';
+ }
+ }
+ else
+ {
+ UpdateLineColumn(c);
+ return (c);
+ }
+ }
+
+ /**
+ * @deprecated
+ * @see #getEndColumn
+ */
+
+ static public int getColumn() {
+ return bufcolumn[bufpos];
+ }
+
+ /**
+ * @deprecated
+ * @see #getEndLine
+ */
+
+ static public int getLine() {
+ return bufline[bufpos];
+ }
+
+ static public int getEndColumn() {
+ return bufcolumn[bufpos];
+ }
+
+ static public int getEndLine() {
+ return bufline[bufpos];
+ }
+
+ static public int getBeginColumn() {
+ return bufcolumn[tokenBegin];
+ }
+
+ static public int getBeginLine() {
+ return bufline[tokenBegin];
+ }
+
+ static public void backup(int amount) {
+
+ inBuf += amount;
+ if ((bufpos -= amount) < 0)
+ bufpos += bufsize;
+ }
+
+ public JavaCharStream(java.io.Reader dstream,
+ int startline, int startcolumn, int buffersize)
+ {
+ if (inputStream != null)
+ throw new Error("\n ERROR: Second call to the constructor of a static JavaCharStream. You must\n" +
+ " either use ReInit() or set the JavaCC option STATIC to false\n" +
+ " during the generation of this class.");
+ inputStream = dstream;
+ line = startline;
+ column = startcolumn - 1;
+
+ available = bufsize = buffersize;
+ buffer = new char[buffersize];
+ bufline = new int[buffersize];
+ bufcolumn = new int[buffersize];
+ nextCharBuf = new char[4096];
+ }
+
+ public JavaCharStream(java.io.Reader dstream,
+ int startline, int startcolumn)
+ {
+ this(dstream, startline, startcolumn, 4096);
+ }
+
+ public JavaCharStream(java.io.Reader dstream)
+ {
+ this(dstream, 1, 1, 4096);
+ }
+ public void ReInit(java.io.Reader dstream,
+ int startline, int startcolumn, int buffersize)
+ {
+ inputStream = dstream;
+ line = startline;
+ column = startcolumn - 1;
+
+ if (buffer == null || buffersize != buffer.length)
+ {
+ available = bufsize = buffersize;
+ buffer = new char[buffersize];
+ bufline = new int[buffersize];
+ bufcolumn = new int[buffersize];
+ nextCharBuf = new char[4096];
+ }
+ prevCharIsLF = prevCharIsCR = false;
+ tokenBegin = inBuf = maxNextCharInd = 0;
+ nextCharInd = bufpos = -1;
+ }
+
+ public void ReInit(java.io.Reader dstream,
+ int startline, int startcolumn)
+ {
+ ReInit(dstream, startline, startcolumn, 4096);
+ }
+
+ public void ReInit(java.io.Reader dstream)
+ {
+ ReInit(dstream, 1, 1, 4096);
+ }
+ public JavaCharStream(java.io.InputStream dstream, String encoding, int startline,
+ int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException
+ {
+ this(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize);
+ }
+
+ public JavaCharStream(java.io.InputStream dstream, int startline,
+ int startcolumn, int buffersize)
+ {
+ this(new java.io.InputStreamReader(dstream), startline, startcolumn, 4096);
+ }
+
+ public JavaCharStream(java.io.InputStream dstream, String encoding, int startline,
+ int startcolumn) throws java.io.UnsupportedEncodingException
+ {
+ this(dstream, encoding, startline, startcolumn, 4096);
+ }
+
+ public JavaCharStream(java.io.InputStream dstream, int startline,
+ int startcolumn)
+ {
+ this(dstream, startline, startcolumn, 4096);
+ }
+
+ public JavaCharStream(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException
+ {
+ this(dstream, encoding, 1, 1, 4096);
+ }
+
+ public JavaCharStream(java.io.InputStream dstream)
+ {
+ this(dstream, 1, 1, 4096);
+ }
+
+ public void ReInit(java.io.InputStream dstream, String encoding, int startline,
+ int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException
+ {
+ ReInit(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize);
+ }
+
+ public void ReInit(java.io.InputStream dstream, int startline,
+ int startcolumn, int buffersize)
+ {
+ ReInit(new java.io.InputStreamReader(dstream), startline, startcolumn, buffersize);
+ }
+ public void ReInit(java.io.InputStream dstream, String encoding, int startline,
+ int startcolumn) throws java.io.UnsupportedEncodingException
+ {
+ ReInit(dstream, encoding, startline, startcolumn, 4096);
+ }
+ public void ReInit(java.io.InputStream dstream, int startline,
+ int startcolumn)
+ {
+ ReInit(dstream, startline, startcolumn, 4096);
+ }
+ public void ReInit(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException
+ {
+ ReInit(dstream, encoding, 1, 1, 4096);
+ }
+
+ public void ReInit(java.io.InputStream dstream)
+ {
+ ReInit(dstream, 1, 1, 4096);
+ }
+
+ static public String GetImage()
+ {
+ if (bufpos >= tokenBegin)
+ return new String(buffer, tokenBegin, bufpos - tokenBegin + 1);
+ else
+ return new String(buffer, tokenBegin, bufsize - tokenBegin) +
+ new String(buffer, 0, bufpos + 1);
+ }
+
+ static public char[] GetSuffix(int len)
+ {
+ char[] ret = new char[len];
+
+ if ((bufpos + 1) >= len)
+ System.arraycopy(buffer, bufpos - len + 1, ret, 0, len);
+ else
+ {
+ System.arraycopy(buffer, bufsize - (len - bufpos - 1), ret, 0,
+ len - bufpos - 1);
+ System.arraycopy(buffer, 0, ret, len - bufpos - 1, bufpos + 1);
+ }
+
+ return ret;
+ }
+
+ static public void Done()
+ {
+ nextCharBuf = null;
+ buffer = null;
+ bufline = null;
+ bufcolumn = null;
+ }
+
+ /**
+ * Method to adjust line and column numbers for the start of a token.
+ */
+ static public void adjustBeginLineColumn(int newLine, int newCol)
+ {
+ int start = tokenBegin;
+ int len;
+
+ if (bufpos >= tokenBegin)
+ {
+ len = bufpos - tokenBegin + inBuf + 1;
+ }
+ else
+ {
+ len = bufsize - tokenBegin + bufpos + 1 + inBuf;
+ }
+
+ int i = 0, j = 0, k = 0;
+ int nextColDiff = 0, columnDiff = 0;
+
+ while (i < len &&
+ bufline[j = start % bufsize] == bufline[k = ++start % bufsize])
+ {
+ bufline[j] = newLine;
+ nextColDiff = columnDiff + bufcolumn[k] - bufcolumn[j];
+ bufcolumn[j] = newCol + columnDiff;
+ columnDiff = nextColDiff;
+ i++;
+ }
+
+ if (i < len)
+ {
+ bufline[j] = newLine++;
+ bufcolumn[j] = newCol + columnDiff;
+
+ while (i++ < len)
+ {
+ if (bufline[j = start % bufsize] != bufline[++start % bufsize])
+ bufline[j] = newLine++;
+ else
+ bufline[j] = newLine;
+ }
+ }
+
+ line = bufline[j];
+ column = bufcolumn[j];
+ }
+
+}
diff --git a/src/minijava/MiniJavaParser.java b/src/minijava/MiniJavaParser.java
new file mode 100644
index 0000000..fbae7bb
--- /dev/null
+++ b/src/minijava/MiniJavaParser.java
@@ -0,0 +1,1947 @@
+package minijava;
+/* Generated By:JavaCC: Do not edit this line. MiniJavaParser.java */
+import minijava.syntaxtree.AllocationExpression;
+import minijava.syntaxtree.AndExpression;
+import minijava.syntaxtree.ArrayAllocationExpression;
+import minijava.syntaxtree.ArrayAssignmentStatement;
+import minijava.syntaxtree.ArrayLength;
+import minijava.syntaxtree.ArrayLookup;
+import minijava.syntaxtree.ArrayType;
+import minijava.syntaxtree.AssignmentStatement;
+import minijava.syntaxtree.Block;
+import minijava.syntaxtree.BooleanType;
+import minijava.syntaxtree.BracketExpression;
+import minijava.syntaxtree.ClassDeclaration;
+import minijava.syntaxtree.ClassExtendsDeclaration;
+import minijava.syntaxtree.CompareExpression;
+import minijava.syntaxtree.Expression;
+import minijava.syntaxtree.ExpressionList;
+import minijava.syntaxtree.ExpressionRest;
+import minijava.syntaxtree.FalseLiteral;
+import minijava.syntaxtree.FormalParameter;
+import minijava.syntaxtree.FormalParameterList;
+import minijava.syntaxtree.FormalParameterRest;
+import minijava.syntaxtree.Goal;
+import minijava.syntaxtree.Identifier;
+import minijava.syntaxtree.IfStatement;
+import minijava.syntaxtree.IntegerLiteral;
+import minijava.syntaxtree.IntegerType;
+import minijava.syntaxtree.MainClass;
+import minijava.syntaxtree.MessageSend;
+import minijava.syntaxtree.MethodDeclaration;
+import minijava.syntaxtree.MinusExpression;
+import minijava.syntaxtree.NodeChoice;
+import minijava.syntaxtree.NodeListOptional;
+import minijava.syntaxtree.NodeOptional;
+import minijava.syntaxtree.NodeToken;
+import minijava.syntaxtree.NotExpression;
+import minijava.syntaxtree.PlusExpression;
+import minijava.syntaxtree.PrimaryExpression;
+import minijava.syntaxtree.PrintStatement;
+import minijava.syntaxtree.Statement;
+import minijava.syntaxtree.ThisExpression;
+import minijava.syntaxtree.TimesExpression;
+import minijava.syntaxtree.TrueLiteral;
+import minijava.syntaxtree.Type;
+import minijava.syntaxtree.TypeDeclaration;
+import minijava.syntaxtree.VarDeclaration;
+import minijava.syntaxtree.WhileStatement;
+
+
+public class MiniJavaParser implements MiniJavaParserConstants {
+
+ static final public Goal Goal() throws ParseException {
+ MainClass n0;
+ NodeListOptional n1 = new NodeListOptional();
+ TypeDeclaration n2;
+ NodeToken n3;
+ Token n4;
+ n0 = MainClass();
+ label_1:
+ while (true) {
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case CLASS:
+ ;
+ break;
+ default:
+ jj_la1[0] = jj_gen;
+ break label_1;
+ }
+ n2 = TypeDeclaration();
+ n1.addNode(n2);
+ }
+ n1.nodes.trimToSize();
+ n4 = jj_consume_token(0);
+ n4.beginColumn++; n4.endColumn++;
+ n3 = JTBToolkit.makeNodeToken(n4);
+ {if (true) return new Goal(n0,n1,n3);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public MainClass MainClass() throws ParseException {
+ NodeToken n0;
+ Token n1;
+ Identifier n2;
+ NodeToken n3;
+ Token n4;
+ NodeToken n5;
+ Token n6;
+ NodeToken n7;
+ Token n8;
+ NodeToken n9;
+ Token n10;
+ NodeToken n11;
+ Token n12;
+ NodeToken n13;
+ Token n14;
+ NodeToken n15;
+ Token n16;
+ NodeToken n17;
+ Token n18;
+ NodeToken n19;
+ Token n20;
+ Identifier n21;
+ NodeToken n22;
+ Token n23;
+ NodeToken n24;
+ Token n25;
+ PrintStatement n26;
+ NodeToken n27;
+ Token n28;
+ NodeToken n29;
+ Token n30;
+ n1 = jj_consume_token(CLASS);
+ n0 = JTBToolkit.makeNodeToken(n1);
+ n2 = Identifier();
+ n4 = jj_consume_token(LBRACE);
+ n3 = JTBToolkit.makeNodeToken(n4);
+ n6 = jj_consume_token(PUBLIC);
+ n5 = JTBToolkit.makeNodeToken(n6);
+ n8 = jj_consume_token(STATIC);
+ n7 = JTBToolkit.makeNodeToken(n8);
+ n10 = jj_consume_token(VOID);
+ n9 = JTBToolkit.makeNodeToken(n10);
+ n12 = jj_consume_token(MAIN);
+ n11 = JTBToolkit.makeNodeToken(n12);
+ n14 = jj_consume_token(LPAREN);
+ n13 = JTBToolkit.makeNodeToken(n14);
+ n16 = jj_consume_token(STRING);
+ n15 = JTBToolkit.makeNodeToken(n16);
+ n18 = jj_consume_token(LSQPAREN);
+ n17 = JTBToolkit.makeNodeToken(n18);
+ n20 = jj_consume_token(RSQPAREN);
+ n19 = JTBToolkit.makeNodeToken(n20);
+ n21 = Identifier();
+ n23 = jj_consume_token(RPAREN);
+ n22 = JTBToolkit.makeNodeToken(n23);
+ n25 = jj_consume_token(LBRACE);
+ n24 = JTBToolkit.makeNodeToken(n25);
+ n26 = PrintStatement();
+ n28 = jj_consume_token(RBRACE);
+ n27 = JTBToolkit.makeNodeToken(n28);
+ n30 = jj_consume_token(RBRACE);
+ n29 = JTBToolkit.makeNodeToken(n30);
+ {if (true) return new MainClass(n0,n2,n3,n5,n7,n9,n11,n13,n15,n17,n19,n21,n22,n24,n26,n27,n29);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public TypeDeclaration TypeDeclaration() throws ParseException {
+ NodeChoice n0;
+ ClassDeclaration n1;
+ ClassExtendsDeclaration n2;
+ if (jj_2_1(3)) {
+ n1 = ClassDeclaration();
+ n0 = new NodeChoice(n1, 0);
+ } else {
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case CLASS:
+ n2 = ClassExtendsDeclaration();
+ n0 = new NodeChoice(n2, 1);
+ break;
+ default:
+ jj_la1[1] = jj_gen;
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ }
+ {if (true) return new TypeDeclaration(n0);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public ClassDeclaration ClassDeclaration() throws ParseException {
+ NodeToken n0;
+ Token n1;
+ Identifier n2;
+ NodeToken n3;
+ Token n4;
+ NodeListOptional n5 = new NodeListOptional();
+ VarDeclaration n6;
+ NodeListOptional n7 = new NodeListOptional();
+ MethodDeclaration n8;
+ NodeToken n9;
+ Token n10;
+ n1 = jj_consume_token(CLASS);
+ n0 = JTBToolkit.makeNodeToken(n1);
+ n2 = Identifier();
+ n4 = jj_consume_token(LBRACE);
+ n3 = JTBToolkit.makeNodeToken(n4);
+ label_2:
+ while (true) {
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case BOOLEAN:
+ case INTEGER:
+ case IDENTIFIER:
+ ;
+ break;
+ default:
+ jj_la1[2] = jj_gen;
+ break label_2;
+ }
+ n6 = VarDeclaration();
+ n5.addNode(n6);
+ }
+ n5.nodes.trimToSize();
+ label_3:
+ while (true) {
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case PUBLIC:
+ ;
+ break;
+ default:
+ jj_la1[3] = jj_gen;
+ break label_3;
+ }
+ n8 = MethodDeclaration();
+ n7.addNode(n8);
+ }
+ n7.nodes.trimToSize();
+ n10 = jj_consume_token(RBRACE);
+ n9 = JTBToolkit.makeNodeToken(n10);
+ {if (true) return new ClassDeclaration(n0,n2,n3,n5,n7,n9);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public ClassExtendsDeclaration ClassExtendsDeclaration() throws ParseException {
+ NodeToken n0;
+ Token n1;
+ Identifier n2;
+ NodeToken n3;
+ Token n4;
+ Identifier n5;
+ NodeToken n6;
+ Token n7;
+ NodeListOptional n8 = new NodeListOptional();
+ VarDeclaration n9;
+ NodeListOptional n10 = new NodeListOptional();
+ MethodDeclaration n11;
+ NodeToken n12;
+ Token n13;
+ n1 = jj_consume_token(CLASS);
+ n0 = JTBToolkit.makeNodeToken(n1);
+ n2 = Identifier();
+ n4 = jj_consume_token(EXTENDS);
+ n3 = JTBToolkit.makeNodeToken(n4);
+ n5 = Identifier();
+ n7 = jj_consume_token(LBRACE);
+ n6 = JTBToolkit.makeNodeToken(n7);
+ label_4:
+ while (true) {
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case BOOLEAN:
+ case INTEGER:
+ case IDENTIFIER:
+ ;
+ break;
+ default:
+ jj_la1[4] = jj_gen;
+ break label_4;
+ }
+ n9 = VarDeclaration();
+ n8.addNode(n9);
+ }
+ n8.nodes.trimToSize();
+ label_5:
+ while (true) {
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case PUBLIC:
+ ;
+ break;
+ default:
+ jj_la1[5] = jj_gen;
+ break label_5;
+ }
+ n11 = MethodDeclaration();
+ n10.addNode(n11);
+ }
+ n10.nodes.trimToSize();
+ n13 = jj_consume_token(RBRACE);
+ n12 = JTBToolkit.makeNodeToken(n13);
+ {if (true) return new ClassExtendsDeclaration(n0,n2,n3,n5,n6,n8,n10,n12);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public VarDeclaration VarDeclaration() throws ParseException {
+ Type n0;
+ Identifier n1;
+ NodeToken n2;
+ Token n3;
+ n0 = Type();
+ n1 = Identifier();
+ n3 = jj_consume_token(SEMICOLON);
+ n2 = JTBToolkit.makeNodeToken(n3);
+ {if (true) return new VarDeclaration(n0,n1,n2);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public MethodDeclaration MethodDeclaration() throws ParseException {
+ NodeToken n0;
+ Token n1;
+ Type n2;
+ Identifier n3;
+ NodeToken n4;
+ Token n5;
+ NodeOptional n6 = new NodeOptional();
+ FormalParameterList n7;
+ NodeToken n8;
+ Token n9;
+ NodeToken n10;
+ Token n11;
+ NodeListOptional n12 = new NodeListOptional();
+ VarDeclaration n13;
+ NodeListOptional n14 = new NodeListOptional();
+ Statement n15;
+ NodeToken n16;
+ Token n17;
+ Expression n18;
+ NodeToken n19;
+ Token n20;
+ NodeToken n21;
+ Token n22;
+ n1 = jj_consume_token(PUBLIC);
+ n0 = JTBToolkit.makeNodeToken(n1);
+ n2 = Type();
+ n3 = Identifier();
+ n5 = jj_consume_token(LPAREN);
+ n4 = JTBToolkit.makeNodeToken(n5);
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case BOOLEAN:
+ case INTEGER:
+ case IDENTIFIER:
+ n7 = FormalParameterList();
+ n6.addNode(n7);
+ break;
+ default:
+ jj_la1[6] = jj_gen;
+ ;
+ }
+ n9 = jj_consume_token(RPAREN);
+ n8 = JTBToolkit.makeNodeToken(n9);
+ n11 = jj_consume_token(LBRACE);
+ n10 = JTBToolkit.makeNodeToken(n11);
+ label_6:
+ while (true) {
+ if (jj_2_2(2)) {
+ ;
+ } else {
+ break label_6;
+ }
+ n13 = VarDeclaration();
+ n12.addNode(n13);
+ }
+ n12.nodes.trimToSize();
+ label_7:
+ while (true) {
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case LBRACE:
+ case IF:
+ case WHILE:
+ case PRINT:
+ case IDENTIFIER:
+ ;
+ break;
+ default:
+ jj_la1[7] = jj_gen;
+ break label_7;
+ }
+ n15 = Statement();
+ n14.addNode(n15);
+ }
+ n14.nodes.trimToSize();
+ n17 = jj_consume_token(RETURN);
+ n16 = JTBToolkit.makeNodeToken(n17);
+ n18 = Expression();
+ n20 = jj_consume_token(SEMICOLON);
+ n19 = JTBToolkit.makeNodeToken(n20);
+ n22 = jj_consume_token(RBRACE);
+ n21 = JTBToolkit.makeNodeToken(n22);
+ {if (true) return new MethodDeclaration(n0,n2,n3,n4,n6,n8,n10,n12,n14,n16,n18,n19,n21);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public FormalParameterList FormalParameterList() throws ParseException {
+ FormalParameter n0;
+ NodeListOptional n1 = new NodeListOptional();
+ FormalParameterRest n2;
+ n0 = FormalParameter();
+ label_8:
+ while (true) {
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case 47:
+ ;
+ break;
+ default:
+ jj_la1[8] = jj_gen;
+ break label_8;
+ }
+ n2 = FormalParameterRest();
+ n1.addNode(n2);
+ }
+ n1.nodes.trimToSize();
+ {if (true) return new FormalParameterList(n0,n1);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public FormalParameter FormalParameter() throws ParseException {
+ Type n0;
+ Identifier n1;
+ n0 = Type();
+ n1 = Identifier();
+ {if (true) return new FormalParameter(n0,n1);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public FormalParameterRest FormalParameterRest() throws ParseException {
+ NodeToken n0;
+ Token n1;
+ FormalParameter n2;
+ n1 = jj_consume_token(47);
+ n0 = JTBToolkit.makeNodeToken(n1);
+ n2 = FormalParameter();
+ {if (true) return new FormalParameterRest(n0,n2);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public Type Type() throws ParseException {
+ NodeChoice n0;
+ ArrayType n1;
+ BooleanType n2;
+ IntegerType n3;
+ Identifier n4;
+ if (jj_2_3(3)) {
+ n1 = ArrayType();
+ n0 = new NodeChoice(n1, 0);
+ } else {
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case BOOLEAN:
+ n2 = BooleanType();
+ n0 = new NodeChoice(n2, 1);
+ break;
+ case INTEGER:
+ n3 = IntegerType();
+ n0 = new NodeChoice(n3, 2);
+ break;
+ case IDENTIFIER:
+ n4 = Identifier();
+ n0 = new NodeChoice(n4, 3);
+ break;
+ default:
+ jj_la1[9] = jj_gen;
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ }
+ {if (true) return new Type(n0);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public ArrayType ArrayType() throws ParseException {
+ NodeToken n0;
+ Token n1;
+ NodeToken n2;
+ Token n3;
+ NodeToken n4;
+ Token n5;
+ n1 = jj_consume_token(INTEGER);
+ n0 = JTBToolkit.makeNodeToken(n1);
+ n3 = jj_consume_token(LSQPAREN);
+ n2 = JTBToolkit.makeNodeToken(n3);
+ n5 = jj_consume_token(RSQPAREN);
+ n4 = JTBToolkit.makeNodeToken(n5);
+ {if (true) return new ArrayType(n0,n2,n4);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public BooleanType BooleanType() throws ParseException {
+ NodeToken n0;
+ Token n1;
+ n1 = jj_consume_token(BOOLEAN);
+ n0 = JTBToolkit.makeNodeToken(n1);
+ {if (true) return new BooleanType(n0);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public IntegerType IntegerType() throws ParseException {
+ NodeToken n0;
+ Token n1;
+ n1 = jj_consume_token(INTEGER);
+ n0 = JTBToolkit.makeNodeToken(n1);
+ {if (true) return new IntegerType(n0);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public Statement Statement() throws ParseException {
+ NodeChoice n0;
+ Block n1;
+ AssignmentStatement n2;
+ ArrayAssignmentStatement n3;
+ IfStatement n4;
+ WhileStatement n5;
+ PrintStatement n6;
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case LBRACE:
+ n1 = Block();
+ n0 = new NodeChoice(n1, 0);
+ break;
+ default:
+ jj_la1[10] = jj_gen;
+ if (jj_2_4(2)) {
+ n2 = AssignmentStatement();
+ n0 = new NodeChoice(n2, 1);
+ } else if (jj_2_5(2)) {
+ n3 = ArrayAssignmentStatement();
+ n0 = new NodeChoice(n3, 2);
+ } else {
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case IF:
+ n4 = IfStatement();
+ n0 = new NodeChoice(n4, 3);
+ break;
+ case WHILE:
+ n5 = WhileStatement();
+ n0 = new NodeChoice(n5, 4);
+ break;
+ case PRINT:
+ n6 = PrintStatement();
+ n0 = new NodeChoice(n6, 5);
+ break;
+ default:
+ jj_la1[11] = jj_gen;
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ }
+ }
+ {if (true) return new Statement(n0);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public Block Block() throws ParseException {
+ NodeToken n0;
+ Token n1;
+ NodeListOptional n2 = new NodeListOptional();
+ Statement n3;
+ NodeToken n4;
+ Token n5;
+ n1 = jj_consume_token(LBRACE);
+ n0 = JTBToolkit.makeNodeToken(n1);
+ label_9:
+ while (true) {
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case LBRACE:
+ case IF:
+ case WHILE:
+ case PRINT:
+ case IDENTIFIER:
+ ;
+ break;
+ default:
+ jj_la1[12] = jj_gen;
+ break label_9;
+ }
+ n3 = Statement();
+ n2.addNode(n3);
+ }
+ n2.nodes.trimToSize();
+ n5 = jj_consume_token(RBRACE);
+ n4 = JTBToolkit.makeNodeToken(n5);
+ {if (true) return new Block(n0,n2,n4);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public AssignmentStatement AssignmentStatement() throws ParseException {
+ Identifier n0;
+ NodeToken n1;
+ Token n2;
+ Expression n3;
+ NodeToken n4;
+ Token n5;
+ n0 = Identifier();
+ n2 = jj_consume_token(ASSIGN);
+ n1 = JTBToolkit.makeNodeToken(n2);
+ n3 = Expression();
+ n5 = jj_consume_token(SEMICOLON);
+ n4 = JTBToolkit.makeNodeToken(n5);
+ {if (true) return new AssignmentStatement(n0,n1,n3,n4);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public ArrayAssignmentStatement ArrayAssignmentStatement() throws ParseException {
+ Identifier n0;
+ NodeToken n1;
+ Token n2;
+ Expression n3;
+ NodeToken n4;
+ Token n5;
+ NodeToken n6;
+ Token n7;
+ Expression n8;
+ NodeToken n9;
+ Token n10;
+ n0 = Identifier();
+ n2 = jj_consume_token(LSQPAREN);
+ n1 = JTBToolkit.makeNodeToken(n2);
+ n3 = Expression();
+ n5 = jj_consume_token(RSQPAREN);
+ n4 = JTBToolkit.makeNodeToken(n5);
+ n7 = jj_consume_token(ASSIGN);
+ n6 = JTBToolkit.makeNodeToken(n7);
+ n8 = Expression();
+ n10 = jj_consume_token(SEMICOLON);
+ n9 = JTBToolkit.makeNodeToken(n10);
+ {if (true) return new ArrayAssignmentStatement(n0,n1,n3,n4,n6,n8,n9);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public IfStatement IfStatement() throws ParseException {
+ NodeToken n0;
+ Token n1;
+ NodeToken n2;
+ Token n3;
+ Expression n4;
+ NodeToken n5;
+ Token n6;
+ Statement n7;
+ NodeToken n8;
+ Token n9;
+ Statement n10;
+ n1 = jj_consume_token(IF);
+ n0 = JTBToolkit.makeNodeToken(n1);
+ n3 = jj_consume_token(LPAREN);
+ n2 = JTBToolkit.makeNodeToken(n3);
+ n4 = Expression();
+ n6 = jj_consume_token(RPAREN);
+ n5 = JTBToolkit.makeNodeToken(n6);
+ n7 = Statement();
+ n9 = jj_consume_token(ELSE);
+ n8 = JTBToolkit.makeNodeToken(n9);
+ n10 = Statement();
+ {if (true) return new IfStatement(n0,n2,n4,n5,n7,n8,n10);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public WhileStatement WhileStatement() throws ParseException {
+ NodeToken n0;
+ Token n1;
+ NodeToken n2;
+ Token n3;
+ Expression n4;
+ NodeToken n5;
+ Token n6;
+ Statement n7;
+ n1 = jj_consume_token(WHILE);
+ n0 = JTBToolkit.makeNodeToken(n1);
+ n3 = jj_consume_token(LPAREN);
+ n2 = JTBToolkit.makeNodeToken(n3);
+ n4 = Expression();
+ n6 = jj_consume_token(RPAREN);
+ n5 = JTBToolkit.makeNodeToken(n6);
+ n7 = Statement();
+ {if (true) return new WhileStatement(n0,n2,n4,n5,n7);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public PrintStatement PrintStatement() throws ParseException {
+ NodeToken n0;
+ Token n1;
+ NodeToken n2;
+ Token n3;
+ Expression n4;
+ NodeToken n5;
+ Token n6;
+ NodeToken n7;
+ Token n8;
+ n1 = jj_consume_token(PRINT);
+ n0 = JTBToolkit.makeNodeToken(n1);
+ n3 = jj_consume_token(LPAREN);
+ n2 = JTBToolkit.makeNodeToken(n3);
+ n4 = Expression();
+ n6 = jj_consume_token(RPAREN);
+ n5 = JTBToolkit.makeNodeToken(n6);
+ n8 = jj_consume_token(SEMICOLON);
+ n7 = JTBToolkit.makeNodeToken(n8);
+ {if (true) return new PrintStatement(n0,n2,n4,n5,n7);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public Expression Expression() throws ParseException {
+ NodeChoice n0;
+ AndExpression n1;
+ CompareExpression n2;
+ PlusExpression n3;
+ MinusExpression n4;
+ TimesExpression n5;
+ ArrayLookup n6;
+ ArrayLength n7;
+ MessageSend n8;
+ PrimaryExpression n9;
+ if (jj_2_6(2147483647)) {
+ n1 = AndExpression();
+ n0 = new NodeChoice(n1, 0);
+ } else if (jj_2_7(2147483647)) {
+ n2 = CompareExpression();
+ n0 = new NodeChoice(n2, 1);
+ } else if (jj_2_8(2147483647)) {
+ n3 = PlusExpression();
+ n0 = new NodeChoice(n3, 2);
+ } else if (jj_2_9(2147483647)) {
+ n4 = MinusExpression();
+ n0 = new NodeChoice(n4, 3);
+ } else if (jj_2_10(2147483647)) {
+ n5 = TimesExpression();
+ n0 = new NodeChoice(n5, 4);
+ } else if (jj_2_11(2147483647)) {
+ n6 = ArrayLookup();
+ n0 = new NodeChoice(n6, 5);
+ } else if (jj_2_12(2147483647)) {
+ n7 = ArrayLength();
+ n0 = new NodeChoice(n7, 6);
+ } else if (jj_2_13(2147483647)) {
+ n8 = MessageSend();
+ n0 = new NodeChoice(n8, 7);
+ } else {
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case LPAREN:
+ case NOT:
+ case FALSE:
+ case NEW:
+ case THIS:
+ case TRUE:
+ case INTEGER_LITERAL:
+ case IDENTIFIER:
+ n9 = PrimaryExpression();
+ n0 = new NodeChoice(n9, 8);
+ break;
+ default:
+ jj_la1[13] = jj_gen;
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ }
+ {if (true) return new Expression(n0);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public AndExpression AndExpression() throws ParseException {
+ PrimaryExpression n0;
+ NodeToken n1;
+ Token n2;
+ PrimaryExpression n3;
+ n0 = PrimaryExpression();
+ n2 = jj_consume_token(AND);
+ n1 = JTBToolkit.makeNodeToken(n2);
+ n3 = PrimaryExpression();
+ {if (true) return new AndExpression(n0,n1,n3);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public CompareExpression CompareExpression() throws ParseException {
+ PrimaryExpression n0;
+ NodeToken n1;
+ Token n2;
+ PrimaryExpression n3;
+ n0 = PrimaryExpression();
+ n2 = jj_consume_token(LT);
+ n1 = JTBToolkit.makeNodeToken(n2);
+ n3 = PrimaryExpression();
+ {if (true) return new CompareExpression(n0,n1,n3);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public PlusExpression PlusExpression() throws ParseException {
+ PrimaryExpression n0;
+ NodeToken n1;
+ Token n2;
+ PrimaryExpression n3;
+ n0 = PrimaryExpression();
+ n2 = jj_consume_token(PLUS);
+ n1 = JTBToolkit.makeNodeToken(n2);
+ n3 = PrimaryExpression();
+ {if (true) return new PlusExpression(n0,n1,n3);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public MinusExpression MinusExpression() throws ParseException {
+ PrimaryExpression n0;
+ NodeToken n1;
+ Token n2;
+ PrimaryExpression n3;
+ n0 = PrimaryExpression();
+ n2 = jj_consume_token(MINUS);
+ n1 = JTBToolkit.makeNodeToken(n2);
+ n3 = PrimaryExpression();
+ {if (true) return new MinusExpression(n0,n1,n3);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public TimesExpression TimesExpression() throws ParseException {
+ PrimaryExpression n0;
+ NodeToken n1;
+ Token n2;
+ PrimaryExpression n3;
+ n0 = PrimaryExpression();
+ n2 = jj_consume_token(48);
+ n1 = JTBToolkit.makeNodeToken(n2);
+ n3 = PrimaryExpression();
+ {if (true) return new TimesExpression(n0,n1,n3);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public ArrayLookup ArrayLookup() throws ParseException {
+ PrimaryExpression n0;
+ NodeToken n1;
+ Token n2;
+ PrimaryExpression n3;
+ NodeToken n4;
+ Token n5;
+ n0 = PrimaryExpression();
+ n2 = jj_consume_token(LSQPAREN);
+ n1 = JTBToolkit.makeNodeToken(n2);
+ n3 = PrimaryExpression();
+ n5 = jj_consume_token(RSQPAREN);
+ n4 = JTBToolkit.makeNodeToken(n5);
+ {if (true) return new ArrayLookup(n0,n1,n3,n4);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public ArrayLength ArrayLength() throws ParseException {
+ PrimaryExpression n0;
+ NodeToken n1;
+ Token n2;
+ NodeToken n3;
+ Token n4;
+ n0 = PrimaryExpression();
+ n2 = jj_consume_token(DOT);
+ n1 = JTBToolkit.makeNodeToken(n2);
+ n4 = jj_consume_token(LENGTH);
+ n3 = JTBToolkit.makeNodeToken(n4);
+ {if (true) return new ArrayLength(n0,n1,n3);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public MessageSend MessageSend() throws ParseException {
+ PrimaryExpression n0;
+ NodeToken n1;
+ Token n2;
+ Identifier n3;
+ NodeToken n4;
+ Token n5;
+ NodeOptional n6 = new NodeOptional();
+ ExpressionList n7;
+ NodeToken n8;
+ Token n9;
+ n0 = PrimaryExpression();
+ n2 = jj_consume_token(DOT);
+ n1 = JTBToolkit.makeNodeToken(n2);
+ n3 = Identifier();
+ n5 = jj_consume_token(LPAREN);
+ n4 = JTBToolkit.makeNodeToken(n5);
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case LPAREN:
+ case NOT:
+ case FALSE:
+ case NEW:
+ case THIS:
+ case TRUE:
+ case INTEGER_LITERAL:
+ case IDENTIFIER:
+ n7 = ExpressionList();
+ n6.addNode(n7);
+ break;
+ default:
+ jj_la1[14] = jj_gen;
+ ;
+ }
+ n9 = jj_consume_token(RPAREN);
+ n8 = JTBToolkit.makeNodeToken(n9);
+ {if (true) return new MessageSend(n0,n1,n3,n4,n6,n8);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public ExpressionList ExpressionList() throws ParseException {
+ Expression n0;
+ NodeListOptional n1 = new NodeListOptional();
+ ExpressionRest n2;
+ n0 = Expression();
+ label_10:
+ while (true) {
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case 47:
+ ;
+ break;
+ default:
+ jj_la1[15] = jj_gen;
+ break label_10;
+ }
+ n2 = ExpressionRest();
+ n1.addNode(n2);
+ }
+ n1.nodes.trimToSize();
+ {if (true) return new ExpressionList(n0,n1);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public ExpressionRest ExpressionRest() throws ParseException {
+ NodeToken n0;
+ Token n1;
+ Expression n2;
+ n1 = jj_consume_token(47);
+ n0 = JTBToolkit.makeNodeToken(n1);
+ n2 = Expression();
+ {if (true) return new ExpressionRest(n0,n2);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public PrimaryExpression PrimaryExpression() throws ParseException {
+ NodeChoice n0;
+ IntegerLiteral n1;
+ TrueLiteral n2;
+ FalseLiteral n3;
+ Identifier n4;
+ ThisExpression n5;
+ ArrayAllocationExpression n6;
+ AllocationExpression n7;
+ NotExpression n8;
+ BracketExpression n9;
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case INTEGER_LITERAL:
+ n1 = IntegerLiteral();
+ n0 = new NodeChoice(n1, 0);
+ break;
+ case TRUE:
+ n2 = TrueLiteral();
+ n0 = new NodeChoice(n2, 1);
+ break;
+ case FALSE:
+ n3 = FalseLiteral();
+ n0 = new NodeChoice(n3, 2);
+ break;
+ case IDENTIFIER:
+ n4 = Identifier();
+ n0 = new NodeChoice(n4, 3);
+ break;
+ case THIS:
+ n5 = ThisExpression();
+ n0 = new NodeChoice(n5, 4);
+ break;
+ default:
+ jj_la1[16] = jj_gen;
+ if (jj_2_14(3)) {
+ n6 = ArrayAllocationExpression();
+ n0 = new NodeChoice(n6, 5);
+ } else {
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case NEW:
+ n7 = AllocationExpression();
+ n0 = new NodeChoice(n7, 6);
+ break;
+ case NOT:
+ n8 = NotExpression();
+ n0 = new NodeChoice(n8, 7);
+ break;
+ case LPAREN:
+ n9 = BracketExpression();
+ n0 = new NodeChoice(n9, 8);
+ break;
+ default:
+ jj_la1[17] = jj_gen;
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ }
+ }
+ {if (true) return new PrimaryExpression(n0);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public IntegerLiteral IntegerLiteral() throws ParseException {
+ NodeToken n0;
+ Token n1;
+ n1 = jj_consume_token(INTEGER_LITERAL);
+ n0 = JTBToolkit.makeNodeToken(n1);
+ {if (true) return new IntegerLiteral(n0);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public TrueLiteral TrueLiteral() throws ParseException {
+ NodeToken n0;
+ Token n1;
+ n1 = jj_consume_token(TRUE);
+ n0 = JTBToolkit.makeNodeToken(n1);
+ {if (true) return new TrueLiteral(n0);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public FalseLiteral FalseLiteral() throws ParseException {
+ NodeToken n0;
+ Token n1;
+ n1 = jj_consume_token(FALSE);
+ n0 = JTBToolkit.makeNodeToken(n1);
+ {if (true) return new FalseLiteral(n0);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public Identifier Identifier() throws ParseException {
+ NodeToken n0;
+ Token n1;
+ n1 = jj_consume_token(IDENTIFIER);
+ n0 = JTBToolkit.makeNodeToken(n1);
+ {if (true) return new Identifier(n0);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public ThisExpression ThisExpression() throws ParseException {
+ NodeToken n0;
+ Token n1;
+ n1 = jj_consume_token(THIS);
+ n0 = JTBToolkit.makeNodeToken(n1);
+ {if (true) return new ThisExpression(n0);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public ArrayAllocationExpression ArrayAllocationExpression() throws ParseException {
+ NodeToken n0;
+ Token n1;
+ NodeToken n2;
+ Token n3;
+ NodeToken n4;
+ Token n5;
+ Expression n6;
+ NodeToken n7;
+ Token n8;
+ n1 = jj_consume_token(NEW);
+ n0 = JTBToolkit.makeNodeToken(n1);
+ n3 = jj_consume_token(INTEGER);
+ n2 = JTBToolkit.makeNodeToken(n3);
+ n5 = jj_consume_token(LSQPAREN);
+ n4 = JTBToolkit.makeNodeToken(n5);
+ n6 = Expression();
+ n8 = jj_consume_token(RSQPAREN);
+ n7 = JTBToolkit.makeNodeToken(n8);
+ {if (true) return new ArrayAllocationExpression(n0,n2,n4,n6,n7);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public AllocationExpression AllocationExpression() throws ParseException {
+ NodeToken n0;
+ Token n1;
+ Identifier n2;
+ NodeToken n3;
+ Token n4;
+ NodeToken n5;
+ Token n6;
+ n1 = jj_consume_token(NEW);
+ n0 = JTBToolkit.makeNodeToken(n1);
+ n2 = Identifier();
+ n4 = jj_consume_token(LPAREN);
+ n3 = JTBToolkit.makeNodeToken(n4);
+ n6 = jj_consume_token(RPAREN);
+ n5 = JTBToolkit.makeNodeToken(n6);
+ {if (true) return new AllocationExpression(n0,n2,n3,n5);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public NotExpression NotExpression() throws ParseException {
+ NodeToken n0;
+ Token n1;
+ Expression n2;
+ n1 = jj_consume_token(NOT);
+ n0 = JTBToolkit.makeNodeToken(n1);
+ n2 = Expression();
+ {if (true) return new NotExpression(n0,n2);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public BracketExpression BracketExpression() throws ParseException {
+ NodeToken n0;
+ Token n1;
+ Expression n2;
+ NodeToken n3;
+ Token n4;
+ n1 = jj_consume_token(LPAREN);
+ n0 = JTBToolkit.makeNodeToken(n1);
+ n2 = Expression();
+ n4 = jj_consume_token(RPAREN);
+ n3 = JTBToolkit.makeNodeToken(n4);
+ {if (true) return new BracketExpression(n0,n2,n3);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final private boolean jj_2_1(int xla) {
+ jj_la = xla; jj_lastpos = jj_scanpos = token;
+ try { return !jj_3_1(); }
+ catch(LookaheadSuccess ls) { return true; }
+ finally { jj_save(0, xla); }
+ }
+
+ static final private boolean jj_2_2(int xla) {
+ jj_la = xla; jj_lastpos = jj_scanpos = token;
+ try { return !jj_3_2(); }
+ catch(LookaheadSuccess ls) { return true; }
+ finally { jj_save(1, xla); }
+ }
+
+ static final private boolean jj_2_3(int xla) {
+ jj_la = xla; jj_lastpos = jj_scanpos = token;
+ try { return !jj_3_3(); }
+ catch(LookaheadSuccess ls) { return true; }
+ finally { jj_save(2, xla); }
+ }
+
+ static final private boolean jj_2_4(int xla) {
+ jj_la = xla; jj_lastpos = jj_scanpos = token;
+ try { return !jj_3_4(); }
+ catch(LookaheadSuccess ls) { return true; }
+ finally { jj_save(3, xla); }
+ }
+
+ static final private boolean jj_2_5(int xla) {
+ jj_la = xla; jj_lastpos = jj_scanpos = token;
+ try { return !jj_3_5(); }
+ catch(LookaheadSuccess ls) { return true; }
+ finally { jj_save(4, xla); }
+ }
+
+ static final private boolean jj_2_6(int xla) {
+ jj_la = xla; jj_lastpos = jj_scanpos = token;
+ try { return !jj_3_6(); }
+ catch(LookaheadSuccess ls) { return true; }
+ finally { jj_save(5, xla); }
+ }
+
+ static final private boolean jj_2_7(int xla) {
+ jj_la = xla; jj_lastpos = jj_scanpos = token;
+ try { return !jj_3_7(); }
+ catch(LookaheadSuccess ls) { return true; }
+ finally { jj_save(6, xla); }
+ }
+
+ static final private boolean jj_2_8(int xla) {
+ jj_la = xla; jj_lastpos = jj_scanpos = token;
+ try { return !jj_3_8(); }
+ catch(LookaheadSuccess ls) { return true; }
+ finally { jj_save(7, xla); }
+ }
+
+ static final private boolean jj_2_9(int xla) {
+ jj_la = xla; jj_lastpos = jj_scanpos = token;
+ try { return !jj_3_9(); }
+ catch(LookaheadSuccess ls) { return true; }
+ finally { jj_save(8, xla); }
+ }
+
+ static final private boolean jj_2_10(int xla) {
+ jj_la = xla; jj_lastpos = jj_scanpos = token;
+ try { return !jj_3_10(); }
+ catch(LookaheadSuccess ls) { return true; }
+ finally { jj_save(9, xla); }
+ }
+
+ static final private boolean jj_2_11(int xla) {
+ jj_la = xla; jj_lastpos = jj_scanpos = token;
+ try { return !jj_3_11(); }
+ catch(LookaheadSuccess ls) { return true; }
+ finally { jj_save(10, xla); }
+ }
+
+ static final private boolean jj_2_12(int xla) {
+ jj_la = xla; jj_lastpos = jj_scanpos = token;
+ try { return !jj_3_12(); }
+ catch(LookaheadSuccess ls) { return true; }
+ finally { jj_save(11, xla); }
+ }
+
+ static final private boolean jj_2_13(int xla) {
+ jj_la = xla; jj_lastpos = jj_scanpos = token;
+ try { return !jj_3_13(); }
+ catch(LookaheadSuccess ls) { return true; }
+ finally { jj_save(12, xla); }
+ }
+
+ static final private boolean jj_2_14(int xla) {
+ jj_la = xla; jj_lastpos = jj_scanpos = token;
+ try { return !jj_3_14(); }
+ catch(LookaheadSuccess ls) { return true; }
+ finally { jj_save(13, xla); }
+ }
+
+ static final private boolean jj_3R_57() {
+ if (jj_3R_16()) return true;
+ if (jj_scan_token(DOT)) return true;
+ if (jj_3R_17()) return true;
+ if (jj_scan_token(LPAREN)) return true;
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_58()) jj_scanpos = xsp;
+ if (jj_scan_token(RPAREN)) return true;
+ return false;
+ }
+
+ static final private boolean jj_3R_52() {
+ if (jj_3R_16()) return true;
+ if (jj_scan_token(PLUS)) return true;
+ if (jj_3R_16()) return true;
+ return false;
+ }
+
+ static final private boolean jj_3R_27() {
+ if (jj_3R_37()) return true;
+ return false;
+ }
+
+ static final private boolean jj_3R_39() {
+ if (jj_scan_token(INTEGER)) return true;
+ return false;
+ }
+
+ static final private boolean jj_3R_26() {
+ if (jj_3R_36()) return true;
+ return false;
+ }
+
+ static final private boolean jj_3R_25() {
+ if (jj_3R_35()) return true;
+ return false;
+ }
+
+ static final private boolean jj_3_14() {
+ if (jj_3R_18()) return true;
+ return false;
+ }
+
+ static final private boolean jj_3R_18() {
+ if (jj_scan_token(NEW)) return true;
+ if (jj_scan_token(INTEGER)) return true;
+ if (jj_scan_token(LSQPAREN)) return true;
+ if (jj_3R_40()) return true;
+ if (jj_scan_token(RSQPAREN)) return true;
+ return false;
+ }
+
+ static final private boolean jj_3R_24() {
+ if (jj_3R_34()) return true;
+ return false;
+ }
+
+ static final private boolean jj_3R_51() {
+ if (jj_3R_16()) return true;
+ if (jj_scan_token(LT)) return true;
+ if (jj_3R_16()) return true;
+ return false;
+ }
+
+ static final private boolean jj_3R_38() {
+ if (jj_scan_token(BOOLEAN)) return true;
+ return false;
+ }
+
+ static final private boolean jj_3R_23() {
+ if (jj_3R_17()) return true;
+ return false;
+ }
+
+ static final private boolean jj_3R_14() {
+ if (jj_3R_17()) return true;
+ if (jj_scan_token(ASSIGN)) return true;
+ return false;
+ }
+
+ static final private boolean jj_3R_22() {
+ if (jj_3R_33()) return true;
+ return false;
+ }
+
+ static final private boolean jj_3R_56() {
+ if (jj_3R_16()) return true;
+ if (jj_scan_token(DOT)) return true;
+ if (jj_scan_token(LENGTH)) return true;
+ return false;
+ }
+
+ static final private boolean jj_3R_21() {
+ if (jj_3R_32()) return true;
+ return false;
+ }
+
+ static final private boolean jj_3R_20() {
+ if (jj_3R_31()) return true;
+ return false;
+ }
+
+ static final private boolean jj_3R_13() {
+ if (jj_scan_token(INTEGER)) return true;
+ if (jj_scan_token(LSQPAREN)) return true;
+ if (jj_scan_token(RSQPAREN)) return true;
+ return false;
+ }
+
+ static final private boolean jj_3R_16() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_20()) {
+ jj_scanpos = xsp;
+ if (jj_3R_21()) {
+ jj_scanpos = xsp;
+ if (jj_3R_22()) {
+ jj_scanpos = xsp;
+ if (jj_3R_23()) {
+ jj_scanpos = xsp;
+ if (jj_3R_24()) {
+ jj_scanpos = xsp;
+ if (jj_3_14()) {
+ jj_scanpos = xsp;
+ if (jj_3R_25()) {
+ jj_scanpos = xsp;
+ if (jj_3R_26()) {
+ jj_scanpos = xsp;
+ if (jj_3R_27()) return true;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ static final private boolean jj_3R_50() {
+ if (jj_3R_16()) return true;
+ if (jj_scan_token(AND)) return true;
+ if (jj_3R_16()) return true;
+ return false;
+ }
+
+ static final private boolean jj_3R_34() {
+ if (jj_scan_token(THIS)) return true;
+ return false;
+ }
+
+ static final private boolean jj_3_2() {
+ if (jj_3R_12()) return true;
+ return false;
+ }
+
+ static final private boolean jj_3R_55() {
+ if (jj_3R_16()) return true;
+ if (jj_scan_token(LSQPAREN)) return true;
+ if (jj_3R_16()) return true;
+ if (jj_scan_token(RSQPAREN)) return true;
+ return false;
+ }
+
+ static final private boolean jj_3_13() {
+ if (jj_3R_16()) return true;
+ if (jj_scan_token(DOT)) return true;
+ if (jj_3R_17()) return true;
+ if (jj_scan_token(LPAREN)) return true;
+ return false;
+ }
+
+ static final private boolean jj_3_12() {
+ if (jj_3R_16()) return true;
+ if (jj_scan_token(DOT)) return true;
+ if (jj_scan_token(LENGTH)) return true;
+ return false;
+ }
+
+ static final private boolean jj_3R_17() {
+ if (jj_scan_token(IDENTIFIER)) return true;
+ return false;
+ }
+
+ static final private boolean jj_3R_49() {
+ if (jj_3R_16()) return true;
+ return false;
+ }
+
+ static final private boolean jj_3R_30() {
+ if (jj_3R_17()) return true;
+ return false;
+ }
+
+ static final private boolean jj_3_11() {
+ if (jj_3R_16()) return true;
+ if (jj_scan_token(LSQPAREN)) return true;
+ return false;
+ }
+
+ static final private boolean jj_3R_29() {
+ if (jj_3R_39()) return true;
+ return false;
+ }
+
+ static final private boolean jj_3R_48() {
+ if (jj_3R_57()) return true;
+ return false;
+ }
+
+ static final private boolean jj_3R_37() {
+ if (jj_scan_token(LPAREN)) return true;
+ if (jj_3R_40()) return true;
+ if (jj_scan_token(RPAREN)) return true;
+ return false;
+ }
+
+ static final private boolean jj_3R_61() {
+ if (jj_scan_token(47)) return true;
+ if (jj_3R_40()) return true;
+ return false;
+ }
+
+ static final private boolean jj_3R_28() {
+ if (jj_3R_38()) return true;
+ return false;
+ }
+
+ static final private boolean jj_3_10() {
+ if (jj_3R_16()) return true;
+ if (jj_scan_token(48)) return true;
+ return false;
+ }
+
+ static final private boolean jj_3R_47() {
+ if (jj_3R_56()) return true;
+ return false;
+ }
+
+ static final private boolean jj_3_3() {
+ if (jj_3R_13()) return true;
+ return false;
+ }
+
+ static final private boolean jj_3_9() {
+ if (jj_3R_16()) return true;
+ if (jj_scan_token(MINUS)) return true;
+ return false;
+ }
+
+ static final private boolean jj_3R_46() {
+ if (jj_3R_55()) return true;
+ return false;
+ }
+
+ static final private boolean jj_3R_33() {
+ if (jj_scan_token(FALSE)) return true;
+ return false;
+ }
+
+ static final private boolean jj_3R_54() {
+ if (jj_3R_16()) return true;
+ if (jj_scan_token(48)) return true;
+ if (jj_3R_16()) return true;
+ return false;
+ }
+
+ static final private boolean jj_3R_19() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3_3()) {
+ jj_scanpos = xsp;
+ if (jj_3R_28()) {
+ jj_scanpos = xsp;
+ if (jj_3R_29()) {
+ jj_scanpos = xsp;
+ if (jj_3R_30()) return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ static final private boolean jj_3_8() {
+ if (jj_3R_16()) return true;
+ if (jj_scan_token(PLUS)) return true;
+ return false;
+ }
+
+ static final private boolean jj_3R_45() {
+ if (jj_3R_54()) return true;
+ return false;
+ }
+
+ static final private boolean jj_3R_11() {
+ if (jj_scan_token(CLASS)) return true;
+ if (jj_3R_17()) return true;
+ if (jj_scan_token(LBRACE)) return true;
+ return false;
+ }
+
+ static final private boolean jj_3_7() {
+ if (jj_3R_16()) return true;
+ if (jj_scan_token(LT)) return true;
+ return false;
+ }
+
+ static final private boolean jj_3R_60() {
+ if (jj_3R_61()) return true;
+ return false;
+ }
+
+ static final private boolean jj_3R_44() {
+ if (jj_3R_53()) return true;
+ return false;
+ }
+
+ static final private boolean jj_3R_36() {
+ if (jj_scan_token(NOT)) return true;
+ if (jj_3R_40()) return true;
+ return false;
+ }
+
+ static final private boolean jj_3_5() {
+ if (jj_3R_15()) return true;
+ return false;
+ }
+
+ static final private boolean jj_3_6() {
+ if (jj_3R_16()) return true;
+ if (jj_scan_token(AND)) return true;
+ return false;
+ }
+
+ static final private boolean jj_3R_43() {
+ if (jj_3R_52()) return true;
+ return false;
+ }
+
+ static final private boolean jj_3R_59() {
+ if (jj_3R_40()) return true;
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3R_60()) { jj_scanpos = xsp; break; }
+ }
+ return false;
+ }
+
+ static final private boolean jj_3R_32() {
+ if (jj_scan_token(TRUE)) return true;
+ return false;
+ }
+
+ static final private boolean jj_3_4() {
+ if (jj_3R_14()) return true;
+ return false;
+ }
+
+ static final private boolean jj_3R_42() {
+ if (jj_3R_51()) return true;
+ return false;
+ }
+
+ static final private boolean jj_3R_53() {
+ if (jj_3R_16()) return true;
+ if (jj_scan_token(MINUS)) return true;
+ if (jj_3R_16()) return true;
+ return false;
+ }
+
+ static final private boolean jj_3R_41() {
+ if (jj_3R_50()) return true;
+ return false;
+ }
+
+ static final private boolean jj_3R_40() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_41()) {
+ jj_scanpos = xsp;
+ if (jj_3R_42()) {
+ jj_scanpos = xsp;
+ if (jj_3R_43()) {
+ jj_scanpos = xsp;
+ if (jj_3R_44()) {
+ jj_scanpos = xsp;
+ if (jj_3R_45()) {
+ jj_scanpos = xsp;
+ if (jj_3R_46()) {
+ jj_scanpos = xsp;
+ if (jj_3R_47()) {
+ jj_scanpos = xsp;
+ if (jj_3R_48()) {
+ jj_scanpos = xsp;
+ if (jj_3R_49()) return true;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ static final private boolean jj_3R_31() {
+ if (jj_scan_token(INTEGER_LITERAL)) return true;
+ return false;
+ }
+
+ static final private boolean jj_3R_58() {
+ if (jj_3R_59()) return true;
+ return false;
+ }
+
+ static final private boolean jj_3R_35() {
+ if (jj_scan_token(NEW)) return true;
+ if (jj_3R_17()) return true;
+ if (jj_scan_token(LPAREN)) return true;
+ if (jj_scan_token(RPAREN)) return true;
+ return false;
+ }
+
+ static final private boolean jj_3_1() {
+ if (jj_3R_11()) return true;
+ return false;
+ }
+
+ static final private boolean jj_3R_12() {
+ if (jj_3R_19()) return true;
+ if (jj_3R_17()) return true;
+ return false;
+ }
+
+ static final private boolean jj_3R_15() {
+ if (jj_3R_17()) return true;
+ if (jj_scan_token(LSQPAREN)) return true;
+ return false;
+ }
+
+ static private boolean jj_initialized_once = false;
+ static public MiniJavaParserTokenManager token_source;
+ static JavaCharStream jj_input_stream;
+ static public Token token, jj_nt;
+ static private int jj_ntk;
+ static private Token jj_scanpos, jj_lastpos;
+ static private int jj_la;
+ static public boolean lookingAhead = false;
+ static private boolean jj_semLA;
+ static private int jj_gen;
+ static final private int[] jj_la1 = new int[18];
+ static private int[] jj_la1_0;
+ static private int[] jj_la1_1;
+ static {
+ jj_la1_0();
+ jj_la1_1();
+ }
+ private static void jj_la1_0() {
+ jj_la1_0 = new int[] {0x1000000,0x1000000,0x80800000,0x0,0x80800000,0x0,0x80800000,0x60002000,0x0,0x80800000,0x2000,0x60000000,0x60002000,0x10400200,0x10400200,0x0,0x10000000,0x400200,};
+ }
+ private static void jj_la1_1() {
+ jj_la1_1 = new int[] {0x0,0x0,0x1000,0x8,0x1000,0x8,0x1000,0x1200,0x8000,0x1000,0x0,0x200,0x1200,0x1984,0x1984,0x8000,0x1980,0x4,};
+ }
+ static final private JJCalls[] jj_2_rtns = new JJCalls[14];
+ static private boolean jj_rescan = false;
+ static private int jj_gc = 0;
+
+ public MiniJavaParser(java.io.InputStream stream) {
+ this(stream, null);
+ }
+ public MiniJavaParser(java.io.InputStream stream, String encoding) {
+ if (jj_initialized_once) {
+ System.out.println("ERROR: Second call to constructor of static parser. You must");
+ System.out.println(" either use ReInit() or set the JavaCC option STATIC to false");
+ System.out.println(" during parser generation.");
+ throw new Error();
+ }
+ jj_initialized_once = true;
+ try { jj_input_stream = new JavaCharStream(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); }
+ token_source = new MiniJavaParserTokenManager(jj_input_stream);
+ token = new Token();
+ jj_ntk = -1;
+ jj_gen = 0;
+ for (int i = 0; i < 18; i++) jj_la1[i] = -1;
+ for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
+ }
+
+ static public void ReInit(java.io.InputStream stream) {
+ ReInit(stream, null);
+ }
+ static public void ReInit(java.io.InputStream stream, String encoding) {
+ try { jj_input_stream.ReInit(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); }
+ token_source.ReInit(jj_input_stream);
+ token = new Token();
+ jj_ntk = -1;
+ jj_gen = 0;
+ for (int i = 0; i < 18; i++) jj_la1[i] = -1;
+ for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
+ }
+
+ public MiniJavaParser(java.io.Reader stream) {
+ if (jj_initialized_once) {
+ System.out.println("ERROR: Second call to constructor of static parser. You must");
+ System.out.println(" either use ReInit() or set the JavaCC option STATIC to false");
+ System.out.println(" during parser generation.");
+ throw new Error();
+ }
+ jj_initialized_once = true;
+ jj_input_stream = new JavaCharStream(stream, 1, 1);
+ token_source = new MiniJavaParserTokenManager(jj_input_stream);
+ token = new Token();
+ jj_ntk = -1;
+ jj_gen = 0;
+ for (int i = 0; i < 18; i++) jj_la1[i] = -1;
+ for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
+ }
+
+ static public void ReInit(java.io.Reader stream) {
+ jj_input_stream.ReInit(stream, 1, 1);
+ token_source.ReInit(jj_input_stream);
+ token = new Token();
+ jj_ntk = -1;
+ jj_gen = 0;
+ for (int i = 0; i < 18; i++) jj_la1[i] = -1;
+ for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
+ }
+
+ public MiniJavaParser(MiniJavaParserTokenManager tm) {
+ if (jj_initialized_once) {
+ System.out.println("ERROR: Second call to constructor of static parser. You must");
+ System.out.println(" either use ReInit() or set the JavaCC option STATIC to false");
+ System.out.println(" during parser generation.");
+ throw new Error();
+ }
+ jj_initialized_once = true;
+ token_source = tm;
+ token = new Token();
+ jj_ntk = -1;
+ jj_gen = 0;
+ for (int i = 0; i < 18; i++) jj_la1[i] = -1;
+ for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
+ }
+
+ public void ReInit(MiniJavaParserTokenManager tm) {
+ token_source = tm;
+ token = new Token();
+ jj_ntk = -1;
+ jj_gen = 0;
+ for (int i = 0; i < 18; i++) jj_la1[i] = -1;
+ for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
+ }
+
+ static final private Token jj_consume_token(int kind) throws ParseException {
+ Token oldToken;
+ if ((oldToken = token).next != null) token = token.next;
+ else token = token.next = token_source.getNextToken();
+ jj_ntk = -1;
+ if (token.kind == kind) {
+ jj_gen++;
+ if (++jj_gc > 100) {
+ jj_gc = 0;
+ for (int i = 0; i < jj_2_rtns.length; i++) {
+ JJCalls c = jj_2_rtns[i];
+ while (c != null) {
+ if (c.gen < jj_gen) c.first = null;
+ c = c.next;
+ }
+ }
+ }
+ return token;
+ }
+ token = oldToken;
+ jj_kind = kind;
+ throw generateParseException();
+ }
+
+ static private final class LookaheadSuccess extends java.lang.Error { }
+ static final private LookaheadSuccess jj_ls = new LookaheadSuccess();
+ static final private boolean jj_scan_token(int kind) {
+ if (jj_scanpos == jj_lastpos) {
+ jj_la--;
+ if (jj_scanpos.next == null) {
+ jj_lastpos = jj_scanpos = jj_scanpos.next = token_source.getNextToken();
+ } else {
+ jj_lastpos = jj_scanpos = jj_scanpos.next;
+ }
+ } else {
+ jj_scanpos = jj_scanpos.next;
+ }
+ if (jj_rescan) {
+ int i = 0; Token tok = token;
+ while (tok != null && tok != jj_scanpos) { i++; tok = tok.next; }
+ if (tok != null) jj_add_error_token(kind, i);
+ }
+ if (jj_scanpos.kind != kind) return true;
+ if (jj_la == 0 && jj_scanpos == jj_lastpos) throw jj_ls;
+ return false;
+ }
+
+ static final public Token getNextToken() {
+ if (token.next != null) token = token.next;
+ else token = token.next = token_source.getNextToken();
+ jj_ntk = -1;
+ jj_gen++;
+ return token;
+ }
+
+ static final public Token getToken(int index) {
+ Token t = lookingAhead ? jj_scanpos : token;
+ for (int i = 0; i < index; i++) {
+ if (t.next != null) t = t.next;
+ else t = t.next = token_source.getNextToken();
+ }
+ return t;
+ }
+
+ static final private int jj_ntk() {
+ if ((jj_nt=token.next) == null)
+ return (jj_ntk = (token.next=token_source.getNextToken()).kind);
+ else
+ return (jj_ntk = jj_nt.kind);
+ }
+
+ static private java.util.Vector jj_expentries = new java.util.Vector();
+ static private int[] jj_expentry;
+ static private int jj_kind = -1;
+ static private int[] jj_lasttokens = new int[100];
+ static private int jj_endpos;
+
+ static private void jj_add_error_token(int kind, int pos) {
+ if (pos >= 100) return;
+ if (pos == jj_endpos + 1) {
+ jj_lasttokens[jj_endpos++] = kind;
+ } else if (jj_endpos != 0) {
+ jj_expentry = new int[jj_endpos];
+ for (int i = 0; i < jj_endpos; i++) {
+ jj_expentry[i] = jj_lasttokens[i];
+ }
+ boolean exists = false;
+ for (java.util.Enumeration e = jj_expentries.elements(); e.hasMoreElements();) {
+ int[] oldentry = (int[])(e.nextElement());
+ if (oldentry.length == jj_expentry.length) {
+ exists = true;
+ for (int i = 0; i < jj_expentry.length; i++) {
+ if (oldentry[i] != jj_expentry[i]) {
+ exists = false;
+ break;
+ }
+ }
+ if (exists) break;
+ }
+ }
+ if (!exists) jj_expentries.addElement(jj_expentry);
+ if (pos != 0) jj_lasttokens[(jj_endpos = pos) - 1] = kind;
+ }
+ }
+
+ static public ParseException generateParseException() {
+ jj_expentries.removeAllElements();
+ boolean[] la1tokens = new boolean[49];
+ for (int i = 0; i < 49; i++) {
+ la1tokens[i] = false;
+ }
+ if (jj_kind >= 0) {
+ la1tokens[jj_kind] = true;
+ jj_kind = -1;
+ }
+ for (int i = 0; i < 18; i++) {
+ if (jj_la1[i] == jj_gen) {
+ for (int j = 0; j < 32; j++) {
+ if ((jj_la1_0[i] & (1<<j)) != 0) {
+ la1tokens[j] = true;
+ }
+ if ((jj_la1_1[i] & (1<<j)) != 0) {
+ la1tokens[32+j] = true;
+ }
+ }
+ }
+ }
+ for (int i = 0; i < 49; i++) {
+ if (la1tokens[i]) {
+ jj_expentry = new int[1];
+ jj_expentry[0] = i;
+ jj_expentries.addElement(jj_expentry);
+ }
+ }
+ jj_endpos = 0;
+ jj_rescan_token();
+ jj_add_error_token(0, 0);
+ int[][] exptokseq = new int[jj_expentries.size()][];
+ for (int i = 0; i < jj_expentries.size(); i++) {
+ exptokseq[i] = (int[])jj_expentries.elementAt(i);
+ }
+ return new ParseException(token, exptokseq, tokenImage);
+ }
+
+ static final public void enable_tracing() {
+ }
+
+ static final public void disable_tracing() {
+ }
+
+ static final private void jj_rescan_token() {
+ jj_rescan = true;
+ for (int i = 0; i < 14; i++) {
+ try {
+ JJCalls p = jj_2_rtns[i];
+ do {
+ if (p.gen > jj_gen) {
+ jj_la = p.arg; jj_lastpos = jj_scanpos = p.first;
+ switch (i) {
+ case 0: jj_3_1(); break;
+ case 1: jj_3_2(); break;
+ case 2: jj_3_3(); break;
+ case 3: jj_3_4(); break;
+ case 4: jj_3_5(); break;
+ case 5: jj_3_6(); break;
+ case 6: jj_3_7(); break;
+ case 7: jj_3_8(); break;
+ case 8: jj_3_9(); break;
+ case 9: jj_3_10(); break;
+ case 10: jj_3_11(); break;
+ case 11: jj_3_12(); break;
+ case 12: jj_3_13(); break;
+ case 13: jj_3_14(); break;
+ }
+ }
+ p = p.next;
+ } while (p != null);
+ } catch(LookaheadSuccess ls) { }
+ }
+ jj_rescan = false;
+ }
+
+ static final private void jj_save(int index, int xla) {
+ JJCalls p = jj_2_rtns[index];
+ while (p.gen > jj_gen) {
+ if (p.next == null) { p = p.next = new JJCalls(); break; }
+ p = p.next;
+ }
+ p.gen = jj_gen + xla - jj_la; p.first = token; p.arg = xla;
+ }
+
+ static final class JJCalls {
+ int gen;
+ Token first;
+ int arg;
+ JJCalls next;
+ }
+
+}
+
+class JTBToolkit {
+ static NodeToken makeNodeToken(Token t) {
+ return new NodeToken(t.image.intern(), t.kind, t.beginLine, t.beginColumn, t.endLine, t.endColumn);
+ }
+}
diff --git a/src/minijava/MiniJavaParserConstants.java b/src/minijava/MiniJavaParserConstants.java
new file mode 100644
index 0000000..c098476
--- /dev/null
+++ b/src/minijava/MiniJavaParserConstants.java
@@ -0,0 +1,102 @@
+package minijava;
+/* Generated By:JavaCC: Do not edit this line. MiniJavaParserConstants.java */
+public interface MiniJavaParserConstants {
+
+ int EOF = 0;
+ int SINGLE_LINE_COMMENT = 6;
+ int FORMAL_COMMENT = 7;
+ int MULTI_LINE_COMMENT = 8;
+ int LPAREN = 9;
+ int RPAREN = 10;
+ int LSQPAREN = 11;
+ int RSQPAREN = 12;
+ int LBRACE = 13;
+ int RBRACE = 14;
+ int SEMICOLON = 15;
+ int DOT = 16;
+ int ASSIGN = 17;
+ int LT = 18;
+ int PLUS = 19;
+ int MINUS = 20;
+ int AND = 21;
+ int NOT = 22;
+ int BOOLEAN = 23;
+ int CLASS = 24;
+ int INTERFACE = 25;
+ int ELSE = 26;
+ int EXTENDS = 27;
+ int FALSE = 28;
+ int IF = 29;
+ int WHILE = 30;
+ int INTEGER = 31;
+ int LENGTH = 32;
+ int MAIN = 33;
+ int NEW = 34;
+ int PUBLIC = 35;
+ int RETURN = 36;
+ int STATIC = 37;
+ int STRING = 38;
+ int THIS = 39;
+ int TRUE = 40;
+ int PRINT = 41;
+ int VOID = 42;
+ int INTEGER_LITERAL = 43;
+ int IDENTIFIER = 44;
+ int LETTER = 45;
+ int DIGIT = 46;
+
+ int DEFAULT = 0;
+
+ String[] tokenImage = {
+ "<EOF>",
+ "\" \"",
+ "\"\\t\"",
+ "\"\\n\"",
+ "\"\\r\"",
+ "\"\\f\"",
+ "<SINGLE_LINE_COMMENT>",
+ "<FORMAL_COMMENT>",
+ "<MULTI_LINE_COMMENT>",
+ "\"(\"",
+ "\")\"",
+ "\"[\"",
+ "\"]\"",
+ "\"{\"",
+ "\"}\"",
+ "\";\"",
+ "\".\"",
+ "\"=\"",
+ "\"<\"",
+ "\"+\"",
+ "\"-\"",
+ "\"&&\"",
+ "\"!\"",
+ "\"boolean\"",
+ "\"class\"",
+ "\"interface\"",
+ "\"else\"",
+ "\"extends\"",
+ "\"false\"",
+ "\"if\"",
+ "\"while\"",
+ "\"int\"",
+ "\"length\"",
+ "\"main\"",
+ "\"new\"",
+ "\"public\"",
+ "\"return\"",
+ "\"static\"",
+ "\"String\"",
+ "\"this\"",
+ "\"true\"",
+ "\"System.out.println\"",
+ "\"void\"",
+ "<INTEGER_LITERAL>",
+ "<IDENTIFIER>",
+ "<LETTER>",
+ "<DIGIT>",
+ "\",\"",
+ "\"*\"",
+ };
+
+}
diff --git a/src/minijava/MiniJavaParserTokenManager.java b/src/minijava/MiniJavaParserTokenManager.java
new file mode 100644
index 0000000..d6be8f7
--- /dev/null
+++ b/src/minijava/MiniJavaParserTokenManager.java
@@ -0,0 +1,1232 @@
+package minijava;
+/* Generated By:JavaCC: Do not edit this line. MiniJavaParserTokenManager.java */
+
+public class MiniJavaParserTokenManager implements MiniJavaParserConstants
+{
+ public static java.io.PrintStream debugStream = System.out;
+ public static void setDebugStream(java.io.PrintStream ds) { debugStream = ds; }
+private static final int jjStopStringLiteralDfa_0(int pos, long active0)
+{
+ switch (pos)
+ {
+ case 0:
+ if ((active0 & 0x7ffff800000L) != 0L)
+ {
+ jjmatchedKind = 44;
+ return 4;
+ }
+ return -1;
+ case 1:
+ if ((active0 & 0x20000000L) != 0L)
+ return 4;
+ if ((active0 & 0x7ffdf800000L) != 0L)
+ {
+ jjmatchedKind = 44;
+ jjmatchedPos = 1;
+ return 4;
+ }
+ return -1;
+ case 2:
+ if ((active0 & 0x482000000L) != 0L)
+ return 4;
+ if ((active0 & 0x7fb5d800000L) != 0L)
+ {
+ if (jjmatchedPos != 2)
+ {
+ jjmatchedKind = 44;
+ jjmatchedPos = 2;
+ }
+ return 4;
+ }
+ return -1;
+ case 3:
+ if ((active0 & 0x58204000000L) != 0L)
+ return 4;
+ if ((active0 & 0x2795b800000L) != 0L)
+ {
+ jjmatchedKind = 44;
+ jjmatchedPos = 3;
+ return 4;
+ }
+ return -1;
+ case 4:
+ if ((active0 & 0x51000000L) != 0L)
+ return 4;
+ if ((active0 & 0x2790a800000L) != 0L)
+ {
+ jjmatchedKind = 44;
+ jjmatchedPos = 4;
+ return 4;
+ }
+ return -1;
+ case 5:
+ if ((active0 & 0x7900000000L) != 0L)
+ return 4;
+ if ((active0 & 0x2000a800000L) != 0L)
+ {
+ jjmatchedKind = 44;
+ jjmatchedPos = 5;
+ return 4;
+ }
+ return -1;
+ case 6:
+ if ((active0 & 0x20000000000L) != 0L)
+ {
+ if (jjmatchedPos < 5)
+ {
+ jjmatchedKind = 44;
+ jjmatchedPos = 5;
+ }
+ return -1;
+ }
+ if ((active0 & 0x8800000L) != 0L)
+ return 4;
+ if ((active0 & 0x2000000L) != 0L)
+ {
+ jjmatchedKind = 44;
+ jjmatchedPos = 6;
+ return 4;
+ }
+ return -1;
+ case 7:
+ if ((active0 & 0x20000000000L) != 0L)
+ {
+ if (jjmatchedPos < 5)
+ {
+ jjmatchedKind = 44;
+ jjmatchedPos = 5;
+ }
+ return -1;
+ }
+ if ((active0 & 0x2000000L) != 0L)
+ {
+ jjmatchedKind = 44;
+ jjmatchedPos = 7;
+ return 4;
+ }
+ return -1;
+ case 8:
+ if ((active0 & 0x20000000000L) != 0L)
+ {
+ if (jjmatchedPos < 5)
+ {
+ jjmatchedKind = 44;
+ jjmatchedPos = 5;
+ }
+ return -1;
+ }
+ if ((active0 & 0x2000000L) != 0L)
+ return 4;
+ return -1;
+ case 9:
+ if ((active0 & 0x20000000000L) != 0L)
+ {
+ if (jjmatchedPos < 5)
+ {
+ jjmatchedKind = 44;
+ jjmatchedPos = 5;
+ }
+ return -1;
+ }
+ return -1;
+ case 10:
+ if ((active0 & 0x20000000000L) != 0L)
+ {
+ if (jjmatchedPos < 5)
+ {
+ jjmatchedKind = 44;
+ jjmatchedPos = 5;
+ }
+ return -1;
+ }
+ return -1;
+ case 11:
+ if ((active0 & 0x20000000000L) != 0L)
+ {
+ if (jjmatchedPos < 5)
+ {
+ jjmatchedKind = 44;
+ jjmatchedPos = 5;
+ }
+ return -1;
+ }
+ return -1;
+ case 12:
+ if ((active0 & 0x20000000000L) != 0L)
+ {
+ if (jjmatchedPos < 5)
+ {
+ jjmatchedKind = 44;
+ jjmatchedPos = 5;
+ }
+ return -1;
+ }
+ return -1;
+ case 13:
+ if ((active0 & 0x20000000000L) != 0L)
+ {
+ if (jjmatchedPos < 5)
+ {
+ jjmatchedKind = 44;
+ jjmatchedPos = 5;
+ }
+ return -1;
+ }
+ return -1;
+ case 14:
+ if ((active0 & 0x20000000000L) != 0L)
+ {
+ if (jjmatchedPos < 5)
+ {
+ jjmatchedKind = 44;
+ jjmatchedPos = 5;
+ }
+ return -1;
+ }
+ return -1;
+ case 15:
+ if ((active0 & 0x20000000000L) != 0L)
+ {
+ if (jjmatchedPos < 5)
+ {
+ jjmatchedKind = 44;
+ jjmatchedPos = 5;
+ }
+ return -1;
+ }
+ return -1;
+ case 16:
+ if ((active0 & 0x20000000000L) != 0L)
+ {
+ if (jjmatchedPos < 5)
+ {
+ jjmatchedKind = 44;
+ jjmatchedPos = 5;
+ }
+ return -1;
+ }
+ return -1;
+ default :
+ return -1;
+ }
+}
+private static final int jjStartNfa_0(int pos, long active0)
+{
+ return jjMoveNfa_0(jjStopStringLiteralDfa_0(pos, active0), pos + 1);
+}
+static private final int jjStopAtPos(int pos, int kind)
+{
+ jjmatchedKind = kind;
+ jjmatchedPos = pos;
+ return pos + 1;
+}
+static private final int jjStartNfaWithStates_0(int pos, int kind, int state)
+{
+ jjmatchedKind = kind;
+ jjmatchedPos = pos;
+ try { curChar = input_stream.readChar(); }
+ catch(java.io.IOException e) { return pos + 1; }
+ return jjMoveNfa_0(state, pos + 1);
+}
+static private final int jjMoveStringLiteralDfa0_0()
+{
+ switch(curChar)
+ {
+ case 33:
+ return jjStopAtPos(0, 22);
+ case 38:
+ return jjMoveStringLiteralDfa1_0(0x200000L);
+ case 40:
+ return jjStopAtPos(0, 9);
+ case 41:
+ return jjStopAtPos(0, 10);
+ case 42:
+ return jjStopAtPos(0, 48);
+ case 43:
+ return jjStopAtPos(0, 19);
+ case 44:
+ return jjStopAtPos(0, 47);
+ case 45:
+ return jjStopAtPos(0, 20);
+ case 46:
+ return jjStopAtPos(0, 16);
+ case 59:
+ return jjStopAtPos(0, 15);
+ case 60:
+ return jjStopAtPos(0, 18);
+ case 61:
+ return jjStopAtPos(0, 17);
+ case 83:
+ return jjMoveStringLiteralDfa1_0(0x24000000000L);
+ case 91:
+ return jjStopAtPos(0, 11);
+ case 93:
+ return jjStopAtPos(0, 12);
+ case 98:
+ return jjMoveStringLiteralDfa1_0(0x800000L);
+ case 99:
+ return jjMoveStringLiteralDfa1_0(0x1000000L);
+ case 101:
+ return jjMoveStringLiteralDfa1_0(0xc000000L);
+ case 102:
+ return jjMoveStringLiteralDfa1_0(0x10000000L);
+ case 105:
+ return jjMoveStringLiteralDfa1_0(0xa2000000L);
+ case 108:
+ return jjMoveStringLiteralDfa1_0(0x100000000L);
+ case 109:
+ return jjMoveStringLiteralDfa1_0(0x200000000L);
+ case 110:
+ return jjMoveStringLiteralDfa1_0(0x400000000L);
+ case 112:
+ return jjMoveStringLiteralDfa1_0(0x800000000L);
+ case 114:
+ return jjMoveStringLiteralDfa1_0(0x1000000000L);
+ case 115:
+ return jjMoveStringLiteralDfa1_0(0x2000000000L);
+ case 116:
+ return jjMoveStringLiteralDfa1_0(0x18000000000L);
+ case 118:
+ return jjMoveStringLiteralDfa1_0(0x40000000000L);
+ case 119:
+ return jjMoveStringLiteralDfa1_0(0x40000000L);
+ case 123:
+ return jjStopAtPos(0, 13);
+ case 125:
+ return jjStopAtPos(0, 14);
+ default :
+ return jjMoveNfa_0(0, 0);
+ }
+}
+static private final int jjMoveStringLiteralDfa1_0(long active0)
+{
+ try { curChar = input_stream.readChar(); }
+ catch(java.io.IOException e) {
+ jjStopStringLiteralDfa_0(0, active0);
+ return 1;
+ }
+ switch(curChar)
+ {
+ case 38:
+ if ((active0 & 0x200000L) != 0L)
+ return jjStopAtPos(1, 21);
+ break;
+ case 97:
+ return jjMoveStringLiteralDfa2_0(active0, 0x210000000L);
+ case 101:
+ return jjMoveStringLiteralDfa2_0(active0, 0x1500000000L);
+ case 102:
+ if ((active0 & 0x20000000L) != 0L)
+ return jjStartNfaWithStates_0(1, 29, 4);
+ break;
+ case 104:
+ return jjMoveStringLiteralDfa2_0(active0, 0x8040000000L);
+ case 108:
+ return jjMoveStringLiteralDfa2_0(active0, 0x5000000L);
+ case 110:
+ return jjMoveStringLiteralDfa2_0(active0, 0x82000000L);
+ case 111:
+ return jjMoveStringLiteralDfa2_0(active0, 0x40000800000L);
+ case 114:
+ return jjMoveStringLiteralDfa2_0(active0, 0x10000000000L);
+ case 116:
+ return jjMoveStringLiteralDfa2_0(active0, 0x6000000000L);
+ case 117:
+ return jjMoveStringLiteralDfa2_0(active0, 0x800000000L);
+ case 120:
+ return jjMoveStringLiteralDfa2_0(active0, 0x8000000L);
+ case 121:
+ return jjMoveStringLiteralDfa2_0(active0, 0x20000000000L);
+ default :
+ break;
+ }
+ return jjStartNfa_0(0, active0);
+}
+static private final int jjMoveStringLiteralDfa2_0(long old0, long active0)
+{
+ if (((active0 &= old0)) == 0L)
+ return jjStartNfa_0(0, old0);
+ try { curChar = input_stream.readChar(); }
+ catch(java.io.IOException e) {
+ jjStopStringLiteralDfa_0(1, active0);
+ return 2;
+ }
+ switch(curChar)
+ {
+ case 97:
+ return jjMoveStringLiteralDfa3_0(active0, 0x2001000000L);
+ case 98:
+ return jjMoveStringLiteralDfa3_0(active0, 0x800000000L);
+ case 105:
+ return jjMoveStringLiteralDfa3_0(active0, 0x48240000000L);
+ case 108:
+ return jjMoveStringLiteralDfa3_0(active0, 0x10000000L);
+ case 110:
+ return jjMoveStringLiteralDfa3_0(active0, 0x100000000L);
+ case 111:
+ return jjMoveStringLiteralDfa3_0(active0, 0x800000L);
+ case 114:
+ return jjMoveStringLiteralDfa3_0(active0, 0x4000000000L);
+ case 115:
+ return jjMoveStringLiteralDfa3_0(active0, 0x20004000000L);
+ case 116:
+ if ((active0 & 0x80000000L) != 0L)
+ {
+ jjmatchedKind = 31;
+ jjmatchedPos = 2;
+ }
+ return jjMoveStringLiteralDfa3_0(active0, 0x100a000000L);
+ case 117:
+ return jjMoveStringLiteralDfa3_0(active0, 0x10000000000L);
+ case 119:
+ if ((active0 & 0x400000000L) != 0L)
+ return jjStartNfaWithStates_0(2, 34, 4);
+ break;
+ default :
+ break;
+ }
+ return jjStartNfa_0(1, active0);
+}
+static private final int jjMoveStringLiteralDfa3_0(long old0, long active0)
+{
+ if (((active0 &= old0)) == 0L)
+ return jjStartNfa_0(1, old0);
+ try { curChar = input_stream.readChar(); }
+ catch(java.io.IOException e) {
+ jjStopStringLiteralDfa_0(2, active0);
+ return 3;
+ }
+ switch(curChar)
+ {
+ case 100:
+ if ((active0 & 0x40000000000L) != 0L)
+ return jjStartNfaWithStates_0(3, 42, 4);
+ break;
+ case 101:
+ if ((active0 & 0x4000000L) != 0L)
+ return jjStartNfaWithStates_0(3, 26, 4);
+ else if ((active0 & 0x10000000000L) != 0L)
+ return jjStartNfaWithStates_0(3, 40, 4);
+ return jjMoveStringLiteralDfa4_0(active0, 0xa000000L);
+ case 103:
+ return jjMoveStringLiteralDfa4_0(active0, 0x100000000L);
+ case 105:
+ return jjMoveStringLiteralDfa4_0(active0, 0x4000000000L);
+ case 108:
+ return jjMoveStringLiteralDfa4_0(active0, 0x840800000L);
+ case 110:
+ if ((active0 & 0x200000000L) != 0L)
+ return jjStartNfaWithStates_0(3, 33, 4);
+ break;
+ case 115:
+ if ((active0 & 0x8000000000L) != 0L)
+ return jjStartNfaWithStates_0(3, 39, 4);
+ return jjMoveStringLiteralDfa4_0(active0, 0x11000000L);
+ case 116:
+ return jjMoveStringLiteralDfa4_0(active0, 0x22000000000L);
+ case 117:
+ return jjMoveStringLiteralDfa4_0(active0, 0x1000000000L);
+ default :
+ break;
+ }
+ return jjStartNfa_0(2, active0);
+}
+static private final int jjMoveStringLiteralDfa4_0(long old0, long active0)
+{
+ if (((active0 &= old0)) == 0L)
+ return jjStartNfa_0(2, old0);
+ try { curChar = input_stream.readChar(); }
+ catch(java.io.IOException e) {
+ jjStopStringLiteralDfa_0(3, active0);
+ return 4;
+ }
+ switch(curChar)
+ {
+ case 101:
+ if ((active0 & 0x10000000L) != 0L)
+ return jjStartNfaWithStates_0(4, 28, 4);
+ else if ((active0 & 0x40000000L) != 0L)
+ return jjStartNfaWithStates_0(4, 30, 4);
+ return jjMoveStringLiteralDfa5_0(active0, 0x20000800000L);
+ case 105:
+ return jjMoveStringLiteralDfa5_0(active0, 0x2800000000L);
+ case 110:
+ return jjMoveStringLiteralDfa5_0(active0, 0x4008000000L);
+ case 114:
+ return jjMoveStringLiteralDfa5_0(active0, 0x1002000000L);
+ case 115:
+ if ((active0 & 0x1000000L) != 0L)
+ return jjStartNfaWithStates_0(4, 24, 4);
+ break;
+ case 116:
+ return jjMoveStringLiteralDfa5_0(active0, 0x100000000L);
+ default :
+ break;
+ }
+ return jjStartNfa_0(3, active0);
+}
+static private final int jjMoveStringLiteralDfa5_0(long old0, long active0)
+{
+ if (((active0 &= old0)) == 0L)
+ return jjStartNfa_0(3, old0);
+ try { curChar = input_stream.readChar(); }
+ catch(java.io.IOException e) {
+ jjStopStringLiteralDfa_0(4, active0);
+ return 5;
+ }
+ switch(curChar)
+ {
+ case 97:
+ return jjMoveStringLiteralDfa6_0(active0, 0x800000L);
+ case 99:
+ if ((active0 & 0x800000000L) != 0L)
+ return jjStartNfaWithStates_0(5, 35, 4);
+ else if ((active0 & 0x2000000000L) != 0L)
+ return jjStartNfaWithStates_0(5, 37, 4);
+ break;
+ case 100:
+ return jjMoveStringLiteralDfa6_0(active0, 0x8000000L);
+ case 102:
+ return jjMoveStringLiteralDfa6_0(active0, 0x2000000L);
+ case 103:
+ if ((active0 & 0x4000000000L) != 0L)
+ return jjStartNfaWithStates_0(5, 38, 4);
+ break;
+ case 104:
+ if ((active0 & 0x100000000L) != 0L)
+ return jjStartNfaWithStates_0(5, 32, 4);
+ break;
+ case 109:
+ return jjMoveStringLiteralDfa6_0(active0, 0x20000000000L);
+ case 110:
+ if ((active0 & 0x1000000000L) != 0L)
+ return jjStartNfaWithStates_0(5, 36, 4);
+ break;
+ default :
+ break;
+ }
+ return jjStartNfa_0(4, active0);
+}
+static private final int jjMoveStringLiteralDfa6_0(long old0, long active0)
+{
+ if (((active0 &= old0)) == 0L)
+ return jjStartNfa_0(4, old0);
+ try { curChar = input_stream.readChar(); }
+ catch(java.io.IOException e) {
+ jjStopStringLiteralDfa_0(5, active0);
+ return 6;
+ }
+ switch(curChar)
+ {
+ case 46:
+ return jjMoveStringLiteralDfa7_0(active0, 0x20000000000L);
+ case 97:
+ return jjMoveStringLiteralDfa7_0(active0, 0x2000000L);
+ case 110:
+ if ((active0 & 0x800000L) != 0L)
+ return jjStartNfaWithStates_0(6, 23, 4);
+ break;
+ case 115:
+ if ((active0 & 0x8000000L) != 0L)
+ return jjStartNfaWithStates_0(6, 27, 4);
+ break;
+ default :
+ break;
+ }
+ return jjStartNfa_0(5, active0);
+}
+static private final int jjMoveStringLiteralDfa7_0(long old0, long active0)
+{
+ if (((active0 &= old0)) == 0L)
+ return jjStartNfa_0(5, old0);
+ try { curChar = input_stream.readChar(); }
+ catch(java.io.IOException e) {
+ jjStopStringLiteralDfa_0(6, active0);
+ return 7;
+ }
+ switch(curChar)
+ {
+ case 99:
+ return jjMoveStringLiteralDfa8_0(active0, 0x2000000L);
+ case 111:
+ return jjMoveStringLiteralDfa8_0(active0, 0x20000000000L);
+ default :
+ break;
+ }
+ return jjStartNfa_0(6, active0);
+}
+static private final int jjMoveStringLiteralDfa8_0(long old0, long active0)
+{
+ if (((active0 &= old0)) == 0L)
+ return jjStartNfa_0(6, old0);
+ try { curChar = input_stream.readChar(); }
+ catch(java.io.IOException e) {
+ jjStopStringLiteralDfa_0(7, active0);
+ return 8;
+ }
+ switch(curChar)
+ {
+ case 101:
+ if ((active0 & 0x2000000L) != 0L)
+ return jjStartNfaWithStates_0(8, 25, 4);
+ break;
+ case 117:
+ return jjMoveStringLiteralDfa9_0(active0, 0x20000000000L);
+ default :
+ break;
+ }
+ return jjStartNfa_0(7, active0);
+}
+static private final int jjMoveStringLiteralDfa9_0(long old0, long active0)
+{
+ if (((active0 &= old0)) == 0L)
+ return jjStartNfa_0(7, old0);
+ try { curChar = input_stream.readChar(); }
+ catch(java.io.IOException e) {
+ jjStopStringLiteralDfa_0(8, active0);
+ return 9;
+ }
+ switch(curChar)
+ {
+ case 116:
+ return jjMoveStringLiteralDfa10_0(active0, 0x20000000000L);
+ default :
+ break;
+ }
+ return jjStartNfa_0(8, active0);
+}
+static private final int jjMoveStringLiteralDfa10_0(long old0, long active0)
+{
+ if (((active0 &= old0)) == 0L)
+ return jjStartNfa_0(8, old0);
+ try { curChar = input_stream.readChar(); }
+ catch(java.io.IOException e) {
+ jjStopStringLiteralDfa_0(9, active0);
+ return 10;
+ }
+ switch(curChar)
+ {
+ case 46:
+ return jjMoveStringLiteralDfa11_0(active0, 0x20000000000L);
+ default :
+ break;
+ }
+ return jjStartNfa_0(9, active0);
+}
+static private final int jjMoveStringLiteralDfa11_0(long old0, long active0)
+{
+ if (((active0 &= old0)) == 0L)
+ return jjStartNfa_0(9, old0);
+ try { curChar = input_stream.readChar(); }
+ catch(java.io.IOException e) {
+ jjStopStringLiteralDfa_0(10, active0);
+ return 11;
+ }
+ switch(curChar)
+ {
+ case 112:
+ return jjMoveStringLiteralDfa12_0(active0, 0x20000000000L);
+ default :
+ break;
+ }
+ return jjStartNfa_0(10, active0);
+}
+static private final int jjMoveStringLiteralDfa12_0(long old0, long active0)
+{
+ if (((active0 &= old0)) == 0L)
+ return jjStartNfa_0(10, old0);
+ try { curChar = input_stream.readChar(); }
+ catch(java.io.IOException e) {
+ jjStopStringLiteralDfa_0(11, active0);
+ return 12;
+ }
+ switch(curChar)
+ {
+ case 114:
+ return jjMoveStringLiteralDfa13_0(active0, 0x20000000000L);
+ default :
+ break;
+ }
+ return jjStartNfa_0(11, active0);
+}
+static private final int jjMoveStringLiteralDfa13_0(long old0, long active0)
+{
+ if (((active0 &= old0)) == 0L)
+ return jjStartNfa_0(11, old0);
+ try { curChar = input_stream.readChar(); }
+ catch(java.io.IOException e) {
+ jjStopStringLiteralDfa_0(12, active0);
+ return 13;
+ }
+ switch(curChar)
+ {
+ case 105:
+ return jjMoveStringLiteralDfa14_0(active0, 0x20000000000L);
+ default :
+ break;
+ }
+ return jjStartNfa_0(12, active0);
+}
+static private final int jjMoveStringLiteralDfa14_0(long old0, long active0)
+{
+ if (((active0 &= old0)) == 0L)
+ return jjStartNfa_0(12, old0);
+ try { curChar = input_stream.readChar(); }
+ catch(java.io.IOException e) {
+ jjStopStringLiteralDfa_0(13, active0);
+ return 14;
+ }
+ switch(curChar)
+ {
+ case 110:
+ return jjMoveStringLiteralDfa15_0(active0, 0x20000000000L);
+ default :
+ break;
+ }
+ return jjStartNfa_0(13, active0);
+}
+static private final int jjMoveStringLiteralDfa15_0(long old0, long active0)
+{
+ if (((active0 &= old0)) == 0L)
+ return jjStartNfa_0(13, old0);
+ try { curChar = input_stream.readChar(); }
+ catch(java.io.IOException e) {
+ jjStopStringLiteralDfa_0(14, active0);
+ return 15;
+ }
+ switch(curChar)
+ {
+ case 116:
+ return jjMoveStringLiteralDfa16_0(active0, 0x20000000000L);
+ default :
+ break;
+ }
+ return jjStartNfa_0(14, active0);
+}
+static private final int jjMoveStringLiteralDfa16_0(long old0, long active0)
+{
+ if (((active0 &= old0)) == 0L)
+ return jjStartNfa_0(14, old0);
+ try { curChar = input_stream.readChar(); }
+ catch(java.io.IOException e) {
+ jjStopStringLiteralDfa_0(15, active0);
+ return 16;
+ }
+ switch(curChar)
+ {
+ case 108:
+ return jjMoveStringLiteralDfa17_0(active0, 0x20000000000L);
+ default :
+ break;
+ }
+ return jjStartNfa_0(15, active0);
+}
+static private final int jjMoveStringLiteralDfa17_0(long old0, long active0)
+{
+ if (((active0 &= old0)) == 0L)
+ return jjStartNfa_0(15, old0);
+ try { curChar = input_stream.readChar(); }
+ catch(java.io.IOException e) {
+ jjStopStringLiteralDfa_0(16, active0);
+ return 17;
+ }
+ switch(curChar)
+ {
+ case 110:
+ if ((active0 & 0x20000000000L) != 0L)
+ return jjStopAtPos(17, 41);
+ break;
+ default :
+ break;
+ }
+ return jjStartNfa_0(16, active0);
+}
+static private final void jjCheckNAdd(int state)
+{
+ if (jjrounds[state] != jjround)
+ {
+ jjstateSet[jjnewStateCnt++] = state;
+ jjrounds[state] = jjround;
+ }
+}
+static private final void jjAddStates(int start, int end)
+{
+ do {
+ jjstateSet[jjnewStateCnt++] = jjnextStates[start];
+ } while (start++ != end);
+}
+static private final void jjCheckNAddTwoStates(int state1, int state2)
+{
+ jjCheckNAdd(state1);
+ jjCheckNAdd(state2);
+}
+static private final void jjCheckNAddStates(int start, int end)
+{
+ do {
+ jjCheckNAdd(jjnextStates[start]);
+ } while (start++ != end);
+}
+static private final void jjCheckNAddStates(int start)
+{
+ jjCheckNAdd(jjnextStates[start]);
+ jjCheckNAdd(jjnextStates[start + 1]);
+}
+static final long[] jjbitVec0 = {
+ 0x1ff00000fffffffeL, 0xffffffffffffc000L, 0xffffffffL, 0x600000000000000L
+};
+static final long[] jjbitVec2 = {
+ 0x0L, 0x0L, 0x0L, 0xff7fffffff7fffffL
+};
+static final long[] jjbitVec3 = {
+ 0x0L, 0xffffffffffffffffL, 0xffffffffffffffffL, 0xffffffffffffffffL
+};
+static final long[] jjbitVec4 = {
+ 0xffffffffffffffffL, 0xffffffffffffffffL, 0xffffL, 0x0L
+};
+static final long[] jjbitVec5 = {
+ 0xffffffffffffffffL, 0xffffffffffffffffL, 0x0L, 0x0L
+};
+static final long[] jjbitVec6 = {
+ 0x3fffffffffffL, 0x0L, 0x0L, 0x0L
+};
+static final long[] jjbitVec7 = {
+ 0xfffffffffffffffeL, 0xffffffffffffffffL, 0xffffffffffffffffL, 0xffffffffffffffffL
+};
+static final long[] jjbitVec8 = {
+ 0x0L, 0x0L, 0xffffffffffffffffL, 0xffffffffffffffffL
+};
+static private final int jjMoveNfa_0(int startState, int curPos)
+{
+ int[] nextStates;
+ int startsAt = 0;
+ jjnewStateCnt = 24;
+ int i = 1;
+ jjstateSet[0] = startState;
+ int j, kind = 0x7fffffff;
+ for (;;)
+ {
+ if (++jjround == 0x7fffffff)
+ ReInitRounds();
+ if (curChar < 64)
+ {
+ long l = 1L << curChar;
+ MatchLoop: do
+ {
+ switch(jjstateSet[--i])
+ {
+ case 0:
+ if ((0x3fe000000000000L & l) != 0L)
+ {
+ if (kind > 43)
+ kind = 43;
+ jjCheckNAdd(1);
+ }
+ else if (curChar == 47)
+ jjAddStates(0, 2);
+ else if (curChar == 36)
+ {
+ if (kind > 44)
+ kind = 44;
+ jjCheckNAdd(4);
+ }
+ else if (curChar == 48)
+ {
+ if (kind > 43)
+ kind = 43;
+ }
+ break;
+ case 1:
+ if ((0x3ff000000000000L & l) == 0L)
+ break;
+ if (kind > 43)
+ kind = 43;
+ jjCheckNAdd(1);
+ break;
+ case 2:
+ if (curChar == 48 && kind > 43)
+ kind = 43;
+ break;
+ case 3:
+ if (curChar != 36)
+ break;
+ if (kind > 44)
+ kind = 44;
+ jjCheckNAdd(4);
+ break;
+ case 4:
+ if ((0x3ff001000000000L & l) == 0L)
+ break;
+ if (kind > 44)
+ kind = 44;
+ jjCheckNAdd(4);
+ break;
+ case 5:
+ if (curChar == 47)
+ jjAddStates(0, 2);
+ break;
+ case 6:
+ if (curChar == 47)
+ jjCheckNAddStates(3, 5);
+ break;
+ case 7:
+ if ((0xffffffffffffdbffL & l) != 0L)
+ jjCheckNAddStates(3, 5);
+ break;
+ case 8:
+ if ((0x2400L & l) != 0L && kind > 6)
+ kind = 6;
+ break;
+ case 9:
+ if (curChar == 10 && kind > 6)
+ kind = 6;
+ break;
+ case 10:
+ if (curChar == 13)
+ jjstateSet[jjnewStateCnt++] = 9;
+ break;
+ case 11:
+ if (curChar == 42)
+ jjCheckNAddTwoStates(12, 13);
+ break;
+ case 12:
+ if ((0xfffffbffffffffffL & l) != 0L)
+ jjCheckNAddTwoStates(12, 13);
+ break;
+ case 13:
+ if (curChar == 42)
+ jjCheckNAddStates(6, 8);
+ break;
+ case 14:
+ if ((0xffff7bffffffffffL & l) != 0L)
+ jjCheckNAddTwoStates(15, 13);
+ break;
+ case 15:
+ if ((0xfffffbffffffffffL & l) != 0L)
+ jjCheckNAddTwoStates(15, 13);
+ break;
+ case 16:
+ if (curChar == 47 && kind > 7)
+ kind = 7;
+ break;
+ case 17:
+ if (curChar == 42)
+ jjstateSet[jjnewStateCnt++] = 11;
+ break;
+ case 18:
+ if (curChar == 42)
+ jjCheckNAddTwoStates(19, 20);
+ break;
+ case 19:
+ if ((0xfffffbffffffffffL & l) != 0L)
+ jjCheckNAddTwoStates(19, 20);
+ break;
+ case 20:
+ if (curChar == 42)
+ jjCheckNAddStates(9, 11);
+ break;
+ case 21:
+ if ((0xffff7bffffffffffL & l) != 0L)
+ jjCheckNAddTwoStates(22, 20);
+ break;
+ case 22:
+ if ((0xfffffbffffffffffL & l) != 0L)
+ jjCheckNAddTwoStates(22, 20);
+ break;
+ case 23:
+ if (curChar == 47 && kind > 8)
+ kind = 8;
+ break;
+ default : break;
+ }
+ } while(i != startsAt);
+ }
+ else if (curChar < 128)
+ {
+ long l = 1L << (curChar & 077);
+ MatchLoop: do
+ {
+ switch(jjstateSet[--i])
+ {
+ case 0:
+ case 4:
+ if ((0x7fffffe87fffffeL & l) == 0L)
+ break;
+ if (kind > 44)
+ kind = 44;
+ jjCheckNAdd(4);
+ break;
+ case 7:
+ jjAddStates(3, 5);
+ break;
+ case 12:
+ jjCheckNAddTwoStates(12, 13);
+ break;
+ case 14:
+ case 15:
+ jjCheckNAddTwoStates(15, 13);
+ break;
+ case 19:
+ jjCheckNAddTwoStates(19, 20);
+ break;
+ case 21:
+ case 22:
+ jjCheckNAddTwoStates(22, 20);
+ break;
+ default : break;
+ }
+ } while(i != startsAt);
+ }
+ else
+ {
+ int hiByte = (int)(curChar >> 8);
+ int i1 = hiByte >> 6;
+ long l1 = 1L << (hiByte & 077);
+ int i2 = (curChar & 0xff) >> 6;
+ long l2 = 1L << (curChar & 077);
+ MatchLoop: do
+ {
+ switch(jjstateSet[--i])
+ {
+ case 0:
+ case 4:
+ if (!jjCanMove_0(hiByte, i1, i2, l1, l2))
+ break;
+ if (kind > 44)
+ kind = 44;
+ jjCheckNAdd(4);
+ break;
+ case 7:
+ if (jjCanMove_1(hiByte, i1, i2, l1, l2))
+ jjAddStates(3, 5);
+ break;
+ case 12:
+ if (jjCanMove_1(hiByte, i1, i2, l1, l2))
+ jjCheckNAddTwoStates(12, 13);
+ break;
+ case 14:
+ case 15:
+ if (jjCanMove_1(hiByte, i1, i2, l1, l2))
+ jjCheckNAddTwoStates(15, 13);
+ break;
+ case 19:
+ if (jjCanMove_1(hiByte, i1, i2, l1, l2))
+ jjCheckNAddTwoStates(19, 20);
+ break;
+ case 21:
+ case 22:
+ if (jjCanMove_1(hiByte, i1, i2, l1, l2))
+ jjCheckNAddTwoStates(22, 20);
+ break;
+ default : break;
+ }
+ } while(i != startsAt);
+ }
+ if (kind != 0x7fffffff)
+ {
+ jjmatchedKind = kind;
+ jjmatchedPos = curPos;
+ kind = 0x7fffffff;
+ }
+ ++curPos;
+ if ((i = jjnewStateCnt) == (startsAt = 24 - (jjnewStateCnt = startsAt)))
+ return curPos;
+ try { curChar = input_stream.readChar(); }
+ catch(java.io.IOException e) { return curPos; }
+ }
+}
+static final int[] jjnextStates = {
+ 6, 17, 18, 7, 8, 10, 13, 14, 16, 20, 21, 23,
+};
+private static final boolean jjCanMove_0(int hiByte, int i1, int i2, long l1, long l2)
+{
+ switch(hiByte)
+ {
+ case 0:
+ return ((jjbitVec2[i2] & l2) != 0L);
+ case 48:
+ return ((jjbitVec3[i2] & l2) != 0L);
+ case 49:
+ return ((jjbitVec4[i2] & l2) != 0L);
+ case 51:
+ return ((jjbitVec5[i2] & l2) != 0L);
+ case 61:
+ return ((jjbitVec6[i2] & l2) != 0L);
+ default :
+ if ((jjbitVec0[i1] & l1) != 0L)
+ return true;
+ return false;
+ }
+}
+private static final boolean jjCanMove_1(int hiByte, int i1, int i2, long l1, long l2)
+{
+ switch(hiByte)
+ {
+ case 0:
+ return ((jjbitVec8[i2] & l2) != 0L);
+ default :
+ if ((jjbitVec7[i1] & l1) != 0L)
+ return true;
+ return false;
+ }
+}
+public static final String[] jjstrLiteralImages = {
+"", null, null, null, null, null, null, null, null, "\50", "\51", "\133",
+"\135", "\173", "\175", "\73", "\56", "\75", "\74", "\53", "\55", "\46\46", "\41",
+"\142\157\157\154\145\141\156", "\143\154\141\163\163", "\151\156\164\145\162\146\141\143\145",
+"\145\154\163\145", "\145\170\164\145\156\144\163", "\146\141\154\163\145", "\151\146",
+"\167\150\151\154\145", "\151\156\164", "\154\145\156\147\164\150", "\155\141\151\156",
+"\156\145\167", "\160\165\142\154\151\143", "\162\145\164\165\162\156",
+"\163\164\141\164\151\143", "\123\164\162\151\156\147", "\164\150\151\163", "\164\162\165\145",
+"\123\171\163\164\145\155\56\157\165\164\56\160\162\151\156\164\154\156", "\166\157\151\144", null, null, null, null, "\54", "\52", };
+public static final String[] lexStateNames = {
+ "DEFAULT",
+};
+static final long[] jjtoToken = {
+ 0x19ffffffffe01L,
+};
+static final long[] jjtoSkip = {
+ 0x1feL,
+};
+static final long[] jjtoSpecial = {
+ 0x1c0L,
+};
+static protected JavaCharStream input_stream;
+static private final int[] jjrounds = new int[24];
+static private final int[] jjstateSet = new int[48];
+static protected char curChar;
+public MiniJavaParserTokenManager(JavaCharStream stream){
+ if (input_stream != null)
+ throw new TokenMgrError("ERROR: Second call to constructor of static lexer. You must use ReInit() to initialize the static variables.", TokenMgrError.STATIC_LEXER_ERROR);
+ input_stream = stream;
+}
+public MiniJavaParserTokenManager(JavaCharStream stream, int lexState){
+ this(stream);
+ SwitchTo(lexState);
+}
+static public void ReInit(JavaCharStream stream)
+{
+ jjmatchedPos = jjnewStateCnt = 0;
+ curLexState = defaultLexState;
+ input_stream = stream;
+ ReInitRounds();
+}
+static private final void ReInitRounds()
+{
+ int i;
+ jjround = 0x80000001;
+ for (i = 24; i-- > 0;)
+ jjrounds[i] = 0x80000000;
+}
+static public void ReInit(JavaCharStream stream, int lexState)
+{
+ ReInit(stream);
+ SwitchTo(lexState);
+}
+static public void SwitchTo(int lexState)
+{
+ if (lexState >= 1 || lexState < 0)
+ throw new TokenMgrError("Error: Ignoring invalid lexical state : " + lexState + ". State unchanged.", TokenMgrError.INVALID_LEXICAL_STATE);
+ else
+ curLexState = lexState;
+}
+
+static protected Token jjFillToken()
+{
+ Token t = Token.newToken(jjmatchedKind);
+ t.kind = jjmatchedKind;
+ String im = jjstrLiteralImages[jjmatchedKind];
+ t.image = (im == null) ? input_stream.GetImage() : im;
+ t.beginLine = input_stream.getBeginLine();
+ t.beginColumn = input_stream.getBeginColumn();
+ t.endLine = input_stream.getEndLine();
+ t.endColumn = input_stream.getEndColumn();
+ return t;
+}
+
+static int curLexState = 0;
+static int defaultLexState = 0;
+static int jjnewStateCnt;
+static int jjround;
+static int jjmatchedPos;
+static int jjmatchedKind;
+
+public static Token getNextToken()
+{
+ int kind;
+ Token specialToken = null;
+ Token matchedToken;
+ int curPos = 0;
+
+ EOFLoop :
+ for (;;)
+ {
+ try
+ {
+ curChar = input_stream.BeginToken();
+ }
+ catch(java.io.IOException e)
+ {
+ jjmatchedKind = 0;
+ matchedToken = jjFillToken();
+ matchedToken.specialToken = specialToken;
+ return matchedToken;
+ }
+
+ try { input_stream.backup(0);
+ while (curChar <= 32 && (0x100003600L & (1L << curChar)) != 0L)
+ curChar = input_stream.BeginToken();
+ }
+ catch (java.io.IOException e1) { continue EOFLoop; }
+ jjmatchedKind = 0x7fffffff;
+ jjmatchedPos = 0;
+ curPos = jjMoveStringLiteralDfa0_0();
+ if (jjmatchedKind != 0x7fffffff)
+ {
+ if (jjmatchedPos + 1 < curPos)
+ input_stream.backup(curPos - jjmatchedPos - 1);
+ if ((jjtoToken[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L)
+ {
+ matchedToken = jjFillToken();
+ matchedToken.specialToken = specialToken;
+ return matchedToken;
+ }
+ else
+ {
+ if ((jjtoSpecial[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L)
+ {
+ matchedToken = jjFillToken();
+ if (specialToken == null)
+ specialToken = matchedToken;
+ else
+ {
+ matchedToken.specialToken = specialToken;
+ specialToken = (specialToken.next = matchedToken);
+ }
+ }
+ continue EOFLoop;
+ }
+ }
+ int error_line = input_stream.getEndLine();
+ int error_column = input_stream.getEndColumn();
+ String error_after = null;
+ boolean EOFSeen = false;
+ try { input_stream.readChar(); input_stream.backup(1); }
+ catch (java.io.IOException e1) {
+ EOFSeen = true;
+ error_after = curPos <= 1 ? "" : input_stream.GetImage();
+ if (curChar == '\n' || curChar == '\r') {
+ error_line++;
+ error_column = 0;
+ }
+ else
+ error_column++;
+ }
+ if (!EOFSeen) {
+ input_stream.backup(1);
+ error_after = curPos <= 1 ? "" : input_stream.GetImage();
+ }
+ throw new TokenMgrError(EOFSeen, curLexState, error_line, error_column, error_after, curChar, TokenMgrError.LEXICAL_ERROR);
+ }
+}
+
+}
diff --git a/src/minijava/ParseException.java b/src/minijava/ParseException.java
new file mode 100644
index 0000000..9cd26bb
--- /dev/null
+++ b/src/minijava/ParseException.java
@@ -0,0 +1,191 @@
+package minijava;
+/* Generated By:JavaCC: Do not edit this line. ParseException.java Version 3.0 */
+/**
+ * This exception is thrown when parse errors are encountered.
+ * You can explicitly create objects of this exception type by
+ * calling the method generateParseException in the generated
+ * parser.
+ *
+ * You can modify this class to customize your error reporting
+ * mechanisms so long as you retain the public fields.
+ */
+public class ParseException extends Exception {
+
+ /**
+ * This constructor is used by the method "generateParseException"
+ * in the generated parser. Calling this constructor generates
+ * a new object of this type with the fields "currentToken",
+ * "expectedTokenSequences", and "tokenImage" set. The boolean
+ * flag "specialConstructor" is also set to true to indicate that
+ * this constructor was used to create this object.
+ * This constructor calls its super class with the empty string
+ * to force the "toString" method of parent class "Throwable" to
+ * print the error message in the form:
+ * ParseException: <result of getMessage>
+ */
+ public ParseException(Token currentTokenVal,
+ int[][] expectedTokenSequencesVal,
+ String[] tokenImageVal
+ )
+ {
+ super("");
+ specialConstructor = true;
+ currentToken = currentTokenVal;
+ expectedTokenSequences = expectedTokenSequencesVal;
+ tokenImage = tokenImageVal;
+ }
+
+ /**
+ * The following constructors are for use by you for whatever
+ * purpose you can think of. Constructing the exception in this
+ * manner makes the exception behave in the normal way - i.e., as
+ * documented in the class "Throwable". The fields "errorToken",
+ * "expectedTokenSequences", and "tokenImage" do not contain
+ * relevant information. The JavaCC generated code does not use
+ * these constructors.
+ */
+
+ public ParseException() {
+ super();
+ specialConstructor = false;
+ }
+
+ public ParseException(String message) {
+ super(message);
+ specialConstructor = false;
+ }
+
+ /**
+ * This variable determines which constructor was used to create
+ * this object and thereby affects the semantics of the
+ * "getMessage" method (see below).
+ */
+ protected boolean specialConstructor;
+
+ /**
+ * This is the last token that has been consumed successfully. If
+ * this object has been created due to a parse error, the token
+ * followng this token will (therefore) be the first error token.
+ */
+ public Token currentToken;
+
+ /**
+ * Each entry in this array is an array of integers. Each array
+ * of integers represents a sequence of tokens (by their ordinal
+ * values) that is expected at this point of the parse.
+ */
+ public int[][] expectedTokenSequences;
+
+ /**
+ * This is a reference to the "tokenImage" array of the generated
+ * parser within which the parse error occurred. This array is
+ * defined in the generated ...Constants interface.
+ */
+ public String[] tokenImage;
+
+ /**
+ * This method has the standard behavior when this object has been
+ * created using the standard constructors. Otherwise, it uses
+ * "currentToken" and "expectedTokenSequences" to generate a parse
+ * error message and returns it. If this object has been created
+ * due to a parse error, and you do not catch it (it gets thrown
+ * from the parser), then this method is called during the printing
+ * of the final stack trace, and hence the correct error message
+ * gets displayed.
+ */
+ public String getMessage() {
+ if (!specialConstructor) {
+ return super.getMessage();
+ }
+ StringBuffer expected = new StringBuffer();
+ int maxSize = 0;
+ for (int i = 0; i < expectedTokenSequences.length; i++) {
+ if (maxSize < expectedTokenSequences[i].length) {
+ maxSize = expectedTokenSequences[i].length;
+ }
+ for (int j = 0; j < expectedTokenSequences[i].length; j++) {
+ expected.append(tokenImage[expectedTokenSequences[i][j]]).append(" ");
+ }
+ if (expectedTokenSequences[i][expectedTokenSequences[i].length - 1] != 0) {
+ expected.append("...");
+ }
+ expected.append(eol).append(" ");
+ }
+ String retval = "Encountered \"";
+ Token tok = currentToken.next;
+ for (int i = 0; i < maxSize; i++) {
+ if (i != 0) retval += " ";
+ if (tok.kind == 0) {
+ retval += tokenImage[0];
+ break;
+ }
+ retval += add_escapes(tok.image);
+ tok = tok.next;
+ }
+ retval += "\" at line " + currentToken.next.beginLine + ", column " + currentToken.next.beginColumn;
+ retval += "." + eol;
+ if (expectedTokenSequences.length == 1) {
+ retval += "Was expecting:" + eol + " ";
+ } else {
+ retval += "Was expecting one of:" + eol + " ";
+ }
+ retval += expected.toString();
+ return retval;
+ }
+
+ /**
+ * The end of line string for this machine.
+ */
+ protected String eol = System.getProperty("line.separator", "\n");
+
+ /**
+ * Used to convert raw characters to their escaped version
+ * when these raw version cannot be used as part of an ASCII
+ * string literal.
+ */
+ protected String add_escapes(String str) {
+ StringBuffer retval = new StringBuffer();
+ char ch;
+ for (int i = 0; i < str.length(); i++) {
+ switch (str.charAt(i))
+ {
+ case 0 :
+ continue;
+ case '\b':
+ retval.append("\\b");
+ continue;
+ case '\t':
+ retval.append("\\t");
+ continue;
+ case '\n':
+ retval.append("\\n");
+ continue;
+ case '\f':
+ retval.append("\\f");
+ continue;
+ case '\r':
+ retval.append("\\r");
+ continue;
+ case '\"':
+ retval.append("\\\"");
+ continue;
+ case '\'':
+ retval.append("\\\'");
+ continue;
+ case '\\':
+ retval.append("\\\\");
+ continue;
+ default:
+ if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) {
+ String s = "0000" + Integer.toString(ch, 16);
+ retval.append("\\u" + s.substring(s.length() - 4, s.length()));
+ } else {
+ retval.append(ch);
+ }
+ continue;
+ }
+ }
+ return retval.toString();
+ }
+
+}
diff --git a/src/minijava/Token.java b/src/minijava/Token.java
new file mode 100644
index 0000000..f6e2516
--- /dev/null
+++ b/src/minijava/Token.java
@@ -0,0 +1,80 @@
+package minijava;
+/* Generated By:JavaCC: Do not edit this line. Token.java Version 3.0 */
+/**
+ * Describes the input token stream.
+ */
+
+public class Token {
+
+ /**
+ * An integer that describes the kind of this token. This numbering
+ * system is determined by JavaCCParser, and a table of these numbers is
+ * stored in the file ...Constants.java.
+ */
+ public int kind;
+
+ /**
+ * beginLine and beginColumn describe the position of the first character
+ * of this token; endLine and endColumn describe the position of the
+ * last character of this token.
+ */
+ public int beginLine, beginColumn, endLine, endColumn;
+
+ /**
+ * The string image of the token.
+ */
+ public String image;
+
+ /**
+ * A reference to the next regular (non-special) token from the input
+ * stream. If this is the last token from the input stream, or if the
+ * token manager has not read tokens beyond this one, this field is
+ * set to null. This is true only if this token is also a regular
+ * token. Otherwise, see below for a description of the contents of
+ * this field.
+ */
+ public Token next;
+
+ /**
+ * This field is used to access special tokens that occur prior to this
+ * token, but after the immediately preceding regular (non-special) token.
+ * If there are no such special tokens, this field is set to null.
+ * When there are more than one such special token, this field refers
+ * to the last of these special tokens, which in turn refers to the next
+ * previous special token through its specialToken field, and so on
+ * until the first special token (whose specialToken field is null).
+ * The next fields of special tokens refer to other special tokens that
+ * immediately follow it (without an intervening regular token). If there
+ * is no such token, this field is null.
+ */
+ public Token specialToken;
+
+ /**
+ * Returns the image.
+ */
+ public String toString()
+ {
+ return image;
+ }
+
+ /**
+ * Returns a new Token object, by default. However, if you want, you
+ * can create and return subclass objects based on the value of ofKind.
+ * Simply add the cases to the switch for all those special cases.
+ * For example, if you have a subclass of Token called IDToken that
+ * you want to create if ofKind is ID, simlpy add something like :
+ *
+ * case MyParserConstants.ID : return new IDToken();
+ *
+ * to the following switch statement. Then you can cast matchedToken
+ * variable to the appropriate type and use it in your lexical actions.
+ */
+ public static final Token newToken(int ofKind)
+ {
+ switch(ofKind)
+ {
+ default : return new Token();
+ }
+ }
+
+}
diff --git a/src/minijava/TokenMgrError.java b/src/minijava/TokenMgrError.java
new file mode 100644
index 0000000..87d3878
--- /dev/null
+++ b/src/minijava/TokenMgrError.java
@@ -0,0 +1,132 @@
+package minijava;
+/* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 3.0 */
+public class TokenMgrError extends Error
+{
+ /*
+ * Ordinals for various reasons why an Error of this type can be thrown.
+ */
+
+ /**
+ * Lexical error occured.
+ */
+ static final int LEXICAL_ERROR = 0;
+
+ /**
+ * An attempt wass made to create a second instance of a static token manager.
+ */
+ static final int STATIC_LEXER_ERROR = 1;
+
+ /**
+ * Tried to change to an invalid lexical state.
+ */
+ static final int INVALID_LEXICAL_STATE = 2;
+
+ /**
+ * Detected (and bailed out of) an infinite loop in the token manager.
+ */
+ static final int LOOP_DETECTED = 3;
+
+ /**
+ * Indicates the reason why the exception is thrown. It will have
+ * one of the above 4 values.
+ */
+ int errorCode;
+
+ /**
+ * Replaces unprintable characters by their espaced (or unicode escaped)
+ * equivalents in the given string
+ */
+ protected static final String addEscapes(String str) {
+ StringBuffer retval = new StringBuffer();
+ char ch;
+ for (int i = 0; i < str.length(); i++) {
+ switch (str.charAt(i))
+ {
+ case 0 :
+ continue;
+ case '\b':
+ retval.append("\\b");
+ continue;
+ case '\t':
+ retval.append("\\t");
+ continue;
+ case '\n':
+ retval.append("\\n");
+ continue;
+ case '\f':
+ retval.append("\\f");
+ continue;
+ case '\r':
+ retval.append("\\r");
+ continue;
+ case '\"':
+ retval.append("\\\"");
+ continue;
+ case '\'':
+ retval.append("\\\'");
+ continue;
+ case '\\':
+ retval.append("\\\\");
+ continue;
+ default:
+ if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) {
+ String s = "0000" + Integer.toString(ch, 16);
+ retval.append("\\u" + s.substring(s.length() - 4, s.length()));
+ } else {
+ retval.append(ch);
+ }
+ continue;
+ }
+ }
+ return retval.toString();
+ }
+
+ /**
+ * Returns a detailed message for the Error when it is thrown by the
+ * token manager to indicate a lexical error.
+ * Parameters :
+ * EOFSeen : indicates if EOF caused the lexicl error
+ * curLexState : lexical state in which this error occured
+ * errorLine : line number when the error occured
+ * errorColumn : column number when the error occured
+ * errorAfter : prefix that was seen before this error occured
+ * curchar : the offending character
+ * Note: You can customize the lexical error message by modifying this method.
+ */
+ protected static String LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar) {
+ return("Lexical error at line " +
+ errorLine + ", column " +
+ errorColumn + ". Encountered: " +
+ (EOFSeen ? "<EOF> " : ("\"" + addEscapes(String.valueOf(curChar)) + "\"") + " (" + (int)curChar + "), ") +
+ "after : \"" + addEscapes(errorAfter) + "\"");
+ }
+
+ /**
+ * You can also modify the body of this method to customize your error messages.
+ * For example, cases like LOOP_DETECTED and INVALID_LEXICAL_STATE are not
+ * of end-users concern, so you can return something like :
+ *
+ * "Internal Error : Please file a bug report .... "
+ *
+ * from this method for such cases in the release version of your parser.
+ */
+ public String getMessage() {
+ return super.getMessage();
+ }
+
+ /*
+ * Constructors of various flavors follow.
+ */
+
+ public TokenMgrError() {
+ }
+
+ public TokenMgrError(String message, int reason) {
+ super(message);
+ errorCode = reason;
+ }
+
+ public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar, int reason) {
+ this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason);
+ }
+}
diff --git a/src/minijava/minijava2piglet/Main.java b/src/minijava/minijava2piglet/Main.java
new file mode 100644
index 0000000..02e5e22
--- /dev/null
+++ b/src/minijava/minijava2piglet/Main.java
@@ -0,0 +1,37 @@
+package minijava.minijava2piglet;
+
+import minijava.MiniJavaParser;
+import minijava.ParseException;
+import minijava.TokenMgrError;
+import minijava.syntaxtree.Node;
+import minijava.visitor.GJDepthFirst;
+
+
+public class Main {
+
+ public static void main(String[] args) {
+ try {
+ Node root = new MiniJavaParser(System.in).Goal();
+ /*
+ * TODO: Implement your own Visitors and other classes.
+ *
+ */
+ GJDepthFirst v = new GJDepthFirst<Object,Object>() {
+ };
+ //Traverse the Abstract Grammar Tree
+ root.accept(v,null);
+ }
+ catch(TokenMgrError e){
+ //Handle Lexical Errors
+ e.printStackTrace();
+ }
+ catch (ParseException e){
+ //Handle Grammar Errors
+ e.printStackTrace();
+ }
+ catch(Exception e){
+ e.printStackTrace();
+ }
+
+ }
+} \ No newline at end of file
diff --git a/src/minijava/symboltable/MClass.java b/src/minijava/symboltable/MClass.java
new file mode 100644
index 0000000..a5b90f2
--- /dev/null
+++ b/src/minijava/symboltable/MClass.java
@@ -0,0 +1,44 @@
+/**
+ * 该类用于表示声明的类
+ */
+package minijava.symboltable;
+
+import minijava.typecheck.PrintError;
+
+public class MClass extends MType {
+ public MClasses all_classes; // 所有类的列表
+ public boolean isDeclared = false; // 是否已声明,用于检查符号表
+ public String extend_class_name = null; // 所继承的类
+ public MVarList vars;
+ public MMethodList methods;
+
+ public MClass(String v_name, MClasses all, int m_line, int m_column) {
+ super(m_line, m_column);
+ name = v_name;
+ all_classes = all;
+ vars = new MVarList();
+ methods = new MMethodList();
+ }
+
+ public String insertVar(MVariable var) {
+ String var_name = var.getName();
+ if (vars.findVar(var_name)!=-1) {
+ return "Variable double declaration " + "\"" + var_name + "\"";
+ }
+ vars.insertVar(var);
+ return null;
+ }
+
+ public String insertMethod(MMethod method) {
+ String method_name = method.getName();
+ if (vars.findVar(method_name)!=-1) {
+ return "Method name \'" + method_name + "\' is the same of some variable.";
+ }
+ if (methods.findMethod(method_name)!=-1) {
+ return "Method double declaration " + "\"" + method_name + "\".";
+ }
+ methods.addMethod(method);
+ return null;
+ }
+}
+
diff --git a/src/minijava/symboltable/MClasses.java b/src/minijava/symboltable/MClasses.java
new file mode 100644
index 0000000..a4d066f
--- /dev/null
+++ b/src/minijava/symboltable/MClasses.java
@@ -0,0 +1,31 @@
+/**
+ * 所有声明的类的列表
+ */
+package minijava.symboltable;
+
+import java.util.Vector;
+
+public class MClasses extends MType {
+ public Vector<MClass> mj_classes = new Vector<MClass>(); // 用于存放类
+
+ // 在表中插入类
+ public String InsertClass(MClass v_class) {
+ String class_name = v_class.getName();
+ if (Repeated(class_name)) // 如已经定义过该类,返回错误信息
+ return "Class double declaration " + "\"" + class_name + "\"";
+ mj_classes.addElement(v_class);
+ return null;
+ }
+
+ // 判定是否定义同名的类
+ public boolean Repeated(String class_name) {
+ int sz = mj_classes.size();
+ for (int i = 0; i < sz; i++) {
+ String c_name = ((MClass) mj_classes.elementAt(i)).getName();
+ if (c_name.equals(class_name))
+ return true;
+ }
+ return false;
+ }
+}
+
diff --git a/src/minijava/symboltable/MIdentifier.java b/src/minijava/symboltable/MIdentifier.java
new file mode 100644
index 0000000..45340ac
--- /dev/null
+++ b/src/minijava/symboltable/MIdentifier.java
@@ -0,0 +1,17 @@
+/**
+ * 表示标识符的类,可用于表示变量
+ */
+package minijava.symboltable;
+
+public class MIdentifier extends MType {
+ // 定义内置类型
+ public static final String arrType = "int[]";
+ public static final String intType = "int";
+ public static final String boolType = "boolean";
+
+ public MIdentifier(String v_name, int v_line, int v_column) {
+ super(v_line, v_column);
+ name = v_name;
+ }
+}
+
diff --git a/src/minijava/symboltable/MMethod.java b/src/minijava/symboltable/MMethod.java
new file mode 100644
index 0000000..30159cf
--- /dev/null
+++ b/src/minijava/symboltable/MMethod.java
@@ -0,0 +1,11 @@
+package minijava.symboltable;
+
+public class MMethod extends MType {
+ MVarList params;
+ String ret_type_name;
+
+ public MMethod(String m_name, int m_type, int m_column) {
+ super(m_type, m_column);
+ this.name = m_name;
+ }
+}
diff --git a/src/minijava/symboltable/MMethodList.java b/src/minijava/symboltable/MMethodList.java
new file mode 100644
index 0000000..34f79e6
--- /dev/null
+++ b/src/minijava/symboltable/MMethodList.java
@@ -0,0 +1,24 @@
+package minijava.symboltable;
+
+import java.util.Vector;
+
+public class MMethodList extends MType {
+ Vector<MMethod> methods;
+
+ MMethodList() {
+ methods = new Vector<MMethod>();
+ }
+
+ public void addMethod(MMethod method) {
+ methods.addElement(method);
+ }
+
+ public int findMethod(String m_name) {
+ for (int i=0; i<methods.size(); i++) {
+ if (methods.elementAt(i).name.equals(m_name)) {
+ return i;
+ }
+ }
+ return -1;
+ }
+}
diff --git a/src/minijava/symboltable/MType.java b/src/minijava/symboltable/MType.java
new file mode 100644
index 0000000..07b11e7
--- /dev/null
+++ b/src/minijava/symboltable/MType.java
@@ -0,0 +1,43 @@
+/**
+ * 表示类型的类,symboltable包中所有类的父类
+ */
+package minijava.symboltable;
+
+public abstract class MType {
+ protected String name; // 名称
+ protected int line = 0; // 所在行
+ protected int column = 0; // 所在列
+
+ public MType() {
+ };
+
+ public MType(int m_line, int m_column) {
+ line = m_line;
+ column = m_column;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public int getLine() {
+ return line;
+ }
+
+ public int getColumn() {
+ return column;
+ }
+
+ public void setName(String v_name) {
+ name = v_name;
+ }
+
+ public void setLine(int m_line) {
+ line = m_line;
+ }
+
+ public void setColumn(int m_column) {
+ column = m_column;
+ }
+}
+
diff --git a/src/minijava/symboltable/MVarList.java b/src/minijava/symboltable/MVarList.java
new file mode 100644
index 0000000..ede97fc
--- /dev/null
+++ b/src/minijava/symboltable/MVarList.java
@@ -0,0 +1,24 @@
+package minijava.symboltable;
+
+import java.util.Vector;
+
+public class MVarList extends MType {
+ /* a class for storing variables */
+ Vector<MVariable> varlist;
+ public MVarList() {
+ varlist = new Vector<MVariable>();
+ }
+
+ public void insertVar(MVariable var) {
+ varlist.addElement(var);
+ }
+
+ public int findVar(String v_name) {
+ for (int i=0; i<varlist.size(); i++) {
+ if (varlist.elementAt(i).name.equals(v_name)) {
+ return i;
+ }
+ }
+ return -1;
+ }
+}
diff --git a/src/minijava/symboltable/MVariable.java b/src/minijava/symboltable/MVariable.java
new file mode 100644
index 0000000..2655561
--- /dev/null
+++ b/src/minijava/symboltable/MVariable.java
@@ -0,0 +1,11 @@
+package minijava.symboltable;
+
+public class MVariable extends MType {
+ String typename;
+
+ public MVariable(String v_name, String v_type, int v_line, int v_column) {
+ super(v_line, v_column);
+ name = v_name;
+ typename = v_type;
+ }
+}
diff --git a/src/minijava/syntaxtree/AllocationExpression.java b/src/minijava/syntaxtree/AllocationExpression.java
new file mode 100644
index 0000000..d31b05e
--- /dev/null
+++ b/src/minijava/syntaxtree/AllocationExpression.java
@@ -0,0 +1,47 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package minijava.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "new"
+ * f1 -> Identifier()
+ * f2 -> "("
+ * f3 -> ")"
+ */
+public class AllocationExpression implements Node {
+ public NodeToken f0;
+ public Identifier f1;
+ public NodeToken f2;
+ public NodeToken f3;
+
+ public AllocationExpression(NodeToken n0, Identifier n1, NodeToken n2, NodeToken n3) {
+ f0 = n0;
+ f1 = n1;
+ f2 = n2;
+ f3 = n3;
+ }
+
+ public AllocationExpression(Identifier n0) {
+ f0 = new NodeToken("new");
+ f1 = n0;
+ f2 = new NodeToken("(");
+ f3 = new NodeToken(")");
+ }
+
+ public void accept(minijava.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(minijava.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(minijava.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(minijava.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/minijava/syntaxtree/AndExpression.java b/src/minijava/syntaxtree/AndExpression.java
new file mode 100644
index 0000000..bf7637b
--- /dev/null
+++ b/src/minijava/syntaxtree/AndExpression.java
@@ -0,0 +1,43 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package minijava.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> PrimaryExpression()
+ * f1 -> "&&"
+ * f2 -> PrimaryExpression()
+ */
+public class AndExpression implements Node {
+ public PrimaryExpression f0;
+ public NodeToken f1;
+ public PrimaryExpression f2;
+
+ public AndExpression(PrimaryExpression n0, NodeToken n1, PrimaryExpression n2) {
+ f0 = n0;
+ f1 = n1;
+ f2 = n2;
+ }
+
+ public AndExpression(PrimaryExpression n0, PrimaryExpression n1) {
+ f0 = n0;
+ f1 = new NodeToken("&&");
+ f2 = n1;
+ }
+
+ public void accept(minijava.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(minijava.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(minijava.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(minijava.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/minijava/syntaxtree/ArrayAllocationExpression.java b/src/minijava/syntaxtree/ArrayAllocationExpression.java
new file mode 100644
index 0000000..b7e8d07
--- /dev/null
+++ b/src/minijava/syntaxtree/ArrayAllocationExpression.java
@@ -0,0 +1,51 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package minijava.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "new"
+ * f1 -> "int"
+ * f2 -> "["
+ * f3 -> Expression()
+ * f4 -> "]"
+ */
+public class ArrayAllocationExpression implements Node {
+ public NodeToken f0;
+ public NodeToken f1;
+ public NodeToken f2;
+ public Expression f3;
+ public NodeToken f4;
+
+ public ArrayAllocationExpression(NodeToken n0, NodeToken n1, NodeToken n2, Expression n3, NodeToken n4) {
+ f0 = n0;
+ f1 = n1;
+ f2 = n2;
+ f3 = n3;
+ f4 = n4;
+ }
+
+ public ArrayAllocationExpression(Expression n0) {
+ f0 = new NodeToken("new");
+ f1 = new NodeToken("int");
+ f2 = new NodeToken("[");
+ f3 = n0;
+ f4 = new NodeToken("]");
+ }
+
+ public void accept(minijava.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(minijava.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(minijava.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(minijava.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/minijava/syntaxtree/ArrayAssignmentStatement.java b/src/minijava/syntaxtree/ArrayAssignmentStatement.java
new file mode 100644
index 0000000..9ac2eaa
--- /dev/null
+++ b/src/minijava/syntaxtree/ArrayAssignmentStatement.java
@@ -0,0 +1,59 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package minijava.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> Identifier()
+ * f1 -> "["
+ * f2 -> Expression()
+ * f3 -> "]"
+ * f4 -> "="
+ * f5 -> Expression()
+ * f6 -> ";"
+ */
+public class ArrayAssignmentStatement implements Node {
+ public Identifier f0;
+ public NodeToken f1;
+ public Expression f2;
+ public NodeToken f3;
+ public NodeToken f4;
+ public Expression f5;
+ public NodeToken f6;
+
+ public ArrayAssignmentStatement(Identifier n0, NodeToken n1, Expression n2, NodeToken n3, NodeToken n4, Expression n5, NodeToken n6) {
+ f0 = n0;
+ f1 = n1;
+ f2 = n2;
+ f3 = n3;
+ f4 = n4;
+ f5 = n5;
+ f6 = n6;
+ }
+
+ public ArrayAssignmentStatement(Identifier n0, Expression n1, Expression n2) {
+ f0 = n0;
+ f1 = new NodeToken("[");
+ f2 = n1;
+ f3 = new NodeToken("]");
+ f4 = new NodeToken("=");
+ f5 = n2;
+ f6 = new NodeToken(";");
+ }
+
+ public void accept(minijava.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(minijava.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(minijava.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(minijava.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/minijava/syntaxtree/ArrayLength.java b/src/minijava/syntaxtree/ArrayLength.java
new file mode 100644
index 0000000..bb9755e
--- /dev/null
+++ b/src/minijava/syntaxtree/ArrayLength.java
@@ -0,0 +1,43 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package minijava.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> PrimaryExpression()
+ * f1 -> "."
+ * f2 -> "length"
+ */
+public class ArrayLength implements Node {
+ public PrimaryExpression f0;
+ public NodeToken f1;
+ public NodeToken f2;
+
+ public ArrayLength(PrimaryExpression n0, NodeToken n1, NodeToken n2) {
+ f0 = n0;
+ f1 = n1;
+ f2 = n2;
+ }
+
+ public ArrayLength(PrimaryExpression n0) {
+ f0 = n0;
+ f1 = new NodeToken(".");
+ f2 = new NodeToken("length");
+ }
+
+ public void accept(minijava.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(minijava.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(minijava.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(minijava.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/minijava/syntaxtree/ArrayLookup.java b/src/minijava/syntaxtree/ArrayLookup.java
new file mode 100644
index 0000000..248756e
--- /dev/null
+++ b/src/minijava/syntaxtree/ArrayLookup.java
@@ -0,0 +1,47 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package minijava.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> PrimaryExpression()
+ * f1 -> "["
+ * f2 -> PrimaryExpression()
+ * f3 -> "]"
+ */
+public class ArrayLookup implements Node {
+ public PrimaryExpression f0;
+ public NodeToken f1;
+ public PrimaryExpression f2;
+ public NodeToken f3;
+
+ public ArrayLookup(PrimaryExpression n0, NodeToken n1, PrimaryExpression n2, NodeToken n3) {
+ f0 = n0;
+ f1 = n1;
+ f2 = n2;
+ f3 = n3;
+ }
+
+ public ArrayLookup(PrimaryExpression n0, PrimaryExpression n1) {
+ f0 = n0;
+ f1 = new NodeToken("[");
+ f2 = n1;
+ f3 = new NodeToken("]");
+ }
+
+ public void accept(minijava.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(minijava.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(minijava.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(minijava.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/minijava/syntaxtree/ArrayType.java b/src/minijava/syntaxtree/ArrayType.java
new file mode 100644
index 0000000..44cf566
--- /dev/null
+++ b/src/minijava/syntaxtree/ArrayType.java
@@ -0,0 +1,43 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package minijava.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "int"
+ * f1 -> "["
+ * f2 -> "]"
+ */
+public class ArrayType implements Node {
+ public NodeToken f0;
+ public NodeToken f1;
+ public NodeToken f2;
+
+ public ArrayType(NodeToken n0, NodeToken n1, NodeToken n2) {
+ f0 = n0;
+ f1 = n1;
+ f2 = n2;
+ }
+
+ public ArrayType() {
+ f0 = new NodeToken("int");
+ f1 = new NodeToken("[");
+ f2 = new NodeToken("]");
+ }
+
+ public void accept(minijava.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(minijava.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(minijava.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(minijava.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/minijava/syntaxtree/AssignmentStatement.java b/src/minijava/syntaxtree/AssignmentStatement.java
new file mode 100644
index 0000000..9ad3efa
--- /dev/null
+++ b/src/minijava/syntaxtree/AssignmentStatement.java
@@ -0,0 +1,47 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package minijava.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> Identifier()
+ * f1 -> "="
+ * f2 -> Expression()
+ * f3 -> ";"
+ */
+public class AssignmentStatement implements Node {
+ public Identifier f0;
+ public NodeToken f1;
+ public Expression f2;
+ public NodeToken f3;
+
+ public AssignmentStatement(Identifier n0, NodeToken n1, Expression n2, NodeToken n3) {
+ f0 = n0;
+ f1 = n1;
+ f2 = n2;
+ f3 = n3;
+ }
+
+ public AssignmentStatement(Identifier n0, Expression n1) {
+ f0 = n0;
+ f1 = new NodeToken("=");
+ f2 = n1;
+ f3 = new NodeToken(";");
+ }
+
+ public void accept(minijava.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(minijava.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(minijava.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(minijava.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/minijava/syntaxtree/Block.java b/src/minijava/syntaxtree/Block.java
new file mode 100644
index 0000000..1546cc7
--- /dev/null
+++ b/src/minijava/syntaxtree/Block.java
@@ -0,0 +1,43 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package minijava.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "{"
+ * f1 -> ( Statement() )*
+ * f2 -> "}"
+ */
+public class Block implements Node {
+ public NodeToken f0;
+ public NodeListOptional f1;
+ public NodeToken f2;
+
+ public Block(NodeToken n0, NodeListOptional n1, NodeToken n2) {
+ f0 = n0;
+ f1 = n1;
+ f2 = n2;
+ }
+
+ public Block(NodeListOptional n0) {
+ f0 = new NodeToken("{");
+ f1 = n0;
+ f2 = new NodeToken("}");
+ }
+
+ public void accept(minijava.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(minijava.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(minijava.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(minijava.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/minijava/syntaxtree/BooleanType.java b/src/minijava/syntaxtree/BooleanType.java
new file mode 100644
index 0000000..e482c93
--- /dev/null
+++ b/src/minijava/syntaxtree/BooleanType.java
@@ -0,0 +1,35 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package minijava.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "boolean"
+ */
+public class BooleanType implements Node {
+ public NodeToken f0;
+
+ public BooleanType(NodeToken n0) {
+ f0 = n0;
+ }
+
+ public BooleanType() {
+ f0 = new NodeToken("boolean");
+ }
+
+ public void accept(minijava.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(minijava.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(minijava.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(minijava.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/minijava/syntaxtree/BracketExpression.java b/src/minijava/syntaxtree/BracketExpression.java
new file mode 100644
index 0000000..47f83dd
--- /dev/null
+++ b/src/minijava/syntaxtree/BracketExpression.java
@@ -0,0 +1,43 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package minijava.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "("
+ * f1 -> Expression()
+ * f2 -> ")"
+ */
+public class BracketExpression implements Node {
+ public NodeToken f0;
+ public Expression f1;
+ public NodeToken f2;
+
+ public BracketExpression(NodeToken n0, Expression n1, NodeToken n2) {
+ f0 = n0;
+ f1 = n1;
+ f2 = n2;
+ }
+
+ public BracketExpression(Expression n0) {
+ f0 = new NodeToken("(");
+ f1 = n0;
+ f2 = new NodeToken(")");
+ }
+
+ public void accept(minijava.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(minijava.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(minijava.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(minijava.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/minijava/syntaxtree/ClassDeclaration.java b/src/minijava/syntaxtree/ClassDeclaration.java
new file mode 100644
index 0000000..01df615
--- /dev/null
+++ b/src/minijava/syntaxtree/ClassDeclaration.java
@@ -0,0 +1,55 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package minijava.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "class"
+ * f1 -> Identifier()
+ * f2 -> "{"
+ * f3 -> ( VarDeclaration() )*
+ * f4 -> ( MethodDeclaration() )*
+ * f5 -> "}"
+ */
+public class ClassDeclaration implements Node {
+ public NodeToken f0;
+ public Identifier f1;
+ public NodeToken f2;
+ public NodeListOptional f3;
+ public NodeListOptional f4;
+ public NodeToken f5;
+
+ public ClassDeclaration(NodeToken n0, Identifier n1, NodeToken n2, NodeListOptional n3, NodeListOptional n4, NodeToken n5) {
+ f0 = n0;
+ f1 = n1;
+ f2 = n2;
+ f3 = n3;
+ f4 = n4;
+ f5 = n5;
+ }
+
+ public ClassDeclaration(Identifier n0, NodeListOptional n1, NodeListOptional n2) {
+ f0 = new NodeToken("class");
+ f1 = n0;
+ f2 = new NodeToken("{");
+ f3 = n1;
+ f4 = n2;
+ f5 = new NodeToken("}");
+ }
+
+ public void accept(minijava.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(minijava.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(minijava.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(minijava.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/minijava/syntaxtree/ClassExtendsDeclaration.java b/src/minijava/syntaxtree/ClassExtendsDeclaration.java
new file mode 100644
index 0000000..fcadb56
--- /dev/null
+++ b/src/minijava/syntaxtree/ClassExtendsDeclaration.java
@@ -0,0 +1,63 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package minijava.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "class"
+ * f1 -> Identifier()
+ * f2 -> "extends"
+ * f3 -> Identifier()
+ * f4 -> "{"
+ * f5 -> ( VarDeclaration() )*
+ * f6 -> ( MethodDeclaration() )*
+ * f7 -> "}"
+ */
+public class ClassExtendsDeclaration implements Node {
+ public NodeToken f0;
+ public Identifier f1;
+ public NodeToken f2;
+ public Identifier f3;
+ public NodeToken f4;
+ public NodeListOptional f5;
+ public NodeListOptional f6;
+ public NodeToken f7;
+
+ public ClassExtendsDeclaration(NodeToken n0, Identifier n1, NodeToken n2, Identifier n3, NodeToken n4, NodeListOptional n5, NodeListOptional n6, NodeToken n7) {
+ f0 = n0;
+ f1 = n1;
+ f2 = n2;
+ f3 = n3;
+ f4 = n4;
+ f5 = n5;
+ f6 = n6;
+ f7 = n7;
+ }
+
+ public ClassExtendsDeclaration(Identifier n0, Identifier n1, NodeListOptional n2, NodeListOptional n3) {
+ f0 = new NodeToken("class");
+ f1 = n0;
+ f2 = new NodeToken("extends");
+ f3 = n1;
+ f4 = new NodeToken("{");
+ f5 = n2;
+ f6 = n3;
+ f7 = new NodeToken("}");
+ }
+
+ public void accept(minijava.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(minijava.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(minijava.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(minijava.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/minijava/syntaxtree/CompareExpression.java b/src/minijava/syntaxtree/CompareExpression.java
new file mode 100644
index 0000000..e4f2c4c
--- /dev/null
+++ b/src/minijava/syntaxtree/CompareExpression.java
@@ -0,0 +1,43 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package minijava.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> PrimaryExpression()
+ * f1 -> "<"
+ * f2 -> PrimaryExpression()
+ */
+public class CompareExpression implements Node {
+ public PrimaryExpression f0;
+ public NodeToken f1;
+ public PrimaryExpression f2;
+
+ public CompareExpression(PrimaryExpression n0, NodeToken n1, PrimaryExpression n2) {
+ f0 = n0;
+ f1 = n1;
+ f2 = n2;
+ }
+
+ public CompareExpression(PrimaryExpression n0, PrimaryExpression n1) {
+ f0 = n0;
+ f1 = new NodeToken("<");
+ f2 = n1;
+ }
+
+ public void accept(minijava.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(minijava.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(minijava.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(minijava.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/minijava/syntaxtree/Expression.java b/src/minijava/syntaxtree/Expression.java
new file mode 100644
index 0000000..cc138d8
--- /dev/null
+++ b/src/minijava/syntaxtree/Expression.java
@@ -0,0 +1,39 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package minijava.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> AndExpression()
+ * | CompareExpression()
+ * | PlusExpression()
+ * | MinusExpression()
+ * | TimesExpression()
+ * | ArrayLookup()
+ * | ArrayLength()
+ * | MessageSend()
+ * | PrimaryExpression()
+ */
+public class Expression implements Node {
+ public NodeChoice f0;
+
+ public Expression(NodeChoice n0) {
+ f0 = n0;
+ }
+
+ public void accept(minijava.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(minijava.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(minijava.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(minijava.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/minijava/syntaxtree/ExpressionList.java b/src/minijava/syntaxtree/ExpressionList.java
new file mode 100644
index 0000000..4be4f6b
--- /dev/null
+++ b/src/minijava/syntaxtree/ExpressionList.java
@@ -0,0 +1,34 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package minijava.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> Expression()
+ * f1 -> ( ExpressionRest() )*
+ */
+public class ExpressionList implements Node {
+ public Expression f0;
+ public NodeListOptional f1;
+
+ public ExpressionList(Expression n0, NodeListOptional n1) {
+ f0 = n0;
+ f1 = n1;
+ }
+
+ public void accept(minijava.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(minijava.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(minijava.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(minijava.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/minijava/syntaxtree/ExpressionRest.java b/src/minijava/syntaxtree/ExpressionRest.java
new file mode 100644
index 0000000..ec730da
--- /dev/null
+++ b/src/minijava/syntaxtree/ExpressionRest.java
@@ -0,0 +1,39 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package minijava.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> ","
+ * f1 -> Expression()
+ */
+public class ExpressionRest implements Node {
+ public NodeToken f0;
+ public Expression f1;
+
+ public ExpressionRest(NodeToken n0, Expression n1) {
+ f0 = n0;
+ f1 = n1;
+ }
+
+ public ExpressionRest(Expression n0) {
+ f0 = new NodeToken(",");
+ f1 = n0;
+ }
+
+ public void accept(minijava.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(minijava.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(minijava.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(minijava.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/minijava/syntaxtree/FalseLiteral.java b/src/minijava/syntaxtree/FalseLiteral.java
new file mode 100644
index 0000000..9903c27
--- /dev/null
+++ b/src/minijava/syntaxtree/FalseLiteral.java
@@ -0,0 +1,35 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package minijava.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "false"
+ */
+public class FalseLiteral implements Node {
+ public NodeToken f0;
+
+ public FalseLiteral(NodeToken n0) {
+ f0 = n0;
+ }
+
+ public FalseLiteral() {
+ f0 = new NodeToken("false");
+ }
+
+ public void accept(minijava.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(minijava.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(minijava.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(minijava.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/minijava/syntaxtree/FormalParameter.java b/src/minijava/syntaxtree/FormalParameter.java
new file mode 100644
index 0000000..7be4878
--- /dev/null
+++ b/src/minijava/syntaxtree/FormalParameter.java
@@ -0,0 +1,34 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package minijava.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> Type()
+ * f1 -> Identifier()
+ */
+public class FormalParameter implements Node {
+ public Type f0;
+ public Identifier f1;
+
+ public FormalParameter(Type n0, Identifier n1) {
+ f0 = n0;
+ f1 = n1;
+ }
+
+ public void accept(minijava.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(minijava.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(minijava.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(minijava.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/minijava/syntaxtree/FormalParameterList.java b/src/minijava/syntaxtree/FormalParameterList.java
new file mode 100644
index 0000000..00a2e0d
--- /dev/null
+++ b/src/minijava/syntaxtree/FormalParameterList.java
@@ -0,0 +1,34 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package minijava.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> FormalParameter()
+ * f1 -> ( FormalParameterRest() )*
+ */
+public class FormalParameterList implements Node {
+ public FormalParameter f0;
+ public NodeListOptional f1;
+
+ public FormalParameterList(FormalParameter n0, NodeListOptional n1) {
+ f0 = n0;
+ f1 = n1;
+ }
+
+ public void accept(minijava.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(minijava.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(minijava.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(minijava.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/minijava/syntaxtree/FormalParameterRest.java b/src/minijava/syntaxtree/FormalParameterRest.java
new file mode 100644
index 0000000..797b1a5
--- /dev/null
+++ b/src/minijava/syntaxtree/FormalParameterRest.java
@@ -0,0 +1,39 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package minijava.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> ","
+ * f1 -> FormalParameter()
+ */
+public class FormalParameterRest implements Node {
+ public NodeToken f0;
+ public FormalParameter f1;
+
+ public FormalParameterRest(NodeToken n0, FormalParameter n1) {
+ f0 = n0;
+ f1 = n1;
+ }
+
+ public FormalParameterRest(FormalParameter n0) {
+ f0 = new NodeToken(",");
+ f1 = n0;
+ }
+
+ public void accept(minijava.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(minijava.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(minijava.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(minijava.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/minijava/syntaxtree/Goal.java b/src/minijava/syntaxtree/Goal.java
new file mode 100644
index 0000000..9f8b0ae
--- /dev/null
+++ b/src/minijava/syntaxtree/Goal.java
@@ -0,0 +1,43 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package minijava.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> MainClass()
+ * f1 -> ( TypeDeclaration() )*
+ * f2 -> <EOF>
+ */
+public class Goal implements Node {
+ public MainClass f0;
+ public NodeListOptional f1;
+ public NodeToken f2;
+
+ public Goal(MainClass n0, NodeListOptional n1, NodeToken n2) {
+ f0 = n0;
+ f1 = n1;
+ f2 = n2;
+ }
+
+ public Goal(MainClass n0, NodeListOptional n1) {
+ f0 = n0;
+ f1 = n1;
+ f2 = new NodeToken("");
+ }
+
+ public void accept(minijava.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(minijava.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(minijava.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(minijava.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/minijava/syntaxtree/Identifier.java b/src/minijava/syntaxtree/Identifier.java
new file mode 100644
index 0000000..c36e2ba
--- /dev/null
+++ b/src/minijava/syntaxtree/Identifier.java
@@ -0,0 +1,31 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package minijava.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> <IDENTIFIER>
+ */
+public class Identifier implements Node {
+ public NodeToken f0;
+
+ public Identifier(NodeToken n0) {
+ f0 = n0;
+ }
+
+ public void accept(minijava.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(minijava.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(minijava.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(minijava.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/minijava/syntaxtree/IfStatement.java b/src/minijava/syntaxtree/IfStatement.java
new file mode 100644
index 0000000..9b67278
--- /dev/null
+++ b/src/minijava/syntaxtree/IfStatement.java
@@ -0,0 +1,59 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package minijava.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "if"
+ * f1 -> "("
+ * f2 -> Expression()
+ * f3 -> ")"
+ * f4 -> Statement()
+ * f5 -> "else"
+ * f6 -> Statement()
+ */
+public class IfStatement implements Node {
+ public NodeToken f0;
+ public NodeToken f1;
+ public Expression f2;
+ public NodeToken f3;
+ public Statement f4;
+ public NodeToken f5;
+ public Statement f6;
+
+ public IfStatement(NodeToken n0, NodeToken n1, Expression n2, NodeToken n3, Statement n4, NodeToken n5, Statement n6) {
+ f0 = n0;
+ f1 = n1;
+ f2 = n2;
+ f3 = n3;
+ f4 = n4;
+ f5 = n5;
+ f6 = n6;
+ }
+
+ public IfStatement(Expression n0, Statement n1, Statement n2) {
+ f0 = new NodeToken("if");
+ f1 = new NodeToken("(");
+ f2 = n0;
+ f3 = new NodeToken(")");
+ f4 = n1;
+ f5 = new NodeToken("else");
+ f6 = n2;
+ }
+
+ public void accept(minijava.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(minijava.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(minijava.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(minijava.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/minijava/syntaxtree/IntegerLiteral.java b/src/minijava/syntaxtree/IntegerLiteral.java
new file mode 100644
index 0000000..2a1d25a
--- /dev/null
+++ b/src/minijava/syntaxtree/IntegerLiteral.java
@@ -0,0 +1,31 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package minijava.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> <INTEGER_LITERAL>
+ */
+public class IntegerLiteral implements Node {
+ public NodeToken f0;
+
+ public IntegerLiteral(NodeToken n0) {
+ f0 = n0;
+ }
+
+ public void accept(minijava.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(minijava.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(minijava.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(minijava.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/minijava/syntaxtree/IntegerType.java b/src/minijava/syntaxtree/IntegerType.java
new file mode 100644
index 0000000..6c88bf1
--- /dev/null
+++ b/src/minijava/syntaxtree/IntegerType.java
@@ -0,0 +1,35 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package minijava.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "int"
+ */
+public class IntegerType implements Node {
+ public NodeToken f0;
+
+ public IntegerType(NodeToken n0) {
+ f0 = n0;
+ }
+
+ public IntegerType() {
+ f0 = new NodeToken("int");
+ }
+
+ public void accept(minijava.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(minijava.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(minijava.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(minijava.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/minijava/syntaxtree/MainClass.java b/src/minijava/syntaxtree/MainClass.java
new file mode 100644
index 0000000..7a2e91f
--- /dev/null
+++ b/src/minijava/syntaxtree/MainClass.java
@@ -0,0 +1,99 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package minijava.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "class"
+ * f1 -> Identifier()
+ * f2 -> "{"
+ * f3 -> "public"
+ * f4 -> "static"
+ * f5 -> "void"
+ * f6 -> "main"
+ * f7 -> "("
+ * f8 -> "String"
+ * f9 -> "["
+ * f10 -> "]"
+ * f11 -> Identifier()
+ * f12 -> ")"
+ * f13 -> "{"
+ * f14 -> PrintStatement()
+ * f15 -> "}"
+ * f16 -> "}"
+ */
+public class MainClass implements Node {
+ public NodeToken f0;
+ public Identifier f1;
+ public NodeToken f2;
+ public NodeToken f3;
+ public NodeToken f4;
+ public NodeToken f5;
+ public NodeToken f6;
+ public NodeToken f7;
+ public NodeToken f8;
+ public NodeToken f9;
+ public NodeToken f10;
+ public Identifier f11;
+ public NodeToken f12;
+ public NodeToken f13;
+ public PrintStatement f14;
+ public NodeToken f15;
+ public NodeToken f16;
+
+ public MainClass(NodeToken n0, Identifier n1, NodeToken n2, NodeToken n3, NodeToken n4, NodeToken n5, NodeToken n6, NodeToken n7, NodeToken n8, NodeToken n9, NodeToken n10, Identifier n11, NodeToken n12, NodeToken n13, PrintStatement n14, NodeToken n15, NodeToken n16) {
+ f0 = n0;
+ f1 = n1;
+ f2 = n2;
+ f3 = n3;
+ f4 = n4;
+ f5 = n5;
+ f6 = n6;
+ f7 = n7;
+ f8 = n8;
+ f9 = n9;
+ f10 = n10;
+ f11 = n11;
+ f12 = n12;
+ f13 = n13;
+ f14 = n14;
+ f15 = n15;
+ f16 = n16;
+ }
+
+ public MainClass(Identifier n0, Identifier n1, PrintStatement n2) {
+ f0 = new NodeToken("class");
+ f1 = n0;
+ f2 = new NodeToken("{");
+ f3 = new NodeToken("public");
+ f4 = new NodeToken("static");
+ f5 = new NodeToken("void");
+ f6 = new NodeToken("main");
+ f7 = new NodeToken("(");
+ f8 = new NodeToken("String");
+ f9 = new NodeToken("[");
+ f10 = new NodeToken("]");
+ f11 = n1;
+ f12 = new NodeToken(")");
+ f13 = new NodeToken("{");
+ f14 = n2;
+ f15 = new NodeToken("}");
+ f16 = new NodeToken("}");
+ }
+
+ public void accept(minijava.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(minijava.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(minijava.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(minijava.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/minijava/syntaxtree/MessageSend.java b/src/minijava/syntaxtree/MessageSend.java
new file mode 100644
index 0000000..0828f52
--- /dev/null
+++ b/src/minijava/syntaxtree/MessageSend.java
@@ -0,0 +1,55 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package minijava.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> PrimaryExpression()
+ * f1 -> "."
+ * f2 -> Identifier()
+ * f3 -> "("
+ * f4 -> ( ExpressionList() )?
+ * f5 -> ")"
+ */
+public class MessageSend implements Node {
+ public PrimaryExpression f0;
+ public NodeToken f1;
+ public Identifier f2;
+ public NodeToken f3;
+ public NodeOptional f4;
+ public NodeToken f5;
+
+ public MessageSend(PrimaryExpression n0, NodeToken n1, Identifier n2, NodeToken n3, NodeOptional n4, NodeToken n5) {
+ f0 = n0;
+ f1 = n1;
+ f2 = n2;
+ f3 = n3;
+ f4 = n4;
+ f5 = n5;
+ }
+
+ public MessageSend(PrimaryExpression n0, Identifier n1, NodeOptional n2) {
+ f0 = n0;
+ f1 = new NodeToken(".");
+ f2 = n1;
+ f3 = new NodeToken("(");
+ f4 = n2;
+ f5 = new NodeToken(")");
+ }
+
+ public void accept(minijava.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(minijava.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(minijava.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(minijava.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/minijava/syntaxtree/MethodDeclaration.java b/src/minijava/syntaxtree/MethodDeclaration.java
new file mode 100644
index 0000000..f1caae2
--- /dev/null
+++ b/src/minijava/syntaxtree/MethodDeclaration.java
@@ -0,0 +1,83 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package minijava.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "public"
+ * f1 -> Type()
+ * f2 -> Identifier()
+ * f3 -> "("
+ * f4 -> ( FormalParameterList() )?
+ * f5 -> ")"
+ * f6 -> "{"
+ * f7 -> ( VarDeclaration() )*
+ * f8 -> ( Statement() )*
+ * f9 -> "return"
+ * f10 -> Expression()
+ * f11 -> ";"
+ * f12 -> "}"
+ */
+public class MethodDeclaration implements Node {
+ public NodeToken f0;
+ public Type f1;
+ public Identifier f2;
+ public NodeToken f3;
+ public NodeOptional f4;
+ public NodeToken f5;
+ public NodeToken f6;
+ public NodeListOptional f7;
+ public NodeListOptional f8;
+ public NodeToken f9;
+ public Expression f10;
+ public NodeToken f11;
+ public NodeToken f12;
+
+ public MethodDeclaration(NodeToken n0, Type n1, Identifier n2, NodeToken n3, NodeOptional n4, NodeToken n5, NodeToken n6, NodeListOptional n7, NodeListOptional n8, NodeToken n9, Expression n10, NodeToken n11, NodeToken n12) {
+ f0 = n0;
+ f1 = n1;
+ f2 = n2;
+ f3 = n3;
+ f4 = n4;
+ f5 = n5;
+ f6 = n6;
+ f7 = n7;
+ f8 = n8;
+ f9 = n9;
+ f10 = n10;
+ f11 = n11;
+ f12 = n12;
+ }
+
+ public MethodDeclaration(Type n0, Identifier n1, NodeOptional n2, NodeListOptional n3, NodeListOptional n4, Expression n5) {
+ f0 = new NodeToken("public");
+ f1 = n0;
+ f2 = n1;
+ f3 = new NodeToken("(");
+ f4 = n2;
+ f5 = new NodeToken(")");
+ f6 = new NodeToken("{");
+ f7 = n3;
+ f8 = n4;
+ f9 = new NodeToken("return");
+ f10 = n5;
+ f11 = new NodeToken(";");
+ f12 = new NodeToken("}");
+ }
+
+ public void accept(minijava.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(minijava.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(minijava.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(minijava.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/minijava/syntaxtree/MinusExpression.java b/src/minijava/syntaxtree/MinusExpression.java
new file mode 100644
index 0000000..141f73b
--- /dev/null
+++ b/src/minijava/syntaxtree/MinusExpression.java
@@ -0,0 +1,43 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package minijava.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> PrimaryExpression()
+ * f1 -> "-"
+ * f2 -> PrimaryExpression()
+ */
+public class MinusExpression implements Node {
+ public PrimaryExpression f0;
+ public NodeToken f1;
+ public PrimaryExpression f2;
+
+ public MinusExpression(PrimaryExpression n0, NodeToken n1, PrimaryExpression n2) {
+ f0 = n0;
+ f1 = n1;
+ f2 = n2;
+ }
+
+ public MinusExpression(PrimaryExpression n0, PrimaryExpression n1) {
+ f0 = n0;
+ f1 = new NodeToken("-");
+ f2 = n1;
+ }
+
+ public void accept(minijava.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(minijava.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(minijava.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(minijava.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/minijava/syntaxtree/Node.java b/src/minijava/syntaxtree/Node.java
new file mode 100644
index 0000000..2825b98
--- /dev/null
+++ b/src/minijava/syntaxtree/Node.java
@@ -0,0 +1,16 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package minijava.syntaxtree;
+
+/**
+ * The interface which all syntax tree classes must implement.
+ */
+public interface Node extends java.io.Serializable {
+ public void accept(minijava.visitor.Visitor v);
+ public <R,A> R accept(minijava.visitor.GJVisitor<R,A> v, A argu);
+ public <R> R accept(minijava.visitor.GJNoArguVisitor<R> v);
+ public <A> void accept(minijava.visitor.GJVoidVisitor<A> v, A argu);
+}
+
diff --git a/src/minijava/syntaxtree/NodeChoice.java b/src/minijava/syntaxtree/NodeChoice.java
new file mode 100644
index 0000000..fc164cd
--- /dev/null
+++ b/src/minijava/syntaxtree/NodeChoice.java
@@ -0,0 +1,36 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package minijava.syntaxtree;
+
+/**
+ * Represents a grammar choice, e.g. ( A | B )
+ */
+public class NodeChoice implements Node {
+ public NodeChoice(Node node) {
+ this(node, -1);
+ }
+
+ public NodeChoice(Node node, int whichChoice) {
+ choice = node;
+ which = whichChoice;
+ }
+
+ public void accept(minijava.visitor.Visitor v) {
+ choice.accept(v);
+ }
+ public <R,A> R accept(minijava.visitor.GJVisitor<R,A> v, A argu) {
+ return choice.accept(v,argu);
+ }
+ public <R> R accept(minijava.visitor.GJNoArguVisitor<R> v) {
+ return choice.accept(v);
+ }
+ public <A> void accept(minijava.visitor.GJVoidVisitor<A> v, A argu) {
+ choice.accept(v,argu);
+ }
+
+ public Node choice;
+ public int which;
+}
+
diff --git a/src/minijava/syntaxtree/NodeList.java b/src/minijava/syntaxtree/NodeList.java
new file mode 100644
index 0000000..e447306
--- /dev/null
+++ b/src/minijava/syntaxtree/NodeList.java
@@ -0,0 +1,45 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package minijava.syntaxtree;
+
+import java.util.Enumeration;
+import java.util.Vector;
+
+/**
+ * Represents a grammar list, e.g. ( A )+
+ */
+public class NodeList implements NodeListInterface {
+ public NodeList() {
+ nodes = new Vector<Node>();
+ }
+
+ public NodeList(Node firstNode) {
+ nodes = new Vector<Node>();
+ addNode(firstNode);
+ }
+
+ public void addNode(Node n) {
+ nodes.addElement(n);
+ }
+
+ public Enumeration<Node> elements() { return nodes.elements(); }
+ public Node elementAt(int i) { return nodes.elementAt(i); }
+ public int size() { return nodes.size(); }
+ public void accept(minijava.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(minijava.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(minijava.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(minijava.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+
+ public Vector<Node> nodes;
+}
+
diff --git a/src/minijava/syntaxtree/NodeListInterface.java b/src/minijava/syntaxtree/NodeListInterface.java
new file mode 100644
index 0000000..be433ee
--- /dev/null
+++ b/src/minijava/syntaxtree/NodeListInterface.java
@@ -0,0 +1,22 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package minijava.syntaxtree;
+
+/**
+ * The interface which NodeList, NodeListOptional, and NodeSequence
+ * implement.
+ */
+public interface NodeListInterface extends Node {
+ public void addNode(Node n);
+ public Node elementAt(int i);
+ public java.util.Enumeration<Node> elements();
+ public int size();
+
+ public void accept(minijava.visitor.Visitor v);
+ public <R,A> R accept(minijava.visitor.GJVisitor<R,A> v, A argu);
+ public <R> R accept(minijava.visitor.GJNoArguVisitor<R> v);
+ public <A> void accept(minijava.visitor.GJVoidVisitor<A> v, A argu);
+}
+
diff --git a/src/minijava/syntaxtree/NodeListOptional.java b/src/minijava/syntaxtree/NodeListOptional.java
new file mode 100644
index 0000000..a89923e
--- /dev/null
+++ b/src/minijava/syntaxtree/NodeListOptional.java
@@ -0,0 +1,46 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package minijava.syntaxtree;
+
+import java.util.Enumeration;
+import java.util.Vector;
+
+/**
+ * Represents an optional grammar list, e.g. ( A )*
+ */
+public class NodeListOptional implements NodeListInterface {
+ public NodeListOptional() {
+ nodes = new Vector<Node>();
+ }
+
+ public NodeListOptional(Node firstNode) {
+ nodes = new Vector<Node>();
+ addNode(firstNode);
+ }
+
+ public void addNode(Node n) {
+ nodes.addElement(n);
+ }
+
+ public Enumeration<Node> elements() { return nodes.elements(); }
+ public Node elementAt(int i) { return nodes.elementAt(i); }
+ public int size() { return nodes.size(); }
+ public boolean present() { return nodes.size() != 0; }
+ public void accept(minijava.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(minijava.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(minijava.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(minijava.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+
+ public Vector<Node> nodes;
+}
+
diff --git a/src/minijava/syntaxtree/NodeOptional.java b/src/minijava/syntaxtree/NodeOptional.java
new file mode 100644
index 0000000..c88fa21
--- /dev/null
+++ b/src/minijava/syntaxtree/NodeOptional.java
@@ -0,0 +1,41 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package minijava.syntaxtree;
+
+/**
+ * Represents an grammar optional node, e.g. ( A )? or [ A ]
+ */
+public class NodeOptional implements Node {
+ public NodeOptional() {
+ node = null;
+ }
+
+ public NodeOptional(Node n) {
+ addNode(n);
+ }
+
+ public void addNode(Node n) {
+ if ( node != null) // Oh oh!
+ throw new Error("Attempt to set optional node twice");
+
+ node = n;
+ }
+ public void accept(minijava.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(minijava.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(minijava.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(minijava.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+ public boolean present() { return node != null; }
+
+ public Node node;
+}
+
diff --git a/src/minijava/syntaxtree/NodeSequence.java b/src/minijava/syntaxtree/NodeSequence.java
new file mode 100644
index 0000000..5e04993
--- /dev/null
+++ b/src/minijava/syntaxtree/NodeSequence.java
@@ -0,0 +1,46 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package minijava.syntaxtree;
+
+import java.util.Enumeration;
+import java.util.Vector;
+
+/**
+ * Represents a sequence of nodes nested within a choice, list,
+ * optional list, or optional, e.g. ( A B )+ or [ C D E ]
+ */
+public class NodeSequence implements NodeListInterface {
+ public NodeSequence(int n) {
+ nodes = new Vector<Node>(n);
+ }
+
+ public NodeSequence(Node firstNode) {
+ nodes = new Vector<Node>();
+ addNode(firstNode);
+ }
+
+ public void addNode(Node n) {
+ nodes.addElement(n);
+ }
+
+ public Node elementAt(int i) { return nodes.elementAt(i); }
+ public Enumeration<Node> elements() { return nodes.elements(); }
+ public int size() { return nodes.size(); }
+ public void accept(minijava.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(minijava.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(minijava.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(minijava.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+
+ public Vector<Node> nodes;
+}
+
diff --git a/src/minijava/syntaxtree/NodeToken.java b/src/minijava/syntaxtree/NodeToken.java
new file mode 100644
index 0000000..eb20b7b
--- /dev/null
+++ b/src/minijava/syntaxtree/NodeToken.java
@@ -0,0 +1,88 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package minijava.syntaxtree;
+
+import java.util.Enumeration;
+import java.util.Vector;
+/**
+ * Represents a single token in the grammar. If the "-tk" option
+ * is used, also contains a Vector of preceding special tokens.
+ */
+public class NodeToken implements Node {
+ public NodeToken(String s) {
+ this(s, -1, -1, -1, -1, -1); }
+
+ public NodeToken(String s, int kind, int beginLine, int beginColumn, int endLine, int endColumn) {
+ tokenImage = s;
+ specialTokens = null;
+ this.kind = kind;
+ this.beginLine = beginLine;
+ this.beginColumn = beginColumn;
+ this.endLine = endLine;
+ this.endColumn = endColumn;
+ }
+
+ public NodeToken getSpecialAt(int i) {
+ if ( specialTokens == null )
+ throw new java.util.NoSuchElementException("No specials in token");
+ return specialTokens.elementAt(i);
+ }
+
+ public int numSpecials() {
+ if ( specialTokens == null ) return 0;
+ return specialTokens.size();
+ }
+
+ public void addSpecial(NodeToken s) {
+ if ( specialTokens == null ) specialTokens = new Vector<NodeToken>();
+ specialTokens.addElement(s);
+ }
+
+ public void trimSpecials() {
+ if ( specialTokens == null ) return;
+ specialTokens.trimToSize();
+ }
+
+ public String toString() { return tokenImage; }
+
+ public String withSpecials() {
+ if ( specialTokens == null )
+ return tokenImage;
+
+ StringBuffer buf = new StringBuffer();
+
+ for ( Enumeration<NodeToken> e = specialTokens.elements(); e.hasMoreElements(); )
+ buf.append(e.nextElement().toString());
+
+ buf.append(tokenImage);
+ return buf.toString();
+ }
+
+ public void accept(minijava.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(minijava.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(minijava.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(minijava.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+
+ public String tokenImage;
+
+ // Stores a list of NodeTokens
+ public Vector<NodeToken> specialTokens;
+
+ // -1 for these ints means no position info is available.
+ public int beginLine, beginColumn, endLine, endColumn;
+
+ // Equal to the JavaCC token "kind" integer.
+ // -1 if not available.
+ public int kind;
+}
+
diff --git a/src/minijava/syntaxtree/NotExpression.java b/src/minijava/syntaxtree/NotExpression.java
new file mode 100644
index 0000000..015a51e
--- /dev/null
+++ b/src/minijava/syntaxtree/NotExpression.java
@@ -0,0 +1,39 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package minijava.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "!"
+ * f1 -> Expression()
+ */
+public class NotExpression implements Node {
+ public NodeToken f0;
+ public Expression f1;
+
+ public NotExpression(NodeToken n0, Expression n1) {
+ f0 = n0;
+ f1 = n1;
+ }
+
+ public NotExpression(Expression n0) {
+ f0 = new NodeToken("!");
+ f1 = n0;
+ }
+
+ public void accept(minijava.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(minijava.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(minijava.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(minijava.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/minijava/syntaxtree/PlusExpression.java b/src/minijava/syntaxtree/PlusExpression.java
new file mode 100644
index 0000000..5448ad1
--- /dev/null
+++ b/src/minijava/syntaxtree/PlusExpression.java
@@ -0,0 +1,43 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package minijava.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> PrimaryExpression()
+ * f1 -> "+"
+ * f2 -> PrimaryExpression()
+ */
+public class PlusExpression implements Node {
+ public PrimaryExpression f0;
+ public NodeToken f1;
+ public PrimaryExpression f2;
+
+ public PlusExpression(PrimaryExpression n0, NodeToken n1, PrimaryExpression n2) {
+ f0 = n0;
+ f1 = n1;
+ f2 = n2;
+ }
+
+ public PlusExpression(PrimaryExpression n0, PrimaryExpression n1) {
+ f0 = n0;
+ f1 = new NodeToken("+");
+ f2 = n1;
+ }
+
+ public void accept(minijava.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(minijava.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(minijava.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(minijava.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/minijava/syntaxtree/PrimaryExpression.java b/src/minijava/syntaxtree/PrimaryExpression.java
new file mode 100644
index 0000000..04e90a8
--- /dev/null
+++ b/src/minijava/syntaxtree/PrimaryExpression.java
@@ -0,0 +1,39 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package minijava.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> IntegerLiteral()
+ * | TrueLiteral()
+ * | FalseLiteral()
+ * | Identifier()
+ * | ThisExpression()
+ * | ArrayAllocationExpression()
+ * | AllocationExpression()
+ * | NotExpression()
+ * | BracketExpression()
+ */
+public class PrimaryExpression implements Node {
+ public NodeChoice f0;
+
+ public PrimaryExpression(NodeChoice n0) {
+ f0 = n0;
+ }
+
+ public void accept(minijava.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(minijava.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(minijava.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(minijava.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/minijava/syntaxtree/PrintStatement.java b/src/minijava/syntaxtree/PrintStatement.java
new file mode 100644
index 0000000..15bbbba
--- /dev/null
+++ b/src/minijava/syntaxtree/PrintStatement.java
@@ -0,0 +1,51 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package minijava.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "System.out.println"
+ * f1 -> "("
+ * f2 -> Expression()
+ * f3 -> ")"
+ * f4 -> ";"
+ */
+public class PrintStatement implements Node {
+ public NodeToken f0;
+ public NodeToken f1;
+ public Expression f2;
+ public NodeToken f3;
+ public NodeToken f4;
+
+ public PrintStatement(NodeToken n0, NodeToken n1, Expression n2, NodeToken n3, NodeToken n4) {
+ f0 = n0;
+ f1 = n1;
+ f2 = n2;
+ f3 = n3;
+ f4 = n4;
+ }
+
+ public PrintStatement(Expression n0) {
+ f0 = new NodeToken("System.out.println");
+ f1 = new NodeToken("(");
+ f2 = n0;
+ f3 = new NodeToken(")");
+ f4 = new NodeToken(";");
+ }
+
+ public void accept(minijava.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(minijava.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(minijava.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(minijava.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/minijava/syntaxtree/Statement.java b/src/minijava/syntaxtree/Statement.java
new file mode 100644
index 0000000..db2c5d3
--- /dev/null
+++ b/src/minijava/syntaxtree/Statement.java
@@ -0,0 +1,36 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package minijava.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> Block()
+ * | AssignmentStatement()
+ * | ArrayAssignmentStatement()
+ * | IfStatement()
+ * | WhileStatement()
+ * | PrintStatement()
+ */
+public class Statement implements Node {
+ public NodeChoice f0;
+
+ public Statement(NodeChoice n0) {
+ f0 = n0;
+ }
+
+ public void accept(minijava.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(minijava.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(minijava.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(minijava.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/minijava/syntaxtree/ThisExpression.java b/src/minijava/syntaxtree/ThisExpression.java
new file mode 100644
index 0000000..cfb0d97
--- /dev/null
+++ b/src/minijava/syntaxtree/ThisExpression.java
@@ -0,0 +1,35 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package minijava.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "this"
+ */
+public class ThisExpression implements Node {
+ public NodeToken f0;
+
+ public ThisExpression(NodeToken n0) {
+ f0 = n0;
+ }
+
+ public ThisExpression() {
+ f0 = new NodeToken("this");
+ }
+
+ public void accept(minijava.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(minijava.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(minijava.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(minijava.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/minijava/syntaxtree/TimesExpression.java b/src/minijava/syntaxtree/TimesExpression.java
new file mode 100644
index 0000000..fa38fd0
--- /dev/null
+++ b/src/minijava/syntaxtree/TimesExpression.java
@@ -0,0 +1,43 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package minijava.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> PrimaryExpression()
+ * f1 -> "*"
+ * f2 -> PrimaryExpression()
+ */
+public class TimesExpression implements Node {
+ public PrimaryExpression f0;
+ public NodeToken f1;
+ public PrimaryExpression f2;
+
+ public TimesExpression(PrimaryExpression n0, NodeToken n1, PrimaryExpression n2) {
+ f0 = n0;
+ f1 = n1;
+ f2 = n2;
+ }
+
+ public TimesExpression(PrimaryExpression n0, PrimaryExpression n1) {
+ f0 = n0;
+ f1 = new NodeToken("*");
+ f2 = n1;
+ }
+
+ public void accept(minijava.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(minijava.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(minijava.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(minijava.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/minijava/syntaxtree/TrueLiteral.java b/src/minijava/syntaxtree/TrueLiteral.java
new file mode 100644
index 0000000..6d9b04d
--- /dev/null
+++ b/src/minijava/syntaxtree/TrueLiteral.java
@@ -0,0 +1,35 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package minijava.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "true"
+ */
+public class TrueLiteral implements Node {
+ public NodeToken f0;
+
+ public TrueLiteral(NodeToken n0) {
+ f0 = n0;
+ }
+
+ public TrueLiteral() {
+ f0 = new NodeToken("true");
+ }
+
+ public void accept(minijava.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(minijava.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(minijava.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(minijava.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/minijava/syntaxtree/Type.java b/src/minijava/syntaxtree/Type.java
new file mode 100644
index 0000000..2c6980b
--- /dev/null
+++ b/src/minijava/syntaxtree/Type.java
@@ -0,0 +1,34 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package minijava.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> ArrayType()
+ * | BooleanType()
+ * | IntegerType()
+ * | Identifier()
+ */
+public class Type implements Node {
+ public NodeChoice f0;
+
+ public Type(NodeChoice n0) {
+ f0 = n0;
+ }
+
+ public void accept(minijava.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(minijava.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(minijava.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(minijava.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/minijava/syntaxtree/TypeDeclaration.java b/src/minijava/syntaxtree/TypeDeclaration.java
new file mode 100644
index 0000000..6c895f2
--- /dev/null
+++ b/src/minijava/syntaxtree/TypeDeclaration.java
@@ -0,0 +1,32 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package minijava.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> ClassDeclaration()
+ * | ClassExtendsDeclaration()
+ */
+public class TypeDeclaration implements Node {
+ public NodeChoice f0;
+
+ public TypeDeclaration(NodeChoice n0) {
+ f0 = n0;
+ }
+
+ public void accept(minijava.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(minijava.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(minijava.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(minijava.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/minijava/syntaxtree/VarDeclaration.java b/src/minijava/syntaxtree/VarDeclaration.java
new file mode 100644
index 0000000..db5198f
--- /dev/null
+++ b/src/minijava/syntaxtree/VarDeclaration.java
@@ -0,0 +1,43 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package minijava.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> Type()
+ * f1 -> Identifier()
+ * f2 -> ";"
+ */
+public class VarDeclaration implements Node {
+ public Type f0;
+ public Identifier f1;
+ public NodeToken f2;
+
+ public VarDeclaration(Type n0, Identifier n1, NodeToken n2) {
+ f0 = n0;
+ f1 = n1;
+ f2 = n2;
+ }
+
+ public VarDeclaration(Type n0, Identifier n1) {
+ f0 = n0;
+ f1 = n1;
+ f2 = new NodeToken(";");
+ }
+
+ public void accept(minijava.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(minijava.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(minijava.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(minijava.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/minijava/syntaxtree/WhileStatement.java b/src/minijava/syntaxtree/WhileStatement.java
new file mode 100644
index 0000000..e0983e6
--- /dev/null
+++ b/src/minijava/syntaxtree/WhileStatement.java
@@ -0,0 +1,51 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package minijava.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "while"
+ * f1 -> "("
+ * f2 -> Expression()
+ * f3 -> ")"
+ * f4 -> Statement()
+ */
+public class WhileStatement implements Node {
+ public NodeToken f0;
+ public NodeToken f1;
+ public Expression f2;
+ public NodeToken f3;
+ public Statement f4;
+
+ public WhileStatement(NodeToken n0, NodeToken n1, Expression n2, NodeToken n3, Statement n4) {
+ f0 = n0;
+ f1 = n1;
+ f2 = n2;
+ f3 = n3;
+ f4 = n4;
+ }
+
+ public WhileStatement(Expression n0, Statement n1) {
+ f0 = new NodeToken("while");
+ f1 = new NodeToken("(");
+ f2 = n0;
+ f3 = new NodeToken(")");
+ f4 = n1;
+ }
+
+ public void accept(minijava.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(minijava.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(minijava.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(minijava.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/minijava/typecheck/Main.java b/src/minijava/typecheck/Main.java
new file mode 100644
index 0000000..35ac860
--- /dev/null
+++ b/src/minijava/typecheck/Main.java
@@ -0,0 +1,42 @@
+/**
+ * 用于类型检查的主函数入口
+ */
+package minijava.typecheck;
+
+import minijava.MiniJavaParser;
+import minijava.ParseException;
+import minijava.TokenMgrError;
+import minijava.symboltable.MClasses;
+import minijava.symboltable.MType;
+import minijava.syntaxtree.Node;
+import minijava.visitor.BuildSymbolTableVisitor;
+
+public class Main {
+
+ public static void main(String[] args) {
+
+ try {
+ new MiniJavaParser(System.in);
+ Node root = MiniJavaParser.Goal();
+
+ // 初始化符号表中最大的类
+ MType my_classes = new MClasses();
+
+ // 遍历抽象语法树,建立符号表,检查是否重复定义
+ root.accept(new BuildSymbolTableVisitor(), my_classes);
+
+ // 打印错误信息
+ PrintError.printAll();
+ } catch (TokenMgrError e) {
+
+ // Handle Lexical Errors
+ e.printStackTrace();
+ } catch (ParseException e) {
+
+ // Handle Grammar Errors
+ e.printStackTrace();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+} \ No newline at end of file
diff --git a/src/minijava/typecheck/PrintError.java b/src/minijava/typecheck/PrintError.java
new file mode 100644
index 0000000..a5a5157
--- /dev/null
+++ b/src/minijava/typecheck/PrintError.java
@@ -0,0 +1,24 @@
+/**
+ * 存放错误信息并统一打印
+ */
+package minijava.typecheck;
+
+import java.util.Vector;
+
+public class PrintError {
+ private static Vector<String> errors = new Vector<String>();
+
+ public static void print(int line, int column, String error_msg) {
+ String msg = "Line " + line + " Column " + column + ": " + error_msg;
+ errors.addElement(msg); // 存储错误信息
+ }
+
+ // 统一进行打印
+ public static void printAll() {
+ int sz = errors.size();
+ for (int i = 0; i < sz; i++) {
+ System.out.println(errors.elementAt(i));
+ }
+ }
+}
+
diff --git a/src/minijava/visitor/BuildSymbolTableVisitor.java b/src/minijava/visitor/BuildSymbolTableVisitor.java
new file mode 100644
index 0000000..d8d40f1
--- /dev/null
+++ b/src/minijava/visitor/BuildSymbolTableVisitor.java
@@ -0,0 +1,732 @@
+/**
+ * 用于建立符号表的类
+ */
+package minijava.visitor;
+
+import java.util.Enumeration;
+
+import minijava.symboltable.*;
+import minijava.syntaxtree.*;
+import minijava.typecheck.PrintError;
+
+public class BuildSymbolTableVisitor extends GJDepthFirst<MType, MType> {
+ //
+ // Auto class visitors--probably don't need to be overridden.
+ //
+ public MType visit(NodeList n, MType argu) {
+ MType _ret=null;
+ int _count=0;
+ for ( Enumeration<Node> e = n.elements(); e.hasMoreElements(); ) {
+ e.nextElement().accept(this,argu);
+ _count++;
+ }
+ return _ret;
+ }
+
+ public MType visit(NodeListOptional n, MType argu) {
+ if ( n.present() ) {
+ MType _ret=null;
+ int _count=0;
+ for ( Enumeration<Node> e = n.elements(); e.hasMoreElements(); ) {
+ e.nextElement().accept(this,argu);
+ _count++;
+ }
+ return _ret;
+ }
+ else
+ return null;
+ }
+
+ public MType visit(NodeOptional n, MType argu) {
+ if ( n.present() )
+ return n.node.accept(this,argu);
+ else
+ return null;
+ }
+
+ public MType visit(NodeSequence n, MType argu) {
+ MType _ret=null;
+ int _count=0;
+ for ( Enumeration<Node> e = n.elements(); e.hasMoreElements(); ) {
+ e.nextElement().accept(this,argu);
+ _count++;
+ }
+ return _ret;
+ }
+
+ public MType visit(NodeToken n, MType argu) { return null; }
+
+ //
+ // User-generated visitor methods below
+ //
+
+ /**
+ * f0 -> MainClass()
+ * f1 -> ( TypeDeclaration() )*
+ * f2 -> <EOF>
+ */
+ public MType visit(Goal n, MType argu) {
+ MType _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "class"
+ * f1 -> Identifier()
+ * f2 -> "{"
+ * f3 -> "public"
+ * f4 -> "static"
+ * f5 -> "void"
+ * f6 -> "main"
+ * f7 -> "("
+ * f8 -> "String"
+ * f9 -> "["
+ * f10 -> "]"
+ * f11 -> Identifier()
+ * f12 -> ")"
+ * f13 -> "{"
+ * f14 -> PrintStatement()
+ * f15 -> "}"
+ * f16 -> "}"
+ */
+ public MType visit(MainClass n, MType argu) {
+ MType _ret=null;
+ MClass m_class;
+ String class_name;
+ String error_msg;
+
+ n.f0.accept(this, argu);
+
+ // 处理类定义的标识符Identifier()
+ // 获得名字
+ class_name = ((MIdentifier) n.f1.accept(this, argu)).getName();
+
+ // 在符号表中插入该类,如果出错,打印出错信息
+ m_class = new MClass(class_name, (MClasses) argu, n.f1.f0.beginLine,
+ n.f1.f0.beginColumn);
+ error_msg = ((MClasses) argu).InsertClass(m_class);
+ if (error_msg != null)
+ PrintError.print(m_class.getLine(), m_class.getColumn(), error_msg);
+
+ n.f2.accept(this, argu);
+ n.f3.accept(this, argu);
+ n.f4.accept(this, argu);
+ n.f5.accept(this, argu);
+ n.f6.accept(this, argu);
+ n.f7.accept(this, argu);
+ n.f8.accept(this, argu);
+ n.f9.accept(this, argu);
+ n.f10.accept(this, argu);
+ // main的参数,待处理
+ n.f11.accept(this, argu);
+ n.f12.accept(this, argu);
+ n.f13.accept(this, argu);
+ // printStatement
+ n.f14.accept(this, argu);
+ n.f15.accept(this, argu);
+ n.f16.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> ClassDeclaration()
+ * | ClassExtendsDeclaration()
+ */
+ public MType visit(TypeDeclaration n, MType argu) {
+ MType _ret=null;
+ n.f0.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "class"
+ * f1 -> Identifier()
+ * f2 -> "{"
+ * f3 -> ( VarDeclaration() )*
+ * f4 -> ( MethodDeclaration() )*
+ * f5 -> "}"
+ */
+ public MType visit(ClassDeclaration n, MType argu) {
+ MType _ret = null;
+ MClass m_class;
+ String class_name;
+ String error_msg;
+
+ n.f0.accept(this, argu);
+
+ // 处理类定义的标识符Identifier()
+ // 获得名字
+ class_name = ((MIdentifier) n.f1.accept(this, argu)).getName();
+
+ // 在符号表中插入该类,如果出错,打印出错信息
+ m_class = new MClass(class_name, (MClasses) argu, n.f1.f0.beginLine,
+ n.f1.f0.beginColumn);
+ error_msg = ((MClasses) argu).InsertClass(m_class);
+ if (error_msg != null)
+ PrintError.print(m_class.getLine(), m_class.getColumn(), error_msg);
+
+ n.f2.accept(this, argu);
+ n.f3.accept(this, m_class);
+ n.f4.accept(this, m_class);
+ n.f5.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "class"
+ * f1 -> Identifier()
+ * f2 -> "extends"
+ * f3 -> Identifier()
+ * f4 -> "{"
+ * f5 -> ( VarDeclaration() )*
+ * f6 -> ( MethodDeclaration() )*
+ * f7 -> "}"
+ */
+ public MType visit(ClassExtendsDeclaration n, MType argu) {
+ MType _ret=null;
+ MClass m_class;
+ String class_name;
+ String error_msg;
+
+ n.f0.accept(this, argu);
+
+ // 处理子类定义,并加入符号表
+ class_name = ((MIdentifier) n.f1.accept(this, argu)).getName();
+ m_class = new MClass(class_name, (MClasses) argu, n.f1.f0.beginLine,
+ n.f1.f0.beginColumn);
+ error_msg = ((MClasses) argu).InsertClass(m_class);
+ if (error_msg != null)
+ PrintError.print(m_class.getLine(), m_class.getColumn(), error_msg);
+
+ n.f2.accept(this, argu);
+
+ // 将父类名称加入类属性
+ m_class.extend_class_name = ((MIdentifier) n.f3.accept(this, argu)).getName();
+
+ n.f4.accept(this, argu);
+ n.f5.accept(this, m_class);
+ n.f6.accept(this, m_class);
+ n.f7.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> Type()
+ * f1 -> Identifier()
+ * f2 -> ";"
+ */
+ public MType visit(VarDeclaration n, MType argu) {
+ MType _ret=null;
+ MClass m_class = (MClass)argu;
+ String var_name = n.f1.accept(this, argu).getName();
+ String type_name = n.f0.accept(this, argu).getName();
+ // debug
+ System.out.println("Variable: \'" + var_name + "\' from class " + m_class.getName());
+ System.out.println("It has type: " + type_name);
+
+ // 建立并插入变量
+ MVariable var = new MVariable(var_name, type_name, n.f1.f0.beginLine, n.f1.f0.beginColumn);
+ String _err = m_class.insertVar(var);
+ if (_err!=null) {
+ // 重复定义,则输出错误信息
+ PrintError.print(var.getLine(), var.getColumn(), _err);
+ }
+
+ n.f2.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "public"
+ * f1 -> Type()
+ * f2 -> Identifier()
+ * f3 -> "("
+ * f4 -> ( FormalParameterList() )?
+ * f5 -> ")"
+ * f6 -> "{"
+ * f7 -> ( VarDeclaration() )*
+ * f8 -> ( Statement() )*
+ * f9 -> "return"
+ * f10 -> Expression()
+ * f11 -> ";"
+ * f12 -> "}"
+ */
+ public MType visit(MethodDeclaration n, MType argu) {
+ MType _ret = null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ n.f3.accept(this, argu);
+ n.f4.accept(this, argu);
+ n.f5.accept(this, argu);
+ n.f6.accept(this, argu);
+ n.f7.accept(this, argu);
+ n.f8.accept(this, argu);
+ n.f9.accept(this, argu);
+ n.f10.accept(this, argu);
+ n.f11.accept(this, argu);
+ n.f12.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> FormalParameter()
+ * f1 -> ( FormalParameterRest() )*
+ */
+ public MType visit(FormalParameterList n, MType argu) {
+ MType _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> Type()
+ * f1 -> Identifier()
+ */
+ public MType visit(FormalParameter n, MType argu) {
+ MType _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> ","
+ * f1 -> FormalParameter()
+ */
+ public MType visit(FormalParameterRest n, MType argu) {
+ MType _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> ArrayType()
+ * | BooleanType()
+ * | IntegerType()
+ * | Identifier()
+ */
+ public MType visit(Type n, MType argu) {
+ return n.f0.accept(this, argu);
+ }
+
+ /**
+ * f0 -> "int"
+ * f1 -> "["
+ * f2 -> "]"
+ */
+ public MType visit(ArrayType n, MType argu) {
+ MType _ret = new MIdentifier(MIdentifier.arrType, n.f0.beginLine, n.f0.beginColumn);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "boolean"
+ */
+ public MType visit(BooleanType n, MType argu) {
+ MType _ret = new MIdentifier(MIdentifier.boolType, n.f0.beginLine, n.f0.beginColumn);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "int"
+ */
+ public MType visit(IntegerType n, MType argu) {
+ MType _ret = new MIdentifier(MIdentifier.intType, n.f0.beginLine, n.f0.beginColumn);
+ return _ret;
+ }
+
+ /**
+ * f0 -> Block()
+ * | AssignmentStatement()
+ * | ArrayAssignmentStatement()
+ * | IfStatement()
+ * | WhileStatement()
+ * | PrintStatement()
+ */
+ public MType visit(Statement n, MType argu) {
+ MType _ret=null;
+ n.f0.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "{"
+ * f1 -> ( Statement() )*
+ * f2 -> "}"
+ */
+ public MType visit(Block n, MType argu) {
+ MType _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> Identifier()
+ * f1 -> "="
+ * f2 -> Expression()
+ * f3 -> ";"
+ */
+ public MType visit(AssignmentStatement n, MType argu) {
+ MType _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ n.f3.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> Identifier()
+ * f1 -> "["
+ * f2 -> Expression()
+ * f3 -> "]"
+ * f4 -> "="
+ * f5 -> Expression()
+ * f6 -> ";"
+ */
+ public MType visit(ArrayAssignmentStatement n, MType argu) {
+ MType _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ n.f3.accept(this, argu);
+ n.f4.accept(this, argu);
+ n.f5.accept(this, argu);
+ n.f6.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "if"
+ * f1 -> "("
+ * f2 -> Expression()
+ * f3 -> ")"
+ * f4 -> Statement()
+ * f5 -> "else"
+ * f6 -> Statement()
+ */
+ public MType visit(IfStatement n, MType argu) {
+ MType _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ n.f3.accept(this, argu);
+ n.f4.accept(this, argu);
+ n.f5.accept(this, argu);
+ n.f6.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "while"
+ * f1 -> "("
+ * f2 -> Expression()
+ * f3 -> ")"
+ * f4 -> Statement()
+ */
+ public MType visit(WhileStatement n, MType argu) {
+ MType _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ n.f3.accept(this, argu);
+ n.f4.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "System.out.println"
+ * f1 -> "("
+ * f2 -> Expression()
+ * f3 -> ")"
+ * f4 -> ";"
+ */
+ public MType visit(PrintStatement n, MType argu) {
+ MType _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ n.f3.accept(this, argu);
+ n.f4.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> AndExpression()
+ * | CompareExpression()
+ * | PlusExpression()
+ * | MinusExpression()
+ * | TimesExpression()
+ * | ArrayLookup()
+ * | ArrayLength()
+ * | MessageSend()
+ * | PrimaryExpression()
+ */
+ public MType visit(Expression n, MType argu) {
+ MType _ret=null;
+ n.f0.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> PrimaryExpression()
+ * f1 -> "&&"
+ * f2 -> PrimaryExpression()
+ */
+ public MType visit(AndExpression n, MType argu) {
+ MType _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> PrimaryExpression()
+ * f1 -> "<"
+ * f2 -> PrimaryExpression()
+ */
+ public MType visit(CompareExpression n, MType argu) {
+ MType _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> PrimaryExpression()
+ * f1 -> "+"
+ * f2 -> PrimaryExpression()
+ */
+ public MType visit(PlusExpression n, MType argu) {
+ MType _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> PrimaryExpression()
+ * f1 -> "-"
+ * f2 -> PrimaryExpression()
+ */
+ public MType visit(MinusExpression n, MType argu) {
+ MType _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> PrimaryExpression()
+ * f1 -> "*"
+ * f2 -> PrimaryExpression()
+ */
+ public MType visit(TimesExpression n, MType argu) {
+ MType _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> PrimaryExpression()
+ * f1 -> "["
+ * f2 -> PrimaryExpression()
+ * f3 -> "]"
+ */
+ public MType visit(ArrayLookup n, MType argu) {
+ MType _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ n.f3.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> PrimaryExpression()
+ * f1 -> "."
+ * f2 -> "length"
+ */
+ public MType visit(ArrayLength n, MType argu) {
+ MType _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> PrimaryExpression()
+ * f1 -> "."
+ * f2 -> Identifier()
+ * f3 -> "("
+ * f4 -> ( ExpressionList() )?
+ * f5 -> ")"
+ */
+ public MType visit(MessageSend n, MType argu) {
+ MType _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ n.f3.accept(this, argu);
+ n.f4.accept(this, argu);
+ n.f5.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> Expression()
+ * f1 -> ( ExpressionRest() )*
+ */
+ public MType visit(ExpressionList n, MType argu) {
+ MType _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> ","
+ * f1 -> Expression()
+ */
+ public MType visit(ExpressionRest n, MType argu) {
+ MType _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> IntegerLiteral()
+ * | TrueLiteral()
+ * | FalseLiteral()
+ * | Identifier()
+ * | ThisExpression()
+ * | ArrayAllocationExpression()
+ * | AllocationExpression()
+ * | NotExpression()
+ * | BracketExpression()
+ */
+ public MType visit(PrimaryExpression n, MType argu) {
+ MType _ret=null;
+ n.f0.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> <INTEGER_LITERAL>
+ */
+ public MType visit(IntegerLiteral n, MType argu) {
+ MType _ret=null;
+ n.f0.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "true"
+ */
+ public MType visit(TrueLiteral n, MType argu) {
+ MType _ret=null;
+ n.f0.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "false"
+ */
+ public MType visit(FalseLiteral n, MType argu) {
+ MType _ret=null;
+ n.f0.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> <IDENTIFIER>
+ */
+ public MType visit(Identifier n, MType argu) {
+ String identifier_name = n.f0.toString();
+ MType _ret = null;
+ _ret = new MIdentifier(identifier_name, n.f0.beginLine, n.f0.beginColumn);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "this"
+ */
+ public MType visit(ThisExpression n, MType argu) {
+ MType _ret=null;
+ n.f0.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "new"
+ * f1 -> "int"
+ * f2 -> "["
+ * f3 -> Expression()
+ * f4 -> "]"
+ */
+ public MType visit(ArrayAllocationExpression n, MType argu) {
+ MType _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ n.f3.accept(this, argu);
+ n.f4.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "new"
+ * f1 -> Identifier()
+ * f2 -> "("
+ * f3 -> ")"
+ */
+ public MType visit(AllocationExpression n, MType argu) {
+ MType _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ n.f3.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "!"
+ * f1 -> Expression()
+ */
+ public MType visit(NotExpression n, MType argu) {
+ MType _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "("
+ * f1 -> Expression()
+ * f2 -> ")"
+ */
+ public MType visit(BracketExpression n, MType argu) {
+ MType _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ return _ret;
+ }
+
+} \ No newline at end of file
diff --git a/src/minijava/visitor/DepthFirstVisitor.java b/src/minijava/visitor/DepthFirstVisitor.java
new file mode 100644
index 0000000..57d16c2
--- /dev/null
+++ b/src/minijava/visitor/DepthFirstVisitor.java
@@ -0,0 +1,623 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package minijava.visitor;
+import java.util.Enumeration;
+
+import minijava.syntaxtree.AllocationExpression;
+import minijava.syntaxtree.AndExpression;
+import minijava.syntaxtree.ArrayAllocationExpression;
+import minijava.syntaxtree.ArrayAssignmentStatement;
+import minijava.syntaxtree.ArrayLength;
+import minijava.syntaxtree.ArrayLookup;
+import minijava.syntaxtree.ArrayType;
+import minijava.syntaxtree.AssignmentStatement;
+import minijava.syntaxtree.Block;
+import minijava.syntaxtree.BooleanType;
+import minijava.syntaxtree.BracketExpression;
+import minijava.syntaxtree.ClassDeclaration;
+import minijava.syntaxtree.ClassExtendsDeclaration;
+import minijava.syntaxtree.CompareExpression;
+import minijava.syntaxtree.Expression;
+import minijava.syntaxtree.ExpressionList;
+import minijava.syntaxtree.ExpressionRest;
+import minijava.syntaxtree.FalseLiteral;
+import minijava.syntaxtree.FormalParameter;
+import minijava.syntaxtree.FormalParameterList;
+import minijava.syntaxtree.FormalParameterRest;
+import minijava.syntaxtree.Goal;
+import minijava.syntaxtree.Identifier;
+import minijava.syntaxtree.IfStatement;
+import minijava.syntaxtree.IntegerLiteral;
+import minijava.syntaxtree.IntegerType;
+import minijava.syntaxtree.MainClass;
+import minijava.syntaxtree.MessageSend;
+import minijava.syntaxtree.MethodDeclaration;
+import minijava.syntaxtree.MinusExpression;
+import minijava.syntaxtree.Node;
+import minijava.syntaxtree.NodeList;
+import minijava.syntaxtree.NodeListOptional;
+import minijava.syntaxtree.NodeOptional;
+import minijava.syntaxtree.NodeSequence;
+import minijava.syntaxtree.NodeToken;
+import minijava.syntaxtree.NotExpression;
+import minijava.syntaxtree.PlusExpression;
+import minijava.syntaxtree.PrimaryExpression;
+import minijava.syntaxtree.PrintStatement;
+import minijava.syntaxtree.Statement;
+import minijava.syntaxtree.ThisExpression;
+import minijava.syntaxtree.TimesExpression;
+import minijava.syntaxtree.TrueLiteral;
+import minijava.syntaxtree.Type;
+import minijava.syntaxtree.TypeDeclaration;
+import minijava.syntaxtree.VarDeclaration;
+import minijava.syntaxtree.WhileStatement;
+
+/**
+ * Provides default methods which visit each node in the tree in depth-first
+ * order. Your visitors may extend this class.
+ */
+public class DepthFirstVisitor implements Visitor {
+ //
+ // Auto class visitors--probably don't need to be overridden.
+ //
+ public void visit(NodeList n) {
+ for ( Enumeration<Node> e = n.elements(); e.hasMoreElements(); )
+ e.nextElement().accept(this);
+ }
+
+ public void visit(NodeListOptional n) {
+ if ( n.present() )
+ for ( Enumeration<Node> e = n.elements(); e.hasMoreElements(); )
+ e.nextElement().accept(this);
+ }
+
+ public void visit(NodeOptional n) {
+ if ( n.present() )
+ n.node.accept(this);
+ }
+
+ public void visit(NodeSequence n) {
+ for ( Enumeration<Node> e = n.elements(); e.hasMoreElements(); )
+ e.nextElement().accept(this);
+ }
+
+ public void visit(NodeToken n) { }
+
+ //
+ // User-generated visitor methods below
+ //
+
+ /**
+ * f0 -> MainClass()
+ * f1 -> ( TypeDeclaration() )*
+ * f2 -> <EOF>
+ */
+ public void visit(Goal n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ }
+
+ /**
+ * f0 -> "class"
+ * f1 -> Identifier()
+ * f2 -> "{"
+ * f3 -> "public"
+ * f4 -> "static"
+ * f5 -> "void"
+ * f6 -> "main"
+ * f7 -> "("
+ * f8 -> "String"
+ * f9 -> "["
+ * f10 -> "]"
+ * f11 -> Identifier()
+ * f12 -> ")"
+ * f13 -> "{"
+ * f14 -> PrintStatement()
+ * f15 -> "}"
+ * f16 -> "}"
+ */
+ public void visit(MainClass n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ n.f3.accept(this);
+ n.f4.accept(this);
+ n.f5.accept(this);
+ n.f6.accept(this);
+ n.f7.accept(this);
+ n.f8.accept(this);
+ n.f9.accept(this);
+ n.f10.accept(this);
+ n.f11.accept(this);
+ n.f12.accept(this);
+ n.f13.accept(this);
+ n.f14.accept(this);
+ n.f15.accept(this);
+ n.f16.accept(this);
+ }
+
+ /**
+ * f0 -> ClassDeclaration()
+ * | ClassExtendsDeclaration()
+ */
+ public void visit(TypeDeclaration n) {
+ n.f0.accept(this);
+ }
+
+ /**
+ * f0 -> "class"
+ * f1 -> Identifier()
+ * f2 -> "{"
+ * f3 -> ( VarDeclaration() )*
+ * f4 -> ( MethodDeclaration() )*
+ * f5 -> "}"
+ */
+ public void visit(ClassDeclaration n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ n.f3.accept(this);
+ n.f4.accept(this);
+ n.f5.accept(this);
+ }
+
+ /**
+ * f0 -> "class"
+ * f1 -> Identifier()
+ * f2 -> "extends"
+ * f3 -> Identifier()
+ * f4 -> "{"
+ * f5 -> ( VarDeclaration() )*
+ * f6 -> ( MethodDeclaration() )*
+ * f7 -> "}"
+ */
+ public void visit(ClassExtendsDeclaration n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ n.f3.accept(this);
+ n.f4.accept(this);
+ n.f5.accept(this);
+ n.f6.accept(this);
+ n.f7.accept(this);
+ }
+
+ /**
+ * f0 -> Type()
+ * f1 -> Identifier()
+ * f2 -> ";"
+ */
+ public void visit(VarDeclaration n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ }
+
+ /**
+ * f0 -> "public"
+ * f1 -> Type()
+ * f2 -> Identifier()
+ * f3 -> "("
+ * f4 -> ( FormalParameterList() )?
+ * f5 -> ")"
+ * f6 -> "{"
+ * f7 -> ( VarDeclaration() )*
+ * f8 -> ( Statement() )*
+ * f9 -> "return"
+ * f10 -> Expression()
+ * f11 -> ";"
+ * f12 -> "}"
+ */
+ public void visit(MethodDeclaration n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ n.f3.accept(this);
+ n.f4.accept(this);
+ n.f5.accept(this);
+ n.f6.accept(this);
+ n.f7.accept(this);
+ n.f8.accept(this);
+ n.f9.accept(this);
+ n.f10.accept(this);
+ n.f11.accept(this);
+ n.f12.accept(this);
+ }
+
+ /**
+ * f0 -> FormalParameter()
+ * f1 -> ( FormalParameterRest() )*
+ */
+ public void visit(FormalParameterList n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ }
+
+ /**
+ * f0 -> Type()
+ * f1 -> Identifier()
+ */
+ public void visit(FormalParameter n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ }
+
+ /**
+ * f0 -> ","
+ * f1 -> FormalParameter()
+ */
+ public void visit(FormalParameterRest n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ }
+
+ /**
+ * f0 -> ArrayType()
+ * | BooleanType()
+ * | IntegerType()
+ * | Identifier()
+ */
+ public void visit(Type n) {
+ n.f0.accept(this);
+ }
+
+ /**
+ * f0 -> "int"
+ * f1 -> "["
+ * f2 -> "]"
+ */
+ public void visit(ArrayType n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ }
+
+ /**
+ * f0 -> "boolean"
+ */
+ public void visit(BooleanType n) {
+ n.f0.accept(this);
+ }
+
+ /**
+ * f0 -> "int"
+ */
+ public void visit(IntegerType n) {
+ n.f0.accept(this);
+ }
+
+ /**
+ * f0 -> Block()
+ * | AssignmentStatement()
+ * | ArrayAssignmentStatement()
+ * | IfStatement()
+ * | WhileStatement()
+ * | PrintStatement()
+ */
+ public void visit(Statement n) {
+ n.f0.accept(this);
+ }
+
+ /**
+ * f0 -> "{"
+ * f1 -> ( Statement() )*
+ * f2 -> "}"
+ */
+ public void visit(Block n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ }
+
+ /**
+ * f0 -> Identifier()
+ * f1 -> "="
+ * f2 -> Expression()
+ * f3 -> ";"
+ */
+ public void visit(AssignmentStatement n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ n.f3.accept(this);
+ }
+
+ /**
+ * f0 -> Identifier()
+ * f1 -> "["
+ * f2 -> Expression()
+ * f3 -> "]"
+ * f4 -> "="
+ * f5 -> Expression()
+ * f6 -> ";"
+ */
+ public void visit(ArrayAssignmentStatement n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ n.f3.accept(this);
+ n.f4.accept(this);
+ n.f5.accept(this);
+ n.f6.accept(this);
+ }
+
+ /**
+ * f0 -> "if"
+ * f1 -> "("
+ * f2 -> Expression()
+ * f3 -> ")"
+ * f4 -> Statement()
+ * f5 -> "else"
+ * f6 -> Statement()
+ */
+ public void visit(IfStatement n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ n.f3.accept(this);
+ n.f4.accept(this);
+ n.f5.accept(this);
+ n.f6.accept(this);
+ }
+
+ /**
+ * f0 -> "while"
+ * f1 -> "("
+ * f2 -> Expression()
+ * f3 -> ")"
+ * f4 -> Statement()
+ */
+ public void visit(WhileStatement n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ n.f3.accept(this);
+ n.f4.accept(this);
+ }
+
+ /**
+ * f0 -> "System.out.println"
+ * f1 -> "("
+ * f2 -> Expression()
+ * f3 -> ")"
+ * f4 -> ";"
+ */
+ public void visit(PrintStatement n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ n.f3.accept(this);
+ n.f4.accept(this);
+ }
+
+ /**
+ * f0 -> AndExpression()
+ * | CompareExpression()
+ * | PlusExpression()
+ * | MinusExpression()
+ * | TimesExpression()
+ * | ArrayLookup()
+ * | ArrayLength()
+ * | MessageSend()
+ * | PrimaryExpression()
+ */
+ public void visit(Expression n) {
+ n.f0.accept(this);
+ }
+
+ /**
+ * f0 -> PrimaryExpression()
+ * f1 -> "&&"
+ * f2 -> PrimaryExpression()
+ */
+ public void visit(AndExpression n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ }
+
+ /**
+ * f0 -> PrimaryExpression()
+ * f1 -> "<"
+ * f2 -> PrimaryExpression()
+ */
+ public void visit(CompareExpression n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ }
+
+ /**
+ * f0 -> PrimaryExpression()
+ * f1 -> "+"
+ * f2 -> PrimaryExpression()
+ */
+ public void visit(PlusExpression n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ }
+
+ /**
+ * f0 -> PrimaryExpression()
+ * f1 -> "-"
+ * f2 -> PrimaryExpression()
+ */
+ public void visit(MinusExpression n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ }
+
+ /**
+ * f0 -> PrimaryExpression()
+ * f1 -> "*"
+ * f2 -> PrimaryExpression()
+ */
+ public void visit(TimesExpression n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ }
+
+ /**
+ * f0 -> PrimaryExpression()
+ * f1 -> "["
+ * f2 -> PrimaryExpression()
+ * f3 -> "]"
+ */
+ public void visit(ArrayLookup n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ n.f3.accept(this);
+ }
+
+ /**
+ * f0 -> PrimaryExpression()
+ * f1 -> "."
+ * f2 -> "length"
+ */
+ public void visit(ArrayLength n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ }
+
+ /**
+ * f0 -> PrimaryExpression()
+ * f1 -> "."
+ * f2 -> Identifier()
+ * f3 -> "("
+ * f4 -> ( ExpressionList() )?
+ * f5 -> ")"
+ */
+ public void visit(MessageSend n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ n.f3.accept(this);
+ n.f4.accept(this);
+ n.f5.accept(this);
+ }
+
+ /**
+ * f0 -> Expression()
+ * f1 -> ( ExpressionRest() )*
+ */
+ public void visit(ExpressionList n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ }
+
+ /**
+ * f0 -> ","
+ * f1 -> Expression()
+ */
+ public void visit(ExpressionRest n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ }
+
+ /**
+ * f0 -> IntegerLiteral()
+ * | TrueLiteral()
+ * | FalseLiteral()
+ * | Identifier()
+ * | ThisExpression()
+ * | ArrayAllocationExpression()
+ * | AllocationExpression()
+ * | NotExpression()
+ * | BracketExpression()
+ */
+ public void visit(PrimaryExpression n) {
+ n.f0.accept(this);
+ }
+
+ /**
+ * f0 -> <INTEGER_LITERAL>
+ */
+ public void visit(IntegerLiteral n) {
+ n.f0.accept(this);
+ }
+
+ /**
+ * f0 -> "true"
+ */
+ public void visit(TrueLiteral n) {
+ n.f0.accept(this);
+ }
+
+ /**
+ * f0 -> "false"
+ */
+ public void visit(FalseLiteral n) {
+ n.f0.accept(this);
+ }
+
+ /**
+ * f0 -> <IDENTIFIER>
+ */
+ public void visit(Identifier n) {
+ n.f0.accept(this);
+ }
+
+ /**
+ * f0 -> "this"
+ */
+ public void visit(ThisExpression n) {
+ n.f0.accept(this);
+ }
+
+ /**
+ * f0 -> "new"
+ * f1 -> "int"
+ * f2 -> "["
+ * f3 -> Expression()
+ * f4 -> "]"
+ */
+ public void visit(ArrayAllocationExpression n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ n.f3.accept(this);
+ n.f4.accept(this);
+ }
+
+ /**
+ * f0 -> "new"
+ * f1 -> Identifier()
+ * f2 -> "("
+ * f3 -> ")"
+ */
+ public void visit(AllocationExpression n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ n.f3.accept(this);
+ }
+
+ /**
+ * f0 -> "!"
+ * f1 -> Expression()
+ */
+ public void visit(NotExpression n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ }
+
+ /**
+ * f0 -> "("
+ * f1 -> Expression()
+ * f2 -> ")"
+ */
+ public void visit(BracketExpression n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ }
+
+}
diff --git a/src/minijava/visitor/GJDepthFirst.java b/src/minijava/visitor/GJDepthFirst.java
new file mode 100644
index 0000000..3b3889e
--- /dev/null
+++ b/src/minijava/visitor/GJDepthFirst.java
@@ -0,0 +1,727 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package minijava.visitor;
+import java.util.Enumeration;
+
+import minijava.syntaxtree.AllocationExpression;
+import minijava.syntaxtree.AndExpression;
+import minijava.syntaxtree.ArrayAllocationExpression;
+import minijava.syntaxtree.ArrayAssignmentStatement;
+import minijava.syntaxtree.ArrayLength;
+import minijava.syntaxtree.ArrayLookup;
+import minijava.syntaxtree.ArrayType;
+import minijava.syntaxtree.AssignmentStatement;
+import minijava.syntaxtree.Block;
+import minijava.syntaxtree.BooleanType;
+import minijava.syntaxtree.BracketExpression;
+import minijava.syntaxtree.ClassDeclaration;
+import minijava.syntaxtree.ClassExtendsDeclaration;
+import minijava.syntaxtree.CompareExpression;
+import minijava.syntaxtree.Expression;
+import minijava.syntaxtree.ExpressionList;
+import minijava.syntaxtree.ExpressionRest;
+import minijava.syntaxtree.FalseLiteral;
+import minijava.syntaxtree.FormalParameter;
+import minijava.syntaxtree.FormalParameterList;
+import minijava.syntaxtree.FormalParameterRest;
+import minijava.syntaxtree.Goal;
+import minijava.syntaxtree.Identifier;
+import minijava.syntaxtree.IfStatement;
+import minijava.syntaxtree.IntegerLiteral;
+import minijava.syntaxtree.IntegerType;
+import minijava.syntaxtree.MainClass;
+import minijava.syntaxtree.MessageSend;
+import minijava.syntaxtree.MethodDeclaration;
+import minijava.syntaxtree.MinusExpression;
+import minijava.syntaxtree.Node;
+import minijava.syntaxtree.NodeList;
+import minijava.syntaxtree.NodeListOptional;
+import minijava.syntaxtree.NodeOptional;
+import minijava.syntaxtree.NodeSequence;
+import minijava.syntaxtree.NodeToken;
+import minijava.syntaxtree.NotExpression;
+import minijava.syntaxtree.PlusExpression;
+import minijava.syntaxtree.PrimaryExpression;
+import minijava.syntaxtree.PrintStatement;
+import minijava.syntaxtree.Statement;
+import minijava.syntaxtree.ThisExpression;
+import minijava.syntaxtree.TimesExpression;
+import minijava.syntaxtree.TrueLiteral;
+import minijava.syntaxtree.Type;
+import minijava.syntaxtree.TypeDeclaration;
+import minijava.syntaxtree.VarDeclaration;
+import minijava.syntaxtree.WhileStatement;
+
+/**
+ * Provides default methods which visit each node in the tree in depth-first
+ * order. Your visitors may extend this class.
+ */
+public class GJDepthFirst<R,A> implements GJVisitor<R,A> {
+ //
+ // Auto class visitors--probably don't need to be overridden.
+ //
+ public R visit(NodeList n, A argu) {
+ R _ret=null;
+ int _count=0;
+ for ( Enumeration<Node> e = n.elements(); e.hasMoreElements(); ) {
+ e.nextElement().accept(this,argu);
+ _count++;
+ }
+ return _ret;
+ }
+
+ public R visit(NodeListOptional n, A argu) {
+ if ( n.present() ) {
+ R _ret=null;
+ int _count=0;
+ for ( Enumeration<Node> e = n.elements(); e.hasMoreElements(); ) {
+ e.nextElement().accept(this,argu);
+ _count++;
+ }
+ return _ret;
+ }
+ else
+ return null;
+ }
+
+ public R visit(NodeOptional n, A argu) {
+ if ( n.present() )
+ return n.node.accept(this,argu);
+ else
+ return null;
+ }
+
+ public R visit(NodeSequence n, A argu) {
+ R _ret=null;
+ int _count=0;
+ for ( Enumeration<Node> e = n.elements(); e.hasMoreElements(); ) {
+ e.nextElement().accept(this,argu);
+ _count++;
+ }
+ return _ret;
+ }
+
+ public R visit(NodeToken n, A argu) { return null; }
+
+ //
+ // User-generated visitor methods below
+ //
+
+ /**
+ * f0 -> MainClass()
+ * f1 -> ( TypeDeclaration() )*
+ * f2 -> <EOF>
+ */
+ public R visit(Goal n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "class"
+ * f1 -> Identifier()
+ * f2 -> "{"
+ * f3 -> "public"
+ * f4 -> "static"
+ * f5 -> "void"
+ * f6 -> "main"
+ * f7 -> "("
+ * f8 -> "String"
+ * f9 -> "["
+ * f10 -> "]"
+ * f11 -> Identifier()
+ * f12 -> ")"
+ * f13 -> "{"
+ * f14 -> PrintStatement()
+ * f15 -> "}"
+ * f16 -> "}"
+ */
+ public R visit(MainClass n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ n.f3.accept(this, argu);
+ n.f4.accept(this, argu);
+ n.f5.accept(this, argu);
+ n.f6.accept(this, argu);
+ n.f7.accept(this, argu);
+ n.f8.accept(this, argu);
+ n.f9.accept(this, argu);
+ n.f10.accept(this, argu);
+ n.f11.accept(this, argu);
+ n.f12.accept(this, argu);
+ n.f13.accept(this, argu);
+ n.f14.accept(this, argu);
+ n.f15.accept(this, argu);
+ n.f16.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> ClassDeclaration()
+ * | ClassExtendsDeclaration()
+ */
+ public R visit(TypeDeclaration n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "class"
+ * f1 -> Identifier()
+ * f2 -> "{"
+ * f3 -> ( VarDeclaration() )*
+ * f4 -> ( MethodDeclaration() )*
+ * f5 -> "}"
+ */
+ public R visit(ClassDeclaration n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ n.f3.accept(this, argu);
+ n.f4.accept(this, argu);
+ n.f5.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "class"
+ * f1 -> Identifier()
+ * f2 -> "extends"
+ * f3 -> Identifier()
+ * f4 -> "{"
+ * f5 -> ( VarDeclaration() )*
+ * f6 -> ( MethodDeclaration() )*
+ * f7 -> "}"
+ */
+ public R visit(ClassExtendsDeclaration n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ n.f3.accept(this, argu);
+ n.f4.accept(this, argu);
+ n.f5.accept(this, argu);
+ n.f6.accept(this, argu);
+ n.f7.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> Type()
+ * f1 -> Identifier()
+ * f2 -> ";"
+ */
+ public R visit(VarDeclaration n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "public"
+ * f1 -> Type()
+ * f2 -> Identifier()
+ * f3 -> "("
+ * f4 -> ( FormalParameterList() )?
+ * f5 -> ")"
+ * f6 -> "{"
+ * f7 -> ( VarDeclaration() )*
+ * f8 -> ( Statement() )*
+ * f9 -> "return"
+ * f10 -> Expression()
+ * f11 -> ";"
+ * f12 -> "}"
+ */
+ public R visit(MethodDeclaration n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ n.f3.accept(this, argu);
+ n.f4.accept(this, argu);
+ n.f5.accept(this, argu);
+ n.f6.accept(this, argu);
+ n.f7.accept(this, argu);
+ n.f8.accept(this, argu);
+ n.f9.accept(this, argu);
+ n.f10.accept(this, argu);
+ n.f11.accept(this, argu);
+ n.f12.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> FormalParameter()
+ * f1 -> ( FormalParameterRest() )*
+ */
+ public R visit(FormalParameterList n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> Type()
+ * f1 -> Identifier()
+ */
+ public R visit(FormalParameter n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> ","
+ * f1 -> FormalParameter()
+ */
+ public R visit(FormalParameterRest n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> ArrayType()
+ * | BooleanType()
+ * | IntegerType()
+ * | Identifier()
+ */
+ public R visit(Type n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "int"
+ * f1 -> "["
+ * f2 -> "]"
+ */
+ public R visit(ArrayType n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "boolean"
+ */
+ public R visit(BooleanType n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "int"
+ */
+ public R visit(IntegerType n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> Block()
+ * | AssignmentStatement()
+ * | ArrayAssignmentStatement()
+ * | IfStatement()
+ * | WhileStatement()
+ * | PrintStatement()
+ */
+ public R visit(Statement n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "{"
+ * f1 -> ( Statement() )*
+ * f2 -> "}"
+ */
+ public R visit(Block n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> Identifier()
+ * f1 -> "="
+ * f2 -> Expression()
+ * f3 -> ";"
+ */
+ public R visit(AssignmentStatement n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ n.f3.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> Identifier()
+ * f1 -> "["
+ * f2 -> Expression()
+ * f3 -> "]"
+ * f4 -> "="
+ * f5 -> Expression()
+ * f6 -> ";"
+ */
+ public R visit(ArrayAssignmentStatement n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ n.f3.accept(this, argu);
+ n.f4.accept(this, argu);
+ n.f5.accept(this, argu);
+ n.f6.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "if"
+ * f1 -> "("
+ * f2 -> Expression()
+ * f3 -> ")"
+ * f4 -> Statement()
+ * f5 -> "else"
+ * f6 -> Statement()
+ */
+ public R visit(IfStatement n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ n.f3.accept(this, argu);
+ n.f4.accept(this, argu);
+ n.f5.accept(this, argu);
+ n.f6.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "while"
+ * f1 -> "("
+ * f2 -> Expression()
+ * f3 -> ")"
+ * f4 -> Statement()
+ */
+ public R visit(WhileStatement n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ n.f3.accept(this, argu);
+ n.f4.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "System.out.println"
+ * f1 -> "("
+ * f2 -> Expression()
+ * f3 -> ")"
+ * f4 -> ";"
+ */
+ public R visit(PrintStatement n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ n.f3.accept(this, argu);
+ n.f4.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> AndExpression()
+ * | CompareExpression()
+ * | PlusExpression()
+ * | MinusExpression()
+ * | TimesExpression()
+ * | ArrayLookup()
+ * | ArrayLength()
+ * | MessageSend()
+ * | PrimaryExpression()
+ */
+ public R visit(Expression n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> PrimaryExpression()
+ * f1 -> "&&"
+ * f2 -> PrimaryExpression()
+ */
+ public R visit(AndExpression n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> PrimaryExpression()
+ * f1 -> "<"
+ * f2 -> PrimaryExpression()
+ */
+ public R visit(CompareExpression n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> PrimaryExpression()
+ * f1 -> "+"
+ * f2 -> PrimaryExpression()
+ */
+ public R visit(PlusExpression n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> PrimaryExpression()
+ * f1 -> "-"
+ * f2 -> PrimaryExpression()
+ */
+ public R visit(MinusExpression n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> PrimaryExpression()
+ * f1 -> "*"
+ * f2 -> PrimaryExpression()
+ */
+ public R visit(TimesExpression n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> PrimaryExpression()
+ * f1 -> "["
+ * f2 -> PrimaryExpression()
+ * f3 -> "]"
+ */
+ public R visit(ArrayLookup n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ n.f3.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> PrimaryExpression()
+ * f1 -> "."
+ * f2 -> "length"
+ */
+ public R visit(ArrayLength n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> PrimaryExpression()
+ * f1 -> "."
+ * f2 -> Identifier()
+ * f3 -> "("
+ * f4 -> ( ExpressionList() )?
+ * f5 -> ")"
+ */
+ public R visit(MessageSend n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ n.f3.accept(this, argu);
+ n.f4.accept(this, argu);
+ n.f5.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> Expression()
+ * f1 -> ( ExpressionRest() )*
+ */
+ public R visit(ExpressionList n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> ","
+ * f1 -> Expression()
+ */
+ public R visit(ExpressionRest n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> IntegerLiteral()
+ * | TrueLiteral()
+ * | FalseLiteral()
+ * | Identifier()
+ * | ThisExpression()
+ * | ArrayAllocationExpression()
+ * | AllocationExpression()
+ * | NotExpression()
+ * | BracketExpression()
+ */
+ public R visit(PrimaryExpression n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> <INTEGER_LITERAL>
+ */
+ public R visit(IntegerLiteral n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "true"
+ */
+ public R visit(TrueLiteral n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "false"
+ */
+ public R visit(FalseLiteral n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> <IDENTIFIER>
+ */
+ public R visit(Identifier n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "this"
+ */
+ public R visit(ThisExpression n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "new"
+ * f1 -> "int"
+ * f2 -> "["
+ * f3 -> Expression()
+ * f4 -> "]"
+ */
+ public R visit(ArrayAllocationExpression n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ n.f3.accept(this, argu);
+ n.f4.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "new"
+ * f1 -> Identifier()
+ * f2 -> "("
+ * f3 -> ")"
+ */
+ public R visit(AllocationExpression n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ n.f3.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "!"
+ * f1 -> Expression()
+ */
+ public R visit(NotExpression n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "("
+ * f1 -> Expression()
+ * f2 -> ")"
+ */
+ public R visit(BracketExpression n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ return _ret;
+ }
+
+}
diff --git a/src/minijava/visitor/GJNoArguDepthFirst.java b/src/minijava/visitor/GJNoArguDepthFirst.java
new file mode 100644
index 0000000..b44ecbc
--- /dev/null
+++ b/src/minijava/visitor/GJNoArguDepthFirst.java
@@ -0,0 +1,727 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package minijava.visitor;
+import java.util.Enumeration;
+
+import minijava.syntaxtree.AllocationExpression;
+import minijava.syntaxtree.AndExpression;
+import minijava.syntaxtree.ArrayAllocationExpression;
+import minijava.syntaxtree.ArrayAssignmentStatement;
+import minijava.syntaxtree.ArrayLength;
+import minijava.syntaxtree.ArrayLookup;
+import minijava.syntaxtree.ArrayType;
+import minijava.syntaxtree.AssignmentStatement;
+import minijava.syntaxtree.Block;
+import minijava.syntaxtree.BooleanType;
+import minijava.syntaxtree.BracketExpression;
+import minijava.syntaxtree.ClassDeclaration;
+import minijava.syntaxtree.ClassExtendsDeclaration;
+import minijava.syntaxtree.CompareExpression;
+import minijava.syntaxtree.Expression;
+import minijava.syntaxtree.ExpressionList;
+import minijava.syntaxtree.ExpressionRest;
+import minijava.syntaxtree.FalseLiteral;
+import minijava.syntaxtree.FormalParameter;
+import minijava.syntaxtree.FormalParameterList;
+import minijava.syntaxtree.FormalParameterRest;
+import minijava.syntaxtree.Goal;
+import minijava.syntaxtree.Identifier;
+import minijava.syntaxtree.IfStatement;
+import minijava.syntaxtree.IntegerLiteral;
+import minijava.syntaxtree.IntegerType;
+import minijava.syntaxtree.MainClass;
+import minijava.syntaxtree.MessageSend;
+import minijava.syntaxtree.MethodDeclaration;
+import minijava.syntaxtree.MinusExpression;
+import minijava.syntaxtree.Node;
+import minijava.syntaxtree.NodeList;
+import minijava.syntaxtree.NodeListOptional;
+import minijava.syntaxtree.NodeOptional;
+import minijava.syntaxtree.NodeSequence;
+import minijava.syntaxtree.NodeToken;
+import minijava.syntaxtree.NotExpression;
+import minijava.syntaxtree.PlusExpression;
+import minijava.syntaxtree.PrimaryExpression;
+import minijava.syntaxtree.PrintStatement;
+import minijava.syntaxtree.Statement;
+import minijava.syntaxtree.ThisExpression;
+import minijava.syntaxtree.TimesExpression;
+import minijava.syntaxtree.TrueLiteral;
+import minijava.syntaxtree.Type;
+import minijava.syntaxtree.TypeDeclaration;
+import minijava.syntaxtree.VarDeclaration;
+import minijava.syntaxtree.WhileStatement;
+
+/**
+ * Provides default methods which visit each node in the tree in depth-first
+ * order. Your visitors may extend this class.
+ */
+public class GJNoArguDepthFirst<R> implements GJNoArguVisitor<R> {
+ //
+ // Auto class visitors--probably don't need to be overridden.
+ //
+ public R visit(NodeList n) {
+ R _ret=null;
+ int _count=0;
+ for ( Enumeration<Node> e = n.elements(); e.hasMoreElements(); ) {
+ e.nextElement().accept(this);
+ _count++;
+ }
+ return _ret;
+ }
+
+ public R visit(NodeListOptional n) {
+ if ( n.present() ) {
+ R _ret=null;
+ int _count=0;
+ for ( Enumeration<Node> e = n.elements(); e.hasMoreElements(); ) {
+ e.nextElement().accept(this);
+ _count++;
+ }
+ return _ret;
+ }
+ else
+ return null;
+ }
+
+ public R visit(NodeOptional n) {
+ if ( n.present() )
+ return n.node.accept(this);
+ else
+ return null;
+ }
+
+ public R visit(NodeSequence n) {
+ R _ret=null;
+ int _count=0;
+ for ( Enumeration<Node> e = n.elements(); e.hasMoreElements(); ) {
+ e.nextElement().accept(this);
+ _count++;
+ }
+ return _ret;
+ }
+
+ public R visit(NodeToken n) { return null; }
+
+ //
+ // User-generated visitor methods below
+ //
+
+ /**
+ * f0 -> MainClass()
+ * f1 -> ( TypeDeclaration() )*
+ * f2 -> <EOF>
+ */
+ public R visit(Goal n) {
+ R _ret=null;
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "class"
+ * f1 -> Identifier()
+ * f2 -> "{"
+ * f3 -> "public"
+ * f4 -> "static"
+ * f5 -> "void"
+ * f6 -> "main"
+ * f7 -> "("
+ * f8 -> "String"
+ * f9 -> "["
+ * f10 -> "]"
+ * f11 -> Identifier()
+ * f12 -> ")"
+ * f13 -> "{"
+ * f14 -> PrintStatement()
+ * f15 -> "}"
+ * f16 -> "}"
+ */
+ public R visit(MainClass n) {
+ R _ret=null;
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ n.f3.accept(this);
+ n.f4.accept(this);
+ n.f5.accept(this);
+ n.f6.accept(this);
+ n.f7.accept(this);
+ n.f8.accept(this);
+ n.f9.accept(this);
+ n.f10.accept(this);
+ n.f11.accept(this);
+ n.f12.accept(this);
+ n.f13.accept(this);
+ n.f14.accept(this);
+ n.f15.accept(this);
+ n.f16.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> ClassDeclaration()
+ * | ClassExtendsDeclaration()
+ */
+ public R visit(TypeDeclaration n) {
+ R _ret=null;
+ n.f0.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "class"
+ * f1 -> Identifier()
+ * f2 -> "{"
+ * f3 -> ( VarDeclaration() )*
+ * f4 -> ( MethodDeclaration() )*
+ * f5 -> "}"
+ */
+ public R visit(ClassDeclaration n) {
+ R _ret=null;
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ n.f3.accept(this);
+ n.f4.accept(this);
+ n.f5.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "class"
+ * f1 -> Identifier()
+ * f2 -> "extends"
+ * f3 -> Identifier()
+ * f4 -> "{"
+ * f5 -> ( VarDeclaration() )*
+ * f6 -> ( MethodDeclaration() )*
+ * f7 -> "}"
+ */
+ public R visit(ClassExtendsDeclaration n) {
+ R _ret=null;
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ n.f3.accept(this);
+ n.f4.accept(this);
+ n.f5.accept(this);
+ n.f6.accept(this);
+ n.f7.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> Type()
+ * f1 -> Identifier()
+ * f2 -> ";"
+ */
+ public R visit(VarDeclaration n) {
+ R _ret=null;
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "public"
+ * f1 -> Type()
+ * f2 -> Identifier()
+ * f3 -> "("
+ * f4 -> ( FormalParameterList() )?
+ * f5 -> ")"
+ * f6 -> "{"
+ * f7 -> ( VarDeclaration() )*
+ * f8 -> ( Statement() )*
+ * f9 -> "return"
+ * f10 -> Expression()
+ * f11 -> ";"
+ * f12 -> "}"
+ */
+ public R visit(MethodDeclaration n) {
+ R _ret=null;
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ n.f3.accept(this);
+ n.f4.accept(this);
+ n.f5.accept(this);
+ n.f6.accept(this);
+ n.f7.accept(this);
+ n.f8.accept(this);
+ n.f9.accept(this);
+ n.f10.accept(this);
+ n.f11.accept(this);
+ n.f12.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> FormalParameter()
+ * f1 -> ( FormalParameterRest() )*
+ */
+ public R visit(FormalParameterList n) {
+ R _ret=null;
+ n.f0.accept(this);
+ n.f1.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> Type()
+ * f1 -> Identifier()
+ */
+ public R visit(FormalParameter n) {
+ R _ret=null;
+ n.f0.accept(this);
+ n.f1.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> ","
+ * f1 -> FormalParameter()
+ */
+ public R visit(FormalParameterRest n) {
+ R _ret=null;
+ n.f0.accept(this);
+ n.f1.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> ArrayType()
+ * | BooleanType()
+ * | IntegerType()
+ * | Identifier()
+ */
+ public R visit(Type n) {
+ R _ret=null;
+ n.f0.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "int"
+ * f1 -> "["
+ * f2 -> "]"
+ */
+ public R visit(ArrayType n) {
+ R _ret=null;
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "boolean"
+ */
+ public R visit(BooleanType n) {
+ R _ret=null;
+ n.f0.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "int"
+ */
+ public R visit(IntegerType n) {
+ R _ret=null;
+ n.f0.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> Block()
+ * | AssignmentStatement()
+ * | ArrayAssignmentStatement()
+ * | IfStatement()
+ * | WhileStatement()
+ * | PrintStatement()
+ */
+ public R visit(Statement n) {
+ R _ret=null;
+ n.f0.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "{"
+ * f1 -> ( Statement() )*
+ * f2 -> "}"
+ */
+ public R visit(Block n) {
+ R _ret=null;
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> Identifier()
+ * f1 -> "="
+ * f2 -> Expression()
+ * f3 -> ";"
+ */
+ public R visit(AssignmentStatement n) {
+ R _ret=null;
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ n.f3.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> Identifier()
+ * f1 -> "["
+ * f2 -> Expression()
+ * f3 -> "]"
+ * f4 -> "="
+ * f5 -> Expression()
+ * f6 -> ";"
+ */
+ public R visit(ArrayAssignmentStatement n) {
+ R _ret=null;
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ n.f3.accept(this);
+ n.f4.accept(this);
+ n.f5.accept(this);
+ n.f6.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "if"
+ * f1 -> "("
+ * f2 -> Expression()
+ * f3 -> ")"
+ * f4 -> Statement()
+ * f5 -> "else"
+ * f6 -> Statement()
+ */
+ public R visit(IfStatement n) {
+ R _ret=null;
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ n.f3.accept(this);
+ n.f4.accept(this);
+ n.f5.accept(this);
+ n.f6.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "while"
+ * f1 -> "("
+ * f2 -> Expression()
+ * f3 -> ")"
+ * f4 -> Statement()
+ */
+ public R visit(WhileStatement n) {
+ R _ret=null;
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ n.f3.accept(this);
+ n.f4.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "System.out.println"
+ * f1 -> "("
+ * f2 -> Expression()
+ * f3 -> ")"
+ * f4 -> ";"
+ */
+ public R visit(PrintStatement n) {
+ R _ret=null;
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ n.f3.accept(this);
+ n.f4.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> AndExpression()
+ * | CompareExpression()
+ * | PlusExpression()
+ * | MinusExpression()
+ * | TimesExpression()
+ * | ArrayLookup()
+ * | ArrayLength()
+ * | MessageSend()
+ * | PrimaryExpression()
+ */
+ public R visit(Expression n) {
+ R _ret=null;
+ n.f0.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> PrimaryExpression()
+ * f1 -> "&&"
+ * f2 -> PrimaryExpression()
+ */
+ public R visit(AndExpression n) {
+ R _ret=null;
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> PrimaryExpression()
+ * f1 -> "<"
+ * f2 -> PrimaryExpression()
+ */
+ public R visit(CompareExpression n) {
+ R _ret=null;
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> PrimaryExpression()
+ * f1 -> "+"
+ * f2 -> PrimaryExpression()
+ */
+ public R visit(PlusExpression n) {
+ R _ret=null;
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> PrimaryExpression()
+ * f1 -> "-"
+ * f2 -> PrimaryExpression()
+ */
+ public R visit(MinusExpression n) {
+ R _ret=null;
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> PrimaryExpression()
+ * f1 -> "*"
+ * f2 -> PrimaryExpression()
+ */
+ public R visit(TimesExpression n) {
+ R _ret=null;
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> PrimaryExpression()
+ * f1 -> "["
+ * f2 -> PrimaryExpression()
+ * f3 -> "]"
+ */
+ public R visit(ArrayLookup n) {
+ R _ret=null;
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ n.f3.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> PrimaryExpression()
+ * f1 -> "."
+ * f2 -> "length"
+ */
+ public R visit(ArrayLength n) {
+ R _ret=null;
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> PrimaryExpression()
+ * f1 -> "."
+ * f2 -> Identifier()
+ * f3 -> "("
+ * f4 -> ( ExpressionList() )?
+ * f5 -> ")"
+ */
+ public R visit(MessageSend n) {
+ R _ret=null;
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ n.f3.accept(this);
+ n.f4.accept(this);
+ n.f5.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> Expression()
+ * f1 -> ( ExpressionRest() )*
+ */
+ public R visit(ExpressionList n) {
+ R _ret=null;
+ n.f0.accept(this);
+ n.f1.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> ","
+ * f1 -> Expression()
+ */
+ public R visit(ExpressionRest n) {
+ R _ret=null;
+ n.f0.accept(this);
+ n.f1.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> IntegerLiteral()
+ * | TrueLiteral()
+ * | FalseLiteral()
+ * | Identifier()
+ * | ThisExpression()
+ * | ArrayAllocationExpression()
+ * | AllocationExpression()
+ * | NotExpression()
+ * | BracketExpression()
+ */
+ public R visit(PrimaryExpression n) {
+ R _ret=null;
+ n.f0.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> <INTEGER_LITERAL>
+ */
+ public R visit(IntegerLiteral n) {
+ R _ret=null;
+ n.f0.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "true"
+ */
+ public R visit(TrueLiteral n) {
+ R _ret=null;
+ n.f0.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "false"
+ */
+ public R visit(FalseLiteral n) {
+ R _ret=null;
+ n.f0.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> <IDENTIFIER>
+ */
+ public R visit(Identifier n) {
+ R _ret=null;
+ n.f0.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "this"
+ */
+ public R visit(ThisExpression n) {
+ R _ret=null;
+ n.f0.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "new"
+ * f1 -> "int"
+ * f2 -> "["
+ * f3 -> Expression()
+ * f4 -> "]"
+ */
+ public R visit(ArrayAllocationExpression n) {
+ R _ret=null;
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ n.f3.accept(this);
+ n.f4.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "new"
+ * f1 -> Identifier()
+ * f2 -> "("
+ * f3 -> ")"
+ */
+ public R visit(AllocationExpression n) {
+ R _ret=null;
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ n.f3.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "!"
+ * f1 -> Expression()
+ */
+ public R visit(NotExpression n) {
+ R _ret=null;
+ n.f0.accept(this);
+ n.f1.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "("
+ * f1 -> Expression()
+ * f2 -> ")"
+ */
+ public R visit(BracketExpression n) {
+ R _ret=null;
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ return _ret;
+ }
+
+}
diff --git a/src/minijava/visitor/GJNoArguVisitor.java b/src/minijava/visitor/GJNoArguVisitor.java
new file mode 100644
index 0000000..3ef4ecc
--- /dev/null
+++ b/src/minijava/visitor/GJNoArguVisitor.java
@@ -0,0 +1,416 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package minijava.visitor;
+import minijava.syntaxtree.AllocationExpression;
+import minijava.syntaxtree.AndExpression;
+import minijava.syntaxtree.ArrayAllocationExpression;
+import minijava.syntaxtree.ArrayAssignmentStatement;
+import minijava.syntaxtree.ArrayLength;
+import minijava.syntaxtree.ArrayLookup;
+import minijava.syntaxtree.ArrayType;
+import minijava.syntaxtree.AssignmentStatement;
+import minijava.syntaxtree.Block;
+import minijava.syntaxtree.BooleanType;
+import minijava.syntaxtree.BracketExpression;
+import minijava.syntaxtree.ClassDeclaration;
+import minijava.syntaxtree.ClassExtendsDeclaration;
+import minijava.syntaxtree.CompareExpression;
+import minijava.syntaxtree.Expression;
+import minijava.syntaxtree.ExpressionList;
+import minijava.syntaxtree.ExpressionRest;
+import minijava.syntaxtree.FalseLiteral;
+import minijava.syntaxtree.FormalParameter;
+import minijava.syntaxtree.FormalParameterList;
+import minijava.syntaxtree.FormalParameterRest;
+import minijava.syntaxtree.Goal;
+import minijava.syntaxtree.Identifier;
+import minijava.syntaxtree.IfStatement;
+import minijava.syntaxtree.IntegerLiteral;
+import minijava.syntaxtree.IntegerType;
+import minijava.syntaxtree.MainClass;
+import minijava.syntaxtree.MessageSend;
+import minijava.syntaxtree.MethodDeclaration;
+import minijava.syntaxtree.MinusExpression;
+import minijava.syntaxtree.NodeList;
+import minijava.syntaxtree.NodeListOptional;
+import minijava.syntaxtree.NodeOptional;
+import minijava.syntaxtree.NodeSequence;
+import minijava.syntaxtree.NodeToken;
+import minijava.syntaxtree.NotExpression;
+import minijava.syntaxtree.PlusExpression;
+import minijava.syntaxtree.PrimaryExpression;
+import minijava.syntaxtree.PrintStatement;
+import minijava.syntaxtree.Statement;
+import minijava.syntaxtree.ThisExpression;
+import minijava.syntaxtree.TimesExpression;
+import minijava.syntaxtree.TrueLiteral;
+import minijava.syntaxtree.Type;
+import minijava.syntaxtree.TypeDeclaration;
+import minijava.syntaxtree.VarDeclaration;
+import minijava.syntaxtree.WhileStatement;
+
+/**
+ * All GJ visitors with no argument must implement this interface.
+ */
+
+public interface GJNoArguVisitor<R> {
+
+ //
+ // GJ Auto class visitors with no argument
+ //
+
+ public R visit(NodeList n);
+ public R visit(NodeListOptional n);
+ public R visit(NodeOptional n);
+ public R visit(NodeSequence n);
+ public R visit(NodeToken n);
+
+ //
+ // User-generated visitor methods below
+ //
+
+ /**
+ * f0 -> MainClass()
+ * f1 -> ( TypeDeclaration() )*
+ * f2 -> <EOF>
+ */
+ public R visit(Goal n);
+
+ /**
+ * f0 -> "class"
+ * f1 -> Identifier()
+ * f2 -> "{"
+ * f3 -> "public"
+ * f4 -> "static"
+ * f5 -> "void"
+ * f6 -> "main"
+ * f7 -> "("
+ * f8 -> "String"
+ * f9 -> "["
+ * f10 -> "]"
+ * f11 -> Identifier()
+ * f12 -> ")"
+ * f13 -> "{"
+ * f14 -> PrintStatement()
+ * f15 -> "}"
+ * f16 -> "}"
+ */
+ public R visit(MainClass n);
+
+ /**
+ * f0 -> ClassDeclaration()
+ * | ClassExtendsDeclaration()
+ */
+ public R visit(TypeDeclaration n);
+
+ /**
+ * f0 -> "class"
+ * f1 -> Identifier()
+ * f2 -> "{"
+ * f3 -> ( VarDeclaration() )*
+ * f4 -> ( MethodDeclaration() )*
+ * f5 -> "}"
+ */
+ public R visit(ClassDeclaration n);
+
+ /**
+ * f0 -> "class"
+ * f1 -> Identifier()
+ * f2 -> "extends"
+ * f3 -> Identifier()
+ * f4 -> "{"
+ * f5 -> ( VarDeclaration() )*
+ * f6 -> ( MethodDeclaration() )*
+ * f7 -> "}"
+ */
+ public R visit(ClassExtendsDeclaration n);
+
+ /**
+ * f0 -> Type()
+ * f1 -> Identifier()
+ * f2 -> ";"
+ */
+ public R visit(VarDeclaration n);
+
+ /**
+ * f0 -> "public"
+ * f1 -> Type()
+ * f2 -> Identifier()
+ * f3 -> "("
+ * f4 -> ( FormalParameterList() )?
+ * f5 -> ")"
+ * f6 -> "{"
+ * f7 -> ( VarDeclaration() )*
+ * f8 -> ( Statement() )*
+ * f9 -> "return"
+ * f10 -> Expression()
+ * f11 -> ";"
+ * f12 -> "}"
+ */
+ public R visit(MethodDeclaration n);
+
+ /**
+ * f0 -> FormalParameter()
+ * f1 -> ( FormalParameterRest() )*
+ */
+ public R visit(FormalParameterList n);
+
+ /**
+ * f0 -> Type()
+ * f1 -> Identifier()
+ */
+ public R visit(FormalParameter n);
+
+ /**
+ * f0 -> ","
+ * f1 -> FormalParameter()
+ */
+ public R visit(FormalParameterRest n);
+
+ /**
+ * f0 -> ArrayType()
+ * | BooleanType()
+ * | IntegerType()
+ * | Identifier()
+ */
+ public R visit(Type n);
+
+ /**
+ * f0 -> "int"
+ * f1 -> "["
+ * f2 -> "]"
+ */
+ public R visit(ArrayType n);
+
+ /**
+ * f0 -> "boolean"
+ */
+ public R visit(BooleanType n);
+
+ /**
+ * f0 -> "int"
+ */
+ public R visit(IntegerType n);
+
+ /**
+ * f0 -> Block()
+ * | AssignmentStatement()
+ * | ArrayAssignmentStatement()
+ * | IfStatement()
+ * | WhileStatement()
+ * | PrintStatement()
+ */
+ public R visit(Statement n);
+
+ /**
+ * f0 -> "{"
+ * f1 -> ( Statement() )*
+ * f2 -> "}"
+ */
+ public R visit(Block n);
+
+ /**
+ * f0 -> Identifier()
+ * f1 -> "="
+ * f2 -> Expression()
+ * f3 -> ";"
+ */
+ public R visit(AssignmentStatement n);
+
+ /**
+ * f0 -> Identifier()
+ * f1 -> "["
+ * f2 -> Expression()
+ * f3 -> "]"
+ * f4 -> "="
+ * f5 -> Expression()
+ * f6 -> ";"
+ */
+ public R visit(ArrayAssignmentStatement n);
+
+ /**
+ * f0 -> "if"
+ * f1 -> "("
+ * f2 -> Expression()
+ * f3 -> ")"
+ * f4 -> Statement()
+ * f5 -> "else"
+ * f6 -> Statement()
+ */
+ public R visit(IfStatement n);
+
+ /**
+ * f0 -> "while"
+ * f1 -> "("
+ * f2 -> Expression()
+ * f3 -> ")"
+ * f4 -> Statement()
+ */
+ public R visit(WhileStatement n);
+
+ /**
+ * f0 -> "System.out.println"
+ * f1 -> "("
+ * f2 -> Expression()
+ * f3 -> ")"
+ * f4 -> ";"
+ */
+ public R visit(PrintStatement n);
+
+ /**
+ * f0 -> AndExpression()
+ * | CompareExpression()
+ * | PlusExpression()
+ * | MinusExpression()
+ * | TimesExpression()
+ * | ArrayLookup()
+ * | ArrayLength()
+ * | MessageSend()
+ * | PrimaryExpression()
+ */
+ public R visit(Expression n);
+
+ /**
+ * f0 -> PrimaryExpression()
+ * f1 -> "&&"
+ * f2 -> PrimaryExpression()
+ */
+ public R visit(AndExpression n);
+
+ /**
+ * f0 -> PrimaryExpression()
+ * f1 -> "<"
+ * f2 -> PrimaryExpression()
+ */
+ public R visit(CompareExpression n);
+
+ /**
+ * f0 -> PrimaryExpression()
+ * f1 -> "+"
+ * f2 -> PrimaryExpression()
+ */
+ public R visit(PlusExpression n);
+
+ /**
+ * f0 -> PrimaryExpression()
+ * f1 -> "-"
+ * f2 -> PrimaryExpression()
+ */
+ public R visit(MinusExpression n);
+
+ /**
+ * f0 -> PrimaryExpression()
+ * f1 -> "*"
+ * f2 -> PrimaryExpression()
+ */
+ public R visit(TimesExpression n);
+
+ /**
+ * f0 -> PrimaryExpression()
+ * f1 -> "["
+ * f2 -> PrimaryExpression()
+ * f3 -> "]"
+ */
+ public R visit(ArrayLookup n);
+
+ /**
+ * f0 -> PrimaryExpression()
+ * f1 -> "."
+ * f2 -> "length"
+ */
+ public R visit(ArrayLength n);
+
+ /**
+ * f0 -> PrimaryExpression()
+ * f1 -> "."
+ * f2 -> Identifier()
+ * f3 -> "("
+ * f4 -> ( ExpressionList() )?
+ * f5 -> ")"
+ */
+ public R visit(MessageSend n);
+
+ /**
+ * f0 -> Expression()
+ * f1 -> ( ExpressionRest() )*
+ */
+ public R visit(ExpressionList n);
+
+ /**
+ * f0 -> ","
+ * f1 -> Expression()
+ */
+ public R visit(ExpressionRest n);
+
+ /**
+ * f0 -> IntegerLiteral()
+ * | TrueLiteral()
+ * | FalseLiteral()
+ * | Identifier()
+ * | ThisExpression()
+ * | ArrayAllocationExpression()
+ * | AllocationExpression()
+ * | NotExpression()
+ * | BracketExpression()
+ */
+ public R visit(PrimaryExpression n);
+
+ /**
+ * f0 -> <INTEGER_LITERAL>
+ */
+ public R visit(IntegerLiteral n);
+
+ /**
+ * f0 -> "true"
+ */
+ public R visit(TrueLiteral n);
+
+ /**
+ * f0 -> "false"
+ */
+ public R visit(FalseLiteral n);
+
+ /**
+ * f0 -> <IDENTIFIER>
+ */
+ public R visit(Identifier n);
+
+ /**
+ * f0 -> "this"
+ */
+ public R visit(ThisExpression n);
+
+ /**
+ * f0 -> "new"
+ * f1 -> "int"
+ * f2 -> "["
+ * f3 -> Expression()
+ * f4 -> "]"
+ */
+ public R visit(ArrayAllocationExpression n);
+
+ /**
+ * f0 -> "new"
+ * f1 -> Identifier()
+ * f2 -> "("
+ * f3 -> ")"
+ */
+ public R visit(AllocationExpression n);
+
+ /**
+ * f0 -> "!"
+ * f1 -> Expression()
+ */
+ public R visit(NotExpression n);
+
+ /**
+ * f0 -> "("
+ * f1 -> Expression()
+ * f2 -> ")"
+ */
+ public R visit(BracketExpression n);
+
+}
+
diff --git a/src/minijava/visitor/GJVisitor.java b/src/minijava/visitor/GJVisitor.java
new file mode 100644
index 0000000..46c2ea9
--- /dev/null
+++ b/src/minijava/visitor/GJVisitor.java
@@ -0,0 +1,415 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package minijava.visitor;
+import minijava.syntaxtree.AllocationExpression;
+import minijava.syntaxtree.AndExpression;
+import minijava.syntaxtree.ArrayAllocationExpression;
+import minijava.syntaxtree.ArrayAssignmentStatement;
+import minijava.syntaxtree.ArrayLength;
+import minijava.syntaxtree.ArrayLookup;
+import minijava.syntaxtree.ArrayType;
+import minijava.syntaxtree.AssignmentStatement;
+import minijava.syntaxtree.Block;
+import minijava.syntaxtree.BooleanType;
+import minijava.syntaxtree.BracketExpression;
+import minijava.syntaxtree.ClassDeclaration;
+import minijava.syntaxtree.ClassExtendsDeclaration;
+import minijava.syntaxtree.CompareExpression;
+import minijava.syntaxtree.Expression;
+import minijava.syntaxtree.ExpressionList;
+import minijava.syntaxtree.ExpressionRest;
+import minijava.syntaxtree.FalseLiteral;
+import minijava.syntaxtree.FormalParameter;
+import minijava.syntaxtree.FormalParameterList;
+import minijava.syntaxtree.FormalParameterRest;
+import minijava.syntaxtree.Goal;
+import minijava.syntaxtree.Identifier;
+import minijava.syntaxtree.IfStatement;
+import minijava.syntaxtree.IntegerLiteral;
+import minijava.syntaxtree.IntegerType;
+import minijava.syntaxtree.MainClass;
+import minijava.syntaxtree.MessageSend;
+import minijava.syntaxtree.MethodDeclaration;
+import minijava.syntaxtree.MinusExpression;
+import minijava.syntaxtree.NodeList;
+import minijava.syntaxtree.NodeListOptional;
+import minijava.syntaxtree.NodeOptional;
+import minijava.syntaxtree.NodeSequence;
+import minijava.syntaxtree.NodeToken;
+import minijava.syntaxtree.NotExpression;
+import minijava.syntaxtree.PlusExpression;
+import minijava.syntaxtree.PrimaryExpression;
+import minijava.syntaxtree.PrintStatement;
+import minijava.syntaxtree.Statement;
+import minijava.syntaxtree.ThisExpression;
+import minijava.syntaxtree.TimesExpression;
+import minijava.syntaxtree.TrueLiteral;
+import minijava.syntaxtree.Type;
+import minijava.syntaxtree.TypeDeclaration;
+import minijava.syntaxtree.VarDeclaration;
+import minijava.syntaxtree.WhileStatement;
+
+/**
+ * All GJ visitors must implement this interface.
+ */
+
+public interface GJVisitor<R,A> {
+
+ //
+ // GJ Auto class visitors
+ //
+
+ public R visit(NodeList n, A argu);
+ public R visit(NodeListOptional n, A argu);
+ public R visit(NodeOptional n, A argu);
+ public R visit(NodeSequence n, A argu);
+ public R visit(NodeToken n, A argu);
+
+ //
+ // User-generated visitor methods below
+ //
+
+ /**
+ * f0 -> MainClass()
+ * f1 -> ( TypeDeclaration() )*
+ * f2 -> <EOF>
+ */
+ public R visit(Goal n, A argu);
+
+ /**
+ * f0 -> "class"
+ * f1 -> Identifier()
+ * f2 -> "{"
+ * f3 -> "public"
+ * f4 -> "static"
+ * f5 -> "void"
+ * f6 -> "main"
+ * f7 -> "("
+ * f8 -> "String"
+ * f9 -> "["
+ * f10 -> "]"
+ * f11 -> Identifier()
+ * f12 -> ")"
+ * f13 -> "{"
+ * f14 -> PrintStatement()
+ * f15 -> "}"
+ * f16 -> "}"
+ */
+ public R visit(MainClass n, A argu);
+
+ /**
+ * f0 -> ClassDeclaration()
+ * | ClassExtendsDeclaration()
+ */
+ public R visit(TypeDeclaration n, A argu);
+
+ /**
+ * f0 -> "class"
+ * f1 -> Identifier()
+ * f2 -> "{"
+ * f3 -> ( VarDeclaration() )*
+ * f4 -> ( MethodDeclaration() )*
+ * f5 -> "}"
+ */
+ public R visit(ClassDeclaration n, A argu);
+
+ /**
+ * f0 -> "class"
+ * f1 -> Identifier()
+ * f2 -> "extends"
+ * f3 -> Identifier()
+ * f4 -> "{"
+ * f5 -> ( VarDeclaration() )*
+ * f6 -> ( MethodDeclaration() )*
+ * f7 -> "}"
+ */
+ public R visit(ClassExtendsDeclaration n, A argu);
+
+ /**
+ * f0 -> Type()
+ * f1 -> Identifier()
+ * f2 -> ";"
+ */
+ public R visit(VarDeclaration n, A argu);
+
+ /**
+ * f0 -> "public"
+ * f1 -> Type()
+ * f2 -> Identifier()
+ * f3 -> "("
+ * f4 -> ( FormalParameterList() )?
+ * f5 -> ")"
+ * f6 -> "{"
+ * f7 -> ( VarDeclaration() )*
+ * f8 -> ( Statement() )*
+ * f9 -> "return"
+ * f10 -> Expression()
+ * f11 -> ";"
+ * f12 -> "}"
+ */
+ public R visit(MethodDeclaration n, A argu);
+
+ /**
+ * f0 -> FormalParameter()
+ * f1 -> ( FormalParameterRest() )*
+ */
+ public R visit(FormalParameterList n, A argu);
+
+ /**
+ * f0 -> Type()
+ * f1 -> Identifier()
+ */
+ public R visit(FormalParameter n, A argu);
+
+ /**
+ * f0 -> ","
+ * f1 -> FormalParameter()
+ */
+ public R visit(FormalParameterRest n, A argu);
+
+ /**
+ * f0 -> ArrayType()
+ * | BooleanType()
+ * | IntegerType()
+ * | Identifier()
+ */
+ public R visit(Type n, A argu);
+
+ /**
+ * f0 -> "int"
+ * f1 -> "["
+ * f2 -> "]"
+ */
+ public R visit(ArrayType n, A argu);
+
+ /**
+ * f0 -> "boolean"
+ */
+ public R visit(BooleanType n, A argu);
+
+ /**
+ * f0 -> "int"
+ */
+ public R visit(IntegerType n, A argu);
+
+ /**
+ * f0 -> Block()
+ * | AssignmentStatement()
+ * | ArrayAssignmentStatement()
+ * | IfStatement()
+ * | WhileStatement()
+ * | PrintStatement()
+ */
+ public R visit(Statement n, A argu);
+
+ /**
+ * f0 -> "{"
+ * f1 -> ( Statement() )*
+ * f2 -> "}"
+ */
+ public R visit(Block n, A argu);
+
+ /**
+ * f0 -> Identifier()
+ * f1 -> "="
+ * f2 -> Expression()
+ * f3 -> ";"
+ */
+ public R visit(AssignmentStatement n, A argu);
+
+ /**
+ * f0 -> Identifier()
+ * f1 -> "["
+ * f2 -> Expression()
+ * f3 -> "]"
+ * f4 -> "="
+ * f5 -> Expression()
+ * f6 -> ";"
+ */
+ public R visit(ArrayAssignmentStatement n, A argu);
+
+ /**
+ * f0 -> "if"
+ * f1 -> "("
+ * f2 -> Expression()
+ * f3 -> ")"
+ * f4 -> Statement()
+ * f5 -> "else"
+ * f6 -> Statement()
+ */
+ public R visit(IfStatement n, A argu);
+
+ /**
+ * f0 -> "while"
+ * f1 -> "("
+ * f2 -> Expression()
+ * f3 -> ")"
+ * f4 -> Statement()
+ */
+ public R visit(WhileStatement n, A argu);
+
+ /**
+ * f0 -> "System.out.println"
+ * f1 -> "("
+ * f2 -> Expression()
+ * f3 -> ")"
+ * f4 -> ";"
+ */
+ public R visit(PrintStatement n, A argu);
+
+ /**
+ * f0 -> AndExpression()
+ * | CompareExpression()
+ * | PlusExpression()
+ * | MinusExpression()
+ * | TimesExpression()
+ * | ArrayLookup()
+ * | ArrayLength()
+ * | MessageSend()
+ * | PrimaryExpression()
+ */
+ public R visit(Expression n, A argu);
+
+ /**
+ * f0 -> PrimaryExpression()
+ * f1 -> "&&"
+ * f2 -> PrimaryExpression()
+ */
+ public R visit(AndExpression n, A argu);
+
+ /**
+ * f0 -> PrimaryExpression()
+ * f1 -> "<"
+ * f2 -> PrimaryExpression()
+ */
+ public R visit(CompareExpression n, A argu);
+
+ /**
+ * f0 -> PrimaryExpression()
+ * f1 -> "+"
+ * f2 -> PrimaryExpression()
+ */
+ public R visit(PlusExpression n, A argu);
+
+ /**
+ * f0 -> PrimaryExpression()
+ * f1 -> "-"
+ * f2 -> PrimaryExpression()
+ */
+ public R visit(MinusExpression n, A argu);
+
+ /**
+ * f0 -> PrimaryExpression()
+ * f1 -> "*"
+ * f2 -> PrimaryExpression()
+ */
+ public R visit(TimesExpression n, A argu);
+
+ /**
+ * f0 -> PrimaryExpression()
+ * f1 -> "["
+ * f2 -> PrimaryExpression()
+ * f3 -> "]"
+ */
+ public R visit(ArrayLookup n, A argu);
+
+ /**
+ * f0 -> PrimaryExpression()
+ * f1 -> "."
+ * f2 -> "length"
+ */
+ public R visit(ArrayLength n, A argu);
+
+ /**
+ * f0 -> PrimaryExpression()
+ * f1 -> "."
+ * f2 -> Identifier()
+ * f3 -> "("
+ * f4 -> ( ExpressionList() )?
+ * f5 -> ")"
+ */
+ public R visit(MessageSend n, A argu);
+
+ /**
+ * f0 -> Expression()
+ * f1 -> ( ExpressionRest() )*
+ */
+ public R visit(ExpressionList n, A argu);
+
+ /**
+ * f0 -> ","
+ * f1 -> Expression()
+ */
+ public R visit(ExpressionRest n, A argu);
+
+ /**
+ * f0 -> IntegerLiteral()
+ * | TrueLiteral()
+ * | FalseLiteral()
+ * | Identifier()
+ * | ThisExpression()
+ * | ArrayAllocationExpression()
+ * | AllocationExpression()
+ * | NotExpression()
+ * | BracketExpression()
+ */
+ public R visit(PrimaryExpression n, A argu);
+
+ /**
+ * f0 -> <INTEGER_LITERAL>
+ */
+ public R visit(IntegerLiteral n, A argu);
+
+ /**
+ * f0 -> "true"
+ */
+ public R visit(TrueLiteral n, A argu);
+
+ /**
+ * f0 -> "false"
+ */
+ public R visit(FalseLiteral n, A argu);
+
+ /**
+ * f0 -> <IDENTIFIER>
+ */
+ public R visit(Identifier n, A argu);
+
+ /**
+ * f0 -> "this"
+ */
+ public R visit(ThisExpression n, A argu);
+
+ /**
+ * f0 -> "new"
+ * f1 -> "int"
+ * f2 -> "["
+ * f3 -> Expression()
+ * f4 -> "]"
+ */
+ public R visit(ArrayAllocationExpression n, A argu);
+
+ /**
+ * f0 -> "new"
+ * f1 -> Identifier()
+ * f2 -> "("
+ * f3 -> ")"
+ */
+ public R visit(AllocationExpression n, A argu);
+
+ /**
+ * f0 -> "!"
+ * f1 -> Expression()
+ */
+ public R visit(NotExpression n, A argu);
+
+ /**
+ * f0 -> "("
+ * f1 -> Expression()
+ * f2 -> ")"
+ */
+ public R visit(BracketExpression n, A argu);
+
+}
diff --git a/src/minijava/visitor/GJVoidDepthFirst.java b/src/minijava/visitor/GJVoidDepthFirst.java
new file mode 100644
index 0000000..29d6f1f
--- /dev/null
+++ b/src/minijava/visitor/GJVoidDepthFirst.java
@@ -0,0 +1,633 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package minijava.visitor;
+import java.util.Enumeration;
+
+import minijava.syntaxtree.AllocationExpression;
+import minijava.syntaxtree.AndExpression;
+import minijava.syntaxtree.ArrayAllocationExpression;
+import minijava.syntaxtree.ArrayAssignmentStatement;
+import minijava.syntaxtree.ArrayLength;
+import minijava.syntaxtree.ArrayLookup;
+import minijava.syntaxtree.ArrayType;
+import minijava.syntaxtree.AssignmentStatement;
+import minijava.syntaxtree.Block;
+import minijava.syntaxtree.BooleanType;
+import minijava.syntaxtree.BracketExpression;
+import minijava.syntaxtree.ClassDeclaration;
+import minijava.syntaxtree.ClassExtendsDeclaration;
+import minijava.syntaxtree.CompareExpression;
+import minijava.syntaxtree.Expression;
+import minijava.syntaxtree.ExpressionList;
+import minijava.syntaxtree.ExpressionRest;
+import minijava.syntaxtree.FalseLiteral;
+import minijava.syntaxtree.FormalParameter;
+import minijava.syntaxtree.FormalParameterList;
+import minijava.syntaxtree.FormalParameterRest;
+import minijava.syntaxtree.Goal;
+import minijava.syntaxtree.Identifier;
+import minijava.syntaxtree.IfStatement;
+import minijava.syntaxtree.IntegerLiteral;
+import minijava.syntaxtree.IntegerType;
+import minijava.syntaxtree.MainClass;
+import minijava.syntaxtree.MessageSend;
+import minijava.syntaxtree.MethodDeclaration;
+import minijava.syntaxtree.MinusExpression;
+import minijava.syntaxtree.Node;
+import minijava.syntaxtree.NodeList;
+import minijava.syntaxtree.NodeListOptional;
+import minijava.syntaxtree.NodeOptional;
+import minijava.syntaxtree.NodeSequence;
+import minijava.syntaxtree.NodeToken;
+import minijava.syntaxtree.NotExpression;
+import minijava.syntaxtree.PlusExpression;
+import minijava.syntaxtree.PrimaryExpression;
+import minijava.syntaxtree.PrintStatement;
+import minijava.syntaxtree.Statement;
+import minijava.syntaxtree.ThisExpression;
+import minijava.syntaxtree.TimesExpression;
+import minijava.syntaxtree.TrueLiteral;
+import minijava.syntaxtree.Type;
+import minijava.syntaxtree.TypeDeclaration;
+import minijava.syntaxtree.VarDeclaration;
+import minijava.syntaxtree.WhileStatement;
+
+/**
+ * Provides default methods which visit each node in the tree in depth-first
+ * order. Your visitors may extend this class.
+ */
+public class GJVoidDepthFirst<A> implements GJVoidVisitor<A> {
+ //
+ // Auto class visitors--probably don't need to be overridden.
+ //
+ public void visit(NodeList n, A argu) {
+ int _count=0;
+ for ( Enumeration<Node> e = n.elements(); e.hasMoreElements(); ) {
+ e.nextElement().accept(this,argu);
+ _count++;
+ }
+ }
+
+ public void visit(NodeListOptional n, A argu) {
+ if ( n.present() ) {
+ int _count=0;
+ for ( Enumeration<Node> e = n.elements(); e.hasMoreElements(); ) {
+ e.nextElement().accept(this,argu);
+ _count++;
+ }
+ }
+ }
+
+ public void visit(NodeOptional n, A argu) {
+ if ( n.present() )
+ n.node.accept(this,argu);
+ }
+
+ public void visit(NodeSequence n, A argu) {
+ int _count=0;
+ for ( Enumeration<Node> e = n.elements(); e.hasMoreElements(); ) {
+ e.nextElement().accept(this,argu);
+ _count++;
+ }
+ }
+
+ public void visit(NodeToken n, A argu) {}
+
+ //
+ // User-generated visitor methods below
+ //
+
+ /**
+ * f0 -> MainClass()
+ * f1 -> ( TypeDeclaration() )*
+ * f2 -> <EOF>
+ */
+ public void visit(Goal n, A argu) {
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ }
+
+ /**
+ * f0 -> "class"
+ * f1 -> Identifier()
+ * f2 -> "{"
+ * f3 -> "public"
+ * f4 -> "static"
+ * f5 -> "void"
+ * f6 -> "main"
+ * f7 -> "("
+ * f8 -> "String"
+ * f9 -> "["
+ * f10 -> "]"
+ * f11 -> Identifier()
+ * f12 -> ")"
+ * f13 -> "{"
+ * f14 -> PrintStatement()
+ * f15 -> "}"
+ * f16 -> "}"
+ */
+ public void visit(MainClass n, A argu) {
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ n.f3.accept(this, argu);
+ n.f4.accept(this, argu);
+ n.f5.accept(this, argu);
+ n.f6.accept(this, argu);
+ n.f7.accept(this, argu);
+ n.f8.accept(this, argu);
+ n.f9.accept(this, argu);
+ n.f10.accept(this, argu);
+ n.f11.accept(this, argu);
+ n.f12.accept(this, argu);
+ n.f13.accept(this, argu);
+ n.f14.accept(this, argu);
+ n.f15.accept(this, argu);
+ n.f16.accept(this, argu);
+ }
+
+ /**
+ * f0 -> ClassDeclaration()
+ * | ClassExtendsDeclaration()
+ */
+ public void visit(TypeDeclaration n, A argu) {
+ n.f0.accept(this, argu);
+ }
+
+ /**
+ * f0 -> "class"
+ * f1 -> Identifier()
+ * f2 -> "{"
+ * f3 -> ( VarDeclaration() )*
+ * f4 -> ( MethodDeclaration() )*
+ * f5 -> "}"
+ */
+ public void visit(ClassDeclaration n, A argu) {
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ n.f3.accept(this, argu);
+ n.f4.accept(this, argu);
+ n.f5.accept(this, argu);
+ }
+
+ /**
+ * f0 -> "class"
+ * f1 -> Identifier()
+ * f2 -> "extends"
+ * f3 -> Identifier()
+ * f4 -> "{"
+ * f5 -> ( VarDeclaration() )*
+ * f6 -> ( MethodDeclaration() )*
+ * f7 -> "}"
+ */
+ public void visit(ClassExtendsDeclaration n, A argu) {
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ n.f3.accept(this, argu);
+ n.f4.accept(this, argu);
+ n.f5.accept(this, argu);
+ n.f6.accept(this, argu);
+ n.f7.accept(this, argu);
+ }
+
+ /**
+ * f0 -> Type()
+ * f1 -> Identifier()
+ * f2 -> ";"
+ */
+ public void visit(VarDeclaration n, A argu) {
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ }
+
+ /**
+ * f0 -> "public"
+ * f1 -> Type()
+ * f2 -> Identifier()
+ * f3 -> "("
+ * f4 -> ( FormalParameterList() )?
+ * f5 -> ")"
+ * f6 -> "{"
+ * f7 -> ( VarDeclaration() )*
+ * f8 -> ( Statement() )*
+ * f9 -> "return"
+ * f10 -> Expression()
+ * f11 -> ";"
+ * f12 -> "}"
+ */
+ public void visit(MethodDeclaration n, A argu) {
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ n.f3.accept(this, argu);
+ n.f4.accept(this, argu);
+ n.f5.accept(this, argu);
+ n.f6.accept(this, argu);
+ n.f7.accept(this, argu);
+ n.f8.accept(this, argu);
+ n.f9.accept(this, argu);
+ n.f10.accept(this, argu);
+ n.f11.accept(this, argu);
+ n.f12.accept(this, argu);
+ }
+
+ /**
+ * f0 -> FormalParameter()
+ * f1 -> ( FormalParameterRest() )*
+ */
+ public void visit(FormalParameterList n, A argu) {
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ }
+
+ /**
+ * f0 -> Type()
+ * f1 -> Identifier()
+ */
+ public void visit(FormalParameter n, A argu) {
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ }
+
+ /**
+ * f0 -> ","
+ * f1 -> FormalParameter()
+ */
+ public void visit(FormalParameterRest n, A argu) {
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ }
+
+ /**
+ * f0 -> ArrayType()
+ * | BooleanType()
+ * | IntegerType()
+ * | Identifier()
+ */
+ public void visit(Type n, A argu) {
+ n.f0.accept(this, argu);
+ }
+
+ /**
+ * f0 -> "int"
+ * f1 -> "["
+ * f2 -> "]"
+ */
+ public void visit(ArrayType n, A argu) {
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ }
+
+ /**
+ * f0 -> "boolean"
+ */
+ public void visit(BooleanType n, A argu) {
+ n.f0.accept(this, argu);
+ }
+
+ /**
+ * f0 -> "int"
+ */
+ public void visit(IntegerType n, A argu) {
+ n.f0.accept(this, argu);
+ }
+
+ /**
+ * f0 -> Block()
+ * | AssignmentStatement()
+ * | ArrayAssignmentStatement()
+ * | IfStatement()
+ * | WhileStatement()
+ * | PrintStatement()
+ */
+ public void visit(Statement n, A argu) {
+ n.f0.accept(this, argu);
+ }
+
+ /**
+ * f0 -> "{"
+ * f1 -> ( Statement() )*
+ * f2 -> "}"
+ */
+ public void visit(Block n, A argu) {
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ }
+
+ /**
+ * f0 -> Identifier()
+ * f1 -> "="
+ * f2 -> Expression()
+ * f3 -> ";"
+ */
+ public void visit(AssignmentStatement n, A argu) {
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ n.f3.accept(this, argu);
+ }
+
+ /**
+ * f0 -> Identifier()
+ * f1 -> "["
+ * f2 -> Expression()
+ * f3 -> "]"
+ * f4 -> "="
+ * f5 -> Expression()
+ * f6 -> ";"
+ */
+ public void visit(ArrayAssignmentStatement n, A argu) {
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ n.f3.accept(this, argu);
+ n.f4.accept(this, argu);
+ n.f5.accept(this, argu);
+ n.f6.accept(this, argu);
+ }
+
+ /**
+ * f0 -> "if"
+ * f1 -> "("
+ * f2 -> Expression()
+ * f3 -> ")"
+ * f4 -> Statement()
+ * f5 -> "else"
+ * f6 -> Statement()
+ */
+ public void visit(IfStatement n, A argu) {
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ n.f3.accept(this, argu);
+ n.f4.accept(this, argu);
+ n.f5.accept(this, argu);
+ n.f6.accept(this, argu);
+ }
+
+ /**
+ * f0 -> "while"
+ * f1 -> "("
+ * f2 -> Expression()
+ * f3 -> ")"
+ * f4 -> Statement()
+ */
+ public void visit(WhileStatement n, A argu) {
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ n.f3.accept(this, argu);
+ n.f4.accept(this, argu);
+ }
+
+ /**
+ * f0 -> "System.out.println"
+ * f1 -> "("
+ * f2 -> Expression()
+ * f3 -> ")"
+ * f4 -> ";"
+ */
+ public void visit(PrintStatement n, A argu) {
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ n.f3.accept(this, argu);
+ n.f4.accept(this, argu);
+ }
+
+ /**
+ * f0 -> AndExpression()
+ * | CompareExpression()
+ * | PlusExpression()
+ * | MinusExpression()
+ * | TimesExpression()
+ * | ArrayLookup()
+ * | ArrayLength()
+ * | MessageSend()
+ * | PrimaryExpression()
+ */
+ public void visit(Expression n, A argu) {
+ n.f0.accept(this, argu);
+ }
+
+ /**
+ * f0 -> PrimaryExpression()
+ * f1 -> "&&"
+ * f2 -> PrimaryExpression()
+ */
+ public void visit(AndExpression n, A argu) {
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ }
+
+ /**
+ * f0 -> PrimaryExpression()
+ * f1 -> "<"
+ * f2 -> PrimaryExpression()
+ */
+ public void visit(CompareExpression n, A argu) {
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ }
+
+ /**
+ * f0 -> PrimaryExpression()
+ * f1 -> "+"
+ * f2 -> PrimaryExpression()
+ */
+ public void visit(PlusExpression n, A argu) {
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ }
+
+ /**
+ * f0 -> PrimaryExpression()
+ * f1 -> "-"
+ * f2 -> PrimaryExpression()
+ */
+ public void visit(MinusExpression n, A argu) {
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ }
+
+ /**
+ * f0 -> PrimaryExpression()
+ * f1 -> "*"
+ * f2 -> PrimaryExpression()
+ */
+ public void visit(TimesExpression n, A argu) {
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ }
+
+ /**
+ * f0 -> PrimaryExpression()
+ * f1 -> "["
+ * f2 -> PrimaryExpression()
+ * f3 -> "]"
+ */
+ public void visit(ArrayLookup n, A argu) {
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ n.f3.accept(this, argu);
+ }
+
+ /**
+ * f0 -> PrimaryExpression()
+ * f1 -> "."
+ * f2 -> "length"
+ */
+ public void visit(ArrayLength n, A argu) {
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ }
+
+ /**
+ * f0 -> PrimaryExpression()
+ * f1 -> "."
+ * f2 -> Identifier()
+ * f3 -> "("
+ * f4 -> ( ExpressionList() )?
+ * f5 -> ")"
+ */
+ public void visit(MessageSend n, A argu) {
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ n.f3.accept(this, argu);
+ n.f4.accept(this, argu);
+ n.f5.accept(this, argu);
+ }
+
+ /**
+ * f0 -> Expression()
+ * f1 -> ( ExpressionRest() )*
+ */
+ public void visit(ExpressionList n, A argu) {
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ }
+
+ /**
+ * f0 -> ","
+ * f1 -> Expression()
+ */
+ public void visit(ExpressionRest n, A argu) {
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ }
+
+ /**
+ * f0 -> IntegerLiteral()
+ * | TrueLiteral()
+ * | FalseLiteral()
+ * | Identifier()
+ * | ThisExpression()
+ * | ArrayAllocationExpression()
+ * | AllocationExpression()
+ * | NotExpression()
+ * | BracketExpression()
+ */
+ public void visit(PrimaryExpression n, A argu) {
+ n.f0.accept(this, argu);
+ }
+
+ /**
+ * f0 -> <INTEGER_LITERAL>
+ */
+ public void visit(IntegerLiteral n, A argu) {
+ n.f0.accept(this, argu);
+ }
+
+ /**
+ * f0 -> "true"
+ */
+ public void visit(TrueLiteral n, A argu) {
+ n.f0.accept(this, argu);
+ }
+
+ /**
+ * f0 -> "false"
+ */
+ public void visit(FalseLiteral n, A argu) {
+ n.f0.accept(this, argu);
+ }
+
+ /**
+ * f0 -> <IDENTIFIER>
+ */
+ public void visit(Identifier n, A argu) {
+ n.f0.accept(this, argu);
+ }
+
+ /**
+ * f0 -> "this"
+ */
+ public void visit(ThisExpression n, A argu) {
+ n.f0.accept(this, argu);
+ }
+
+ /**
+ * f0 -> "new"
+ * f1 -> "int"
+ * f2 -> "["
+ * f3 -> Expression()
+ * f4 -> "]"
+ */
+ public void visit(ArrayAllocationExpression n, A argu) {
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ n.f3.accept(this, argu);
+ n.f4.accept(this, argu);
+ }
+
+ /**
+ * f0 -> "new"
+ * f1 -> Identifier()
+ * f2 -> "("
+ * f3 -> ")"
+ */
+ public void visit(AllocationExpression n, A argu) {
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ n.f3.accept(this, argu);
+ }
+
+ /**
+ * f0 -> "!"
+ * f1 -> Expression()
+ */
+ public void visit(NotExpression n, A argu) {
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ }
+
+ /**
+ * f0 -> "("
+ * f1 -> Expression()
+ * f2 -> ")"
+ */
+ public void visit(BracketExpression n, A argu) {
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ }
+
+}
diff --git a/src/minijava/visitor/GJVoidVisitor.java b/src/minijava/visitor/GJVoidVisitor.java
new file mode 100644
index 0000000..43cf200
--- /dev/null
+++ b/src/minijava/visitor/GJVoidVisitor.java
@@ -0,0 +1,416 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package minijava.visitor;
+import minijava.syntaxtree.AllocationExpression;
+import minijava.syntaxtree.AndExpression;
+import minijava.syntaxtree.ArrayAllocationExpression;
+import minijava.syntaxtree.ArrayAssignmentStatement;
+import minijava.syntaxtree.ArrayLength;
+import minijava.syntaxtree.ArrayLookup;
+import minijava.syntaxtree.ArrayType;
+import minijava.syntaxtree.AssignmentStatement;
+import minijava.syntaxtree.Block;
+import minijava.syntaxtree.BooleanType;
+import minijava.syntaxtree.BracketExpression;
+import minijava.syntaxtree.ClassDeclaration;
+import minijava.syntaxtree.ClassExtendsDeclaration;
+import minijava.syntaxtree.CompareExpression;
+import minijava.syntaxtree.Expression;
+import minijava.syntaxtree.ExpressionList;
+import minijava.syntaxtree.ExpressionRest;
+import minijava.syntaxtree.FalseLiteral;
+import minijava.syntaxtree.FormalParameter;
+import minijava.syntaxtree.FormalParameterList;
+import minijava.syntaxtree.FormalParameterRest;
+import minijava.syntaxtree.Goal;
+import minijava.syntaxtree.Identifier;
+import minijava.syntaxtree.IfStatement;
+import minijava.syntaxtree.IntegerLiteral;
+import minijava.syntaxtree.IntegerType;
+import minijava.syntaxtree.MainClass;
+import minijava.syntaxtree.MessageSend;
+import minijava.syntaxtree.MethodDeclaration;
+import minijava.syntaxtree.MinusExpression;
+import minijava.syntaxtree.NodeList;
+import minijava.syntaxtree.NodeListOptional;
+import minijava.syntaxtree.NodeOptional;
+import minijava.syntaxtree.NodeSequence;
+import minijava.syntaxtree.NodeToken;
+import minijava.syntaxtree.NotExpression;
+import minijava.syntaxtree.PlusExpression;
+import minijava.syntaxtree.PrimaryExpression;
+import minijava.syntaxtree.PrintStatement;
+import minijava.syntaxtree.Statement;
+import minijava.syntaxtree.ThisExpression;
+import minijava.syntaxtree.TimesExpression;
+import minijava.syntaxtree.TrueLiteral;
+import minijava.syntaxtree.Type;
+import minijava.syntaxtree.TypeDeclaration;
+import minijava.syntaxtree.VarDeclaration;
+import minijava.syntaxtree.WhileStatement;
+
+/**
+ * All GJ void visitors must implement this interface.
+ */
+
+public interface GJVoidVisitor<A> {
+
+ //
+ // GJ void Auto class visitors
+ //
+
+ public void visit(NodeList n, A argu);
+ public void visit(NodeListOptional n, A argu);
+ public void visit(NodeOptional n, A argu);
+ public void visit(NodeSequence n, A argu);
+ public void visit(NodeToken n, A argu);
+
+ //
+ // User-generated visitor methods below
+ //
+
+ /**
+ * f0 -> MainClass()
+ * f1 -> ( TypeDeclaration() )*
+ * f2 -> <EOF>
+ */
+ public void visit(Goal n, A argu);
+
+ /**
+ * f0 -> "class"
+ * f1 -> Identifier()
+ * f2 -> "{"
+ * f3 -> "public"
+ * f4 -> "static"
+ * f5 -> "void"
+ * f6 -> "main"
+ * f7 -> "("
+ * f8 -> "String"
+ * f9 -> "["
+ * f10 -> "]"
+ * f11 -> Identifier()
+ * f12 -> ")"
+ * f13 -> "{"
+ * f14 -> PrintStatement()
+ * f15 -> "}"
+ * f16 -> "}"
+ */
+ public void visit(MainClass n, A argu);
+
+ /**
+ * f0 -> ClassDeclaration()
+ * | ClassExtendsDeclaration()
+ */
+ public void visit(TypeDeclaration n, A argu);
+
+ /**
+ * f0 -> "class"
+ * f1 -> Identifier()
+ * f2 -> "{"
+ * f3 -> ( VarDeclaration() )*
+ * f4 -> ( MethodDeclaration() )*
+ * f5 -> "}"
+ */
+ public void visit(ClassDeclaration n, A argu);
+
+ /**
+ * f0 -> "class"
+ * f1 -> Identifier()
+ * f2 -> "extends"
+ * f3 -> Identifier()
+ * f4 -> "{"
+ * f5 -> ( VarDeclaration() )*
+ * f6 -> ( MethodDeclaration() )*
+ * f7 -> "}"
+ */
+ public void visit(ClassExtendsDeclaration n, A argu);
+
+ /**
+ * f0 -> Type()
+ * f1 -> Identifier()
+ * f2 -> ";"
+ */
+ public void visit(VarDeclaration n, A argu);
+
+ /**
+ * f0 -> "public"
+ * f1 -> Type()
+ * f2 -> Identifier()
+ * f3 -> "("
+ * f4 -> ( FormalParameterList() )?
+ * f5 -> ")"
+ * f6 -> "{"
+ * f7 -> ( VarDeclaration() )*
+ * f8 -> ( Statement() )*
+ * f9 -> "return"
+ * f10 -> Expression()
+ * f11 -> ";"
+ * f12 -> "}"
+ */
+ public void visit(MethodDeclaration n, A argu);
+
+ /**
+ * f0 -> FormalParameter()
+ * f1 -> ( FormalParameterRest() )*
+ */
+ public void visit(FormalParameterList n, A argu);
+
+ /**
+ * f0 -> Type()
+ * f1 -> Identifier()
+ */
+ public void visit(FormalParameter n, A argu);
+
+ /**
+ * f0 -> ","
+ * f1 -> FormalParameter()
+ */
+ public void visit(FormalParameterRest n, A argu);
+
+ /**
+ * f0 -> ArrayType()
+ * | BooleanType()
+ * | IntegerType()
+ * | Identifier()
+ */
+ public void visit(Type n, A argu);
+
+ /**
+ * f0 -> "int"
+ * f1 -> "["
+ * f2 -> "]"
+ */
+ public void visit(ArrayType n, A argu);
+
+ /**
+ * f0 -> "boolean"
+ */
+ public void visit(BooleanType n, A argu);
+
+ /**
+ * f0 -> "int"
+ */
+ public void visit(IntegerType n, A argu);
+
+ /**
+ * f0 -> Block()
+ * | AssignmentStatement()
+ * | ArrayAssignmentStatement()
+ * | IfStatement()
+ * | WhileStatement()
+ * | PrintStatement()
+ */
+ public void visit(Statement n, A argu);
+
+ /**
+ * f0 -> "{"
+ * f1 -> ( Statement() )*
+ * f2 -> "}"
+ */
+ public void visit(Block n, A argu);
+
+ /**
+ * f0 -> Identifier()
+ * f1 -> "="
+ * f2 -> Expression()
+ * f3 -> ";"
+ */
+ public void visit(AssignmentStatement n, A argu);
+
+ /**
+ * f0 -> Identifier()
+ * f1 -> "["
+ * f2 -> Expression()
+ * f3 -> "]"
+ * f4 -> "="
+ * f5 -> Expression()
+ * f6 -> ";"
+ */
+ public void visit(ArrayAssignmentStatement n, A argu);
+
+ /**
+ * f0 -> "if"
+ * f1 -> "("
+ * f2 -> Expression()
+ * f3 -> ")"
+ * f4 -> Statement()
+ * f5 -> "else"
+ * f6 -> Statement()
+ */
+ public void visit(IfStatement n, A argu);
+
+ /**
+ * f0 -> "while"
+ * f1 -> "("
+ * f2 -> Expression()
+ * f3 -> ")"
+ * f4 -> Statement()
+ */
+ public void visit(WhileStatement n, A argu);
+
+ /**
+ * f0 -> "System.out.println"
+ * f1 -> "("
+ * f2 -> Expression()
+ * f3 -> ")"
+ * f4 -> ";"
+ */
+ public void visit(PrintStatement n, A argu);
+
+ /**
+ * f0 -> AndExpression()
+ * | CompareExpression()
+ * | PlusExpression()
+ * | MinusExpression()
+ * | TimesExpression()
+ * | ArrayLookup()
+ * | ArrayLength()
+ * | MessageSend()
+ * | PrimaryExpression()
+ */
+ public void visit(Expression n, A argu);
+
+ /**
+ * f0 -> PrimaryExpression()
+ * f1 -> "&&"
+ * f2 -> PrimaryExpression()
+ */
+ public void visit(AndExpression n, A argu);
+
+ /**
+ * f0 -> PrimaryExpression()
+ * f1 -> "<"
+ * f2 -> PrimaryExpression()
+ */
+ public void visit(CompareExpression n, A argu);
+
+ /**
+ * f0 -> PrimaryExpression()
+ * f1 -> "+"
+ * f2 -> PrimaryExpression()
+ */
+ public void visit(PlusExpression n, A argu);
+
+ /**
+ * f0 -> PrimaryExpression()
+ * f1 -> "-"
+ * f2 -> PrimaryExpression()
+ */
+ public void visit(MinusExpression n, A argu);
+
+ /**
+ * f0 -> PrimaryExpression()
+ * f1 -> "*"
+ * f2 -> PrimaryExpression()
+ */
+ public void visit(TimesExpression n, A argu);
+
+ /**
+ * f0 -> PrimaryExpression()
+ * f1 -> "["
+ * f2 -> PrimaryExpression()
+ * f3 -> "]"
+ */
+ public void visit(ArrayLookup n, A argu);
+
+ /**
+ * f0 -> PrimaryExpression()
+ * f1 -> "."
+ * f2 -> "length"
+ */
+ public void visit(ArrayLength n, A argu);
+
+ /**
+ * f0 -> PrimaryExpression()
+ * f1 -> "."
+ * f2 -> Identifier()
+ * f3 -> "("
+ * f4 -> ( ExpressionList() )?
+ * f5 -> ")"
+ */
+ public void visit(MessageSend n, A argu);
+
+ /**
+ * f0 -> Expression()
+ * f1 -> ( ExpressionRest() )*
+ */
+ public void visit(ExpressionList n, A argu);
+
+ /**
+ * f0 -> ","
+ * f1 -> Expression()
+ */
+ public void visit(ExpressionRest n, A argu);
+
+ /**
+ * f0 -> IntegerLiteral()
+ * | TrueLiteral()
+ * | FalseLiteral()
+ * | Identifier()
+ * | ThisExpression()
+ * | ArrayAllocationExpression()
+ * | AllocationExpression()
+ * | NotExpression()
+ * | BracketExpression()
+ */
+ public void visit(PrimaryExpression n, A argu);
+
+ /**
+ * f0 -> <INTEGER_LITERAL>
+ */
+ public void visit(IntegerLiteral n, A argu);
+
+ /**
+ * f0 -> "true"
+ */
+ public void visit(TrueLiteral n, A argu);
+
+ /**
+ * f0 -> "false"
+ */
+ public void visit(FalseLiteral n, A argu);
+
+ /**
+ * f0 -> <IDENTIFIER>
+ */
+ public void visit(Identifier n, A argu);
+
+ /**
+ * f0 -> "this"
+ */
+ public void visit(ThisExpression n, A argu);
+
+ /**
+ * f0 -> "new"
+ * f1 -> "int"
+ * f2 -> "["
+ * f3 -> Expression()
+ * f4 -> "]"
+ */
+ public void visit(ArrayAllocationExpression n, A argu);
+
+ /**
+ * f0 -> "new"
+ * f1 -> Identifier()
+ * f2 -> "("
+ * f3 -> ")"
+ */
+ public void visit(AllocationExpression n, A argu);
+
+ /**
+ * f0 -> "!"
+ * f1 -> Expression()
+ */
+ public void visit(NotExpression n, A argu);
+
+ /**
+ * f0 -> "("
+ * f1 -> Expression()
+ * f2 -> ")"
+ */
+ public void visit(BracketExpression n, A argu);
+
+}
+
diff --git a/src/minijava/visitor/Visitor.java b/src/minijava/visitor/Visitor.java
new file mode 100644
index 0000000..c2a3afa
--- /dev/null
+++ b/src/minijava/visitor/Visitor.java
@@ -0,0 +1,416 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package minijava.visitor;
+import minijava.syntaxtree.AllocationExpression;
+import minijava.syntaxtree.AndExpression;
+import minijava.syntaxtree.ArrayAllocationExpression;
+import minijava.syntaxtree.ArrayAssignmentStatement;
+import minijava.syntaxtree.ArrayLength;
+import minijava.syntaxtree.ArrayLookup;
+import minijava.syntaxtree.ArrayType;
+import minijava.syntaxtree.AssignmentStatement;
+import minijava.syntaxtree.Block;
+import minijava.syntaxtree.BooleanType;
+import minijava.syntaxtree.BracketExpression;
+import minijava.syntaxtree.ClassDeclaration;
+import minijava.syntaxtree.ClassExtendsDeclaration;
+import minijava.syntaxtree.CompareExpression;
+import minijava.syntaxtree.Expression;
+import minijava.syntaxtree.ExpressionList;
+import minijava.syntaxtree.ExpressionRest;
+import minijava.syntaxtree.FalseLiteral;
+import minijava.syntaxtree.FormalParameter;
+import minijava.syntaxtree.FormalParameterList;
+import minijava.syntaxtree.FormalParameterRest;
+import minijava.syntaxtree.Goal;
+import minijava.syntaxtree.Identifier;
+import minijava.syntaxtree.IfStatement;
+import minijava.syntaxtree.IntegerLiteral;
+import minijava.syntaxtree.IntegerType;
+import minijava.syntaxtree.MainClass;
+import minijava.syntaxtree.MessageSend;
+import minijava.syntaxtree.MethodDeclaration;
+import minijava.syntaxtree.MinusExpression;
+import minijava.syntaxtree.NodeList;
+import minijava.syntaxtree.NodeListOptional;
+import minijava.syntaxtree.NodeOptional;
+import minijava.syntaxtree.NodeSequence;
+import minijava.syntaxtree.NodeToken;
+import minijava.syntaxtree.NotExpression;
+import minijava.syntaxtree.PlusExpression;
+import minijava.syntaxtree.PrimaryExpression;
+import minijava.syntaxtree.PrintStatement;
+import minijava.syntaxtree.Statement;
+import minijava.syntaxtree.ThisExpression;
+import minijava.syntaxtree.TimesExpression;
+import minijava.syntaxtree.TrueLiteral;
+import minijava.syntaxtree.Type;
+import minijava.syntaxtree.TypeDeclaration;
+import minijava.syntaxtree.VarDeclaration;
+import minijava.syntaxtree.WhileStatement;
+
+/**
+ * All void visitors must implement this interface.
+ */
+
+public interface Visitor {
+
+ //
+ // void Auto class visitors
+ //
+
+ public void visit(NodeList n);
+ public void visit(NodeListOptional n);
+ public void visit(NodeOptional n);
+ public void visit(NodeSequence n);
+ public void visit(NodeToken n);
+
+ //
+ // User-generated visitor methods below
+ //
+
+ /**
+ * f0 -> MainClass()
+ * f1 -> ( TypeDeclaration() )*
+ * f2 -> <EOF>
+ */
+ public void visit(Goal n);
+
+ /**
+ * f0 -> "class"
+ * f1 -> Identifier()
+ * f2 -> "{"
+ * f3 -> "public"
+ * f4 -> "static"
+ * f5 -> "void"
+ * f6 -> "main"
+ * f7 -> "("
+ * f8 -> "String"
+ * f9 -> "["
+ * f10 -> "]"
+ * f11 -> Identifier()
+ * f12 -> ")"
+ * f13 -> "{"
+ * f14 -> PrintStatement()
+ * f15 -> "}"
+ * f16 -> "}"
+ */
+ public void visit(MainClass n);
+
+ /**
+ * f0 -> ClassDeclaration()
+ * | ClassExtendsDeclaration()
+ */
+ public void visit(TypeDeclaration n);
+
+ /**
+ * f0 -> "class"
+ * f1 -> Identifier()
+ * f2 -> "{"
+ * f3 -> ( VarDeclaration() )*
+ * f4 -> ( MethodDeclaration() )*
+ * f5 -> "}"
+ */
+ public void visit(ClassDeclaration n);
+
+ /**
+ * f0 -> "class"
+ * f1 -> Identifier()
+ * f2 -> "extends"
+ * f3 -> Identifier()
+ * f4 -> "{"
+ * f5 -> ( VarDeclaration() )*
+ * f6 -> ( MethodDeclaration() )*
+ * f7 -> "}"
+ */
+ public void visit(ClassExtendsDeclaration n);
+
+ /**
+ * f0 -> Type()
+ * f1 -> Identifier()
+ * f2 -> ";"
+ */
+ public void visit(VarDeclaration n);
+
+ /**
+ * f0 -> "public"
+ * f1 -> Type()
+ * f2 -> Identifier()
+ * f3 -> "("
+ * f4 -> ( FormalParameterList() )?
+ * f5 -> ")"
+ * f6 -> "{"
+ * f7 -> ( VarDeclaration() )*
+ * f8 -> ( Statement() )*
+ * f9 -> "return"
+ * f10 -> Expression()
+ * f11 -> ";"
+ * f12 -> "}"
+ */
+ public void visit(MethodDeclaration n);
+
+ /**
+ * f0 -> FormalParameter()
+ * f1 -> ( FormalParameterRest() )*
+ */
+ public void visit(FormalParameterList n);
+
+ /**
+ * f0 -> Type()
+ * f1 -> Identifier()
+ */
+ public void visit(FormalParameter n);
+
+ /**
+ * f0 -> ","
+ * f1 -> FormalParameter()
+ */
+ public void visit(FormalParameterRest n);
+
+ /**
+ * f0 -> ArrayType()
+ * | BooleanType()
+ * | IntegerType()
+ * | Identifier()
+ */
+ public void visit(Type n);
+
+ /**
+ * f0 -> "int"
+ * f1 -> "["
+ * f2 -> "]"
+ */
+ public void visit(ArrayType n);
+
+ /**
+ * f0 -> "boolean"
+ */
+ public void visit(BooleanType n);
+
+ /**
+ * f0 -> "int"
+ */
+ public void visit(IntegerType n);
+
+ /**
+ * f0 -> Block()
+ * | AssignmentStatement()
+ * | ArrayAssignmentStatement()
+ * | IfStatement()
+ * | WhileStatement()
+ * | PrintStatement()
+ */
+ public void visit(Statement n);
+
+ /**
+ * f0 -> "{"
+ * f1 -> ( Statement() )*
+ * f2 -> "}"
+ */
+ public void visit(Block n);
+
+ /**
+ * f0 -> Identifier()
+ * f1 -> "="
+ * f2 -> Expression()
+ * f3 -> ";"
+ */
+ public void visit(AssignmentStatement n);
+
+ /**
+ * f0 -> Identifier()
+ * f1 -> "["
+ * f2 -> Expression()
+ * f3 -> "]"
+ * f4 -> "="
+ * f5 -> Expression()
+ * f6 -> ";"
+ */
+ public void visit(ArrayAssignmentStatement n);
+
+ /**
+ * f0 -> "if"
+ * f1 -> "("
+ * f2 -> Expression()
+ * f3 -> ")"
+ * f4 -> Statement()
+ * f5 -> "else"
+ * f6 -> Statement()
+ */
+ public void visit(IfStatement n);
+
+ /**
+ * f0 -> "while"
+ * f1 -> "("
+ * f2 -> Expression()
+ * f3 -> ")"
+ * f4 -> Statement()
+ */
+ public void visit(WhileStatement n);
+
+ /**
+ * f0 -> "System.out.println"
+ * f1 -> "("
+ * f2 -> Expression()
+ * f3 -> ")"
+ * f4 -> ";"
+ */
+ public void visit(PrintStatement n);
+
+ /**
+ * f0 -> AndExpression()
+ * | CompareExpression()
+ * | PlusExpression()
+ * | MinusExpression()
+ * | TimesExpression()
+ * | ArrayLookup()
+ * | ArrayLength()
+ * | MessageSend()
+ * | PrimaryExpression()
+ */
+ public void visit(Expression n);
+
+ /**
+ * f0 -> PrimaryExpression()
+ * f1 -> "&&"
+ * f2 -> PrimaryExpression()
+ */
+ public void visit(AndExpression n);
+
+ /**
+ * f0 -> PrimaryExpression()
+ * f1 -> "<"
+ * f2 -> PrimaryExpression()
+ */
+ public void visit(CompareExpression n);
+
+ /**
+ * f0 -> PrimaryExpression()
+ * f1 -> "+"
+ * f2 -> PrimaryExpression()
+ */
+ public void visit(PlusExpression n);
+
+ /**
+ * f0 -> PrimaryExpression()
+ * f1 -> "-"
+ * f2 -> PrimaryExpression()
+ */
+ public void visit(MinusExpression n);
+
+ /**
+ * f0 -> PrimaryExpression()
+ * f1 -> "*"
+ * f2 -> PrimaryExpression()
+ */
+ public void visit(TimesExpression n);
+
+ /**
+ * f0 -> PrimaryExpression()
+ * f1 -> "["
+ * f2 -> PrimaryExpression()
+ * f3 -> "]"
+ */
+ public void visit(ArrayLookup n);
+
+ /**
+ * f0 -> PrimaryExpression()
+ * f1 -> "."
+ * f2 -> "length"
+ */
+ public void visit(ArrayLength n);
+
+ /**
+ * f0 -> PrimaryExpression()
+ * f1 -> "."
+ * f2 -> Identifier()
+ * f3 -> "("
+ * f4 -> ( ExpressionList() )?
+ * f5 -> ")"
+ */
+ public void visit(MessageSend n);
+
+ /**
+ * f0 -> Expression()
+ * f1 -> ( ExpressionRest() )*
+ */
+ public void visit(ExpressionList n);
+
+ /**
+ * f0 -> ","
+ * f1 -> Expression()
+ */
+ public void visit(ExpressionRest n);
+
+ /**
+ * f0 -> IntegerLiteral()
+ * | TrueLiteral()
+ * | FalseLiteral()
+ * | Identifier()
+ * | ThisExpression()
+ * | ArrayAllocationExpression()
+ * | AllocationExpression()
+ * | NotExpression()
+ * | BracketExpression()
+ */
+ public void visit(PrimaryExpression n);
+
+ /**
+ * f0 -> <INTEGER_LITERAL>
+ */
+ public void visit(IntegerLiteral n);
+
+ /**
+ * f0 -> "true"
+ */
+ public void visit(TrueLiteral n);
+
+ /**
+ * f0 -> "false"
+ */
+ public void visit(FalseLiteral n);
+
+ /**
+ * f0 -> <IDENTIFIER>
+ */
+ public void visit(Identifier n);
+
+ /**
+ * f0 -> "this"
+ */
+ public void visit(ThisExpression n);
+
+ /**
+ * f0 -> "new"
+ * f1 -> "int"
+ * f2 -> "["
+ * f3 -> Expression()
+ * f4 -> "]"
+ */
+ public void visit(ArrayAllocationExpression n);
+
+ /**
+ * f0 -> "new"
+ * f1 -> Identifier()
+ * f2 -> "("
+ * f3 -> ")"
+ */
+ public void visit(AllocationExpression n);
+
+ /**
+ * f0 -> "!"
+ * f1 -> Expression()
+ */
+ public void visit(NotExpression n);
+
+ /**
+ * f0 -> "("
+ * f1 -> Expression()
+ * f2 -> ")"
+ */
+ public void visit(BracketExpression n);
+
+}
+
diff --git a/src/piglet/JavaCharStream.java b/src/piglet/JavaCharStream.java
new file mode 100644
index 0000000..1b04b25
--- /dev/null
+++ b/src/piglet/JavaCharStream.java
@@ -0,0 +1,587 @@
+package piglet;
+/* Generated By:JavaCC: Do not edit this line. JavaCharStream.java Version 4.0 */
+/**
+ * An implementation of interface CharStream, where the stream is assumed to
+ * contain only ASCII characters (with java-like unicode escape processing).
+ */
+
+public class JavaCharStream
+{
+ public static final boolean staticFlag = true;
+ static final int hexval(char c) throws java.io.IOException {
+ switch(c)
+ {
+ case '0' :
+ return 0;
+ case '1' :
+ return 1;
+ case '2' :
+ return 2;
+ case '3' :
+ return 3;
+ case '4' :
+ return 4;
+ case '5' :
+ return 5;
+ case '6' :
+ return 6;
+ case '7' :
+ return 7;
+ case '8' :
+ return 8;
+ case '9' :
+ return 9;
+
+ case 'a' :
+ case 'A' :
+ return 10;
+ case 'b' :
+ case 'B' :
+ return 11;
+ case 'c' :
+ case 'C' :
+ return 12;
+ case 'd' :
+ case 'D' :
+ return 13;
+ case 'e' :
+ case 'E' :
+ return 14;
+ case 'f' :
+ case 'F' :
+ return 15;
+ }
+
+ throw new java.io.IOException(); // Should never come here
+ }
+
+ static public int bufpos = -1;
+ static int bufsize;
+ static int available;
+ static int tokenBegin;
+ static protected int bufline[];
+ static protected int bufcolumn[];
+
+ static protected int column = 0;
+ static protected int line = 1;
+
+ static protected boolean prevCharIsCR = false;
+ static protected boolean prevCharIsLF = false;
+
+ static protected java.io.Reader inputStream;
+
+ static protected char[] nextCharBuf;
+ static protected char[] buffer;
+ static protected int maxNextCharInd = 0;
+ static protected int nextCharInd = -1;
+ static protected int inBuf = 0;
+ static protected int tabSize = 8;
+
+ static protected void setTabSize(int i) { tabSize = i; }
+ static protected int getTabSize(int i) { return tabSize; }
+
+ static protected void ExpandBuff(boolean wrapAround)
+ {
+ char[] newbuffer = new char[bufsize + 2048];
+ int newbufline[] = new int[bufsize + 2048];
+ int newbufcolumn[] = new int[bufsize + 2048];
+
+ try
+ {
+ if (wrapAround)
+ {
+ System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin);
+ System.arraycopy(buffer, 0, newbuffer,
+ bufsize - tokenBegin, bufpos);
+ buffer = newbuffer;
+
+ System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin);
+ System.arraycopy(bufline, 0, newbufline, bufsize - tokenBegin, bufpos);
+ bufline = newbufline;
+
+ System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin);
+ System.arraycopy(bufcolumn, 0, newbufcolumn, bufsize - tokenBegin, bufpos);
+ bufcolumn = newbufcolumn;
+
+ bufpos += (bufsize - tokenBegin);
+ }
+ else
+ {
+ System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin);
+ buffer = newbuffer;
+
+ System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin);
+ bufline = newbufline;
+
+ System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin);
+ bufcolumn = newbufcolumn;
+
+ bufpos -= tokenBegin;
+ }
+ }
+ catch (Throwable t)
+ {
+ throw new Error(t.getMessage());
+ }
+
+ available = (bufsize += 2048);
+ tokenBegin = 0;
+ }
+
+ static protected void FillBuff() throws java.io.IOException
+ {
+ int i;
+ if (maxNextCharInd == 4096)
+ maxNextCharInd = nextCharInd = 0;
+
+ try {
+ if ((i = inputStream.read(nextCharBuf, maxNextCharInd,
+ 4096 - maxNextCharInd)) == -1)
+ {
+ inputStream.close();
+ throw new java.io.IOException();
+ }
+ else
+ maxNextCharInd += i;
+ return;
+ }
+ catch(java.io.IOException e) {
+ if (bufpos != 0)
+ {
+ --bufpos;
+ backup(0);
+ }
+ else
+ {
+ bufline[bufpos] = line;
+ bufcolumn[bufpos] = column;
+ }
+ throw e;
+ }
+ }
+
+ static protected char ReadByte() throws java.io.IOException
+ {
+ if (++nextCharInd >= maxNextCharInd)
+ FillBuff();
+
+ return nextCharBuf[nextCharInd];
+ }
+
+ static public char BeginToken() throws java.io.IOException
+ {
+ if (inBuf > 0)
+ {
+ --inBuf;
+
+ if (++bufpos == bufsize)
+ bufpos = 0;
+
+ tokenBegin = bufpos;
+ return buffer[bufpos];
+ }
+
+ tokenBegin = 0;
+ bufpos = -1;
+
+ return readChar();
+ }
+
+ static protected void AdjustBuffSize()
+ {
+ if (available == bufsize)
+ {
+ if (tokenBegin > 2048)
+ {
+ bufpos = 0;
+ available = tokenBegin;
+ }
+ else
+ ExpandBuff(false);
+ }
+ else if (available > tokenBegin)
+ available = bufsize;
+ else if ((tokenBegin - available) < 2048)
+ ExpandBuff(true);
+ else
+ available = tokenBegin;
+ }
+
+ static protected void UpdateLineColumn(char c)
+ {
+ column++;
+
+ if (prevCharIsLF)
+ {
+ prevCharIsLF = false;
+ line += (column = 1);
+ }
+ else if (prevCharIsCR)
+ {
+ prevCharIsCR = false;
+ if (c == '\n')
+ {
+ prevCharIsLF = true;
+ }
+ else
+ line += (column = 1);
+ }
+
+ switch (c)
+ {
+ case '\r' :
+ prevCharIsCR = true;
+ break;
+ case '\n' :
+ prevCharIsLF = true;
+ break;
+ case '\t' :
+ column--;
+ column += (tabSize - (column % tabSize));
+ break;
+ default :
+ break;
+ }
+
+ bufline[bufpos] = line;
+ bufcolumn[bufpos] = column;
+ }
+
+ static public char readChar() throws java.io.IOException
+ {
+ if (inBuf > 0)
+ {
+ --inBuf;
+
+ if (++bufpos == bufsize)
+ bufpos = 0;
+
+ return buffer[bufpos];
+ }
+
+ char c;
+
+ if (++bufpos == available)
+ AdjustBuffSize();
+
+ if ((buffer[bufpos] = c = ReadByte()) == '\\')
+ {
+ UpdateLineColumn(c);
+
+ int backSlashCnt = 1;
+
+ for (;;) // Read all the backslashes
+ {
+ if (++bufpos == available)
+ AdjustBuffSize();
+
+ try
+ {
+ if ((buffer[bufpos] = c = ReadByte()) != '\\')
+ {
+ UpdateLineColumn(c);
+ // found a non-backslash char.
+ if ((c == 'u') && ((backSlashCnt & 1) == 1))
+ {
+ if (--bufpos < 0)
+ bufpos = bufsize - 1;
+
+ break;
+ }
+
+ backup(backSlashCnt);
+ return '\\';
+ }
+ }
+ catch(java.io.IOException e)
+ {
+ if (backSlashCnt > 1)
+ backup(backSlashCnt);
+
+ return '\\';
+ }
+
+ UpdateLineColumn(c);
+ backSlashCnt++;
+ }
+
+ // Here, we have seen an odd number of backslash's followed by a 'u'
+ try
+ {
+ while ((c = ReadByte()) == 'u')
+ ++column;
+
+ buffer[bufpos] = c = (char)(hexval(c) << 12 |
+ hexval(ReadByte()) << 8 |
+ hexval(ReadByte()) << 4 |
+ hexval(ReadByte()));
+
+ column += 4;
+ }
+ catch(java.io.IOException e)
+ {
+ throw new Error("Invalid escape character at line " + line +
+ " column " + column + ".");
+ }
+
+ if (backSlashCnt == 1)
+ return c;
+ else
+ {
+ backup(backSlashCnt - 1);
+ return '\\';
+ }
+ }
+ else
+ {
+ UpdateLineColumn(c);
+ return (c);
+ }
+ }
+
+ /**
+ * @deprecated
+ * @see #getEndColumn
+ */
+
+ static public int getColumn() {
+ return bufcolumn[bufpos];
+ }
+
+ /**
+ * @deprecated
+ * @see #getEndLine
+ */
+
+ static public int getLine() {
+ return bufline[bufpos];
+ }
+
+ static public int getEndColumn() {
+ return bufcolumn[bufpos];
+ }
+
+ static public int getEndLine() {
+ return bufline[bufpos];
+ }
+
+ static public int getBeginColumn() {
+ return bufcolumn[tokenBegin];
+ }
+
+ static public int getBeginLine() {
+ return bufline[tokenBegin];
+ }
+
+ static public void backup(int amount) {
+
+ inBuf += amount;
+ if ((bufpos -= amount) < 0)
+ bufpos += bufsize;
+ }
+
+ public JavaCharStream(java.io.Reader dstream,
+ int startline, int startcolumn, int buffersize)
+ {
+ if (inputStream != null)
+ throw new Error("\n ERROR: Second call to the constructor of a static JavaCharStream. You must\n" +
+ " either use ReInit() or set the JavaCC option STATIC to false\n" +
+ " during the generation of this class.");
+ inputStream = dstream;
+ line = startline;
+ column = startcolumn - 1;
+
+ available = bufsize = buffersize;
+ buffer = new char[buffersize];
+ bufline = new int[buffersize];
+ bufcolumn = new int[buffersize];
+ nextCharBuf = new char[4096];
+ }
+
+ public JavaCharStream(java.io.Reader dstream,
+ int startline, int startcolumn)
+ {
+ this(dstream, startline, startcolumn, 4096);
+ }
+
+ public JavaCharStream(java.io.Reader dstream)
+ {
+ this(dstream, 1, 1, 4096);
+ }
+ public void ReInit(java.io.Reader dstream,
+ int startline, int startcolumn, int buffersize)
+ {
+ inputStream = dstream;
+ line = startline;
+ column = startcolumn - 1;
+
+ if (buffer == null || buffersize != buffer.length)
+ {
+ available = bufsize = buffersize;
+ buffer = new char[buffersize];
+ bufline = new int[buffersize];
+ bufcolumn = new int[buffersize];
+ nextCharBuf = new char[4096];
+ }
+ prevCharIsLF = prevCharIsCR = false;
+ tokenBegin = inBuf = maxNextCharInd = 0;
+ nextCharInd = bufpos = -1;
+ }
+
+ public void ReInit(java.io.Reader dstream,
+ int startline, int startcolumn)
+ {
+ ReInit(dstream, startline, startcolumn, 4096);
+ }
+
+ public void ReInit(java.io.Reader dstream)
+ {
+ ReInit(dstream, 1, 1, 4096);
+ }
+ public JavaCharStream(java.io.InputStream dstream, String encoding, int startline,
+ int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException
+ {
+ this(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize);
+ }
+
+ public JavaCharStream(java.io.InputStream dstream, int startline,
+ int startcolumn, int buffersize)
+ {
+ this(new java.io.InputStreamReader(dstream), startline, startcolumn, 4096);
+ }
+
+ public JavaCharStream(java.io.InputStream dstream, String encoding, int startline,
+ int startcolumn) throws java.io.UnsupportedEncodingException
+ {
+ this(dstream, encoding, startline, startcolumn, 4096);
+ }
+
+ public JavaCharStream(java.io.InputStream dstream, int startline,
+ int startcolumn)
+ {
+ this(dstream, startline, startcolumn, 4096);
+ }
+
+ public JavaCharStream(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException
+ {
+ this(dstream, encoding, 1, 1, 4096);
+ }
+
+ public JavaCharStream(java.io.InputStream dstream)
+ {
+ this(dstream, 1, 1, 4096);
+ }
+
+ public void ReInit(java.io.InputStream dstream, String encoding, int startline,
+ int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException
+ {
+ ReInit(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize);
+ }
+
+ public void ReInit(java.io.InputStream dstream, int startline,
+ int startcolumn, int buffersize)
+ {
+ ReInit(new java.io.InputStreamReader(dstream), startline, startcolumn, buffersize);
+ }
+ public void ReInit(java.io.InputStream dstream, String encoding, int startline,
+ int startcolumn) throws java.io.UnsupportedEncodingException
+ {
+ ReInit(dstream, encoding, startline, startcolumn, 4096);
+ }
+ public void ReInit(java.io.InputStream dstream, int startline,
+ int startcolumn)
+ {
+ ReInit(dstream, startline, startcolumn, 4096);
+ }
+ public void ReInit(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException
+ {
+ ReInit(dstream, encoding, 1, 1, 4096);
+ }
+
+ public void ReInit(java.io.InputStream dstream)
+ {
+ ReInit(dstream, 1, 1, 4096);
+ }
+
+ static public String GetImage()
+ {
+ if (bufpos >= tokenBegin)
+ return new String(buffer, tokenBegin, bufpos - tokenBegin + 1);
+ else
+ return new String(buffer, tokenBegin, bufsize - tokenBegin) +
+ new String(buffer, 0, bufpos + 1);
+ }
+
+ static public char[] GetSuffix(int len)
+ {
+ char[] ret = new char[len];
+
+ if ((bufpos + 1) >= len)
+ System.arraycopy(buffer, bufpos - len + 1, ret, 0, len);
+ else
+ {
+ System.arraycopy(buffer, bufsize - (len - bufpos - 1), ret, 0,
+ len - bufpos - 1);
+ System.arraycopy(buffer, 0, ret, len - bufpos - 1, bufpos + 1);
+ }
+
+ return ret;
+ }
+
+ static public void Done()
+ {
+ nextCharBuf = null;
+ buffer = null;
+ bufline = null;
+ bufcolumn = null;
+ }
+
+ /**
+ * Method to adjust line and column numbers for the start of a token.
+ */
+ static public void adjustBeginLineColumn(int newLine, int newCol)
+ {
+ int start = tokenBegin;
+ int len;
+
+ if (bufpos >= tokenBegin)
+ {
+ len = bufpos - tokenBegin + inBuf + 1;
+ }
+ else
+ {
+ len = bufsize - tokenBegin + bufpos + 1 + inBuf;
+ }
+
+ int i = 0, j = 0, k = 0;
+ int nextColDiff = 0, columnDiff = 0;
+
+ while (i < len &&
+ bufline[j = start % bufsize] == bufline[k = ++start % bufsize])
+ {
+ bufline[j] = newLine;
+ nextColDiff = columnDiff + bufcolumn[k] - bufcolumn[j];
+ bufcolumn[j] = newCol + columnDiff;
+ columnDiff = nextColDiff;
+ i++;
+ }
+
+ if (i < len)
+ {
+ bufline[j] = newLine++;
+ bufcolumn[j] = newCol + columnDiff;
+
+ while (i++ < len)
+ {
+ if (bufline[j = start % bufsize] != bufline[++start % bufsize])
+ bufline[j] = newLine++;
+ else
+ bufline[j] = newLine;
+ }
+ }
+
+ line = bufline[j];
+ column = bufcolumn[j];
+ }
+
+}
diff --git a/src/piglet/ParseException.java b/src/piglet/ParseException.java
new file mode 100644
index 0000000..8923138
--- /dev/null
+++ b/src/piglet/ParseException.java
@@ -0,0 +1,192 @@
+package piglet;
+
+/* Generated By:JavaCC: Do not edit this line. ParseException.java Version 3.0 */
+/**
+ * This exception is thrown when parse errors are encountered.
+ * You can explicitly create objects of this exception type by
+ * calling the method generateParseException in the generated
+ * parser.
+ *
+ * You can modify this class to customize your error reporting
+ * mechanisms so long as you retain the public fields.
+ */
+public class ParseException extends Exception {
+
+ /**
+ * This constructor is used by the method "generateParseException"
+ * in the generated parser. Calling this constructor generates
+ * a new object of this type with the fields "currentToken",
+ * "expectedTokenSequences", and "tokenImage" set. The boolean
+ * flag "specialConstructor" is also set to true to indicate that
+ * this constructor was used to create this object.
+ * This constructor calls its super class with the empty string
+ * to force the "toString" method of parent class "Throwable" to
+ * print the error message in the form:
+ * ParseException: <result of getMessage>
+ */
+ public ParseException(Token currentTokenVal,
+ int[][] expectedTokenSequencesVal,
+ String[] tokenImageVal
+ )
+ {
+ super("");
+ specialConstructor = true;
+ currentToken = currentTokenVal;
+ expectedTokenSequences = expectedTokenSequencesVal;
+ tokenImage = tokenImageVal;
+ }
+
+ /**
+ * The following constructors are for use by you for whatever
+ * purpose you can think of. Constructing the exception in this
+ * manner makes the exception behave in the normal way - i.e., as
+ * documented in the class "Throwable". The fields "errorToken",
+ * "expectedTokenSequences", and "tokenImage" do not contain
+ * relevant information. The JavaCC generated code does not use
+ * these constructors.
+ */
+
+ public ParseException() {
+ super();
+ specialConstructor = false;
+ }
+
+ public ParseException(String message) {
+ super(message);
+ specialConstructor = false;
+ }
+
+ /**
+ * This variable determines which constructor was used to create
+ * this object and thereby affects the semantics of the
+ * "getMessage" method (see below).
+ */
+ protected boolean specialConstructor;
+
+ /**
+ * This is the last token that has been consumed successfully. If
+ * this object has been created due to a parse error, the token
+ * followng this token will (therefore) be the first error token.
+ */
+ public Token currentToken;
+
+ /**
+ * Each entry in this array is an array of integers. Each array
+ * of integers represents a sequence of tokens (by their ordinal
+ * values) that is expected at this point of the parse.
+ */
+ public int[][] expectedTokenSequences;
+
+ /**
+ * This is a reference to the "tokenImage" array of the generated
+ * parser within which the parse error occurred. This array is
+ * defined in the generated ...Constants interface.
+ */
+ public String[] tokenImage;
+
+ /**
+ * This method has the standard behavior when this object has been
+ * created using the standard constructors. Otherwise, it uses
+ * "currentToken" and "expectedTokenSequences" to generate a parse
+ * error message and returns it. If this object has been created
+ * due to a parse error, and you do not catch it (it gets thrown
+ * from the parser), then this method is called during the printing
+ * of the final stack trace, and hence the correct error message
+ * gets displayed.
+ */
+ public String getMessage() {
+ if (!specialConstructor) {
+ return super.getMessage();
+ }
+ StringBuffer expected = new StringBuffer();
+ int maxSize = 0;
+ for (int i = 0; i < expectedTokenSequences.length; i++) {
+ if (maxSize < expectedTokenSequences[i].length) {
+ maxSize = expectedTokenSequences[i].length;
+ }
+ for (int j = 0; j < expectedTokenSequences[i].length; j++) {
+ expected.append(tokenImage[expectedTokenSequences[i][j]]).append(" ");
+ }
+ if (expectedTokenSequences[i][expectedTokenSequences[i].length - 1] != 0) {
+ expected.append("...");
+ }
+ expected.append(eol).append(" ");
+ }
+ String retval = "Encountered \"";
+ Token tok = currentToken.next;
+ for (int i = 0; i < maxSize; i++) {
+ if (i != 0) retval += " ";
+ if (tok.kind == 0) {
+ retval += tokenImage[0];
+ break;
+ }
+ retval += add_escapes(tok.image);
+ tok = tok.next;
+ }
+ retval += "\" at line " + currentToken.next.beginLine + ", column " + currentToken.next.beginColumn;
+ retval += "." + eol;
+ if (expectedTokenSequences.length == 1) {
+ retval += "Was expecting:" + eol + " ";
+ } else {
+ retval += "Was expecting one of:" + eol + " ";
+ }
+ retval += expected.toString();
+ return retval;
+ }
+
+ /**
+ * The end of line string for this machine.
+ */
+ protected String eol = System.getProperty("line.separator", "\n");
+
+ /**
+ * Used to convert raw characters to their escaped version
+ * when these raw version cannot be used as part of an ASCII
+ * string literal.
+ */
+ protected String add_escapes(String str) {
+ StringBuffer retval = new StringBuffer();
+ char ch;
+ for (int i = 0; i < str.length(); i++) {
+ switch (str.charAt(i))
+ {
+ case 0 :
+ continue;
+ case '\b':
+ retval.append("\\b");
+ continue;
+ case '\t':
+ retval.append("\\t");
+ continue;
+ case '\n':
+ retval.append("\\n");
+ continue;
+ case '\f':
+ retval.append("\\f");
+ continue;
+ case '\r':
+ retval.append("\\r");
+ continue;
+ case '\"':
+ retval.append("\\\"");
+ continue;
+ case '\'':
+ retval.append("\\\'");
+ continue;
+ case '\\':
+ retval.append("\\\\");
+ continue;
+ default:
+ if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) {
+ String s = "0000" + Integer.toString(ch, 16);
+ retval.append("\\u" + s.substring(s.length() - 4, s.length()));
+ } else {
+ retval.append(ch);
+ }
+ continue;
+ }
+ }
+ return retval.toString();
+ }
+
+}
diff --git a/src/piglet/PigletParser.java b/src/piglet/PigletParser.java
new file mode 100644
index 0000000..fe6b4ec
--- /dev/null
+++ b/src/piglet/PigletParser.java
@@ -0,0 +1,676 @@
+package piglet;
+/* Generated By:JavaCC: Do not edit this line. PigletParser.java */
+import piglet.syntaxtree.BinOp;
+import piglet.syntaxtree.CJumpStmt;
+import piglet.syntaxtree.Call;
+import piglet.syntaxtree.ErrorStmt;
+import piglet.syntaxtree.Exp;
+import piglet.syntaxtree.Goal;
+import piglet.syntaxtree.HAllocate;
+import piglet.syntaxtree.HLoadStmt;
+import piglet.syntaxtree.HStoreStmt;
+import piglet.syntaxtree.IntegerLiteral;
+import piglet.syntaxtree.JumpStmt;
+import piglet.syntaxtree.Label;
+import piglet.syntaxtree.MoveStmt;
+import piglet.syntaxtree.NoOpStmt;
+import piglet.syntaxtree.NodeChoice;
+import piglet.syntaxtree.NodeListOptional;
+import piglet.syntaxtree.NodeOptional;
+import piglet.syntaxtree.NodeSequence;
+import piglet.syntaxtree.NodeToken;
+import piglet.syntaxtree.Operator;
+import piglet.syntaxtree.PrintStmt;
+import piglet.syntaxtree.Procedure;
+import piglet.syntaxtree.Stmt;
+import piglet.syntaxtree.StmtExp;
+import piglet.syntaxtree.StmtList;
+import piglet.syntaxtree.Temp;
+
+
+public class PigletParser implements PigletParserConstants {
+
+ static final public Goal Goal() throws ParseException {
+ NodeToken n0;
+ Token n1;
+ StmtList n2;
+ NodeToken n3;
+ Token n4;
+ NodeListOptional n5 = new NodeListOptional();
+ Procedure n6;
+ NodeToken n7;
+ Token n8;
+ n1 = jj_consume_token(MAIN);
+ n0 = JTBToolkit.makeNodeToken(n1);
+ n2 = StmtList();
+ n4 = jj_consume_token(END);
+ n3 = JTBToolkit.makeNodeToken(n4);
+ label_1:
+ while (true) {
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case IDENTIFIER:
+ ;
+ break;
+ default:
+ jj_la1[0] = jj_gen;
+ break label_1;
+ }
+ n6 = Procedure();
+ n5.addNode(n6);
+ }
+ n5.nodes.trimToSize();
+ n8 = jj_consume_token(0);
+ n8.beginColumn++; n8.endColumn++;
+ n7 = JTBToolkit.makeNodeToken(n8);
+ {if (true) return new Goal(n0,n2,n3,n5,n7);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public StmtList StmtList() throws ParseException {
+ NodeListOptional n0 = new NodeListOptional();
+ NodeSequence n1;
+ NodeOptional n2;
+ Label n3;
+ Stmt n4;
+ label_2:
+ while (true) {
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case NOOP:
+ case MOVE:
+ case ERROR:
+ case PRINT:
+ case JUMP:
+ case CJUMP:
+ case HSTORE:
+ case HLOAD:
+ case IDENTIFIER:
+ ;
+ break;
+ default:
+ jj_la1[1] = jj_gen;
+ break label_2;
+ }
+ n2 = new NodeOptional();
+ n1 = new NodeSequence(2);
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case IDENTIFIER:
+ n3 = Label();
+ n2.addNode(n3);
+ break;
+ default:
+ jj_la1[2] = jj_gen;
+ ;
+ }
+ n1.addNode(n2);
+ n4 = Stmt();
+ n1.addNode(n4);
+ n0.addNode(n1);
+ }
+ n0.nodes.trimToSize();
+ {if (true) return new StmtList(n0);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public Procedure Procedure() throws ParseException {
+ Label n0;
+ NodeToken n1;
+ Token n2;
+ IntegerLiteral n3;
+ NodeToken n4;
+ Token n5;
+ StmtExp n6;
+ n0 = Label();
+ n2 = jj_consume_token(LSQPAREN);
+ n1 = JTBToolkit.makeNodeToken(n2);
+ n3 = IntegerLiteral();
+ n5 = jj_consume_token(RSQPAREN);
+ n4 = JTBToolkit.makeNodeToken(n5);
+ n6 = StmtExp();
+ {if (true) return new Procedure(n0,n1,n3,n4,n6);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public Stmt Stmt() throws ParseException {
+ NodeChoice n0;
+ NoOpStmt n1;
+ ErrorStmt n2;
+ CJumpStmt n3;
+ JumpStmt n4;
+ HStoreStmt n5;
+ HLoadStmt n6;
+ MoveStmt n7;
+ PrintStmt n8;
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case NOOP:
+ n1 = NoOpStmt();
+ n0 = new NodeChoice(n1, 0);
+ break;
+ case ERROR:
+ n2 = ErrorStmt();
+ n0 = new NodeChoice(n2, 1);
+ break;
+ case CJUMP:
+ n3 = CJumpStmt();
+ n0 = new NodeChoice(n3, 2);
+ break;
+ case JUMP:
+ n4 = JumpStmt();
+ n0 = new NodeChoice(n4, 3);
+ break;
+ case HSTORE:
+ n5 = HStoreStmt();
+ n0 = new NodeChoice(n5, 4);
+ break;
+ case HLOAD:
+ n6 = HLoadStmt();
+ n0 = new NodeChoice(n6, 5);
+ break;
+ case MOVE:
+ n7 = MoveStmt();
+ n0 = new NodeChoice(n7, 6);
+ break;
+ case PRINT:
+ n8 = PrintStmt();
+ n0 = new NodeChoice(n8, 7);
+ break;
+ default:
+ jj_la1[3] = jj_gen;
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ {if (true) return new Stmt(n0);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public NoOpStmt NoOpStmt() throws ParseException {
+ NodeToken n0;
+ Token n1;
+ n1 = jj_consume_token(NOOP);
+ n0 = JTBToolkit.makeNodeToken(n1);
+ {if (true) return new NoOpStmt(n0);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public ErrorStmt ErrorStmt() throws ParseException {
+ NodeToken n0;
+ Token n1;
+ n1 = jj_consume_token(ERROR);
+ n0 = JTBToolkit.makeNodeToken(n1);
+ {if (true) return new ErrorStmt(n0);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public CJumpStmt CJumpStmt() throws ParseException {
+ NodeToken n0;
+ Token n1;
+ Exp n2;
+ Label n3;
+ n1 = jj_consume_token(CJUMP);
+ n0 = JTBToolkit.makeNodeToken(n1);
+ n2 = Exp();
+ n3 = Label();
+ {if (true) return new CJumpStmt(n0,n2,n3);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public JumpStmt JumpStmt() throws ParseException {
+ NodeToken n0;
+ Token n1;
+ Label n2;
+ n1 = jj_consume_token(JUMP);
+ n0 = JTBToolkit.makeNodeToken(n1);
+ n2 = Label();
+ {if (true) return new JumpStmt(n0,n2);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public HStoreStmt HStoreStmt() throws ParseException {
+ NodeToken n0;
+ Token n1;
+ Exp n2;
+ IntegerLiteral n3;
+ Exp n4;
+ n1 = jj_consume_token(HSTORE);
+ n0 = JTBToolkit.makeNodeToken(n1);
+ n2 = Exp();
+ n3 = IntegerLiteral();
+ n4 = Exp();
+ {if (true) return new HStoreStmt(n0,n2,n3,n4);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public HLoadStmt HLoadStmt() throws ParseException {
+ NodeToken n0;
+ Token n1;
+ Temp n2;
+ Exp n3;
+ IntegerLiteral n4;
+ n1 = jj_consume_token(HLOAD);
+ n0 = JTBToolkit.makeNodeToken(n1);
+ n2 = Temp();
+ n3 = Exp();
+ n4 = IntegerLiteral();
+ {if (true) return new HLoadStmt(n0,n2,n3,n4);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public MoveStmt MoveStmt() throws ParseException {
+ NodeToken n0;
+ Token n1;
+ Temp n2;
+ Exp n3;
+ n1 = jj_consume_token(MOVE);
+ n0 = JTBToolkit.makeNodeToken(n1);
+ n2 = Temp();
+ n3 = Exp();
+ {if (true) return new MoveStmt(n0,n2,n3);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public PrintStmt PrintStmt() throws ParseException {
+ NodeToken n0;
+ Token n1;
+ Exp n2;
+ n1 = jj_consume_token(PRINT);
+ n0 = JTBToolkit.makeNodeToken(n1);
+ n2 = Exp();
+ {if (true) return new PrintStmt(n0,n2);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public Exp Exp() throws ParseException {
+ NodeChoice n0;
+ StmtExp n1;
+ Call n2;
+ HAllocate n3;
+ BinOp n4;
+ Temp n5;
+ IntegerLiteral n6;
+ Label n7;
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case BEGIN:
+ n1 = StmtExp();
+ n0 = new NodeChoice(n1, 0);
+ break;
+ case CALL:
+ n2 = Call();
+ n0 = new NodeChoice(n2, 1);
+ break;
+ case HALLOCATE:
+ n3 = HAllocate();
+ n0 = new NodeChoice(n3, 2);
+ break;
+ case LT:
+ case PLUS:
+ case MINUS:
+ case TIMES:
+ n4 = BinOp();
+ n0 = new NodeChoice(n4, 3);
+ break;
+ case TEMP:
+ n5 = Temp();
+ n0 = new NodeChoice(n5, 4);
+ break;
+ case INTEGER_LITERAL:
+ n6 = IntegerLiteral();
+ n0 = new NodeChoice(n6, 5);
+ break;
+ case IDENTIFIER:
+ n7 = Label();
+ n0 = new NodeChoice(n7, 6);
+ break;
+ default:
+ jj_la1[4] = jj_gen;
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ {if (true) return new Exp(n0);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public StmtExp StmtExp() throws ParseException {
+ NodeToken n0;
+ Token n1;
+ StmtList n2;
+ NodeToken n3;
+ Token n4;
+ Exp n5;
+ NodeToken n6;
+ Token n7;
+ n1 = jj_consume_token(BEGIN);
+ n0 = JTBToolkit.makeNodeToken(n1);
+ n2 = StmtList();
+ n4 = jj_consume_token(RETURN);
+ n3 = JTBToolkit.makeNodeToken(n4);
+ n5 = Exp();
+ n7 = jj_consume_token(END);
+ n6 = JTBToolkit.makeNodeToken(n7);
+ {if (true) return new StmtExp(n0,n2,n3,n5,n6);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public Call Call() throws ParseException {
+ NodeToken n0;
+ Token n1;
+ Exp n2;
+ NodeToken n3;
+ Token n4;
+ NodeListOptional n5 = new NodeListOptional();
+ Exp n6;
+ NodeToken n7;
+ Token n8;
+ n1 = jj_consume_token(CALL);
+ n0 = JTBToolkit.makeNodeToken(n1);
+ n2 = Exp();
+ n4 = jj_consume_token(LPAREN);
+ n3 = JTBToolkit.makeNodeToken(n4);
+ label_3:
+ while (true) {
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case LT:
+ case PLUS:
+ case MINUS:
+ case TIMES:
+ case HALLOCATE:
+ case CALL:
+ case BEGIN:
+ case TEMP:
+ case INTEGER_LITERAL:
+ case IDENTIFIER:
+ ;
+ break;
+ default:
+ jj_la1[5] = jj_gen;
+ break label_3;
+ }
+ n6 = Exp();
+ n5.addNode(n6);
+ }
+ n5.nodes.trimToSize();
+ n8 = jj_consume_token(RPAREN);
+ n7 = JTBToolkit.makeNodeToken(n8);
+ {if (true) return new Call(n0,n2,n3,n5,n7);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public HAllocate HAllocate() throws ParseException {
+ NodeToken n0;
+ Token n1;
+ Exp n2;
+ n1 = jj_consume_token(HALLOCATE);
+ n0 = JTBToolkit.makeNodeToken(n1);
+ n2 = Exp();
+ {if (true) return new HAllocate(n0,n2);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public BinOp BinOp() throws ParseException {
+ Operator n0;
+ Exp n1;
+ Exp n2;
+ n0 = Operator();
+ n1 = Exp();
+ n2 = Exp();
+ {if (true) return new BinOp(n0,n1,n2);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public Operator Operator() throws ParseException {
+ NodeChoice n0;
+ NodeToken n1;
+ Token n2;
+ NodeToken n3;
+ Token n4;
+ NodeToken n5;
+ Token n6;
+ NodeToken n7;
+ Token n8;
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case LT:
+ n2 = jj_consume_token(LT);
+ n1 = JTBToolkit.makeNodeToken(n2);
+ n0 = new NodeChoice(n1, 0);
+ break;
+ case PLUS:
+ n4 = jj_consume_token(PLUS);
+ n3 = JTBToolkit.makeNodeToken(n4);
+ n0 = new NodeChoice(n3, 1);
+ break;
+ case MINUS:
+ n6 = jj_consume_token(MINUS);
+ n5 = JTBToolkit.makeNodeToken(n6);
+ n0 = new NodeChoice(n5, 2);
+ break;
+ case TIMES:
+ n8 = jj_consume_token(TIMES);
+ n7 = JTBToolkit.makeNodeToken(n8);
+ n0 = new NodeChoice(n7, 3);
+ break;
+ default:
+ jj_la1[6] = jj_gen;
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ {if (true) return new Operator(n0);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public Temp Temp() throws ParseException {
+ NodeToken n0;
+ Token n1;
+ IntegerLiteral n2;
+ n1 = jj_consume_token(TEMP);
+ n0 = JTBToolkit.makeNodeToken(n1);
+ n2 = IntegerLiteral();
+ {if (true) return new Temp(n0,n2);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public IntegerLiteral IntegerLiteral() throws ParseException {
+ NodeToken n0;
+ Token n1;
+ n1 = jj_consume_token(INTEGER_LITERAL);
+ n0 = JTBToolkit.makeNodeToken(n1);
+ {if (true) return new IntegerLiteral(n0);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public Label Label() throws ParseException {
+ NodeToken n0;
+ Token n1;
+ n1 = jj_consume_token(IDENTIFIER);
+ n0 = JTBToolkit.makeNodeToken(n1);
+ {if (true) return new Label(n0);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static private boolean jj_initialized_once = false;
+ static public PigletParserTokenManager token_source;
+ static JavaCharStream jj_input_stream;
+ static public Token token, jj_nt;
+ static private int jj_ntk;
+ static private int jj_gen;
+ static final private int[] jj_la1 = new int[7];
+ static private int[] jj_la1_0;
+ static private int[] jj_la1_1;
+ static {
+ jj_la1_0();
+ jj_la1_1();
+ }
+ private static void jj_la1_0() {
+ jj_la1_0 = new int[] {0x0,0x0,0x0,0x0,0x48c10000,0x48c10000,0x8c10000,};
+ }
+ private static void jj_la1_1() {
+ jj_la1_1 = new int[] {0x8000,0x879b,0x8000,0x79b,0xd024,0xd024,0x0,};
+ }
+
+ public PigletParser(java.io.InputStream stream) {
+ this(stream, null);
+ }
+ public PigletParser(java.io.InputStream stream, String encoding) {
+ if (jj_initialized_once) {
+ System.out.println("ERROR: Second call to constructor of static parser. You must");
+ System.out.println(" either use ReInit() or set the JavaCC option STATIC to false");
+ System.out.println(" during parser generation.");
+ throw new Error();
+ }
+ jj_initialized_once = true;
+ try { jj_input_stream = new JavaCharStream(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); }
+ token_source = new PigletParserTokenManager(jj_input_stream);
+ token = new Token();
+ jj_ntk = -1;
+ jj_gen = 0;
+ for (int i = 0; i < 7; i++) jj_la1[i] = -1;
+ }
+
+ static public void ReInit(java.io.InputStream stream) {
+ ReInit(stream, null);
+ }
+ static public void ReInit(java.io.InputStream stream, String encoding) {
+ try { jj_input_stream.ReInit(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); }
+ token_source.ReInit(jj_input_stream);
+ token = new Token();
+ jj_ntk = -1;
+ jj_gen = 0;
+ for (int i = 0; i < 7; i++) jj_la1[i] = -1;
+ }
+
+ public PigletParser(java.io.Reader stream) {
+ if (jj_initialized_once) {
+ System.out.println("ERROR: Second call to constructor of static parser. You must");
+ System.out.println(" either use ReInit() or set the JavaCC option STATIC to false");
+ System.out.println(" during parser generation.");
+ throw new Error();
+ }
+ jj_initialized_once = true;
+ jj_input_stream = new JavaCharStream(stream, 1, 1);
+ token_source = new PigletParserTokenManager(jj_input_stream);
+ token = new Token();
+ jj_ntk = -1;
+ jj_gen = 0;
+ for (int i = 0; i < 7; i++) jj_la1[i] = -1;
+ }
+
+ static public void ReInit(java.io.Reader stream) {
+ jj_input_stream.ReInit(stream, 1, 1);
+ token_source.ReInit(jj_input_stream);
+ token = new Token();
+ jj_ntk = -1;
+ jj_gen = 0;
+ for (int i = 0; i < 7; i++) jj_la1[i] = -1;
+ }
+
+ public PigletParser(PigletParserTokenManager tm) {
+ if (jj_initialized_once) {
+ System.out.println("ERROR: Second call to constructor of static parser. You must");
+ System.out.println(" either use ReInit() or set the JavaCC option STATIC to false");
+ System.out.println(" during parser generation.");
+ throw new Error();
+ }
+ jj_initialized_once = true;
+ token_source = tm;
+ token = new Token();
+ jj_ntk = -1;
+ jj_gen = 0;
+ for (int i = 0; i < 7; i++) jj_la1[i] = -1;
+ }
+
+ public void ReInit(PigletParserTokenManager tm) {
+ token_source = tm;
+ token = new Token();
+ jj_ntk = -1;
+ jj_gen = 0;
+ for (int i = 0; i < 7; i++) jj_la1[i] = -1;
+ }
+
+ static final private Token jj_consume_token(int kind) throws ParseException {
+ Token oldToken;
+ if ((oldToken = token).next != null) token = token.next;
+ else token = token.next = token_source.getNextToken();
+ jj_ntk = -1;
+ if (token.kind == kind) {
+ jj_gen++;
+ return token;
+ }
+ token = oldToken;
+ jj_kind = kind;
+ throw generateParseException();
+ }
+
+ static final public Token getNextToken() {
+ if (token.next != null) token = token.next;
+ else token = token.next = token_source.getNextToken();
+ jj_ntk = -1;
+ jj_gen++;
+ return token;
+ }
+
+ static final public Token getToken(int index) {
+ Token t = token;
+ for (int i = 0; i < index; i++) {
+ if (t.next != null) t = t.next;
+ else t = t.next = token_source.getNextToken();
+ }
+ return t;
+ }
+
+ static final private int jj_ntk() {
+ if ((jj_nt=token.next) == null)
+ return (jj_ntk = (token.next=token_source.getNextToken()).kind);
+ else
+ return (jj_ntk = jj_nt.kind);
+ }
+
+ static private java.util.Vector jj_expentries = new java.util.Vector();
+ static private int[] jj_expentry;
+ static private int jj_kind = -1;
+
+ static public ParseException generateParseException() {
+ jj_expentries.removeAllElements();
+ boolean[] la1tokens = new boolean[50];
+ for (int i = 0; i < 50; i++) {
+ la1tokens[i] = false;
+ }
+ if (jj_kind >= 0) {
+ la1tokens[jj_kind] = true;
+ jj_kind = -1;
+ }
+ for (int i = 0; i < 7; i++) {
+ if (jj_la1[i] == jj_gen) {
+ for (int j = 0; j < 32; j++) {
+ if ((jj_la1_0[i] & (1<<j)) != 0) {
+ la1tokens[j] = true;
+ }
+ if ((jj_la1_1[i] & (1<<j)) != 0) {
+ la1tokens[32+j] = true;
+ }
+ }
+ }
+ }
+ for (int i = 0; i < 50; i++) {
+ if (la1tokens[i]) {
+ jj_expentry = new int[1];
+ jj_expentry[0] = i;
+ jj_expentries.addElement(jj_expentry);
+ }
+ }
+ int[][] exptokseq = new int[jj_expentries.size()][];
+ for (int i = 0; i < jj_expentries.size(); i++) {
+ exptokseq[i] = (int[])jj_expentries.elementAt(i);
+ }
+ return new ParseException(token, exptokseq, tokenImage);
+ }
+
+ static final public void enable_tracing() {
+ }
+
+ static final public void disable_tracing() {
+ }
+
+}
+
+class JTBToolkit {
+ static NodeToken makeNodeToken(Token t) {
+ return new NodeToken(t.image.intern(), t.kind, t.beginLine, t.beginColumn, t.endLine, t.endColumn);
+ }
+}
diff --git a/src/piglet/PigletParserConstants.java b/src/piglet/PigletParserConstants.java
new file mode 100644
index 0000000..d552fd5
--- /dev/null
+++ b/src/piglet/PigletParserConstants.java
@@ -0,0 +1,106 @@
+package piglet;
+/* Generated By:JavaCC: Do not edit this line. PigletParserConstants.java */
+public interface PigletParserConstants {
+
+ int EOF = 0;
+ int SINGLE_LINE_COMMENT = 6;
+ int FORMAL_COMMENT = 7;
+ int MULTI_LINE_COMMENT = 8;
+ int LPAREN = 9;
+ int RPAREN = 10;
+ int LBRACE = 11;
+ int RBRACE = 12;
+ int LSQPAREN = 13;
+ int RSQPAREN = 14;
+ int DOT = 15;
+ int LT = 16;
+ int LE = 17;
+ int GT = 18;
+ int GE = 19;
+ int NE = 20;
+ int EQ = 21;
+ int PLUS = 22;
+ int MINUS = 23;
+ int AND = 24;
+ int OR = 25;
+ int NOT = 26;
+ int TIMES = 27;
+ int MAIN = 28;
+ int CODE = 29;
+ int HALLOCATE = 30;
+ int END = 31;
+ int NOOP = 32;
+ int MOVE = 33;
+ int CALL = 34;
+ int ERROR = 35;
+ int PRINT = 36;
+ int BEGIN = 37;
+ int RETURN = 38;
+ int JUMP = 39;
+ int CJUMP = 40;
+ int HSTORE = 41;
+ int HLOAD = 42;
+ int MEM = 43;
+ int TEMP = 44;
+ int ARG = 45;
+ int INTEGER_LITERAL = 46;
+ int IDENTIFIER = 47;
+ int LETTER = 48;
+ int DIGIT = 49;
+
+ int DEFAULT = 0;
+
+ String[] tokenImage = {
+ "<EOF>",
+ "\" \"",
+ "\"\\t\"",
+ "\"\\n\"",
+ "\"\\r\"",
+ "\"\\f\"",
+ "<SINGLE_LINE_COMMENT>",
+ "<FORMAL_COMMENT>",
+ "<MULTI_LINE_COMMENT>",
+ "\"(\"",
+ "\")\"",
+ "\"{\"",
+ "\"}\"",
+ "\"[\"",
+ "\"]\"",
+ "\".\"",
+ "\"LT\"",
+ "\"LE\"",
+ "\"GT\"",
+ "\"GE\"",
+ "\"NE\"",
+ "\"EQ\"",
+ "\"PLUS\"",
+ "\"MINUS\"",
+ "\"AND\"",
+ "\"OR\"",
+ "\"NOT\"",
+ "\"TIMES\"",
+ "\"MAIN\"",
+ "\"CODE\"",
+ "\"HALLOCATE\"",
+ "\"END\"",
+ "\"NOOP\"",
+ "\"MOVE\"",
+ "\"CALL\"",
+ "\"ERROR\"",
+ "\"PRINT\"",
+ "\"BEGIN\"",
+ "\"RETURN\"",
+ "\"JUMP\"",
+ "\"CJUMP\"",
+ "\"HSTORE\"",
+ "\"HLOAD\"",
+ "\"MEM\"",
+ "\"TEMP\"",
+ "\"ARG\"",
+ "<INTEGER_LITERAL>",
+ "<IDENTIFIER>",
+ "<LETTER>",
+ "<DIGIT>",
+ };
+
+}
diff --git a/src/piglet/PigletParserTokenManager.java b/src/piglet/PigletParserTokenManager.java
new file mode 100644
index 0000000..34b879d
--- /dev/null
+++ b/src/piglet/PigletParserTokenManager.java
@@ -0,0 +1,925 @@
+package piglet;
+/* Generated By:JavaCC: Do not edit this line. PigletParserTokenManager.java */
+
+
+public class PigletParserTokenManager implements PigletParserConstants
+{
+ public static java.io.PrintStream debugStream = System.out;
+ public static void setDebugStream(java.io.PrintStream ds) { debugStream = ds; }
+private static final int jjStopStringLiteralDfa_0(int pos, long active0)
+{
+ switch (pos)
+ {
+ case 0:
+ if ((active0 & 0x3fffffff0000L) != 0L)
+ {
+ jjmatchedKind = 47;
+ return 4;
+ }
+ return -1;
+ case 1:
+ if ((active0 & 0x3ffffdc00000L) != 0L)
+ {
+ jjmatchedKind = 47;
+ jjmatchedPos = 1;
+ return 4;
+ }
+ if ((active0 & 0x23f0000L) != 0L)
+ return 4;
+ return -1;
+ case 2:
+ if ((active0 & 0x17ff78c00000L) != 0L)
+ {
+ jjmatchedKind = 47;
+ jjmatchedPos = 2;
+ return 4;
+ }
+ if ((active0 & 0x280085000000L) != 0L)
+ return 4;
+ return -1;
+ case 3:
+ if ((active0 & 0x77848800000L) != 0L)
+ {
+ jjmatchedKind = 47;
+ jjmatchedPos = 3;
+ return 4;
+ }
+ if ((active0 & 0x108730400000L) != 0L)
+ return 4;
+ return -1;
+ case 4:
+ if ((active0 & 0x53808800000L) != 0L)
+ return 4;
+ if ((active0 & 0x24040000000L) != 0L)
+ {
+ jjmatchedKind = 47;
+ jjmatchedPos = 4;
+ return 4;
+ }
+ return -1;
+ case 5:
+ if ((active0 & 0x24000000000L) != 0L)
+ return 4;
+ if ((active0 & 0x40000000L) != 0L)
+ {
+ jjmatchedKind = 47;
+ jjmatchedPos = 5;
+ return 4;
+ }
+ return -1;
+ case 6:
+ if ((active0 & 0x40000000L) != 0L)
+ {
+ jjmatchedKind = 47;
+ jjmatchedPos = 6;
+ return 4;
+ }
+ return -1;
+ case 7:
+ if ((active0 & 0x40000000L) != 0L)
+ {
+ jjmatchedKind = 47;
+ jjmatchedPos = 7;
+ return 4;
+ }
+ return -1;
+ default :
+ return -1;
+ }
+}
+private static final int jjStartNfa_0(int pos, long active0)
+{
+ return jjMoveNfa_0(jjStopStringLiteralDfa_0(pos, active0), pos + 1);
+}
+static private final int jjStopAtPos(int pos, int kind)
+{
+ jjmatchedKind = kind;
+ jjmatchedPos = pos;
+ return pos + 1;
+}
+static private final int jjStartNfaWithStates_0(int pos, int kind, int state)
+{
+ jjmatchedKind = kind;
+ jjmatchedPos = pos;
+ try { curChar = input_stream.readChar(); }
+ catch(java.io.IOException e) { return pos + 1; }
+ return jjMoveNfa_0(state, pos + 1);
+}
+static private final int jjMoveStringLiteralDfa0_0()
+{
+ switch(curChar)
+ {
+ case 40:
+ return jjStopAtPos(0, 9);
+ case 41:
+ return jjStopAtPos(0, 10);
+ case 46:
+ return jjStopAtPos(0, 15);
+ case 65:
+ return jjMoveStringLiteralDfa1_0(0x200001000000L);
+ case 66:
+ return jjMoveStringLiteralDfa1_0(0x2000000000L);
+ case 67:
+ return jjMoveStringLiteralDfa1_0(0x10420000000L);
+ case 69:
+ return jjMoveStringLiteralDfa1_0(0x880200000L);
+ case 71:
+ return jjMoveStringLiteralDfa1_0(0xc0000L);
+ case 72:
+ return jjMoveStringLiteralDfa1_0(0x60040000000L);
+ case 74:
+ return jjMoveStringLiteralDfa1_0(0x8000000000L);
+ case 76:
+ return jjMoveStringLiteralDfa1_0(0x30000L);
+ case 77:
+ return jjMoveStringLiteralDfa1_0(0x80210800000L);
+ case 78:
+ return jjMoveStringLiteralDfa1_0(0x104100000L);
+ case 79:
+ return jjMoveStringLiteralDfa1_0(0x2000000L);
+ case 80:
+ return jjMoveStringLiteralDfa1_0(0x1000400000L);
+ case 82:
+ return jjMoveStringLiteralDfa1_0(0x4000000000L);
+ case 84:
+ return jjMoveStringLiteralDfa1_0(0x100008000000L);
+ case 91:
+ return jjStopAtPos(0, 13);
+ case 93:
+ return jjStopAtPos(0, 14);
+ case 123:
+ return jjStopAtPos(0, 11);
+ case 125:
+ return jjStopAtPos(0, 12);
+ default :
+ return jjMoveNfa_0(0, 0);
+ }
+}
+static private final int jjMoveStringLiteralDfa1_0(long active0)
+{
+ try { curChar = input_stream.readChar(); }
+ catch(java.io.IOException e) {
+ jjStopStringLiteralDfa_0(0, active0);
+ return 1;
+ }
+ switch(curChar)
+ {
+ case 65:
+ return jjMoveStringLiteralDfa2_0(active0, 0x450000000L);
+ case 69:
+ if ((active0 & 0x20000L) != 0L)
+ return jjStartNfaWithStates_0(1, 17, 4);
+ else if ((active0 & 0x80000L) != 0L)
+ return jjStartNfaWithStates_0(1, 19, 4);
+ else if ((active0 & 0x100000L) != 0L)
+ return jjStartNfaWithStates_0(1, 20, 4);
+ return jjMoveStringLiteralDfa2_0(active0, 0x186000000000L);
+ case 73:
+ return jjMoveStringLiteralDfa2_0(active0, 0x8800000L);
+ case 74:
+ return jjMoveStringLiteralDfa2_0(active0, 0x10000000000L);
+ case 76:
+ return jjMoveStringLiteralDfa2_0(active0, 0x40000400000L);
+ case 78:
+ return jjMoveStringLiteralDfa2_0(active0, 0x81000000L);
+ case 79:
+ return jjMoveStringLiteralDfa2_0(active0, 0x324000000L);
+ case 81:
+ if ((active0 & 0x200000L) != 0L)
+ return jjStartNfaWithStates_0(1, 21, 4);
+ break;
+ case 82:
+ if ((active0 & 0x2000000L) != 0L)
+ return jjStartNfaWithStates_0(1, 25, 4);
+ return jjMoveStringLiteralDfa2_0(active0, 0x201800000000L);
+ case 83:
+ return jjMoveStringLiteralDfa2_0(active0, 0x20000000000L);
+ case 84:
+ if ((active0 & 0x10000L) != 0L)
+ return jjStartNfaWithStates_0(1, 16, 4);
+ else if ((active0 & 0x40000L) != 0L)
+ return jjStartNfaWithStates_0(1, 18, 4);
+ break;
+ case 85:
+ return jjMoveStringLiteralDfa2_0(active0, 0x8000000000L);
+ default :
+ break;
+ }
+ return jjStartNfa_0(0, active0);
+}
+static private final int jjMoveStringLiteralDfa2_0(long old0, long active0)
+{
+ if (((active0 &= old0)) == 0L)
+ return jjStartNfa_0(0, old0);
+ try { curChar = input_stream.readChar(); }
+ catch(java.io.IOException e) {
+ jjStopStringLiteralDfa_0(1, active0);
+ return 2;
+ }
+ switch(curChar)
+ {
+ case 68:
+ if ((active0 & 0x1000000L) != 0L)
+ return jjStartNfaWithStates_0(2, 24, 4);
+ else if ((active0 & 0x80000000L) != 0L)
+ return jjStartNfaWithStates_0(2, 31, 4);
+ return jjMoveStringLiteralDfa3_0(active0, 0x20000000L);
+ case 71:
+ if ((active0 & 0x200000000000L) != 0L)
+ return jjStartNfaWithStates_0(2, 45, 4);
+ return jjMoveStringLiteralDfa3_0(active0, 0x2000000000L);
+ case 73:
+ return jjMoveStringLiteralDfa3_0(active0, 0x1010000000L);
+ case 76:
+ return jjMoveStringLiteralDfa3_0(active0, 0x440000000L);
+ case 77:
+ if ((active0 & 0x80000000000L) != 0L)
+ return jjStartNfaWithStates_0(2, 43, 4);
+ return jjMoveStringLiteralDfa3_0(active0, 0x108008000000L);
+ case 78:
+ return jjMoveStringLiteralDfa3_0(active0, 0x800000L);
+ case 79:
+ return jjMoveStringLiteralDfa3_0(active0, 0x40100000000L);
+ case 82:
+ return jjMoveStringLiteralDfa3_0(active0, 0x800000000L);
+ case 84:
+ if ((active0 & 0x4000000L) != 0L)
+ return jjStartNfaWithStates_0(2, 26, 4);
+ return jjMoveStringLiteralDfa3_0(active0, 0x24000000000L);
+ case 85:
+ return jjMoveStringLiteralDfa3_0(active0, 0x10000400000L);
+ case 86:
+ return jjMoveStringLiteralDfa3_0(active0, 0x200000000L);
+ default :
+ break;
+ }
+ return jjStartNfa_0(1, active0);
+}
+static private final int jjMoveStringLiteralDfa3_0(long old0, long active0)
+{
+ if (((active0 &= old0)) == 0L)
+ return jjStartNfa_0(1, old0);
+ try { curChar = input_stream.readChar(); }
+ catch(java.io.IOException e) {
+ jjStopStringLiteralDfa_0(2, active0);
+ return 3;
+ }
+ switch(curChar)
+ {
+ case 65:
+ return jjMoveStringLiteralDfa4_0(active0, 0x40000000000L);
+ case 69:
+ if ((active0 & 0x20000000L) != 0L)
+ return jjStartNfaWithStates_0(3, 29, 4);
+ else if ((active0 & 0x200000000L) != 0L)
+ return jjStartNfaWithStates_0(3, 33, 4);
+ return jjMoveStringLiteralDfa4_0(active0, 0x8000000L);
+ case 73:
+ return jjMoveStringLiteralDfa4_0(active0, 0x2000000000L);
+ case 76:
+ if ((active0 & 0x400000000L) != 0L)
+ return jjStartNfaWithStates_0(3, 34, 4);
+ return jjMoveStringLiteralDfa4_0(active0, 0x40000000L);
+ case 77:
+ return jjMoveStringLiteralDfa4_0(active0, 0x10000000000L);
+ case 78:
+ if ((active0 & 0x10000000L) != 0L)
+ return jjStartNfaWithStates_0(3, 28, 4);
+ return jjMoveStringLiteralDfa4_0(active0, 0x1000000000L);
+ case 79:
+ return jjMoveStringLiteralDfa4_0(active0, 0x20800000000L);
+ case 80:
+ if ((active0 & 0x100000000L) != 0L)
+ return jjStartNfaWithStates_0(3, 32, 4);
+ else if ((active0 & 0x8000000000L) != 0L)
+ return jjStartNfaWithStates_0(3, 39, 4);
+ else if ((active0 & 0x100000000000L) != 0L)
+ return jjStartNfaWithStates_0(3, 44, 4);
+ break;
+ case 83:
+ if ((active0 & 0x400000L) != 0L)
+ return jjStartNfaWithStates_0(3, 22, 4);
+ break;
+ case 85:
+ return jjMoveStringLiteralDfa4_0(active0, 0x4000800000L);
+ default :
+ break;
+ }
+ return jjStartNfa_0(2, active0);
+}
+static private final int jjMoveStringLiteralDfa4_0(long old0, long active0)
+{
+ if (((active0 &= old0)) == 0L)
+ return jjStartNfa_0(2, old0);
+ try { curChar = input_stream.readChar(); }
+ catch(java.io.IOException e) {
+ jjStopStringLiteralDfa_0(3, active0);
+ return 4;
+ }
+ switch(curChar)
+ {
+ case 68:
+ if ((active0 & 0x40000000000L) != 0L)
+ return jjStartNfaWithStates_0(4, 42, 4);
+ break;
+ case 78:
+ if ((active0 & 0x2000000000L) != 0L)
+ return jjStartNfaWithStates_0(4, 37, 4);
+ break;
+ case 79:
+ return jjMoveStringLiteralDfa5_0(active0, 0x40000000L);
+ case 80:
+ if ((active0 & 0x10000000000L) != 0L)
+ return jjStartNfaWithStates_0(4, 40, 4);
+ break;
+ case 82:
+ if ((active0 & 0x800000000L) != 0L)
+ return jjStartNfaWithStates_0(4, 35, 4);
+ return jjMoveStringLiteralDfa5_0(active0, 0x24000000000L);
+ case 83:
+ if ((active0 & 0x800000L) != 0L)
+ return jjStartNfaWithStates_0(4, 23, 4);
+ else if ((active0 & 0x8000000L) != 0L)
+ return jjStartNfaWithStates_0(4, 27, 4);
+ break;
+ case 84:
+ if ((active0 & 0x1000000000L) != 0L)
+ return jjStartNfaWithStates_0(4, 36, 4);
+ break;
+ default :
+ break;
+ }
+ return jjStartNfa_0(3, active0);
+}
+static private final int jjMoveStringLiteralDfa5_0(long old0, long active0)
+{
+ if (((active0 &= old0)) == 0L)
+ return jjStartNfa_0(3, old0);
+ try { curChar = input_stream.readChar(); }
+ catch(java.io.IOException e) {
+ jjStopStringLiteralDfa_0(4, active0);
+ return 5;
+ }
+ switch(curChar)
+ {
+ case 67:
+ return jjMoveStringLiteralDfa6_0(active0, 0x40000000L);
+ case 69:
+ if ((active0 & 0x20000000000L) != 0L)
+ return jjStartNfaWithStates_0(5, 41, 4);
+ break;
+ case 78:
+ if ((active0 & 0x4000000000L) != 0L)
+ return jjStartNfaWithStates_0(5, 38, 4);
+ break;
+ default :
+ break;
+ }
+ return jjStartNfa_0(4, active0);
+}
+static private final int jjMoveStringLiteralDfa6_0(long old0, long active0)
+{
+ if (((active0 &= old0)) == 0L)
+ return jjStartNfa_0(4, old0);
+ try { curChar = input_stream.readChar(); }
+ catch(java.io.IOException e) {
+ jjStopStringLiteralDfa_0(5, active0);
+ return 6;
+ }
+ switch(curChar)
+ {
+ case 65:
+ return jjMoveStringLiteralDfa7_0(active0, 0x40000000L);
+ default :
+ break;
+ }
+ return jjStartNfa_0(5, active0);
+}
+static private final int jjMoveStringLiteralDfa7_0(long old0, long active0)
+{
+ if (((active0 &= old0)) == 0L)
+ return jjStartNfa_0(5, old0);
+ try { curChar = input_stream.readChar(); }
+ catch(java.io.IOException e) {
+ jjStopStringLiteralDfa_0(6, active0);
+ return 7;
+ }
+ switch(curChar)
+ {
+ case 84:
+ return jjMoveStringLiteralDfa8_0(active0, 0x40000000L);
+ default :
+ break;
+ }
+ return jjStartNfa_0(6, active0);
+}
+static private final int jjMoveStringLiteralDfa8_0(long old0, long active0)
+{
+ if (((active0 &= old0)) == 0L)
+ return jjStartNfa_0(6, old0);
+ try { curChar = input_stream.readChar(); }
+ catch(java.io.IOException e) {
+ jjStopStringLiteralDfa_0(7, active0);
+ return 8;
+ }
+ switch(curChar)
+ {
+ case 69:
+ if ((active0 & 0x40000000L) != 0L)
+ return jjStartNfaWithStates_0(8, 30, 4);
+ break;
+ default :
+ break;
+ }
+ return jjStartNfa_0(7, active0);
+}
+static private final void jjCheckNAdd(int state)
+{
+ if (jjrounds[state] != jjround)
+ {
+ jjstateSet[jjnewStateCnt++] = state;
+ jjrounds[state] = jjround;
+ }
+}
+static private final void jjAddStates(int start, int end)
+{
+ do {
+ jjstateSet[jjnewStateCnt++] = jjnextStates[start];
+ } while (start++ != end);
+}
+static private final void jjCheckNAddTwoStates(int state1, int state2)
+{
+ jjCheckNAdd(state1);
+ jjCheckNAdd(state2);
+}
+static private final void jjCheckNAddStates(int start, int end)
+{
+ do {
+ jjCheckNAdd(jjnextStates[start]);
+ } while (start++ != end);
+}
+static private final void jjCheckNAddStates(int start)
+{
+ jjCheckNAdd(jjnextStates[start]);
+ jjCheckNAdd(jjnextStates[start + 1]);
+}
+static final long[] jjbitVec0 = {
+ 0x1ff00000fffffffeL, 0xffffffffffffc000L, 0xffffffffL, 0x600000000000000L
+};
+static final long[] jjbitVec2 = {
+ 0x0L, 0x0L, 0x0L, 0xff7fffffff7fffffL
+};
+static final long[] jjbitVec3 = {
+ 0x0L, 0xffffffffffffffffL, 0xffffffffffffffffL, 0xffffffffffffffffL
+};
+static final long[] jjbitVec4 = {
+ 0xffffffffffffffffL, 0xffffffffffffffffL, 0xffffL, 0x0L
+};
+static final long[] jjbitVec5 = {
+ 0xffffffffffffffffL, 0xffffffffffffffffL, 0x0L, 0x0L
+};
+static final long[] jjbitVec6 = {
+ 0x3fffffffffffL, 0x0L, 0x0L, 0x0L
+};
+static final long[] jjbitVec7 = {
+ 0xfffffffffffffffeL, 0xffffffffffffffffL, 0xffffffffffffffffL, 0xffffffffffffffffL
+};
+static final long[] jjbitVec8 = {
+ 0x0L, 0x0L, 0xffffffffffffffffL, 0xffffffffffffffffL
+};
+static private final int jjMoveNfa_0(int startState, int curPos)
+{
+ int[] nextStates;
+ int startsAt = 0;
+ jjnewStateCnt = 24;
+ int i = 1;
+ jjstateSet[0] = startState;
+ int j, kind = 0x7fffffff;
+ for (;;)
+ {
+ if (++jjround == 0x7fffffff)
+ ReInitRounds();
+ if (curChar < 64)
+ {
+ long l = 1L << curChar;
+ MatchLoop: do
+ {
+ switch(jjstateSet[--i])
+ {
+ case 0:
+ if ((0x3fe000000000000L & l) != 0L)
+ {
+ if (kind > 46)
+ kind = 46;
+ jjCheckNAdd(1);
+ }
+ else if (curChar == 47)
+ jjAddStates(0, 2);
+ else if (curChar == 36)
+ {
+ if (kind > 47)
+ kind = 47;
+ jjCheckNAdd(4);
+ }
+ else if (curChar == 48)
+ {
+ if (kind > 46)
+ kind = 46;
+ }
+ break;
+ case 1:
+ if ((0x3ff000000000000L & l) == 0L)
+ break;
+ if (kind > 46)
+ kind = 46;
+ jjCheckNAdd(1);
+ break;
+ case 2:
+ if (curChar == 48 && kind > 46)
+ kind = 46;
+ break;
+ case 3:
+ if (curChar != 36)
+ break;
+ if (kind > 47)
+ kind = 47;
+ jjCheckNAdd(4);
+ break;
+ case 4:
+ if ((0x3ff001000000000L & l) == 0L)
+ break;
+ if (kind > 47)
+ kind = 47;
+ jjCheckNAdd(4);
+ break;
+ case 5:
+ if (curChar == 47)
+ jjAddStates(0, 2);
+ break;
+ case 6:
+ if (curChar == 47)
+ jjCheckNAddStates(3, 5);
+ break;
+ case 7:
+ if ((0xffffffffffffdbffL & l) != 0L)
+ jjCheckNAddStates(3, 5);
+ break;
+ case 8:
+ if ((0x2400L & l) != 0L && kind > 6)
+ kind = 6;
+ break;
+ case 9:
+ if (curChar == 10 && kind > 6)
+ kind = 6;
+ break;
+ case 10:
+ if (curChar == 13)
+ jjstateSet[jjnewStateCnt++] = 9;
+ break;
+ case 11:
+ if (curChar == 42)
+ jjCheckNAddTwoStates(12, 13);
+ break;
+ case 12:
+ if ((0xfffffbffffffffffL & l) != 0L)
+ jjCheckNAddTwoStates(12, 13);
+ break;
+ case 13:
+ if (curChar == 42)
+ jjCheckNAddStates(6, 8);
+ break;
+ case 14:
+ if ((0xffff7bffffffffffL & l) != 0L)
+ jjCheckNAddTwoStates(15, 13);
+ break;
+ case 15:
+ if ((0xfffffbffffffffffL & l) != 0L)
+ jjCheckNAddTwoStates(15, 13);
+ break;
+ case 16:
+ if (curChar == 47 && kind > 7)
+ kind = 7;
+ break;
+ case 17:
+ if (curChar == 42)
+ jjstateSet[jjnewStateCnt++] = 11;
+ break;
+ case 18:
+ if (curChar == 42)
+ jjCheckNAddTwoStates(19, 20);
+ break;
+ case 19:
+ if ((0xfffffbffffffffffL & l) != 0L)
+ jjCheckNAddTwoStates(19, 20);
+ break;
+ case 20:
+ if (curChar == 42)
+ jjCheckNAddStates(9, 11);
+ break;
+ case 21:
+ if ((0xffff7bffffffffffL & l) != 0L)
+ jjCheckNAddTwoStates(22, 20);
+ break;
+ case 22:
+ if ((0xfffffbffffffffffL & l) != 0L)
+ jjCheckNAddTwoStates(22, 20);
+ break;
+ case 23:
+ if (curChar == 47 && kind > 8)
+ kind = 8;
+ break;
+ default : break;
+ }
+ } while(i != startsAt);
+ }
+ else if (curChar < 128)
+ {
+ long l = 1L << (curChar & 077);
+ MatchLoop: do
+ {
+ switch(jjstateSet[--i])
+ {
+ case 0:
+ case 4:
+ if ((0x7fffffe87fffffeL & l) == 0L)
+ break;
+ if (kind > 47)
+ kind = 47;
+ jjCheckNAdd(4);
+ break;
+ case 7:
+ jjAddStates(3, 5);
+ break;
+ case 12:
+ jjCheckNAddTwoStates(12, 13);
+ break;
+ case 14:
+ case 15:
+ jjCheckNAddTwoStates(15, 13);
+ break;
+ case 19:
+ jjCheckNAddTwoStates(19, 20);
+ break;
+ case 21:
+ case 22:
+ jjCheckNAddTwoStates(22, 20);
+ break;
+ default : break;
+ }
+ } while(i != startsAt);
+ }
+ else
+ {
+ int hiByte = (int)(curChar >> 8);
+ int i1 = hiByte >> 6;
+ long l1 = 1L << (hiByte & 077);
+ int i2 = (curChar & 0xff) >> 6;
+ long l2 = 1L << (curChar & 077);
+ MatchLoop: do
+ {
+ switch(jjstateSet[--i])
+ {
+ case 0:
+ case 4:
+ if (!jjCanMove_0(hiByte, i1, i2, l1, l2))
+ break;
+ if (kind > 47)
+ kind = 47;
+ jjCheckNAdd(4);
+ break;
+ case 7:
+ if (jjCanMove_1(hiByte, i1, i2, l1, l2))
+ jjAddStates(3, 5);
+ break;
+ case 12:
+ if (jjCanMove_1(hiByte, i1, i2, l1, l2))
+ jjCheckNAddTwoStates(12, 13);
+ break;
+ case 14:
+ case 15:
+ if (jjCanMove_1(hiByte, i1, i2, l1, l2))
+ jjCheckNAddTwoStates(15, 13);
+ break;
+ case 19:
+ if (jjCanMove_1(hiByte, i1, i2, l1, l2))
+ jjCheckNAddTwoStates(19, 20);
+ break;
+ case 21:
+ case 22:
+ if (jjCanMove_1(hiByte, i1, i2, l1, l2))
+ jjCheckNAddTwoStates(22, 20);
+ break;
+ default : break;
+ }
+ } while(i != startsAt);
+ }
+ if (kind != 0x7fffffff)
+ {
+ jjmatchedKind = kind;
+ jjmatchedPos = curPos;
+ kind = 0x7fffffff;
+ }
+ ++curPos;
+ if ((i = jjnewStateCnt) == (startsAt = 24 - (jjnewStateCnt = startsAt)))
+ return curPos;
+ try { curChar = input_stream.readChar(); }
+ catch(java.io.IOException e) { return curPos; }
+ }
+}
+static final int[] jjnextStates = {
+ 6, 17, 18, 7, 8, 10, 13, 14, 16, 20, 21, 23,
+};
+private static final boolean jjCanMove_0(int hiByte, int i1, int i2, long l1, long l2)
+{
+ switch(hiByte)
+ {
+ case 0:
+ return ((jjbitVec2[i2] & l2) != 0L);
+ case 48:
+ return ((jjbitVec3[i2] & l2) != 0L);
+ case 49:
+ return ((jjbitVec4[i2] & l2) != 0L);
+ case 51:
+ return ((jjbitVec5[i2] & l2) != 0L);
+ case 61:
+ return ((jjbitVec6[i2] & l2) != 0L);
+ default :
+ if ((jjbitVec0[i1] & l1) != 0L)
+ return true;
+ return false;
+ }
+}
+private static final boolean jjCanMove_1(int hiByte, int i1, int i2, long l1, long l2)
+{
+ switch(hiByte)
+ {
+ case 0:
+ return ((jjbitVec8[i2] & l2) != 0L);
+ default :
+ if ((jjbitVec7[i1] & l1) != 0L)
+ return true;
+ return false;
+ }
+}
+public static final String[] jjstrLiteralImages = {
+"", null, null, null, null, null, null, null, null, "\50", "\51", "\173",
+"\175", "\133", "\135", "\56", "\114\124", "\114\105", "\107\124", "\107\105",
+"\116\105", "\105\121", "\120\114\125\123", "\115\111\116\125\123", "\101\116\104",
+"\117\122", "\116\117\124", "\124\111\115\105\123", "\115\101\111\116",
+"\103\117\104\105", "\110\101\114\114\117\103\101\124\105", "\105\116\104", "\116\117\117\120",
+"\115\117\126\105", "\103\101\114\114", "\105\122\122\117\122", "\120\122\111\116\124",
+"\102\105\107\111\116", "\122\105\124\125\122\116", "\112\125\115\120", "\103\112\125\115\120",
+"\110\123\124\117\122\105", "\110\114\117\101\104", "\115\105\115", "\124\105\115\120", "\101\122\107",
+null, null, null, null, };
+public static final String[] lexStateNames = {
+ "DEFAULT",
+};
+static final long[] jjtoToken = {
+ 0xfffffffffe01L,
+};
+static final long[] jjtoSkip = {
+ 0x1feL,
+};
+static final long[] jjtoSpecial = {
+ 0x1c0L,
+};
+static protected JavaCharStream input_stream;
+static private final int[] jjrounds = new int[24];
+static private final int[] jjstateSet = new int[48];
+static protected char curChar;
+public PigletParserTokenManager(JavaCharStream stream){
+ if (input_stream != null)
+ throw new TokenMgrError("ERROR: Second call to constructor of static lexer. You must use ReInit() to initialize the static variables.", TokenMgrError.STATIC_LEXER_ERROR);
+ input_stream = stream;
+}
+public PigletParserTokenManager(JavaCharStream stream, int lexState){
+ this(stream);
+ SwitchTo(lexState);
+}
+static public void ReInit(JavaCharStream stream)
+{
+ jjmatchedPos = jjnewStateCnt = 0;
+ curLexState = defaultLexState;
+ input_stream = stream;
+ ReInitRounds();
+}
+static private final void ReInitRounds()
+{
+ int i;
+ jjround = 0x80000001;
+ for (i = 24; i-- > 0;)
+ jjrounds[i] = 0x80000000;
+}
+static public void ReInit(JavaCharStream stream, int lexState)
+{
+ ReInit(stream);
+ SwitchTo(lexState);
+}
+static public void SwitchTo(int lexState)
+{
+ if (lexState >= 1 || lexState < 0)
+ throw new TokenMgrError("Error: Ignoring invalid lexical state : " + lexState + ". State unchanged.", TokenMgrError.INVALID_LEXICAL_STATE);
+ else
+ curLexState = lexState;
+}
+
+static protected Token jjFillToken()
+{
+ Token t = Token.newToken(jjmatchedKind);
+ t.kind = jjmatchedKind;
+ String im = jjstrLiteralImages[jjmatchedKind];
+ t.image = (im == null) ? input_stream.GetImage() : im;
+ t.beginLine = input_stream.getBeginLine();
+ t.beginColumn = input_stream.getBeginColumn();
+ t.endLine = input_stream.getEndLine();
+ t.endColumn = input_stream.getEndColumn();
+ return t;
+}
+
+static int curLexState = 0;
+static int defaultLexState = 0;
+static int jjnewStateCnt;
+static int jjround;
+static int jjmatchedPos;
+static int jjmatchedKind;
+
+public static Token getNextToken()
+{
+ int kind;
+ Token specialToken = null;
+ Token matchedToken;
+ int curPos = 0;
+
+ EOFLoop :
+ for (;;)
+ {
+ try
+ {
+ curChar = input_stream.BeginToken();
+ }
+ catch(java.io.IOException e)
+ {
+ jjmatchedKind = 0;
+ matchedToken = jjFillToken();
+ matchedToken.specialToken = specialToken;
+ return matchedToken;
+ }
+
+ try { input_stream.backup(0);
+ while (curChar <= 32 && (0x100003600L & (1L << curChar)) != 0L)
+ curChar = input_stream.BeginToken();
+ }
+ catch (java.io.IOException e1) { continue EOFLoop; }
+ jjmatchedKind = 0x7fffffff;
+ jjmatchedPos = 0;
+ curPos = jjMoveStringLiteralDfa0_0();
+ if (jjmatchedKind != 0x7fffffff)
+ {
+ if (jjmatchedPos + 1 < curPos)
+ input_stream.backup(curPos - jjmatchedPos - 1);
+ if ((jjtoToken[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L)
+ {
+ matchedToken = jjFillToken();
+ matchedToken.specialToken = specialToken;
+ return matchedToken;
+ }
+ else
+ {
+ if ((jjtoSpecial[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L)
+ {
+ matchedToken = jjFillToken();
+ if (specialToken == null)
+ specialToken = matchedToken;
+ else
+ {
+ matchedToken.specialToken = specialToken;
+ specialToken = (specialToken.next = matchedToken);
+ }
+ }
+ continue EOFLoop;
+ }
+ }
+ int error_line = input_stream.getEndLine();
+ int error_column = input_stream.getEndColumn();
+ String error_after = null;
+ boolean EOFSeen = false;
+ try { input_stream.readChar(); input_stream.backup(1); }
+ catch (java.io.IOException e1) {
+ EOFSeen = true;
+ error_after = curPos <= 1 ? "" : input_stream.GetImage();
+ if (curChar == '\n' || curChar == '\r') {
+ error_line++;
+ error_column = 0;
+ }
+ else
+ error_column++;
+ }
+ if (!EOFSeen) {
+ input_stream.backup(1);
+ error_after = curPos <= 1 ? "" : input_stream.GetImage();
+ }
+ throw new TokenMgrError(EOFSeen, curLexState, error_line, error_column, error_after, curChar, TokenMgrError.LEXICAL_ERROR);
+ }
+}
+
+}
diff --git a/src/piglet/Token.java b/src/piglet/Token.java
new file mode 100644
index 0000000..9714846
--- /dev/null
+++ b/src/piglet/Token.java
@@ -0,0 +1,80 @@
+package piglet;
+/* Generated By:JavaCC: Do not edit this line. Token.java Version 3.0 */
+/**
+ * Describes the input token stream.
+ */
+
+public class Token {
+
+ /**
+ * An integer that describes the kind of this token. This numbering
+ * system is determined by JavaCCParser, and a table of these numbers is
+ * stored in the file ...Constants.java.
+ */
+ public int kind;
+
+ /**
+ * beginLine and beginColumn describe the position of the first character
+ * of this token; endLine and endColumn describe the position of the
+ * last character of this token.
+ */
+ public int beginLine, beginColumn, endLine, endColumn;
+
+ /**
+ * The string image of the token.
+ */
+ public String image;
+
+ /**
+ * A reference to the next regular (non-special) token from the input
+ * stream. If this is the last token from the input stream, or if the
+ * token manager has not read tokens beyond this one, this field is
+ * set to null. This is true only if this token is also a regular
+ * token. Otherwise, see below for a description of the contents of
+ * this field.
+ */
+ public Token next;
+
+ /**
+ * This field is used to access special tokens that occur prior to this
+ * token, but after the immediately preceding regular (non-special) token.
+ * If there are no such special tokens, this field is set to null.
+ * When there are more than one such special token, this field refers
+ * to the last of these special tokens, which in turn refers to the next
+ * previous special token through its specialToken field, and so on
+ * until the first special token (whose specialToken field is null).
+ * The next fields of special tokens refer to other special tokens that
+ * immediately follow it (without an intervening regular token). If there
+ * is no such token, this field is null.
+ */
+ public Token specialToken;
+
+ /**
+ * Returns the image.
+ */
+ public String toString()
+ {
+ return image;
+ }
+
+ /**
+ * Returns a new Token object, by default. However, if you want, you
+ * can create and return subclass objects based on the value of ofKind.
+ * Simply add the cases to the switch for all those special cases.
+ * For example, if you have a subclass of Token called IDToken that
+ * you want to create if ofKind is ID, simlpy add something like :
+ *
+ * case MyParserConstants.ID : return new IDToken();
+ *
+ * to the following switch statement. Then you can cast matchedToken
+ * variable to the appropriate type and use it in your lexical actions.
+ */
+ public static final Token newToken(int ofKind)
+ {
+ switch(ofKind)
+ {
+ default : return new Token();
+ }
+ }
+
+}
diff --git a/src/piglet/TokenMgrError.java b/src/piglet/TokenMgrError.java
new file mode 100644
index 0000000..daa3242
--- /dev/null
+++ b/src/piglet/TokenMgrError.java
@@ -0,0 +1,132 @@
+package piglet;
+/* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 3.0 */
+public class TokenMgrError extends Error
+{
+ /*
+ * Ordinals for various reasons why an Error of this type can be thrown.
+ */
+
+ /**
+ * Lexical error occured.
+ */
+ static final int LEXICAL_ERROR = 0;
+
+ /**
+ * An attempt wass made to create a second instance of a static token manager.
+ */
+ static final int STATIC_LEXER_ERROR = 1;
+
+ /**
+ * Tried to change to an invalid lexical state.
+ */
+ static final int INVALID_LEXICAL_STATE = 2;
+
+ /**
+ * Detected (and bailed out of) an infinite loop in the token manager.
+ */
+ static final int LOOP_DETECTED = 3;
+
+ /**
+ * Indicates the reason why the exception is thrown. It will have
+ * one of the above 4 values.
+ */
+ int errorCode;
+
+ /**
+ * Replaces unprintable characters by their espaced (or unicode escaped)
+ * equivalents in the given string
+ */
+ protected static final String addEscapes(String str) {
+ StringBuffer retval = new StringBuffer();
+ char ch;
+ for (int i = 0; i < str.length(); i++) {
+ switch (str.charAt(i))
+ {
+ case 0 :
+ continue;
+ case '\b':
+ retval.append("\\b");
+ continue;
+ case '\t':
+ retval.append("\\t");
+ continue;
+ case '\n':
+ retval.append("\\n");
+ continue;
+ case '\f':
+ retval.append("\\f");
+ continue;
+ case '\r':
+ retval.append("\\r");
+ continue;
+ case '\"':
+ retval.append("\\\"");
+ continue;
+ case '\'':
+ retval.append("\\\'");
+ continue;
+ case '\\':
+ retval.append("\\\\");
+ continue;
+ default:
+ if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) {
+ String s = "0000" + Integer.toString(ch, 16);
+ retval.append("\\u" + s.substring(s.length() - 4, s.length()));
+ } else {
+ retval.append(ch);
+ }
+ continue;
+ }
+ }
+ return retval.toString();
+ }
+
+ /**
+ * Returns a detailed message for the Error when it is thrown by the
+ * token manager to indicate a lexical error.
+ * Parameters :
+ * EOFSeen : indicates if EOF caused the lexicl error
+ * curLexState : lexical state in which this error occured
+ * errorLine : line number when the error occured
+ * errorColumn : column number when the error occured
+ * errorAfter : prefix that was seen before this error occured
+ * curchar : the offending character
+ * Note: You can customize the lexical error message by modifying this method.
+ */
+ protected static String LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar) {
+ return("Lexical error at line " +
+ errorLine + ", column " +
+ errorColumn + ". Encountered: " +
+ (EOFSeen ? "<EOF> " : ("\"" + addEscapes(String.valueOf(curChar)) + "\"") + " (" + (int)curChar + "), ") +
+ "after : \"" + addEscapes(errorAfter) + "\"");
+ }
+
+ /**
+ * You can also modify the body of this method to customize your error messages.
+ * For example, cases like LOOP_DETECTED and INVALID_LEXICAL_STATE are not
+ * of end-users concern, so you can return something like :
+ *
+ * "Internal Error : Please file a bug report .... "
+ *
+ * from this method for such cases in the release version of your parser.
+ */
+ public String getMessage() {
+ return super.getMessage();
+ }
+
+ /*
+ * Constructors of various flavors follow.
+ */
+
+ public TokenMgrError() {
+ }
+
+ public TokenMgrError(String message, int reason) {
+ super(message);
+ errorCode = reason;
+ }
+
+ public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar, int reason) {
+ this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason);
+ }
+}
diff --git a/src/piglet/piglet2spiglet/Main.java b/src/piglet/piglet2spiglet/Main.java
new file mode 100644
index 0000000..db68b6a
--- /dev/null
+++ b/src/piglet/piglet2spiglet/Main.java
@@ -0,0 +1,38 @@
+package piglet.piglet2spiglet;
+
+
+import piglet.ParseException;
+import piglet.PigletParser;
+import piglet.TokenMgrError;
+import piglet.syntaxtree.Node;
+import piglet.visitor.GJDepthFirst;
+
+
+public class Main {
+
+ public static void main(String[] args) {
+ try {
+ Node root = new PigletParser(System.in).Goal();
+ /*
+ * TODO: Implement your own Visitors and other classes.
+ *
+ */
+ GJDepthFirst v = new GJDepthFirst<Object,Object>() {
+ };
+ //Traverse the Abstract Grammar Tree
+ root.accept(v,null);
+ }
+ catch(TokenMgrError e){
+ //Handle Lexical Errors
+ e.printStackTrace();
+ }
+ catch (ParseException e){
+ //Handle Grammar Errors
+ e.printStackTrace();
+ }
+ catch(Exception e){
+ e.printStackTrace();
+ }
+
+ }
+} \ No newline at end of file
diff --git a/src/piglet/syntaxtree/BinOp.java b/src/piglet/syntaxtree/BinOp.java
new file mode 100644
index 0000000..4ef5e2c
--- /dev/null
+++ b/src/piglet/syntaxtree/BinOp.java
@@ -0,0 +1,37 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package piglet.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> Operator()
+ * f1 -> Exp()
+ * f2 -> Exp()
+ */
+public class BinOp implements Node {
+ public Operator f0;
+ public Exp f1;
+ public Exp f2;
+
+ public BinOp(Operator n0, Exp n1, Exp n2) {
+ f0 = n0;
+ f1 = n1;
+ f2 = n2;
+ }
+
+ public void accept(piglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(piglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(piglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(piglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/piglet/syntaxtree/CJumpStmt.java b/src/piglet/syntaxtree/CJumpStmt.java
new file mode 100644
index 0000000..68827ba
--- /dev/null
+++ b/src/piglet/syntaxtree/CJumpStmt.java
@@ -0,0 +1,43 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package piglet.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "CJUMP"
+ * f1 -> Exp()
+ * f2 -> Label()
+ */
+public class CJumpStmt implements Node {
+ public NodeToken f0;
+ public Exp f1;
+ public Label f2;
+
+ public CJumpStmt(NodeToken n0, Exp n1, Label n2) {
+ f0 = n0;
+ f1 = n1;
+ f2 = n2;
+ }
+
+ public CJumpStmt(Exp n0, Label n1) {
+ f0 = new NodeToken("CJUMP");
+ f1 = n0;
+ f2 = n1;
+ }
+
+ public void accept(piglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(piglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(piglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(piglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/piglet/syntaxtree/Call.java b/src/piglet/syntaxtree/Call.java
new file mode 100644
index 0000000..6592374
--- /dev/null
+++ b/src/piglet/syntaxtree/Call.java
@@ -0,0 +1,51 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package piglet.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "CALL"
+ * f1 -> Exp()
+ * f2 -> "("
+ * f3 -> ( Exp() )*
+ * f4 -> ")"
+ */
+public class Call implements Node {
+ public NodeToken f0;
+ public Exp f1;
+ public NodeToken f2;
+ public NodeListOptional f3;
+ public NodeToken f4;
+
+ public Call(NodeToken n0, Exp n1, NodeToken n2, NodeListOptional n3, NodeToken n4) {
+ f0 = n0;
+ f1 = n1;
+ f2 = n2;
+ f3 = n3;
+ f4 = n4;
+ }
+
+ public Call(Exp n0, NodeListOptional n1) {
+ f0 = new NodeToken("CALL");
+ f1 = n0;
+ f2 = new NodeToken("(");
+ f3 = n1;
+ f4 = new NodeToken(")");
+ }
+
+ public void accept(piglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(piglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(piglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(piglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/piglet/syntaxtree/ErrorStmt.java b/src/piglet/syntaxtree/ErrorStmt.java
new file mode 100644
index 0000000..7811766
--- /dev/null
+++ b/src/piglet/syntaxtree/ErrorStmt.java
@@ -0,0 +1,35 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package piglet.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "ERROR"
+ */
+public class ErrorStmt implements Node {
+ public NodeToken f0;
+
+ public ErrorStmt(NodeToken n0) {
+ f0 = n0;
+ }
+
+ public ErrorStmt() {
+ f0 = new NodeToken("ERROR");
+ }
+
+ public void accept(piglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(piglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(piglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(piglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/piglet/syntaxtree/Exp.java b/src/piglet/syntaxtree/Exp.java
new file mode 100644
index 0000000..62f1fb0
--- /dev/null
+++ b/src/piglet/syntaxtree/Exp.java
@@ -0,0 +1,37 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package piglet.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> StmtExp()
+ * | Call()
+ * | HAllocate()
+ * | BinOp()
+ * | Temp()
+ * | IntegerLiteral()
+ * | Label()
+ */
+public class Exp implements Node {
+ public NodeChoice f0;
+
+ public Exp(NodeChoice n0) {
+ f0 = n0;
+ }
+
+ public void accept(piglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(piglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(piglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(piglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/piglet/syntaxtree/Goal.java b/src/piglet/syntaxtree/Goal.java
new file mode 100644
index 0000000..43dc3be
--- /dev/null
+++ b/src/piglet/syntaxtree/Goal.java
@@ -0,0 +1,51 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package piglet.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "MAIN"
+ * f1 -> StmtList()
+ * f2 -> "END"
+ * f3 -> ( Procedure() )*
+ * f4 -> <EOF>
+ */
+public class Goal implements Node {
+ public NodeToken f0;
+ public StmtList f1;
+ public NodeToken f2;
+ public NodeListOptional f3;
+ public NodeToken f4;
+
+ public Goal(NodeToken n0, StmtList n1, NodeToken n2, NodeListOptional n3, NodeToken n4) {
+ f0 = n0;
+ f1 = n1;
+ f2 = n2;
+ f3 = n3;
+ f4 = n4;
+ }
+
+ public Goal(StmtList n0, NodeListOptional n1) {
+ f0 = new NodeToken("MAIN");
+ f1 = n0;
+ f2 = new NodeToken("END");
+ f3 = n1;
+ f4 = new NodeToken("");
+ }
+
+ public void accept(piglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(piglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(piglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(piglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/piglet/syntaxtree/HAllocate.java b/src/piglet/syntaxtree/HAllocate.java
new file mode 100644
index 0000000..495ef0e
--- /dev/null
+++ b/src/piglet/syntaxtree/HAllocate.java
@@ -0,0 +1,39 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package piglet.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "HALLOCATE"
+ * f1 -> Exp()
+ */
+public class HAllocate implements Node {
+ public NodeToken f0;
+ public Exp f1;
+
+ public HAllocate(NodeToken n0, Exp n1) {
+ f0 = n0;
+ f1 = n1;
+ }
+
+ public HAllocate(Exp n0) {
+ f0 = new NodeToken("HALLOCATE");
+ f1 = n0;
+ }
+
+ public void accept(piglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(piglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(piglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(piglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/piglet/syntaxtree/HLoadStmt.java b/src/piglet/syntaxtree/HLoadStmt.java
new file mode 100644
index 0000000..423972c
--- /dev/null
+++ b/src/piglet/syntaxtree/HLoadStmt.java
@@ -0,0 +1,47 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package piglet.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "HLOAD"
+ * f1 -> Temp()
+ * f2 -> Exp()
+ * f3 -> IntegerLiteral()
+ */
+public class HLoadStmt implements Node {
+ public NodeToken f0;
+ public Temp f1;
+ public Exp f2;
+ public IntegerLiteral f3;
+
+ public HLoadStmt(NodeToken n0, Temp n1, Exp n2, IntegerLiteral n3) {
+ f0 = n0;
+ f1 = n1;
+ f2 = n2;
+ f3 = n3;
+ }
+
+ public HLoadStmt(Temp n0, Exp n1, IntegerLiteral n2) {
+ f0 = new NodeToken("HLOAD");
+ f1 = n0;
+ f2 = n1;
+ f3 = n2;
+ }
+
+ public void accept(piglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(piglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(piglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(piglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/piglet/syntaxtree/HStoreStmt.java b/src/piglet/syntaxtree/HStoreStmt.java
new file mode 100644
index 0000000..8384618
--- /dev/null
+++ b/src/piglet/syntaxtree/HStoreStmt.java
@@ -0,0 +1,47 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package piglet.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "HSTORE"
+ * f1 -> Exp()
+ * f2 -> IntegerLiteral()
+ * f3 -> Exp()
+ */
+public class HStoreStmt implements Node {
+ public NodeToken f0;
+ public Exp f1;
+ public IntegerLiteral f2;
+ public Exp f3;
+
+ public HStoreStmt(NodeToken n0, Exp n1, IntegerLiteral n2, Exp n3) {
+ f0 = n0;
+ f1 = n1;
+ f2 = n2;
+ f3 = n3;
+ }
+
+ public HStoreStmt(Exp n0, IntegerLiteral n1, Exp n2) {
+ f0 = new NodeToken("HSTORE");
+ f1 = n0;
+ f2 = n1;
+ f3 = n2;
+ }
+
+ public void accept(piglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(piglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(piglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(piglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/piglet/syntaxtree/IntegerLiteral.java b/src/piglet/syntaxtree/IntegerLiteral.java
new file mode 100644
index 0000000..2f50375
--- /dev/null
+++ b/src/piglet/syntaxtree/IntegerLiteral.java
@@ -0,0 +1,31 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package piglet.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> <INTEGER_LITERAL>
+ */
+public class IntegerLiteral implements Node {
+ public NodeToken f0;
+
+ public IntegerLiteral(NodeToken n0) {
+ f0 = n0;
+ }
+
+ public void accept(piglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(piglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(piglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(piglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/piglet/syntaxtree/JumpStmt.java b/src/piglet/syntaxtree/JumpStmt.java
new file mode 100644
index 0000000..759ffd6
--- /dev/null
+++ b/src/piglet/syntaxtree/JumpStmt.java
@@ -0,0 +1,39 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package piglet.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "JUMP"
+ * f1 -> Label()
+ */
+public class JumpStmt implements Node {
+ public NodeToken f0;
+ public Label f1;
+
+ public JumpStmt(NodeToken n0, Label n1) {
+ f0 = n0;
+ f1 = n1;
+ }
+
+ public JumpStmt(Label n0) {
+ f0 = new NodeToken("JUMP");
+ f1 = n0;
+ }
+
+ public void accept(piglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(piglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(piglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(piglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/piglet/syntaxtree/Label.java b/src/piglet/syntaxtree/Label.java
new file mode 100644
index 0000000..4db8432
--- /dev/null
+++ b/src/piglet/syntaxtree/Label.java
@@ -0,0 +1,31 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package piglet.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> <IDENTIFIER>
+ */
+public class Label implements Node {
+ public NodeToken f0;
+
+ public Label(NodeToken n0) {
+ f0 = n0;
+ }
+
+ public void accept(piglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(piglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(piglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(piglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/piglet/syntaxtree/MoveStmt.java b/src/piglet/syntaxtree/MoveStmt.java
new file mode 100644
index 0000000..8a034c3
--- /dev/null
+++ b/src/piglet/syntaxtree/MoveStmt.java
@@ -0,0 +1,43 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package piglet.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "MOVE"
+ * f1 -> Temp()
+ * f2 -> Exp()
+ */
+public class MoveStmt implements Node {
+ public NodeToken f0;
+ public Temp f1;
+ public Exp f2;
+
+ public MoveStmt(NodeToken n0, Temp n1, Exp n2) {
+ f0 = n0;
+ f1 = n1;
+ f2 = n2;
+ }
+
+ public MoveStmt(Temp n0, Exp n1) {
+ f0 = new NodeToken("MOVE");
+ f1 = n0;
+ f2 = n1;
+ }
+
+ public void accept(piglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(piglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(piglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(piglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/piglet/syntaxtree/NoOpStmt.java b/src/piglet/syntaxtree/NoOpStmt.java
new file mode 100644
index 0000000..c5116f4
--- /dev/null
+++ b/src/piglet/syntaxtree/NoOpStmt.java
@@ -0,0 +1,35 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package piglet.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "NOOP"
+ */
+public class NoOpStmt implements Node {
+ public NodeToken f0;
+
+ public NoOpStmt(NodeToken n0) {
+ f0 = n0;
+ }
+
+ public NoOpStmt() {
+ f0 = new NodeToken("NOOP");
+ }
+
+ public void accept(piglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(piglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(piglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(piglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/piglet/syntaxtree/Node.java b/src/piglet/syntaxtree/Node.java
new file mode 100644
index 0000000..3b31a93
--- /dev/null
+++ b/src/piglet/syntaxtree/Node.java
@@ -0,0 +1,16 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package piglet.syntaxtree;
+
+/**
+ * The interface which all syntax tree classes must implement.
+ */
+public interface Node extends java.io.Serializable {
+ public void accept(piglet.visitor.Visitor v);
+ public <R,A> R accept(piglet.visitor.GJVisitor<R,A> v, A argu);
+ public <R> R accept(piglet.visitor.GJNoArguVisitor<R> v);
+ public <A> void accept(piglet.visitor.GJVoidVisitor<A> v, A argu);
+}
+
diff --git a/src/piglet/syntaxtree/NodeChoice.java b/src/piglet/syntaxtree/NodeChoice.java
new file mode 100644
index 0000000..d6daa49
--- /dev/null
+++ b/src/piglet/syntaxtree/NodeChoice.java
@@ -0,0 +1,36 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package piglet.syntaxtree;
+
+/**
+ * Represents a grammar choice, e.g. ( A | B )
+ */
+public class NodeChoice implements Node {
+ public NodeChoice(Node node) {
+ this(node, -1);
+ }
+
+ public NodeChoice(Node node, int whichChoice) {
+ choice = node;
+ which = whichChoice;
+ }
+
+ public void accept(piglet.visitor.Visitor v) {
+ choice.accept(v);
+ }
+ public <R,A> R accept(piglet.visitor.GJVisitor<R,A> v, A argu) {
+ return choice.accept(v,argu);
+ }
+ public <R> R accept(piglet.visitor.GJNoArguVisitor<R> v) {
+ return choice.accept(v);
+ }
+ public <A> void accept(piglet.visitor.GJVoidVisitor<A> v, A argu) {
+ choice.accept(v,argu);
+ }
+
+ public Node choice;
+ public int which;
+}
+
diff --git a/src/piglet/syntaxtree/NodeList.java b/src/piglet/syntaxtree/NodeList.java
new file mode 100644
index 0000000..c8b5c9d
--- /dev/null
+++ b/src/piglet/syntaxtree/NodeList.java
@@ -0,0 +1,45 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package piglet.syntaxtree;
+
+import java.util.Enumeration;
+import java.util.Vector;
+
+/**
+ * Represents a grammar list, e.g. ( A )+
+ */
+public class NodeList implements NodeListInterface {
+ public NodeList() {
+ nodes = new Vector<Node>();
+ }
+
+ public NodeList(Node firstNode) {
+ nodes = new Vector<Node>();
+ addNode(firstNode);
+ }
+
+ public void addNode(Node n) {
+ nodes.addElement(n);
+ }
+
+ public Enumeration<Node> elements() { return nodes.elements(); }
+ public Node elementAt(int i) { return nodes.elementAt(i); }
+ public int size() { return nodes.size(); }
+ public void accept(piglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(piglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(piglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(piglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+
+ public Vector<Node> nodes;
+}
+
diff --git a/src/piglet/syntaxtree/NodeListInterface.java b/src/piglet/syntaxtree/NodeListInterface.java
new file mode 100644
index 0000000..7fbd7a8
--- /dev/null
+++ b/src/piglet/syntaxtree/NodeListInterface.java
@@ -0,0 +1,22 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package piglet.syntaxtree;
+
+/**
+ * The interface which NodeList, NodeListOptional, and NodeSequence
+ * implement.
+ */
+public interface NodeListInterface extends Node {
+ public void addNode(Node n);
+ public Node elementAt(int i);
+ public java.util.Enumeration<Node> elements();
+ public int size();
+
+ public void accept(piglet.visitor.Visitor v);
+ public <R,A> R accept(piglet.visitor.GJVisitor<R,A> v, A argu);
+ public <R> R accept(piglet.visitor.GJNoArguVisitor<R> v);
+ public <A> void accept(piglet.visitor.GJVoidVisitor<A> v, A argu);
+}
+
diff --git a/src/piglet/syntaxtree/NodeListOptional.java b/src/piglet/syntaxtree/NodeListOptional.java
new file mode 100644
index 0000000..975ccea
--- /dev/null
+++ b/src/piglet/syntaxtree/NodeListOptional.java
@@ -0,0 +1,46 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package piglet.syntaxtree;
+
+import java.util.Enumeration;
+import java.util.Vector;
+
+/**
+ * Represents an optional grammar list, e.g. ( A )*
+ */
+public class NodeListOptional implements NodeListInterface {
+ public NodeListOptional() {
+ nodes = new Vector<Node>();
+ }
+
+ public NodeListOptional(Node firstNode) {
+ nodes = new Vector<Node>();
+ addNode(firstNode);
+ }
+
+ public void addNode(Node n) {
+ nodes.addElement(n);
+ }
+
+ public Enumeration<Node> elements() { return nodes.elements(); }
+ public Node elementAt(int i) { return nodes.elementAt(i); }
+ public int size() { return nodes.size(); }
+ public boolean present() { return nodes.size() != 0; }
+ public void accept(piglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(piglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(piglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(piglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+
+ public Vector<Node> nodes;
+}
+
diff --git a/src/piglet/syntaxtree/NodeOptional.java b/src/piglet/syntaxtree/NodeOptional.java
new file mode 100644
index 0000000..160ba16
--- /dev/null
+++ b/src/piglet/syntaxtree/NodeOptional.java
@@ -0,0 +1,41 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package piglet.syntaxtree;
+
+/**
+ * Represents an grammar optional node, e.g. ( A )? or [ A ]
+ */
+public class NodeOptional implements Node {
+ public NodeOptional() {
+ node = null;
+ }
+
+ public NodeOptional(Node n) {
+ addNode(n);
+ }
+
+ public void addNode(Node n) {
+ if ( node != null) // Oh oh!
+ throw new Error("Attempt to set optional node twice");
+
+ node = n;
+ }
+ public void accept(piglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(piglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(piglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(piglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+ public boolean present() { return node != null; }
+
+ public Node node;
+}
+
diff --git a/src/piglet/syntaxtree/NodeSequence.java b/src/piglet/syntaxtree/NodeSequence.java
new file mode 100644
index 0000000..b935394
--- /dev/null
+++ b/src/piglet/syntaxtree/NodeSequence.java
@@ -0,0 +1,46 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package piglet.syntaxtree;
+
+import java.util.Enumeration;
+import java.util.Vector;
+
+/**
+ * Represents a sequence of nodes nested within a choice, list,
+ * optional list, or optional, e.g. ( A B )+ or [ C D E ]
+ */
+public class NodeSequence implements NodeListInterface {
+ public NodeSequence(int n) {
+ nodes = new Vector<Node>(n);
+ }
+
+ public NodeSequence(Node firstNode) {
+ nodes = new Vector<Node>();
+ addNode(firstNode);
+ }
+
+ public void addNode(Node n) {
+ nodes.addElement(n);
+ }
+
+ public Node elementAt(int i) { return nodes.elementAt(i); }
+ public Enumeration<Node> elements() { return nodes.elements(); }
+ public int size() { return nodes.size(); }
+ public void accept(piglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(piglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(piglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(piglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+
+ public Vector<Node> nodes;
+}
+
diff --git a/src/piglet/syntaxtree/NodeToken.java b/src/piglet/syntaxtree/NodeToken.java
new file mode 100644
index 0000000..5d9c6e6
--- /dev/null
+++ b/src/piglet/syntaxtree/NodeToken.java
@@ -0,0 +1,88 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package piglet.syntaxtree;
+
+import java.util.Enumeration;
+import java.util.Vector;
+/**
+ * Represents a single token in the grammar. If the "-tk" option
+ * is used, also contains a Vector of preceding special tokens.
+ */
+public class NodeToken implements Node {
+ public NodeToken(String s) {
+ this(s, -1, -1, -1, -1, -1); }
+
+ public NodeToken(String s, int kind, int beginLine, int beginColumn, int endLine, int endColumn) {
+ tokenImage = s;
+ specialTokens = null;
+ this.kind = kind;
+ this.beginLine = beginLine;
+ this.beginColumn = beginColumn;
+ this.endLine = endLine;
+ this.endColumn = endColumn;
+ }
+
+ public NodeToken getSpecialAt(int i) {
+ if ( specialTokens == null )
+ throw new java.util.NoSuchElementException("No specials in token");
+ return specialTokens.elementAt(i);
+ }
+
+ public int numSpecials() {
+ if ( specialTokens == null ) return 0;
+ return specialTokens.size();
+ }
+
+ public void addSpecial(NodeToken s) {
+ if ( specialTokens == null ) specialTokens = new Vector<NodeToken>();
+ specialTokens.addElement(s);
+ }
+
+ public void trimSpecials() {
+ if ( specialTokens == null ) return;
+ specialTokens.trimToSize();
+ }
+
+ public String toString() { return tokenImage; }
+
+ public String withSpecials() {
+ if ( specialTokens == null )
+ return tokenImage;
+
+ StringBuffer buf = new StringBuffer();
+
+ for ( Enumeration<NodeToken> e = specialTokens.elements(); e.hasMoreElements(); )
+ buf.append(e.nextElement().toString());
+
+ buf.append(tokenImage);
+ return buf.toString();
+ }
+
+ public void accept(piglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(piglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(piglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(piglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+
+ public String tokenImage;
+
+ // Stores a list of NodeTokens
+ public Vector<NodeToken> specialTokens;
+
+ // -1 for these ints means no position info is available.
+ public int beginLine, beginColumn, endLine, endColumn;
+
+ // Equal to the JavaCC token "kind" integer.
+ // -1 if not available.
+ public int kind;
+}
+
diff --git a/src/piglet/syntaxtree/Operator.java b/src/piglet/syntaxtree/Operator.java
new file mode 100644
index 0000000..15a3a4c
--- /dev/null
+++ b/src/piglet/syntaxtree/Operator.java
@@ -0,0 +1,34 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package piglet.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "LT"
+ * | "PLUS"
+ * | "MINUS"
+ * | "TIMES"
+ */
+public class Operator implements Node {
+ public NodeChoice f0;
+
+ public Operator(NodeChoice n0) {
+ f0 = n0;
+ }
+
+ public void accept(piglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(piglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(piglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(piglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/piglet/syntaxtree/PrintStmt.java b/src/piglet/syntaxtree/PrintStmt.java
new file mode 100644
index 0000000..0a61ea0
--- /dev/null
+++ b/src/piglet/syntaxtree/PrintStmt.java
@@ -0,0 +1,39 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package piglet.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "PRINT"
+ * f1 -> Exp()
+ */
+public class PrintStmt implements Node {
+ public NodeToken f0;
+ public Exp f1;
+
+ public PrintStmt(NodeToken n0, Exp n1) {
+ f0 = n0;
+ f1 = n1;
+ }
+
+ public PrintStmt(Exp n0) {
+ f0 = new NodeToken("PRINT");
+ f1 = n0;
+ }
+
+ public void accept(piglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(piglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(piglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(piglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/piglet/syntaxtree/Procedure.java b/src/piglet/syntaxtree/Procedure.java
new file mode 100644
index 0000000..99088cd
--- /dev/null
+++ b/src/piglet/syntaxtree/Procedure.java
@@ -0,0 +1,51 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package piglet.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> Label()
+ * f1 -> "["
+ * f2 -> IntegerLiteral()
+ * f3 -> "]"
+ * f4 -> StmtExp()
+ */
+public class Procedure implements Node {
+ public Label f0;
+ public NodeToken f1;
+ public IntegerLiteral f2;
+ public NodeToken f3;
+ public StmtExp f4;
+
+ public Procedure(Label n0, NodeToken n1, IntegerLiteral n2, NodeToken n3, StmtExp n4) {
+ f0 = n0;
+ f1 = n1;
+ f2 = n2;
+ f3 = n3;
+ f4 = n4;
+ }
+
+ public Procedure(Label n0, IntegerLiteral n1, StmtExp n2) {
+ f0 = n0;
+ f1 = new NodeToken("[");
+ f2 = n1;
+ f3 = new NodeToken("]");
+ f4 = n2;
+ }
+
+ public void accept(piglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(piglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(piglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(piglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/piglet/syntaxtree/Stmt.java b/src/piglet/syntaxtree/Stmt.java
new file mode 100644
index 0000000..de54076
--- /dev/null
+++ b/src/piglet/syntaxtree/Stmt.java
@@ -0,0 +1,38 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package piglet.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> NoOpStmt()
+ * | ErrorStmt()
+ * | CJumpStmt()
+ * | JumpStmt()
+ * | HStoreStmt()
+ * | HLoadStmt()
+ * | MoveStmt()
+ * | PrintStmt()
+ */
+public class Stmt implements Node {
+ public NodeChoice f0;
+
+ public Stmt(NodeChoice n0) {
+ f0 = n0;
+ }
+
+ public void accept(piglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(piglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(piglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(piglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/piglet/syntaxtree/StmtExp.java b/src/piglet/syntaxtree/StmtExp.java
new file mode 100644
index 0000000..3bdb951
--- /dev/null
+++ b/src/piglet/syntaxtree/StmtExp.java
@@ -0,0 +1,51 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package piglet.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "BEGIN"
+ * f1 -> StmtList()
+ * f2 -> "RETURN"
+ * f3 -> Exp()
+ * f4 -> "END"
+ */
+public class StmtExp implements Node {
+ public NodeToken f0;
+ public StmtList f1;
+ public NodeToken f2;
+ public Exp f3;
+ public NodeToken f4;
+
+ public StmtExp(NodeToken n0, StmtList n1, NodeToken n2, Exp n3, NodeToken n4) {
+ f0 = n0;
+ f1 = n1;
+ f2 = n2;
+ f3 = n3;
+ f4 = n4;
+ }
+
+ public StmtExp(StmtList n0, Exp n1) {
+ f0 = new NodeToken("BEGIN");
+ f1 = n0;
+ f2 = new NodeToken("RETURN");
+ f3 = n1;
+ f4 = new NodeToken("END");
+ }
+
+ public void accept(piglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(piglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(piglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(piglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/piglet/syntaxtree/StmtList.java b/src/piglet/syntaxtree/StmtList.java
new file mode 100644
index 0000000..ef87ebd
--- /dev/null
+++ b/src/piglet/syntaxtree/StmtList.java
@@ -0,0 +1,31 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package piglet.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> ( ( Label() )? Stmt() )*
+ */
+public class StmtList implements Node {
+ public NodeListOptional f0;
+
+ public StmtList(NodeListOptional n0) {
+ f0 = n0;
+ }
+
+ public void accept(piglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(piglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(piglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(piglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/piglet/syntaxtree/Temp.java b/src/piglet/syntaxtree/Temp.java
new file mode 100644
index 0000000..38d7fba
--- /dev/null
+++ b/src/piglet/syntaxtree/Temp.java
@@ -0,0 +1,39 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package piglet.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "TEMP"
+ * f1 -> IntegerLiteral()
+ */
+public class Temp implements Node {
+ public NodeToken f0;
+ public IntegerLiteral f1;
+
+ public Temp(NodeToken n0, IntegerLiteral n1) {
+ f0 = n0;
+ f1 = n1;
+ }
+
+ public Temp(IntegerLiteral n0) {
+ f0 = new NodeToken("TEMP");
+ f1 = n0;
+ }
+
+ public void accept(piglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(piglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(piglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(piglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/piglet/visitor/DepthFirstVisitor.java b/src/piglet/visitor/DepthFirstVisitor.java
new file mode 100644
index 0000000..630facf
--- /dev/null
+++ b/src/piglet/visitor/DepthFirstVisitor.java
@@ -0,0 +1,298 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package piglet.visitor;
+import java.util.Enumeration;
+
+import piglet.syntaxtree.BinOp;
+import piglet.syntaxtree.CJumpStmt;
+import piglet.syntaxtree.Call;
+import piglet.syntaxtree.ErrorStmt;
+import piglet.syntaxtree.Exp;
+import piglet.syntaxtree.Goal;
+import piglet.syntaxtree.HAllocate;
+import piglet.syntaxtree.HLoadStmt;
+import piglet.syntaxtree.HStoreStmt;
+import piglet.syntaxtree.IntegerLiteral;
+import piglet.syntaxtree.JumpStmt;
+import piglet.syntaxtree.Label;
+import piglet.syntaxtree.MoveStmt;
+import piglet.syntaxtree.NoOpStmt;
+import piglet.syntaxtree.Node;
+import piglet.syntaxtree.NodeList;
+import piglet.syntaxtree.NodeListOptional;
+import piglet.syntaxtree.NodeOptional;
+import piglet.syntaxtree.NodeSequence;
+import piglet.syntaxtree.NodeToken;
+import piglet.syntaxtree.Operator;
+import piglet.syntaxtree.PrintStmt;
+import piglet.syntaxtree.Procedure;
+import piglet.syntaxtree.Stmt;
+import piglet.syntaxtree.StmtExp;
+import piglet.syntaxtree.StmtList;
+import piglet.syntaxtree.Temp;
+
+/**
+ * Provides default methods which visit each node in the tree in depth-first
+ * order. Your visitors may extend this class.
+ */
+public class DepthFirstVisitor implements Visitor {
+ //
+ // Auto class visitors--probably don't need to be overridden.
+ //
+ public void visit(NodeList n) {
+ for ( Enumeration<Node> e = n.elements(); e.hasMoreElements(); )
+ e.nextElement().accept(this);
+ }
+
+ public void visit(NodeListOptional n) {
+ if ( n.present() )
+ for ( Enumeration<Node> e = n.elements(); e.hasMoreElements(); )
+ e.nextElement().accept(this);
+ }
+
+ public void visit(NodeOptional n) {
+ if ( n.present() )
+ n.node.accept(this);
+ }
+
+ public void visit(NodeSequence n) {
+ for ( Enumeration<Node> e = n.elements(); e.hasMoreElements(); )
+ e.nextElement().accept(this);
+ }
+
+ public void visit(NodeToken n) { }
+
+ //
+ // User-generated visitor methods below
+ //
+
+ /**
+ * f0 -> "MAIN"
+ * f1 -> StmtList()
+ * f2 -> "END"
+ * f3 -> ( Procedure() )*
+ * f4 -> <EOF>
+ */
+ public void visit(Goal n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ n.f3.accept(this);
+ n.f4.accept(this);
+ }
+
+ /**
+ * f0 -> ( ( Label() )? Stmt() )*
+ */
+ public void visit(StmtList n) {
+ n.f0.accept(this);
+ }
+
+ /**
+ * f0 -> Label()
+ * f1 -> "["
+ * f2 -> IntegerLiteral()
+ * f3 -> "]"
+ * f4 -> StmtExp()
+ */
+ public void visit(Procedure n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ n.f3.accept(this);
+ n.f4.accept(this);
+ }
+
+ /**
+ * f0 -> NoOpStmt()
+ * | ErrorStmt()
+ * | CJumpStmt()
+ * | JumpStmt()
+ * | HStoreStmt()
+ * | HLoadStmt()
+ * | MoveStmt()
+ * | PrintStmt()
+ */
+ public void visit(Stmt n) {
+ n.f0.accept(this);
+ }
+
+ /**
+ * f0 -> "NOOP"
+ */
+ public void visit(NoOpStmt n) {
+ n.f0.accept(this);
+ }
+
+ /**
+ * f0 -> "ERROR"
+ */
+ public void visit(ErrorStmt n) {
+ n.f0.accept(this);
+ }
+
+ /**
+ * f0 -> "CJUMP"
+ * f1 -> Exp()
+ * f2 -> Label()
+ */
+ public void visit(CJumpStmt n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ }
+
+ /**
+ * f0 -> "JUMP"
+ * f1 -> Label()
+ */
+ public void visit(JumpStmt n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ }
+
+ /**
+ * f0 -> "HSTORE"
+ * f1 -> Exp()
+ * f2 -> IntegerLiteral()
+ * f3 -> Exp()
+ */
+ public void visit(HStoreStmt n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ n.f3.accept(this);
+ }
+
+ /**
+ * f0 -> "HLOAD"
+ * f1 -> Temp()
+ * f2 -> Exp()
+ * f3 -> IntegerLiteral()
+ */
+ public void visit(HLoadStmt n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ n.f3.accept(this);
+ }
+
+ /**
+ * f0 -> "MOVE"
+ * f1 -> Temp()
+ * f2 -> Exp()
+ */
+ public void visit(MoveStmt n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ }
+
+ /**
+ * f0 -> "PRINT"
+ * f1 -> Exp()
+ */
+ public void visit(PrintStmt n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ }
+
+ /**
+ * f0 -> StmtExp()
+ * | Call()
+ * | HAllocate()
+ * | BinOp()
+ * | Temp()
+ * | IntegerLiteral()
+ * | Label()
+ */
+ public void visit(Exp n) {
+ n.f0.accept(this);
+ }
+
+ /**
+ * f0 -> "BEGIN"
+ * f1 -> StmtList()
+ * f2 -> "RETURN"
+ * f3 -> Exp()
+ * f4 -> "END"
+ */
+ public void visit(StmtExp n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ n.f3.accept(this);
+ n.f4.accept(this);
+ }
+
+ /**
+ * f0 -> "CALL"
+ * f1 -> Exp()
+ * f2 -> "("
+ * f3 -> ( Exp() )*
+ * f4 -> ")"
+ */
+ public void visit(Call n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ n.f3.accept(this);
+ n.f4.accept(this);
+ }
+
+ /**
+ * f0 -> "HALLOCATE"
+ * f1 -> Exp()
+ */
+ public void visit(HAllocate n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ }
+
+ /**
+ * f0 -> Operator()
+ * f1 -> Exp()
+ * f2 -> Exp()
+ */
+ public void visit(BinOp n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ }
+
+ /**
+ * f0 -> "LT"
+ * | "PLUS"
+ * | "MINUS"
+ * | "TIMES"
+ */
+ public void visit(Operator n) {
+ n.f0.accept(this);
+ }
+
+ /**
+ * f0 -> "TEMP"
+ * f1 -> IntegerLiteral()
+ */
+ public void visit(Temp n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ }
+
+ /**
+ * f0 -> <INTEGER_LITERAL>
+ */
+ public void visit(IntegerLiteral n) {
+ n.f0.accept(this);
+ }
+
+ /**
+ * f0 -> <IDENTIFIER>
+ */
+ public void visit(Label n) {
+ n.f0.accept(this);
+ }
+
+}
diff --git a/src/piglet/visitor/GJDepthFirst.java b/src/piglet/visitor/GJDepthFirst.java
new file mode 100644
index 0000000..62e3b8a
--- /dev/null
+++ b/src/piglet/visitor/GJDepthFirst.java
@@ -0,0 +1,360 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package piglet.visitor;
+import java.util.Enumeration;
+
+import piglet.syntaxtree.BinOp;
+import piglet.syntaxtree.CJumpStmt;
+import piglet.syntaxtree.Call;
+import piglet.syntaxtree.ErrorStmt;
+import piglet.syntaxtree.Exp;
+import piglet.syntaxtree.Goal;
+import piglet.syntaxtree.HAllocate;
+import piglet.syntaxtree.HLoadStmt;
+import piglet.syntaxtree.HStoreStmt;
+import piglet.syntaxtree.IntegerLiteral;
+import piglet.syntaxtree.JumpStmt;
+import piglet.syntaxtree.Label;
+import piglet.syntaxtree.MoveStmt;
+import piglet.syntaxtree.NoOpStmt;
+import piglet.syntaxtree.Node;
+import piglet.syntaxtree.NodeList;
+import piglet.syntaxtree.NodeListOptional;
+import piglet.syntaxtree.NodeOptional;
+import piglet.syntaxtree.NodeSequence;
+import piglet.syntaxtree.NodeToken;
+import piglet.syntaxtree.Operator;
+import piglet.syntaxtree.PrintStmt;
+import piglet.syntaxtree.Procedure;
+import piglet.syntaxtree.Stmt;
+import piglet.syntaxtree.StmtExp;
+import piglet.syntaxtree.StmtList;
+import piglet.syntaxtree.Temp;
+
+/**
+ * Provides default methods which visit each node in the tree in depth-first
+ * order. Your visitors may extend this class.
+ */
+public class GJDepthFirst<R,A> implements GJVisitor<R,A> {
+ //
+ // Auto class visitors--probably don't need to be overridden.
+ //
+ public R visit(NodeList n, A argu) {
+ R _ret=null;
+ int _count=0;
+ for ( Enumeration<Node> e = n.elements(); e.hasMoreElements(); ) {
+ e.nextElement().accept(this,argu);
+ _count++;
+ }
+ return _ret;
+ }
+
+ public R visit(NodeListOptional n, A argu) {
+ if ( n.present() ) {
+ R _ret=null;
+ int _count=0;
+ for ( Enumeration<Node> e = n.elements(); e.hasMoreElements(); ) {
+ e.nextElement().accept(this,argu);
+ _count++;
+ }
+ return _ret;
+ }
+ else
+ return null;
+ }
+
+ public R visit(NodeOptional n, A argu) {
+ if ( n.present() )
+ return n.node.accept(this,argu);
+ else
+ return null;
+ }
+
+ public R visit(NodeSequence n, A argu) {
+ R _ret=null;
+ int _count=0;
+ for ( Enumeration<Node> e = n.elements(); e.hasMoreElements(); ) {
+ e.nextElement().accept(this,argu);
+ _count++;
+ }
+ return _ret;
+ }
+
+ public R visit(NodeToken n, A argu) { return null; }
+
+ //
+ // User-generated visitor methods below
+ //
+
+ /**
+ * f0 -> "MAIN"
+ * f1 -> StmtList()
+ * f2 -> "END"
+ * f3 -> ( Procedure() )*
+ * f4 -> <EOF>
+ */
+ public R visit(Goal n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ n.f3.accept(this, argu);
+ n.f4.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> ( ( Label() )? Stmt() )*
+ */
+ public R visit(StmtList n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> Label()
+ * f1 -> "["
+ * f2 -> IntegerLiteral()
+ * f3 -> "]"
+ * f4 -> StmtExp()
+ */
+ public R visit(Procedure n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ n.f3.accept(this, argu);
+ n.f4.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> NoOpStmt()
+ * | ErrorStmt()
+ * | CJumpStmt()
+ * | JumpStmt()
+ * | HStoreStmt()
+ * | HLoadStmt()
+ * | MoveStmt()
+ * | PrintStmt()
+ */
+ public R visit(Stmt n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "NOOP"
+ */
+ public R visit(NoOpStmt n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "ERROR"
+ */
+ public R visit(ErrorStmt n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "CJUMP"
+ * f1 -> Exp()
+ * f2 -> Label()
+ */
+ public R visit(CJumpStmt n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "JUMP"
+ * f1 -> Label()
+ */
+ public R visit(JumpStmt n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "HSTORE"
+ * f1 -> Exp()
+ * f2 -> IntegerLiteral()
+ * f3 -> Exp()
+ */
+ public R visit(HStoreStmt n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ n.f3.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "HLOAD"
+ * f1 -> Temp()
+ * f2 -> Exp()
+ * f3 -> IntegerLiteral()
+ */
+ public R visit(HLoadStmt n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ n.f3.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "MOVE"
+ * f1 -> Temp()
+ * f2 -> Exp()
+ */
+ public R visit(MoveStmt n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "PRINT"
+ * f1 -> Exp()
+ */
+ public R visit(PrintStmt n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> StmtExp()
+ * | Call()
+ * | HAllocate()
+ * | BinOp()
+ * | Temp()
+ * | IntegerLiteral()
+ * | Label()
+ */
+ public R visit(Exp n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "BEGIN"
+ * f1 -> StmtList()
+ * f2 -> "RETURN"
+ * f3 -> Exp()
+ * f4 -> "END"
+ */
+ public R visit(StmtExp n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ n.f3.accept(this, argu);
+ n.f4.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "CALL"
+ * f1 -> Exp()
+ * f2 -> "("
+ * f3 -> ( Exp() )*
+ * f4 -> ")"
+ */
+ public R visit(Call n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ n.f3.accept(this, argu);
+ n.f4.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "HALLOCATE"
+ * f1 -> Exp()
+ */
+ public R visit(HAllocate n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> Operator()
+ * f1 -> Exp()
+ * f2 -> Exp()
+ */
+ public R visit(BinOp n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "LT"
+ * | "PLUS"
+ * | "MINUS"
+ * | "TIMES"
+ */
+ public R visit(Operator n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "TEMP"
+ * f1 -> IntegerLiteral()
+ */
+ public R visit(Temp n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> <INTEGER_LITERAL>
+ */
+ public R visit(IntegerLiteral n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> <IDENTIFIER>
+ */
+ public R visit(Label n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ return _ret;
+ }
+
+}
diff --git a/src/piglet/visitor/GJNoArguDepthFirst.java b/src/piglet/visitor/GJNoArguDepthFirst.java
new file mode 100644
index 0000000..f4a460e
--- /dev/null
+++ b/src/piglet/visitor/GJNoArguDepthFirst.java
@@ -0,0 +1,360 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package piglet.visitor;
+import java.util.Enumeration;
+
+import piglet.syntaxtree.BinOp;
+import piglet.syntaxtree.CJumpStmt;
+import piglet.syntaxtree.Call;
+import piglet.syntaxtree.ErrorStmt;
+import piglet.syntaxtree.Exp;
+import piglet.syntaxtree.Goal;
+import piglet.syntaxtree.HAllocate;
+import piglet.syntaxtree.HLoadStmt;
+import piglet.syntaxtree.HStoreStmt;
+import piglet.syntaxtree.IntegerLiteral;
+import piglet.syntaxtree.JumpStmt;
+import piglet.syntaxtree.Label;
+import piglet.syntaxtree.MoveStmt;
+import piglet.syntaxtree.NoOpStmt;
+import piglet.syntaxtree.Node;
+import piglet.syntaxtree.NodeList;
+import piglet.syntaxtree.NodeListOptional;
+import piglet.syntaxtree.NodeOptional;
+import piglet.syntaxtree.NodeSequence;
+import piglet.syntaxtree.NodeToken;
+import piglet.syntaxtree.Operator;
+import piglet.syntaxtree.PrintStmt;
+import piglet.syntaxtree.Procedure;
+import piglet.syntaxtree.Stmt;
+import piglet.syntaxtree.StmtExp;
+import piglet.syntaxtree.StmtList;
+import piglet.syntaxtree.Temp;
+
+/**
+ * Provides default methods which visit each node in the tree in depth-first
+ * order. Your visitors may extend this class.
+ */
+public class GJNoArguDepthFirst<R> implements GJNoArguVisitor<R> {
+ //
+ // Auto class visitors--probably don't need to be overridden.
+ //
+ public R visit(NodeList n) {
+ R _ret=null;
+ int _count=0;
+ for ( Enumeration<Node> e = n.elements(); e.hasMoreElements(); ) {
+ e.nextElement().accept(this);
+ _count++;
+ }
+ return _ret;
+ }
+
+ public R visit(NodeListOptional n) {
+ if ( n.present() ) {
+ R _ret=null;
+ int _count=0;
+ for ( Enumeration<Node> e = n.elements(); e.hasMoreElements(); ) {
+ e.nextElement().accept(this);
+ _count++;
+ }
+ return _ret;
+ }
+ else
+ return null;
+ }
+
+ public R visit(NodeOptional n) {
+ if ( n.present() )
+ return n.node.accept(this);
+ else
+ return null;
+ }
+
+ public R visit(NodeSequence n) {
+ R _ret=null;
+ int _count=0;
+ for ( Enumeration<Node> e = n.elements(); e.hasMoreElements(); ) {
+ e.nextElement().accept(this);
+ _count++;
+ }
+ return _ret;
+ }
+
+ public R visit(NodeToken n) { return null; }
+
+ //
+ // User-generated visitor methods below
+ //
+
+ /**
+ * f0 -> "MAIN"
+ * f1 -> StmtList()
+ * f2 -> "END"
+ * f3 -> ( Procedure() )*
+ * f4 -> <EOF>
+ */
+ public R visit(Goal n) {
+ R _ret=null;
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ n.f3.accept(this);
+ n.f4.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> ( ( Label() )? Stmt() )*
+ */
+ public R visit(StmtList n) {
+ R _ret=null;
+ n.f0.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> Label()
+ * f1 -> "["
+ * f2 -> IntegerLiteral()
+ * f3 -> "]"
+ * f4 -> StmtExp()
+ */
+ public R visit(Procedure n) {
+ R _ret=null;
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ n.f3.accept(this);
+ n.f4.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> NoOpStmt()
+ * | ErrorStmt()
+ * | CJumpStmt()
+ * | JumpStmt()
+ * | HStoreStmt()
+ * | HLoadStmt()
+ * | MoveStmt()
+ * | PrintStmt()
+ */
+ public R visit(Stmt n) {
+ R _ret=null;
+ n.f0.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "NOOP"
+ */
+ public R visit(NoOpStmt n) {
+ R _ret=null;
+ n.f0.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "ERROR"
+ */
+ public R visit(ErrorStmt n) {
+ R _ret=null;
+ n.f0.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "CJUMP"
+ * f1 -> Exp()
+ * f2 -> Label()
+ */
+ public R visit(CJumpStmt n) {
+ R _ret=null;
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "JUMP"
+ * f1 -> Label()
+ */
+ public R visit(JumpStmt n) {
+ R _ret=null;
+ n.f0.accept(this);
+ n.f1.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "HSTORE"
+ * f1 -> Exp()
+ * f2 -> IntegerLiteral()
+ * f3 -> Exp()
+ */
+ public R visit(HStoreStmt n) {
+ R _ret=null;
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ n.f3.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "HLOAD"
+ * f1 -> Temp()
+ * f2 -> Exp()
+ * f3 -> IntegerLiteral()
+ */
+ public R visit(HLoadStmt n) {
+ R _ret=null;
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ n.f3.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "MOVE"
+ * f1 -> Temp()
+ * f2 -> Exp()
+ */
+ public R visit(MoveStmt n) {
+ R _ret=null;
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "PRINT"
+ * f1 -> Exp()
+ */
+ public R visit(PrintStmt n) {
+ R _ret=null;
+ n.f0.accept(this);
+ n.f1.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> StmtExp()
+ * | Call()
+ * | HAllocate()
+ * | BinOp()
+ * | Temp()
+ * | IntegerLiteral()
+ * | Label()
+ */
+ public R visit(Exp n) {
+ R _ret=null;
+ n.f0.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "BEGIN"
+ * f1 -> StmtList()
+ * f2 -> "RETURN"
+ * f3 -> Exp()
+ * f4 -> "END"
+ */
+ public R visit(StmtExp n) {
+ R _ret=null;
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ n.f3.accept(this);
+ n.f4.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "CALL"
+ * f1 -> Exp()
+ * f2 -> "("
+ * f3 -> ( Exp() )*
+ * f4 -> ")"
+ */
+ public R visit(Call n) {
+ R _ret=null;
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ n.f3.accept(this);
+ n.f4.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "HALLOCATE"
+ * f1 -> Exp()
+ */
+ public R visit(HAllocate n) {
+ R _ret=null;
+ n.f0.accept(this);
+ n.f1.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> Operator()
+ * f1 -> Exp()
+ * f2 -> Exp()
+ */
+ public R visit(BinOp n) {
+ R _ret=null;
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "LT"
+ * | "PLUS"
+ * | "MINUS"
+ * | "TIMES"
+ */
+ public R visit(Operator n) {
+ R _ret=null;
+ n.f0.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "TEMP"
+ * f1 -> IntegerLiteral()
+ */
+ public R visit(Temp n) {
+ R _ret=null;
+ n.f0.accept(this);
+ n.f1.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> <INTEGER_LITERAL>
+ */
+ public R visit(IntegerLiteral n) {
+ R _ret=null;
+ n.f0.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> <IDENTIFIER>
+ */
+ public R visit(Label n) {
+ R _ret=null;
+ n.f0.accept(this);
+ return _ret;
+ }
+
+}
diff --git a/src/piglet/visitor/GJNoArguVisitor.java b/src/piglet/visitor/GJNoArguVisitor.java
new file mode 100644
index 0000000..3801f67
--- /dev/null
+++ b/src/piglet/visitor/GJNoArguVisitor.java
@@ -0,0 +1,207 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package piglet.visitor;
+import piglet.syntaxtree.BinOp;
+import piglet.syntaxtree.CJumpStmt;
+import piglet.syntaxtree.Call;
+import piglet.syntaxtree.ErrorStmt;
+import piglet.syntaxtree.Exp;
+import piglet.syntaxtree.Goal;
+import piglet.syntaxtree.HAllocate;
+import piglet.syntaxtree.HLoadStmt;
+import piglet.syntaxtree.HStoreStmt;
+import piglet.syntaxtree.IntegerLiteral;
+import piglet.syntaxtree.JumpStmt;
+import piglet.syntaxtree.Label;
+import piglet.syntaxtree.MoveStmt;
+import piglet.syntaxtree.NoOpStmt;
+import piglet.syntaxtree.NodeList;
+import piglet.syntaxtree.NodeListOptional;
+import piglet.syntaxtree.NodeOptional;
+import piglet.syntaxtree.NodeSequence;
+import piglet.syntaxtree.NodeToken;
+import piglet.syntaxtree.Operator;
+import piglet.syntaxtree.PrintStmt;
+import piglet.syntaxtree.Procedure;
+import piglet.syntaxtree.Stmt;
+import piglet.syntaxtree.StmtExp;
+import piglet.syntaxtree.StmtList;
+import piglet.syntaxtree.Temp;
+
+/**
+ * All GJ visitors with no argument must implement this interface.
+ */
+
+public interface GJNoArguVisitor<R> {
+
+ //
+ // GJ Auto class visitors with no argument
+ //
+
+ public R visit(NodeList n);
+ public R visit(NodeListOptional n);
+ public R visit(NodeOptional n);
+ public R visit(NodeSequence n);
+ public R visit(NodeToken n);
+
+ //
+ // User-generated visitor methods below
+ //
+
+ /**
+ * f0 -> "MAIN"
+ * f1 -> StmtList()
+ * f2 -> "END"
+ * f3 -> ( Procedure() )*
+ * f4 -> <EOF>
+ */
+ public R visit(Goal n);
+
+ /**
+ * f0 -> ( ( Label() )? Stmt() )*
+ */
+ public R visit(StmtList n);
+
+ /**
+ * f0 -> Label()
+ * f1 -> "["
+ * f2 -> IntegerLiteral()
+ * f3 -> "]"
+ * f4 -> StmtExp()
+ */
+ public R visit(Procedure n);
+
+ /**
+ * f0 -> NoOpStmt()
+ * | ErrorStmt()
+ * | CJumpStmt()
+ * | JumpStmt()
+ * | HStoreStmt()
+ * | HLoadStmt()
+ * | MoveStmt()
+ * | PrintStmt()
+ */
+ public R visit(Stmt n);
+
+ /**
+ * f0 -> "NOOP"
+ */
+ public R visit(NoOpStmt n);
+
+ /**
+ * f0 -> "ERROR"
+ */
+ public R visit(ErrorStmt n);
+
+ /**
+ * f0 -> "CJUMP"
+ * f1 -> Exp()
+ * f2 -> Label()
+ */
+ public R visit(CJumpStmt n);
+
+ /**
+ * f0 -> "JUMP"
+ * f1 -> Label()
+ */
+ public R visit(JumpStmt n);
+
+ /**
+ * f0 -> "HSTORE"
+ * f1 -> Exp()
+ * f2 -> IntegerLiteral()
+ * f3 -> Exp()
+ */
+ public R visit(HStoreStmt n);
+
+ /**
+ * f0 -> "HLOAD"
+ * f1 -> Temp()
+ * f2 -> Exp()
+ * f3 -> IntegerLiteral()
+ */
+ public R visit(HLoadStmt n);
+
+ /**
+ * f0 -> "MOVE"
+ * f1 -> Temp()
+ * f2 -> Exp()
+ */
+ public R visit(MoveStmt n);
+
+ /**
+ * f0 -> "PRINT"
+ * f1 -> Exp()
+ */
+ public R visit(PrintStmt n);
+
+ /**
+ * f0 -> StmtExp()
+ * | Call()
+ * | HAllocate()
+ * | BinOp()
+ * | Temp()
+ * | IntegerLiteral()
+ * | Label()
+ */
+ public R visit(Exp n);
+
+ /**
+ * f0 -> "BEGIN"
+ * f1 -> StmtList()
+ * f2 -> "RETURN"
+ * f3 -> Exp()
+ * f4 -> "END"
+ */
+ public R visit(StmtExp n);
+
+ /**
+ * f0 -> "CALL"
+ * f1 -> Exp()
+ * f2 -> "("
+ * f3 -> ( Exp() )*
+ * f4 -> ")"
+ */
+ public R visit(Call n);
+
+ /**
+ * f0 -> "HALLOCATE"
+ * f1 -> Exp()
+ */
+ public R visit(HAllocate n);
+
+ /**
+ * f0 -> Operator()
+ * f1 -> Exp()
+ * f2 -> Exp()
+ */
+ public R visit(BinOp n);
+
+ /**
+ * f0 -> "LT"
+ * | "PLUS"
+ * | "MINUS"
+ * | "TIMES"
+ */
+ public R visit(Operator n);
+
+ /**
+ * f0 -> "TEMP"
+ * f1 -> IntegerLiteral()
+ */
+ public R visit(Temp n);
+
+ /**
+ * f0 -> <INTEGER_LITERAL>
+ */
+ public R visit(IntegerLiteral n);
+
+ /**
+ * f0 -> <IDENTIFIER>
+ */
+ public R visit(Label n);
+
+}
+
diff --git a/src/piglet/visitor/GJVisitor.java b/src/piglet/visitor/GJVisitor.java
new file mode 100644
index 0000000..ace5cac
--- /dev/null
+++ b/src/piglet/visitor/GJVisitor.java
@@ -0,0 +1,206 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package piglet.visitor;
+import piglet.syntaxtree.BinOp;
+import piglet.syntaxtree.CJumpStmt;
+import piglet.syntaxtree.Call;
+import piglet.syntaxtree.ErrorStmt;
+import piglet.syntaxtree.Exp;
+import piglet.syntaxtree.Goal;
+import piglet.syntaxtree.HAllocate;
+import piglet.syntaxtree.HLoadStmt;
+import piglet.syntaxtree.HStoreStmt;
+import piglet.syntaxtree.IntegerLiteral;
+import piglet.syntaxtree.JumpStmt;
+import piglet.syntaxtree.Label;
+import piglet.syntaxtree.MoveStmt;
+import piglet.syntaxtree.NoOpStmt;
+import piglet.syntaxtree.NodeList;
+import piglet.syntaxtree.NodeListOptional;
+import piglet.syntaxtree.NodeOptional;
+import piglet.syntaxtree.NodeSequence;
+import piglet.syntaxtree.NodeToken;
+import piglet.syntaxtree.Operator;
+import piglet.syntaxtree.PrintStmt;
+import piglet.syntaxtree.Procedure;
+import piglet.syntaxtree.Stmt;
+import piglet.syntaxtree.StmtExp;
+import piglet.syntaxtree.StmtList;
+import piglet.syntaxtree.Temp;
+
+/**
+ * All GJ visitors must implement this interface.
+ */
+
+public interface GJVisitor<R,A> {
+
+ //
+ // GJ Auto class visitors
+ //
+
+ public R visit(NodeList n, A argu);
+ public R visit(NodeListOptional n, A argu);
+ public R visit(NodeOptional n, A argu);
+ public R visit(NodeSequence n, A argu);
+ public R visit(NodeToken n, A argu);
+
+ //
+ // User-generated visitor methods below
+ //
+
+ /**
+ * f0 -> "MAIN"
+ * f1 -> StmtList()
+ * f2 -> "END"
+ * f3 -> ( Procedure() )*
+ * f4 -> <EOF>
+ */
+ public R visit(Goal n, A argu);
+
+ /**
+ * f0 -> ( ( Label() )? Stmt() )*
+ */
+ public R visit(StmtList n, A argu);
+
+ /**
+ * f0 -> Label()
+ * f1 -> "["
+ * f2 -> IntegerLiteral()
+ * f3 -> "]"
+ * f4 -> StmtExp()
+ */
+ public R visit(Procedure n, A argu);
+
+ /**
+ * f0 -> NoOpStmt()
+ * | ErrorStmt()
+ * | CJumpStmt()
+ * | JumpStmt()
+ * | HStoreStmt()
+ * | HLoadStmt()
+ * | MoveStmt()
+ * | PrintStmt()
+ */
+ public R visit(Stmt n, A argu);
+
+ /**
+ * f0 -> "NOOP"
+ */
+ public R visit(NoOpStmt n, A argu);
+
+ /**
+ * f0 -> "ERROR"
+ */
+ public R visit(ErrorStmt n, A argu);
+
+ /**
+ * f0 -> "CJUMP"
+ * f1 -> Exp()
+ * f2 -> Label()
+ */
+ public R visit(CJumpStmt n, A argu);
+
+ /**
+ * f0 -> "JUMP"
+ * f1 -> Label()
+ */
+ public R visit(JumpStmt n, A argu);
+
+ /**
+ * f0 -> "HSTORE"
+ * f1 -> Exp()
+ * f2 -> IntegerLiteral()
+ * f3 -> Exp()
+ */
+ public R visit(HStoreStmt n, A argu);
+
+ /**
+ * f0 -> "HLOAD"
+ * f1 -> Temp()
+ * f2 -> Exp()
+ * f3 -> IntegerLiteral()
+ */
+ public R visit(HLoadStmt n, A argu);
+
+ /**
+ * f0 -> "MOVE"
+ * f1 -> Temp()
+ * f2 -> Exp()
+ */
+ public R visit(MoveStmt n, A argu);
+
+ /**
+ * f0 -> "PRINT"
+ * f1 -> Exp()
+ */
+ public R visit(PrintStmt n, A argu);
+
+ /**
+ * f0 -> StmtExp()
+ * | Call()
+ * | HAllocate()
+ * | BinOp()
+ * | Temp()
+ * | IntegerLiteral()
+ * | Label()
+ */
+ public R visit(Exp n, A argu);
+
+ /**
+ * f0 -> "BEGIN"
+ * f1 -> StmtList()
+ * f2 -> "RETURN"
+ * f3 -> Exp()
+ * f4 -> "END"
+ */
+ public R visit(StmtExp n, A argu);
+
+ /**
+ * f0 -> "CALL"
+ * f1 -> Exp()
+ * f2 -> "("
+ * f3 -> ( Exp() )*
+ * f4 -> ")"
+ */
+ public R visit(Call n, A argu);
+
+ /**
+ * f0 -> "HALLOCATE"
+ * f1 -> Exp()
+ */
+ public R visit(HAllocate n, A argu);
+
+ /**
+ * f0 -> Operator()
+ * f1 -> Exp()
+ * f2 -> Exp()
+ */
+ public R visit(BinOp n, A argu);
+
+ /**
+ * f0 -> "LT"
+ * | "PLUS"
+ * | "MINUS"
+ * | "TIMES"
+ */
+ public R visit(Operator n, A argu);
+
+ /**
+ * f0 -> "TEMP"
+ * f1 -> IntegerLiteral()
+ */
+ public R visit(Temp n, A argu);
+
+ /**
+ * f0 -> <INTEGER_LITERAL>
+ */
+ public R visit(IntegerLiteral n, A argu);
+
+ /**
+ * f0 -> <IDENTIFIER>
+ */
+ public R visit(Label n, A argu);
+
+}
diff --git a/src/piglet/visitor/GJVoidDepthFirst.java b/src/piglet/visitor/GJVoidDepthFirst.java
new file mode 100644
index 0000000..df106e3
--- /dev/null
+++ b/src/piglet/visitor/GJVoidDepthFirst.java
@@ -0,0 +1,308 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package piglet.visitor;
+import java.util.Enumeration;
+
+import piglet.syntaxtree.BinOp;
+import piglet.syntaxtree.CJumpStmt;
+import piglet.syntaxtree.Call;
+import piglet.syntaxtree.ErrorStmt;
+import piglet.syntaxtree.Exp;
+import piglet.syntaxtree.Goal;
+import piglet.syntaxtree.HAllocate;
+import piglet.syntaxtree.HLoadStmt;
+import piglet.syntaxtree.HStoreStmt;
+import piglet.syntaxtree.IntegerLiteral;
+import piglet.syntaxtree.JumpStmt;
+import piglet.syntaxtree.Label;
+import piglet.syntaxtree.MoveStmt;
+import piglet.syntaxtree.NoOpStmt;
+import piglet.syntaxtree.Node;
+import piglet.syntaxtree.NodeList;
+import piglet.syntaxtree.NodeListOptional;
+import piglet.syntaxtree.NodeOptional;
+import piglet.syntaxtree.NodeSequence;
+import piglet.syntaxtree.NodeToken;
+import piglet.syntaxtree.Operator;
+import piglet.syntaxtree.PrintStmt;
+import piglet.syntaxtree.Procedure;
+import piglet.syntaxtree.Stmt;
+import piglet.syntaxtree.StmtExp;
+import piglet.syntaxtree.StmtList;
+import piglet.syntaxtree.Temp;
+
+/**
+ * Provides default methods which visit each node in the tree in depth-first
+ * order. Your visitors may extend this class.
+ */
+public class GJVoidDepthFirst<A> implements GJVoidVisitor<A> {
+ //
+ // Auto class visitors--probably don't need to be overridden.
+ //
+ public void visit(NodeList n, A argu) {
+ int _count=0;
+ for ( Enumeration<Node> e = n.elements(); e.hasMoreElements(); ) {
+ e.nextElement().accept(this,argu);
+ _count++;
+ }
+ }
+
+ public void visit(NodeListOptional n, A argu) {
+ if ( n.present() ) {
+ int _count=0;
+ for ( Enumeration<Node> e = n.elements(); e.hasMoreElements(); ) {
+ e.nextElement().accept(this,argu);
+ _count++;
+ }
+ }
+ }
+
+ public void visit(NodeOptional n, A argu) {
+ if ( n.present() )
+ n.node.accept(this,argu);
+ }
+
+ public void visit(NodeSequence n, A argu) {
+ int _count=0;
+ for ( Enumeration<Node> e = n.elements(); e.hasMoreElements(); ) {
+ e.nextElement().accept(this,argu);
+ _count++;
+ }
+ }
+
+ public void visit(NodeToken n, A argu) {}
+
+ //
+ // User-generated visitor methods below
+ //
+
+ /**
+ * f0 -> "MAIN"
+ * f1 -> StmtList()
+ * f2 -> "END"
+ * f3 -> ( Procedure() )*
+ * f4 -> <EOF>
+ */
+ public void visit(Goal n, A argu) {
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ n.f3.accept(this, argu);
+ n.f4.accept(this, argu);
+ }
+
+ /**
+ * f0 -> ( ( Label() )? Stmt() )*
+ */
+ public void visit(StmtList n, A argu) {
+ n.f0.accept(this, argu);
+ }
+
+ /**
+ * f0 -> Label()
+ * f1 -> "["
+ * f2 -> IntegerLiteral()
+ * f3 -> "]"
+ * f4 -> StmtExp()
+ */
+ public void visit(Procedure n, A argu) {
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ n.f3.accept(this, argu);
+ n.f4.accept(this, argu);
+ }
+
+ /**
+ * f0 -> NoOpStmt()
+ * | ErrorStmt()
+ * | CJumpStmt()
+ * | JumpStmt()
+ * | HStoreStmt()
+ * | HLoadStmt()
+ * | MoveStmt()
+ * | PrintStmt()
+ */
+ public void visit(Stmt n, A argu) {
+ n.f0.accept(this, argu);
+ }
+
+ /**
+ * f0 -> "NOOP"
+ */
+ public void visit(NoOpStmt n, A argu) {
+ n.f0.accept(this, argu);
+ }
+
+ /**
+ * f0 -> "ERROR"
+ */
+ public void visit(ErrorStmt n, A argu) {
+ n.f0.accept(this, argu);
+ }
+
+ /**
+ * f0 -> "CJUMP"
+ * f1 -> Exp()
+ * f2 -> Label()
+ */
+ public void visit(CJumpStmt n, A argu) {
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ }
+
+ /**
+ * f0 -> "JUMP"
+ * f1 -> Label()
+ */
+ public void visit(JumpStmt n, A argu) {
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ }
+
+ /**
+ * f0 -> "HSTORE"
+ * f1 -> Exp()
+ * f2 -> IntegerLiteral()
+ * f3 -> Exp()
+ */
+ public void visit(HStoreStmt n, A argu) {
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ n.f3.accept(this, argu);
+ }
+
+ /**
+ * f0 -> "HLOAD"
+ * f1 -> Temp()
+ * f2 -> Exp()
+ * f3 -> IntegerLiteral()
+ */
+ public void visit(HLoadStmt n, A argu) {
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ n.f3.accept(this, argu);
+ }
+
+ /**
+ * f0 -> "MOVE"
+ * f1 -> Temp()
+ * f2 -> Exp()
+ */
+ public void visit(MoveStmt n, A argu) {
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ }
+
+ /**
+ * f0 -> "PRINT"
+ * f1 -> Exp()
+ */
+ public void visit(PrintStmt n, A argu) {
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ }
+
+ /**
+ * f0 -> StmtExp()
+ * | Call()
+ * | HAllocate()
+ * | BinOp()
+ * | Temp()
+ * | IntegerLiteral()
+ * | Label()
+ */
+ public void visit(Exp n, A argu) {
+ n.f0.accept(this, argu);
+ }
+
+ /**
+ * f0 -> "BEGIN"
+ * f1 -> StmtList()
+ * f2 -> "RETURN"
+ * f3 -> Exp()
+ * f4 -> "END"
+ */
+ public void visit(StmtExp n, A argu) {
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ n.f3.accept(this, argu);
+ n.f4.accept(this, argu);
+ }
+
+ /**
+ * f0 -> "CALL"
+ * f1 -> Exp()
+ * f2 -> "("
+ * f3 -> ( Exp() )*
+ * f4 -> ")"
+ */
+ public void visit(Call n, A argu) {
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ n.f3.accept(this, argu);
+ n.f4.accept(this, argu);
+ }
+
+ /**
+ * f0 -> "HALLOCATE"
+ * f1 -> Exp()
+ */
+ public void visit(HAllocate n, A argu) {
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ }
+
+ /**
+ * f0 -> Operator()
+ * f1 -> Exp()
+ * f2 -> Exp()
+ */
+ public void visit(BinOp n, A argu) {
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ }
+
+ /**
+ * f0 -> "LT"
+ * | "PLUS"
+ * | "MINUS"
+ * | "TIMES"
+ */
+ public void visit(Operator n, A argu) {
+ n.f0.accept(this, argu);
+ }
+
+ /**
+ * f0 -> "TEMP"
+ * f1 -> IntegerLiteral()
+ */
+ public void visit(Temp n, A argu) {
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ }
+
+ /**
+ * f0 -> <INTEGER_LITERAL>
+ */
+ public void visit(IntegerLiteral n, A argu) {
+ n.f0.accept(this, argu);
+ }
+
+ /**
+ * f0 -> <IDENTIFIER>
+ */
+ public void visit(Label n, A argu) {
+ n.f0.accept(this, argu);
+ }
+
+}
diff --git a/src/piglet/visitor/GJVoidVisitor.java b/src/piglet/visitor/GJVoidVisitor.java
new file mode 100644
index 0000000..206778e
--- /dev/null
+++ b/src/piglet/visitor/GJVoidVisitor.java
@@ -0,0 +1,207 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package piglet.visitor;
+import piglet.syntaxtree.BinOp;
+import piglet.syntaxtree.CJumpStmt;
+import piglet.syntaxtree.Call;
+import piglet.syntaxtree.ErrorStmt;
+import piglet.syntaxtree.Exp;
+import piglet.syntaxtree.Goal;
+import piglet.syntaxtree.HAllocate;
+import piglet.syntaxtree.HLoadStmt;
+import piglet.syntaxtree.HStoreStmt;
+import piglet.syntaxtree.IntegerLiteral;
+import piglet.syntaxtree.JumpStmt;
+import piglet.syntaxtree.Label;
+import piglet.syntaxtree.MoveStmt;
+import piglet.syntaxtree.NoOpStmt;
+import piglet.syntaxtree.NodeList;
+import piglet.syntaxtree.NodeListOptional;
+import piglet.syntaxtree.NodeOptional;
+import piglet.syntaxtree.NodeSequence;
+import piglet.syntaxtree.NodeToken;
+import piglet.syntaxtree.Operator;
+import piglet.syntaxtree.PrintStmt;
+import piglet.syntaxtree.Procedure;
+import piglet.syntaxtree.Stmt;
+import piglet.syntaxtree.StmtExp;
+import piglet.syntaxtree.StmtList;
+import piglet.syntaxtree.Temp;
+
+/**
+ * All GJ void visitors must implement this interface.
+ */
+
+public interface GJVoidVisitor<A> {
+
+ //
+ // GJ void Auto class visitors
+ //
+
+ public void visit(NodeList n, A argu);
+ public void visit(NodeListOptional n, A argu);
+ public void visit(NodeOptional n, A argu);
+ public void visit(NodeSequence n, A argu);
+ public void visit(NodeToken n, A argu);
+
+ //
+ // User-generated visitor methods below
+ //
+
+ /**
+ * f0 -> "MAIN"
+ * f1 -> StmtList()
+ * f2 -> "END"
+ * f3 -> ( Procedure() )*
+ * f4 -> <EOF>
+ */
+ public void visit(Goal n, A argu);
+
+ /**
+ * f0 -> ( ( Label() )? Stmt() )*
+ */
+ public void visit(StmtList n, A argu);
+
+ /**
+ * f0 -> Label()
+ * f1 -> "["
+ * f2 -> IntegerLiteral()
+ * f3 -> "]"
+ * f4 -> StmtExp()
+ */
+ public void visit(Procedure n, A argu);
+
+ /**
+ * f0 -> NoOpStmt()
+ * | ErrorStmt()
+ * | CJumpStmt()
+ * | JumpStmt()
+ * | HStoreStmt()
+ * | HLoadStmt()
+ * | MoveStmt()
+ * | PrintStmt()
+ */
+ public void visit(Stmt n, A argu);
+
+ /**
+ * f0 -> "NOOP"
+ */
+ public void visit(NoOpStmt n, A argu);
+
+ /**
+ * f0 -> "ERROR"
+ */
+ public void visit(ErrorStmt n, A argu);
+
+ /**
+ * f0 -> "CJUMP"
+ * f1 -> Exp()
+ * f2 -> Label()
+ */
+ public void visit(CJumpStmt n, A argu);
+
+ /**
+ * f0 -> "JUMP"
+ * f1 -> Label()
+ */
+ public void visit(JumpStmt n, A argu);
+
+ /**
+ * f0 -> "HSTORE"
+ * f1 -> Exp()
+ * f2 -> IntegerLiteral()
+ * f3 -> Exp()
+ */
+ public void visit(HStoreStmt n, A argu);
+
+ /**
+ * f0 -> "HLOAD"
+ * f1 -> Temp()
+ * f2 -> Exp()
+ * f3 -> IntegerLiteral()
+ */
+ public void visit(HLoadStmt n, A argu);
+
+ /**
+ * f0 -> "MOVE"
+ * f1 -> Temp()
+ * f2 -> Exp()
+ */
+ public void visit(MoveStmt n, A argu);
+
+ /**
+ * f0 -> "PRINT"
+ * f1 -> Exp()
+ */
+ public void visit(PrintStmt n, A argu);
+
+ /**
+ * f0 -> StmtExp()
+ * | Call()
+ * | HAllocate()
+ * | BinOp()
+ * | Temp()
+ * | IntegerLiteral()
+ * | Label()
+ */
+ public void visit(Exp n, A argu);
+
+ /**
+ * f0 -> "BEGIN"
+ * f1 -> StmtList()
+ * f2 -> "RETURN"
+ * f3 -> Exp()
+ * f4 -> "END"
+ */
+ public void visit(StmtExp n, A argu);
+
+ /**
+ * f0 -> "CALL"
+ * f1 -> Exp()
+ * f2 -> "("
+ * f3 -> ( Exp() )*
+ * f4 -> ")"
+ */
+ public void visit(Call n, A argu);
+
+ /**
+ * f0 -> "HALLOCATE"
+ * f1 -> Exp()
+ */
+ public void visit(HAllocate n, A argu);
+
+ /**
+ * f0 -> Operator()
+ * f1 -> Exp()
+ * f2 -> Exp()
+ */
+ public void visit(BinOp n, A argu);
+
+ /**
+ * f0 -> "LT"
+ * | "PLUS"
+ * | "MINUS"
+ * | "TIMES"
+ */
+ public void visit(Operator n, A argu);
+
+ /**
+ * f0 -> "TEMP"
+ * f1 -> IntegerLiteral()
+ */
+ public void visit(Temp n, A argu);
+
+ /**
+ * f0 -> <INTEGER_LITERAL>
+ */
+ public void visit(IntegerLiteral n, A argu);
+
+ /**
+ * f0 -> <IDENTIFIER>
+ */
+ public void visit(Label n, A argu);
+
+}
+
diff --git a/src/piglet/visitor/Visitor.java b/src/piglet/visitor/Visitor.java
new file mode 100644
index 0000000..e7ceed5
--- /dev/null
+++ b/src/piglet/visitor/Visitor.java
@@ -0,0 +1,207 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package piglet.visitor;
+import piglet.syntaxtree.BinOp;
+import piglet.syntaxtree.CJumpStmt;
+import piglet.syntaxtree.Call;
+import piglet.syntaxtree.ErrorStmt;
+import piglet.syntaxtree.Exp;
+import piglet.syntaxtree.Goal;
+import piglet.syntaxtree.HAllocate;
+import piglet.syntaxtree.HLoadStmt;
+import piglet.syntaxtree.HStoreStmt;
+import piglet.syntaxtree.IntegerLiteral;
+import piglet.syntaxtree.JumpStmt;
+import piglet.syntaxtree.Label;
+import piglet.syntaxtree.MoveStmt;
+import piglet.syntaxtree.NoOpStmt;
+import piglet.syntaxtree.NodeList;
+import piglet.syntaxtree.NodeListOptional;
+import piglet.syntaxtree.NodeOptional;
+import piglet.syntaxtree.NodeSequence;
+import piglet.syntaxtree.NodeToken;
+import piglet.syntaxtree.Operator;
+import piglet.syntaxtree.PrintStmt;
+import piglet.syntaxtree.Procedure;
+import piglet.syntaxtree.Stmt;
+import piglet.syntaxtree.StmtExp;
+import piglet.syntaxtree.StmtList;
+import piglet.syntaxtree.Temp;
+
+/**
+ * All void visitors must implement this interface.
+ */
+
+public interface Visitor {
+
+ //
+ // void Auto class visitors
+ //
+
+ public void visit(NodeList n);
+ public void visit(NodeListOptional n);
+ public void visit(NodeOptional n);
+ public void visit(NodeSequence n);
+ public void visit(NodeToken n);
+
+ //
+ // User-generated visitor methods below
+ //
+
+ /**
+ * f0 -> "MAIN"
+ * f1 -> StmtList()
+ * f2 -> "END"
+ * f3 -> ( Procedure() )*
+ * f4 -> <EOF>
+ */
+ public void visit(Goal n);
+
+ /**
+ * f0 -> ( ( Label() )? Stmt() )*
+ */
+ public void visit(StmtList n);
+
+ /**
+ * f0 -> Label()
+ * f1 -> "["
+ * f2 -> IntegerLiteral()
+ * f3 -> "]"
+ * f4 -> StmtExp()
+ */
+ public void visit(Procedure n);
+
+ /**
+ * f0 -> NoOpStmt()
+ * | ErrorStmt()
+ * | CJumpStmt()
+ * | JumpStmt()
+ * | HStoreStmt()
+ * | HLoadStmt()
+ * | MoveStmt()
+ * | PrintStmt()
+ */
+ public void visit(Stmt n);
+
+ /**
+ * f0 -> "NOOP"
+ */
+ public void visit(NoOpStmt n);
+
+ /**
+ * f0 -> "ERROR"
+ */
+ public void visit(ErrorStmt n);
+
+ /**
+ * f0 -> "CJUMP"
+ * f1 -> Exp()
+ * f2 -> Label()
+ */
+ public void visit(CJumpStmt n);
+
+ /**
+ * f0 -> "JUMP"
+ * f1 -> Label()
+ */
+ public void visit(JumpStmt n);
+
+ /**
+ * f0 -> "HSTORE"
+ * f1 -> Exp()
+ * f2 -> IntegerLiteral()
+ * f3 -> Exp()
+ */
+ public void visit(HStoreStmt n);
+
+ /**
+ * f0 -> "HLOAD"
+ * f1 -> Temp()
+ * f2 -> Exp()
+ * f3 -> IntegerLiteral()
+ */
+ public void visit(HLoadStmt n);
+
+ /**
+ * f0 -> "MOVE"
+ * f1 -> Temp()
+ * f2 -> Exp()
+ */
+ public void visit(MoveStmt n);
+
+ /**
+ * f0 -> "PRINT"
+ * f1 -> Exp()
+ */
+ public void visit(PrintStmt n);
+
+ /**
+ * f0 -> StmtExp()
+ * | Call()
+ * | HAllocate()
+ * | BinOp()
+ * | Temp()
+ * | IntegerLiteral()
+ * | Label()
+ */
+ public void visit(Exp n);
+
+ /**
+ * f0 -> "BEGIN"
+ * f1 -> StmtList()
+ * f2 -> "RETURN"
+ * f3 -> Exp()
+ * f4 -> "END"
+ */
+ public void visit(StmtExp n);
+
+ /**
+ * f0 -> "CALL"
+ * f1 -> Exp()
+ * f2 -> "("
+ * f3 -> ( Exp() )*
+ * f4 -> ")"
+ */
+ public void visit(Call n);
+
+ /**
+ * f0 -> "HALLOCATE"
+ * f1 -> Exp()
+ */
+ public void visit(HAllocate n);
+
+ /**
+ * f0 -> Operator()
+ * f1 -> Exp()
+ * f2 -> Exp()
+ */
+ public void visit(BinOp n);
+
+ /**
+ * f0 -> "LT"
+ * | "PLUS"
+ * | "MINUS"
+ * | "TIMES"
+ */
+ public void visit(Operator n);
+
+ /**
+ * f0 -> "TEMP"
+ * f1 -> IntegerLiteral()
+ */
+ public void visit(Temp n);
+
+ /**
+ * f0 -> <INTEGER_LITERAL>
+ */
+ public void visit(IntegerLiteral n);
+
+ /**
+ * f0 -> <IDENTIFIER>
+ */
+ public void visit(Label n);
+
+}
+
diff --git a/src/spiglet/JavaCharStream.java b/src/spiglet/JavaCharStream.java
new file mode 100644
index 0000000..e176d4c
--- /dev/null
+++ b/src/spiglet/JavaCharStream.java
@@ -0,0 +1,587 @@
+package spiglet;
+/* Generated By:JavaCC: Do not edit this line. JavaCharStream.java Version 4.0 */
+/**
+ * An implementation of interface CharStream, where the stream is assumed to
+ * contain only ASCII characters (with java-like unicode escape processing).
+ */
+
+public class JavaCharStream
+{
+ public static final boolean staticFlag = true;
+ static final int hexval(char c) throws java.io.IOException {
+ switch(c)
+ {
+ case '0' :
+ return 0;
+ case '1' :
+ return 1;
+ case '2' :
+ return 2;
+ case '3' :
+ return 3;
+ case '4' :
+ return 4;
+ case '5' :
+ return 5;
+ case '6' :
+ return 6;
+ case '7' :
+ return 7;
+ case '8' :
+ return 8;
+ case '9' :
+ return 9;
+
+ case 'a' :
+ case 'A' :
+ return 10;
+ case 'b' :
+ case 'B' :
+ return 11;
+ case 'c' :
+ case 'C' :
+ return 12;
+ case 'd' :
+ case 'D' :
+ return 13;
+ case 'e' :
+ case 'E' :
+ return 14;
+ case 'f' :
+ case 'F' :
+ return 15;
+ }
+
+ throw new java.io.IOException(); // Should never come here
+ }
+
+ static public int bufpos = -1;
+ static int bufsize;
+ static int available;
+ static int tokenBegin;
+ static protected int bufline[];
+ static protected int bufcolumn[];
+
+ static protected int column = 0;
+ static protected int line = 1;
+
+ static protected boolean prevCharIsCR = false;
+ static protected boolean prevCharIsLF = false;
+
+ static protected java.io.Reader inputStream;
+
+ static protected char[] nextCharBuf;
+ static protected char[] buffer;
+ static protected int maxNextCharInd = 0;
+ static protected int nextCharInd = -1;
+ static protected int inBuf = 0;
+ static protected int tabSize = 8;
+
+ static protected void setTabSize(int i) { tabSize = i; }
+ static protected int getTabSize(int i) { return tabSize; }
+
+ static protected void ExpandBuff(boolean wrapAround)
+ {
+ char[] newbuffer = new char[bufsize + 2048];
+ int newbufline[] = new int[bufsize + 2048];
+ int newbufcolumn[] = new int[bufsize + 2048];
+
+ try
+ {
+ if (wrapAround)
+ {
+ System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin);
+ System.arraycopy(buffer, 0, newbuffer,
+ bufsize - tokenBegin, bufpos);
+ buffer = newbuffer;
+
+ System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin);
+ System.arraycopy(bufline, 0, newbufline, bufsize - tokenBegin, bufpos);
+ bufline = newbufline;
+
+ System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin);
+ System.arraycopy(bufcolumn, 0, newbufcolumn, bufsize - tokenBegin, bufpos);
+ bufcolumn = newbufcolumn;
+
+ bufpos += (bufsize - tokenBegin);
+ }
+ else
+ {
+ System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin);
+ buffer = newbuffer;
+
+ System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin);
+ bufline = newbufline;
+
+ System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin);
+ bufcolumn = newbufcolumn;
+
+ bufpos -= tokenBegin;
+ }
+ }
+ catch (Throwable t)
+ {
+ throw new Error(t.getMessage());
+ }
+
+ available = (bufsize += 2048);
+ tokenBegin = 0;
+ }
+
+ static protected void FillBuff() throws java.io.IOException
+ {
+ int i;
+ if (maxNextCharInd == 4096)
+ maxNextCharInd = nextCharInd = 0;
+
+ try {
+ if ((i = inputStream.read(nextCharBuf, maxNextCharInd,
+ 4096 - maxNextCharInd)) == -1)
+ {
+ inputStream.close();
+ throw new java.io.IOException();
+ }
+ else
+ maxNextCharInd += i;
+ return;
+ }
+ catch(java.io.IOException e) {
+ if (bufpos != 0)
+ {
+ --bufpos;
+ backup(0);
+ }
+ else
+ {
+ bufline[bufpos] = line;
+ bufcolumn[bufpos] = column;
+ }
+ throw e;
+ }
+ }
+
+ static protected char ReadByte() throws java.io.IOException
+ {
+ if (++nextCharInd >= maxNextCharInd)
+ FillBuff();
+
+ return nextCharBuf[nextCharInd];
+ }
+
+ static public char BeginToken() throws java.io.IOException
+ {
+ if (inBuf > 0)
+ {
+ --inBuf;
+
+ if (++bufpos == bufsize)
+ bufpos = 0;
+
+ tokenBegin = bufpos;
+ return buffer[bufpos];
+ }
+
+ tokenBegin = 0;
+ bufpos = -1;
+
+ return readChar();
+ }
+
+ static protected void AdjustBuffSize()
+ {
+ if (available == bufsize)
+ {
+ if (tokenBegin > 2048)
+ {
+ bufpos = 0;
+ available = tokenBegin;
+ }
+ else
+ ExpandBuff(false);
+ }
+ else if (available > tokenBegin)
+ available = bufsize;
+ else if ((tokenBegin - available) < 2048)
+ ExpandBuff(true);
+ else
+ available = tokenBegin;
+ }
+
+ static protected void UpdateLineColumn(char c)
+ {
+ column++;
+
+ if (prevCharIsLF)
+ {
+ prevCharIsLF = false;
+ line += (column = 1);
+ }
+ else if (prevCharIsCR)
+ {
+ prevCharIsCR = false;
+ if (c == '\n')
+ {
+ prevCharIsLF = true;
+ }
+ else
+ line += (column = 1);
+ }
+
+ switch (c)
+ {
+ case '\r' :
+ prevCharIsCR = true;
+ break;
+ case '\n' :
+ prevCharIsLF = true;
+ break;
+ case '\t' :
+ column--;
+ column += (tabSize - (column % tabSize));
+ break;
+ default :
+ break;
+ }
+
+ bufline[bufpos] = line;
+ bufcolumn[bufpos] = column;
+ }
+
+ static public char readChar() throws java.io.IOException
+ {
+ if (inBuf > 0)
+ {
+ --inBuf;
+
+ if (++bufpos == bufsize)
+ bufpos = 0;
+
+ return buffer[bufpos];
+ }
+
+ char c;
+
+ if (++bufpos == available)
+ AdjustBuffSize();
+
+ if ((buffer[bufpos] = c = ReadByte()) == '\\')
+ {
+ UpdateLineColumn(c);
+
+ int backSlashCnt = 1;
+
+ for (;;) // Read all the backslashes
+ {
+ if (++bufpos == available)
+ AdjustBuffSize();
+
+ try
+ {
+ if ((buffer[bufpos] = c = ReadByte()) != '\\')
+ {
+ UpdateLineColumn(c);
+ // found a non-backslash char.
+ if ((c == 'u') && ((backSlashCnt & 1) == 1))
+ {
+ if (--bufpos < 0)
+ bufpos = bufsize - 1;
+
+ break;
+ }
+
+ backup(backSlashCnt);
+ return '\\';
+ }
+ }
+ catch(java.io.IOException e)
+ {
+ if (backSlashCnt > 1)
+ backup(backSlashCnt);
+
+ return '\\';
+ }
+
+ UpdateLineColumn(c);
+ backSlashCnt++;
+ }
+
+ // Here, we have seen an odd number of backslash's followed by a 'u'
+ try
+ {
+ while ((c = ReadByte()) == 'u')
+ ++column;
+
+ buffer[bufpos] = c = (char)(hexval(c) << 12 |
+ hexval(ReadByte()) << 8 |
+ hexval(ReadByte()) << 4 |
+ hexval(ReadByte()));
+
+ column += 4;
+ }
+ catch(java.io.IOException e)
+ {
+ throw new Error("Invalid escape character at line " + line +
+ " column " + column + ".");
+ }
+
+ if (backSlashCnt == 1)
+ return c;
+ else
+ {
+ backup(backSlashCnt - 1);
+ return '\\';
+ }
+ }
+ else
+ {
+ UpdateLineColumn(c);
+ return (c);
+ }
+ }
+
+ /**
+ * @deprecated
+ * @see #getEndColumn
+ */
+
+ static public int getColumn() {
+ return bufcolumn[bufpos];
+ }
+
+ /**
+ * @deprecated
+ * @see #getEndLine
+ */
+
+ static public int getLine() {
+ return bufline[bufpos];
+ }
+
+ static public int getEndColumn() {
+ return bufcolumn[bufpos];
+ }
+
+ static public int getEndLine() {
+ return bufline[bufpos];
+ }
+
+ static public int getBeginColumn() {
+ return bufcolumn[tokenBegin];
+ }
+
+ static public int getBeginLine() {
+ return bufline[tokenBegin];
+ }
+
+ static public void backup(int amount) {
+
+ inBuf += amount;
+ if ((bufpos -= amount) < 0)
+ bufpos += bufsize;
+ }
+
+ public JavaCharStream(java.io.Reader dstream,
+ int startline, int startcolumn, int buffersize)
+ {
+ if (inputStream != null)
+ throw new Error("\n ERROR: Second call to the constructor of a static JavaCharStream. You must\n" +
+ " either use ReInit() or set the JavaCC option STATIC to false\n" +
+ " during the generation of this class.");
+ inputStream = dstream;
+ line = startline;
+ column = startcolumn - 1;
+
+ available = bufsize = buffersize;
+ buffer = new char[buffersize];
+ bufline = new int[buffersize];
+ bufcolumn = new int[buffersize];
+ nextCharBuf = new char[4096];
+ }
+
+ public JavaCharStream(java.io.Reader dstream,
+ int startline, int startcolumn)
+ {
+ this(dstream, startline, startcolumn, 4096);
+ }
+
+ public JavaCharStream(java.io.Reader dstream)
+ {
+ this(dstream, 1, 1, 4096);
+ }
+ public void ReInit(java.io.Reader dstream,
+ int startline, int startcolumn, int buffersize)
+ {
+ inputStream = dstream;
+ line = startline;
+ column = startcolumn - 1;
+
+ if (buffer == null || buffersize != buffer.length)
+ {
+ available = bufsize = buffersize;
+ buffer = new char[buffersize];
+ bufline = new int[buffersize];
+ bufcolumn = new int[buffersize];
+ nextCharBuf = new char[4096];
+ }
+ prevCharIsLF = prevCharIsCR = false;
+ tokenBegin = inBuf = maxNextCharInd = 0;
+ nextCharInd = bufpos = -1;
+ }
+
+ public void ReInit(java.io.Reader dstream,
+ int startline, int startcolumn)
+ {
+ ReInit(dstream, startline, startcolumn, 4096);
+ }
+
+ public void ReInit(java.io.Reader dstream)
+ {
+ ReInit(dstream, 1, 1, 4096);
+ }
+ public JavaCharStream(java.io.InputStream dstream, String encoding, int startline,
+ int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException
+ {
+ this(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize);
+ }
+
+ public JavaCharStream(java.io.InputStream dstream, int startline,
+ int startcolumn, int buffersize)
+ {
+ this(new java.io.InputStreamReader(dstream), startline, startcolumn, 4096);
+ }
+
+ public JavaCharStream(java.io.InputStream dstream, String encoding, int startline,
+ int startcolumn) throws java.io.UnsupportedEncodingException
+ {
+ this(dstream, encoding, startline, startcolumn, 4096);
+ }
+
+ public JavaCharStream(java.io.InputStream dstream, int startline,
+ int startcolumn)
+ {
+ this(dstream, startline, startcolumn, 4096);
+ }
+
+ public JavaCharStream(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException
+ {
+ this(dstream, encoding, 1, 1, 4096);
+ }
+
+ public JavaCharStream(java.io.InputStream dstream)
+ {
+ this(dstream, 1, 1, 4096);
+ }
+
+ public void ReInit(java.io.InputStream dstream, String encoding, int startline,
+ int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException
+ {
+ ReInit(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize);
+ }
+
+ public void ReInit(java.io.InputStream dstream, int startline,
+ int startcolumn, int buffersize)
+ {
+ ReInit(new java.io.InputStreamReader(dstream), startline, startcolumn, buffersize);
+ }
+ public void ReInit(java.io.InputStream dstream, String encoding, int startline,
+ int startcolumn) throws java.io.UnsupportedEncodingException
+ {
+ ReInit(dstream, encoding, startline, startcolumn, 4096);
+ }
+ public void ReInit(java.io.InputStream dstream, int startline,
+ int startcolumn)
+ {
+ ReInit(dstream, startline, startcolumn, 4096);
+ }
+ public void ReInit(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException
+ {
+ ReInit(dstream, encoding, 1, 1, 4096);
+ }
+
+ public void ReInit(java.io.InputStream dstream)
+ {
+ ReInit(dstream, 1, 1, 4096);
+ }
+
+ static public String GetImage()
+ {
+ if (bufpos >= tokenBegin)
+ return new String(buffer, tokenBegin, bufpos - tokenBegin + 1);
+ else
+ return new String(buffer, tokenBegin, bufsize - tokenBegin) +
+ new String(buffer, 0, bufpos + 1);
+ }
+
+ static public char[] GetSuffix(int len)
+ {
+ char[] ret = new char[len];
+
+ if ((bufpos + 1) >= len)
+ System.arraycopy(buffer, bufpos - len + 1, ret, 0, len);
+ else
+ {
+ System.arraycopy(buffer, bufsize - (len - bufpos - 1), ret, 0,
+ len - bufpos - 1);
+ System.arraycopy(buffer, 0, ret, len - bufpos - 1, bufpos + 1);
+ }
+
+ return ret;
+ }
+
+ static public void Done()
+ {
+ nextCharBuf = null;
+ buffer = null;
+ bufline = null;
+ bufcolumn = null;
+ }
+
+ /**
+ * Method to adjust line and column numbers for the start of a token.
+ */
+ static public void adjustBeginLineColumn(int newLine, int newCol)
+ {
+ int start = tokenBegin;
+ int len;
+
+ if (bufpos >= tokenBegin)
+ {
+ len = bufpos - tokenBegin + inBuf + 1;
+ }
+ else
+ {
+ len = bufsize - tokenBegin + bufpos + 1 + inBuf;
+ }
+
+ int i = 0, j = 0, k = 0;
+ int nextColDiff = 0, columnDiff = 0;
+
+ while (i < len &&
+ bufline[j = start % bufsize] == bufline[k = ++start % bufsize])
+ {
+ bufline[j] = newLine;
+ nextColDiff = columnDiff + bufcolumn[k] - bufcolumn[j];
+ bufcolumn[j] = newCol + columnDiff;
+ columnDiff = nextColDiff;
+ i++;
+ }
+
+ if (i < len)
+ {
+ bufline[j] = newLine++;
+ bufcolumn[j] = newCol + columnDiff;
+
+ while (i++ < len)
+ {
+ if (bufline[j = start % bufsize] != bufline[++start % bufsize])
+ bufline[j] = newLine++;
+ else
+ bufline[j] = newLine;
+ }
+ }
+
+ line = bufline[j];
+ column = bufcolumn[j];
+ }
+
+}
diff --git a/src/spiglet/ParseException.java b/src/spiglet/ParseException.java
new file mode 100644
index 0000000..02d1227
--- /dev/null
+++ b/src/spiglet/ParseException.java
@@ -0,0 +1,191 @@
+package spiglet;
+/* Generated By:JavaCC: Do not edit this line. ParseException.java Version 3.0 */
+/**
+ * This exception is thrown when parse errors are encountered.
+ * You can explicitly create objects of this exception type by
+ * calling the method generateParseException in the generated
+ * parser.
+ *
+ * You can modify this class to customize your error reporting
+ * mechanisms so long as you retain the public fields.
+ */
+public class ParseException extends Exception {
+
+ /**
+ * This constructor is used by the method "generateParseException"
+ * in the generated parser. Calling this constructor generates
+ * a new object of this type with the fields "currentToken",
+ * "expectedTokenSequences", and "tokenImage" set. The boolean
+ * flag "specialConstructor" is also set to true to indicate that
+ * this constructor was used to create this object.
+ * This constructor calls its super class with the empty string
+ * to force the "toString" method of parent class "Throwable" to
+ * print the error message in the form:
+ * ParseException: <result of getMessage>
+ */
+ public ParseException(Token currentTokenVal,
+ int[][] expectedTokenSequencesVal,
+ String[] tokenImageVal
+ )
+ {
+ super("");
+ specialConstructor = true;
+ currentToken = currentTokenVal;
+ expectedTokenSequences = expectedTokenSequencesVal;
+ tokenImage = tokenImageVal;
+ }
+
+ /**
+ * The following constructors are for use by you for whatever
+ * purpose you can think of. Constructing the exception in this
+ * manner makes the exception behave in the normal way - i.e., as
+ * documented in the class "Throwable". The fields "errorToken",
+ * "expectedTokenSequences", and "tokenImage" do not contain
+ * relevant information. The JavaCC generated code does not use
+ * these constructors.
+ */
+
+ public ParseException() {
+ super();
+ specialConstructor = false;
+ }
+
+ public ParseException(String message) {
+ super(message);
+ specialConstructor = false;
+ }
+
+ /**
+ * This variable determines which constructor was used to create
+ * this object and thereby affects the semantics of the
+ * "getMessage" method (see below).
+ */
+ protected boolean specialConstructor;
+
+ /**
+ * This is the last token that has been consumed successfully. If
+ * this object has been created due to a parse error, the token
+ * followng this token will (therefore) be the first error token.
+ */
+ public Token currentToken;
+
+ /**
+ * Each entry in this array is an array of integers. Each array
+ * of integers represents a sequence of tokens (by their ordinal
+ * values) that is expected at this point of the parse.
+ */
+ public int[][] expectedTokenSequences;
+
+ /**
+ * This is a reference to the "tokenImage" array of the generated
+ * parser within which the parse error occurred. This array is
+ * defined in the generated ...Constants interface.
+ */
+ public String[] tokenImage;
+
+ /**
+ * This method has the standard behavior when this object has been
+ * created using the standard constructors. Otherwise, it uses
+ * "currentToken" and "expectedTokenSequences" to generate a parse
+ * error message and returns it. If this object has been created
+ * due to a parse error, and you do not catch it (it gets thrown
+ * from the parser), then this method is called during the printing
+ * of the final stack trace, and hence the correct error message
+ * gets displayed.
+ */
+ public String getMessage() {
+ if (!specialConstructor) {
+ return super.getMessage();
+ }
+ StringBuffer expected = new StringBuffer();
+ int maxSize = 0;
+ for (int i = 0; i < expectedTokenSequences.length; i++) {
+ if (maxSize < expectedTokenSequences[i].length) {
+ maxSize = expectedTokenSequences[i].length;
+ }
+ for (int j = 0; j < expectedTokenSequences[i].length; j++) {
+ expected.append(tokenImage[expectedTokenSequences[i][j]]).append(" ");
+ }
+ if (expectedTokenSequences[i][expectedTokenSequences[i].length - 1] != 0) {
+ expected.append("...");
+ }
+ expected.append(eol).append(" ");
+ }
+ String retval = "Encountered \"";
+ Token tok = currentToken.next;
+ for (int i = 0; i < maxSize; i++) {
+ if (i != 0) retval += " ";
+ if (tok.kind == 0) {
+ retval += tokenImage[0];
+ break;
+ }
+ retval += add_escapes(tok.image);
+ tok = tok.next;
+ }
+ retval += "\" at line " + currentToken.next.beginLine + ", column " + currentToken.next.beginColumn;
+ retval += "." + eol;
+ if (expectedTokenSequences.length == 1) {
+ retval += "Was expecting:" + eol + " ";
+ } else {
+ retval += "Was expecting one of:" + eol + " ";
+ }
+ retval += expected.toString();
+ return retval;
+ }
+
+ /**
+ * The end of line string for this machine.
+ */
+ protected String eol = System.getProperty("line.separator", "\n");
+
+ /**
+ * Used to convert raw characters to their escaped version
+ * when these raw version cannot be used as part of an ASCII
+ * string literal.
+ */
+ protected String add_escapes(String str) {
+ StringBuffer retval = new StringBuffer();
+ char ch;
+ for (int i = 0; i < str.length(); i++) {
+ switch (str.charAt(i))
+ {
+ case 0 :
+ continue;
+ case '\b':
+ retval.append("\\b");
+ continue;
+ case '\t':
+ retval.append("\\t");
+ continue;
+ case '\n':
+ retval.append("\\n");
+ continue;
+ case '\f':
+ retval.append("\\f");
+ continue;
+ case '\r':
+ retval.append("\\r");
+ continue;
+ case '\"':
+ retval.append("\\\"");
+ continue;
+ case '\'':
+ retval.append("\\\'");
+ continue;
+ case '\\':
+ retval.append("\\\\");
+ continue;
+ default:
+ if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) {
+ String s = "0000" + Integer.toString(ch, 16);
+ retval.append("\\u" + s.substring(s.length() - 4, s.length()));
+ } else {
+ retval.append(ch);
+ }
+ continue;
+ }
+ }
+ return retval.toString();
+ }
+
+}
diff --git a/src/spiglet/SpigletParser.java b/src/spiglet/SpigletParser.java
new file mode 100644
index 0000000..9e808ad
--- /dev/null
+++ b/src/spiglet/SpigletParser.java
@@ -0,0 +1,682 @@
+package spiglet;
+/* Generated By:JavaCC: Do not edit this line. SpigletParser.java */
+import spiglet.syntaxtree.BinOp;
+import spiglet.syntaxtree.CJumpStmt;
+import spiglet.syntaxtree.Call;
+import spiglet.syntaxtree.ErrorStmt;
+import spiglet.syntaxtree.Exp;
+import spiglet.syntaxtree.Goal;
+import spiglet.syntaxtree.HAllocate;
+import spiglet.syntaxtree.HLoadStmt;
+import spiglet.syntaxtree.HStoreStmt;
+import spiglet.syntaxtree.IntegerLiteral;
+import spiglet.syntaxtree.JumpStmt;
+import spiglet.syntaxtree.Label;
+import spiglet.syntaxtree.MoveStmt;
+import spiglet.syntaxtree.NoOpStmt;
+import spiglet.syntaxtree.NodeChoice;
+import spiglet.syntaxtree.NodeListOptional;
+import spiglet.syntaxtree.NodeOptional;
+import spiglet.syntaxtree.NodeSequence;
+import spiglet.syntaxtree.NodeToken;
+import spiglet.syntaxtree.Operator;
+import spiglet.syntaxtree.PrintStmt;
+import spiglet.syntaxtree.Procedure;
+import spiglet.syntaxtree.SimpleExp;
+import spiglet.syntaxtree.Stmt;
+import spiglet.syntaxtree.StmtExp;
+import spiglet.syntaxtree.StmtList;
+import spiglet.syntaxtree.Temp;
+
+
+public class SpigletParser implements SpigletParserConstants {
+
+ static final public Goal Goal() throws ParseException {
+ NodeToken n0;
+ Token n1;
+ StmtList n2;
+ NodeToken n3;
+ Token n4;
+ NodeListOptional n5 = new NodeListOptional();
+ Procedure n6;
+ NodeToken n7;
+ Token n8;
+ n1 = jj_consume_token(MAIN);
+ n0 = JTBToolkit.makeNodeToken(n1);
+ n2 = StmtList();
+ n4 = jj_consume_token(END);
+ n3 = JTBToolkit.makeNodeToken(n4);
+ label_1:
+ while (true) {
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case IDENTIFIER:
+ ;
+ break;
+ default:
+ jj_la1[0] = jj_gen;
+ break label_1;
+ }
+ n6 = Procedure();
+ n5.addNode(n6);
+ }
+ n5.nodes.trimToSize();
+ n8 = jj_consume_token(0);
+ n8.beginColumn++; n8.endColumn++;
+ n7 = JTBToolkit.makeNodeToken(n8);
+ {if (true) return new Goal(n0,n2,n3,n5,n7);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public StmtList StmtList() throws ParseException {
+ NodeListOptional n0 = new NodeListOptional();
+ NodeSequence n1;
+ NodeOptional n2;
+ Label n3;
+ Stmt n4;
+ label_2:
+ while (true) {
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case NOOP:
+ case MOVE:
+ case ERROR:
+ case PRINT:
+ case JUMP:
+ case CJUMP:
+ case HSTORE:
+ case HLOAD:
+ case IDENTIFIER:
+ ;
+ break;
+ default:
+ jj_la1[1] = jj_gen;
+ break label_2;
+ }
+ n2 = new NodeOptional();
+ n1 = new NodeSequence(2);
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case IDENTIFIER:
+ n3 = Label();
+ n2.addNode(n3);
+ break;
+ default:
+ jj_la1[2] = jj_gen;
+ ;
+ }
+ n1.addNode(n2);
+ n4 = Stmt();
+ n1.addNode(n4);
+ n0.addNode(n1);
+ }
+ n0.nodes.trimToSize();
+ {if (true) return new StmtList(n0);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public Procedure Procedure() throws ParseException {
+ Label n0;
+ NodeToken n1;
+ Token n2;
+ IntegerLiteral n3;
+ NodeToken n4;
+ Token n5;
+ StmtExp n6;
+ n0 = Label();
+ n2 = jj_consume_token(LSQPAREN);
+ n1 = JTBToolkit.makeNodeToken(n2);
+ n3 = IntegerLiteral();
+ n5 = jj_consume_token(RSQPAREN);
+ n4 = JTBToolkit.makeNodeToken(n5);
+ n6 = StmtExp();
+ {if (true) return new Procedure(n0,n1,n3,n4,n6);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public Stmt Stmt() throws ParseException {
+ NodeChoice n0;
+ NoOpStmt n1;
+ ErrorStmt n2;
+ CJumpStmt n3;
+ JumpStmt n4;
+ HStoreStmt n5;
+ HLoadStmt n6;
+ MoveStmt n7;
+ PrintStmt n8;
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case NOOP:
+ n1 = NoOpStmt();
+ n0 = new NodeChoice(n1, 0);
+ break;
+ case ERROR:
+ n2 = ErrorStmt();
+ n0 = new NodeChoice(n2, 1);
+ break;
+ case CJUMP:
+ n3 = CJumpStmt();
+ n0 = new NodeChoice(n3, 2);
+ break;
+ case JUMP:
+ n4 = JumpStmt();
+ n0 = new NodeChoice(n4, 3);
+ break;
+ case HSTORE:
+ n5 = HStoreStmt();
+ n0 = new NodeChoice(n5, 4);
+ break;
+ case HLOAD:
+ n6 = HLoadStmt();
+ n0 = new NodeChoice(n6, 5);
+ break;
+ case MOVE:
+ n7 = MoveStmt();
+ n0 = new NodeChoice(n7, 6);
+ break;
+ case PRINT:
+ n8 = PrintStmt();
+ n0 = new NodeChoice(n8, 7);
+ break;
+ default:
+ jj_la1[3] = jj_gen;
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ {if (true) return new Stmt(n0);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public NoOpStmt NoOpStmt() throws ParseException {
+ NodeToken n0;
+ Token n1;
+ n1 = jj_consume_token(NOOP);
+ n0 = JTBToolkit.makeNodeToken(n1);
+ {if (true) return new NoOpStmt(n0);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public ErrorStmt ErrorStmt() throws ParseException {
+ NodeToken n0;
+ Token n1;
+ n1 = jj_consume_token(ERROR);
+ n0 = JTBToolkit.makeNodeToken(n1);
+ {if (true) return new ErrorStmt(n0);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public CJumpStmt CJumpStmt() throws ParseException {
+ NodeToken n0;
+ Token n1;
+ Temp n2;
+ Label n3;
+ n1 = jj_consume_token(CJUMP);
+ n0 = JTBToolkit.makeNodeToken(n1);
+ n2 = Temp();
+ n3 = Label();
+ {if (true) return new CJumpStmt(n0,n2,n3);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public JumpStmt JumpStmt() throws ParseException {
+ NodeToken n0;
+ Token n1;
+ Label n2;
+ n1 = jj_consume_token(JUMP);
+ n0 = JTBToolkit.makeNodeToken(n1);
+ n2 = Label();
+ {if (true) return new JumpStmt(n0,n2);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public HStoreStmt HStoreStmt() throws ParseException {
+ NodeToken n0;
+ Token n1;
+ Temp n2;
+ IntegerLiteral n3;
+ Temp n4;
+ n1 = jj_consume_token(HSTORE);
+ n0 = JTBToolkit.makeNodeToken(n1);
+ n2 = Temp();
+ n3 = IntegerLiteral();
+ n4 = Temp();
+ {if (true) return new HStoreStmt(n0,n2,n3,n4);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public HLoadStmt HLoadStmt() throws ParseException {
+ NodeToken n0;
+ Token n1;
+ Temp n2;
+ Temp n3;
+ IntegerLiteral n4;
+ n1 = jj_consume_token(HLOAD);
+ n0 = JTBToolkit.makeNodeToken(n1);
+ n2 = Temp();
+ n3 = Temp();
+ n4 = IntegerLiteral();
+ {if (true) return new HLoadStmt(n0,n2,n3,n4);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public MoveStmt MoveStmt() throws ParseException {
+ NodeToken n0;
+ Token n1;
+ Temp n2;
+ Exp n3;
+ n1 = jj_consume_token(MOVE);
+ n0 = JTBToolkit.makeNodeToken(n1);
+ n2 = Temp();
+ n3 = Exp();
+ {if (true) return new MoveStmt(n0,n2,n3);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public PrintStmt PrintStmt() throws ParseException {
+ NodeToken n0;
+ Token n1;
+ SimpleExp n2;
+ n1 = jj_consume_token(PRINT);
+ n0 = JTBToolkit.makeNodeToken(n1);
+ n2 = SimpleExp();
+ {if (true) return new PrintStmt(n0,n2);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public Exp Exp() throws ParseException {
+ NodeChoice n0;
+ Call n1;
+ HAllocate n2;
+ BinOp n3;
+ SimpleExp n4;
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case CALL:
+ n1 = Call();
+ n0 = new NodeChoice(n1, 0);
+ break;
+ case HALLOCATE:
+ n2 = HAllocate();
+ n0 = new NodeChoice(n2, 1);
+ break;
+ case LT:
+ case PLUS:
+ case MINUS:
+ case TIMES:
+ n3 = BinOp();
+ n0 = new NodeChoice(n3, 2);
+ break;
+ case TEMP:
+ case INTEGER_LITERAL:
+ case IDENTIFIER:
+ n4 = SimpleExp();
+ n0 = new NodeChoice(n4, 3);
+ break;
+ default:
+ jj_la1[4] = jj_gen;
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ {if (true) return new Exp(n0);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public StmtExp StmtExp() throws ParseException {
+ NodeToken n0;
+ Token n1;
+ StmtList n2;
+ NodeToken n3;
+ Token n4;
+ SimpleExp n5;
+ NodeToken n6;
+ Token n7;
+ n1 = jj_consume_token(BEGIN);
+ n0 = JTBToolkit.makeNodeToken(n1);
+ n2 = StmtList();
+ n4 = jj_consume_token(RETURN);
+ n3 = JTBToolkit.makeNodeToken(n4);
+ n5 = SimpleExp();
+ n7 = jj_consume_token(END);
+ n6 = JTBToolkit.makeNodeToken(n7);
+ {if (true) return new StmtExp(n0,n2,n3,n5,n6);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public Call Call() throws ParseException {
+ NodeToken n0;
+ Token n1;
+ SimpleExp n2;
+ NodeToken n3;
+ Token n4;
+ NodeListOptional n5 = new NodeListOptional();
+ Temp n6;
+ NodeToken n7;
+ Token n8;
+ n1 = jj_consume_token(CALL);
+ n0 = JTBToolkit.makeNodeToken(n1);
+ n2 = SimpleExp();
+ n4 = jj_consume_token(LPAREN);
+ n3 = JTBToolkit.makeNodeToken(n4);
+ label_3:
+ while (true) {
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case TEMP:
+ ;
+ break;
+ default:
+ jj_la1[5] = jj_gen;
+ break label_3;
+ }
+ n6 = Temp();
+ n5.addNode(n6);
+ }
+ n5.nodes.trimToSize();
+ n8 = jj_consume_token(RPAREN);
+ n7 = JTBToolkit.makeNodeToken(n8);
+ {if (true) return new Call(n0,n2,n3,n5,n7);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public HAllocate HAllocate() throws ParseException {
+ NodeToken n0;
+ Token n1;
+ SimpleExp n2;
+ n1 = jj_consume_token(HALLOCATE);
+ n0 = JTBToolkit.makeNodeToken(n1);
+ n2 = SimpleExp();
+ {if (true) return new HAllocate(n0,n2);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public BinOp BinOp() throws ParseException {
+ Operator n0;
+ Temp n1;
+ SimpleExp n2;
+ n0 = Operator();
+ n1 = Temp();
+ n2 = SimpleExp();
+ {if (true) return new BinOp(n0,n1,n2);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public Operator Operator() throws ParseException {
+ NodeChoice n0;
+ NodeToken n1;
+ Token n2;
+ NodeToken n3;
+ Token n4;
+ NodeToken n5;
+ Token n6;
+ NodeToken n7;
+ Token n8;
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case LT:
+ n2 = jj_consume_token(LT);
+ n1 = JTBToolkit.makeNodeToken(n2);
+ n0 = new NodeChoice(n1, 0);
+ break;
+ case PLUS:
+ n4 = jj_consume_token(PLUS);
+ n3 = JTBToolkit.makeNodeToken(n4);
+ n0 = new NodeChoice(n3, 1);
+ break;
+ case MINUS:
+ n6 = jj_consume_token(MINUS);
+ n5 = JTBToolkit.makeNodeToken(n6);
+ n0 = new NodeChoice(n5, 2);
+ break;
+ case TIMES:
+ n8 = jj_consume_token(TIMES);
+ n7 = JTBToolkit.makeNodeToken(n8);
+ n0 = new NodeChoice(n7, 3);
+ break;
+ default:
+ jj_la1[6] = jj_gen;
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ {if (true) return new Operator(n0);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public SimpleExp SimpleExp() throws ParseException {
+ NodeChoice n0;
+ Temp n1;
+ IntegerLiteral n2;
+ Label n3;
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case TEMP:
+ n1 = Temp();
+ n0 = new NodeChoice(n1, 0);
+ break;
+ case INTEGER_LITERAL:
+ n2 = IntegerLiteral();
+ n0 = new NodeChoice(n2, 1);
+ break;
+ case IDENTIFIER:
+ n3 = Label();
+ n0 = new NodeChoice(n3, 2);
+ break;
+ default:
+ jj_la1[7] = jj_gen;
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ {if (true) return new SimpleExp(n0);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public Temp Temp() throws ParseException {
+ NodeToken n0;
+ Token n1;
+ IntegerLiteral n2;
+ n1 = jj_consume_token(TEMP);
+ n0 = JTBToolkit.makeNodeToken(n1);
+ n2 = IntegerLiteral();
+ {if (true) return new Temp(n0,n2);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public IntegerLiteral IntegerLiteral() throws ParseException {
+ NodeToken n0;
+ Token n1;
+ n1 = jj_consume_token(INTEGER_LITERAL);
+ n0 = JTBToolkit.makeNodeToken(n1);
+ {if (true) return new IntegerLiteral(n0);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static final public Label Label() throws ParseException {
+ NodeToken n0;
+ Token n1;
+ n1 = jj_consume_token(IDENTIFIER);
+ n0 = JTBToolkit.makeNodeToken(n1);
+ {if (true) return new Label(n0);}
+ throw new Error("Missing return statement in function");
+ }
+
+ static private boolean jj_initialized_once = false;
+ static public SpigletParserTokenManager token_source;
+ static JavaCharStream jj_input_stream;
+ static public Token token, jj_nt;
+ static private int jj_ntk;
+ static private int jj_gen;
+ static final private int[] jj_la1 = new int[8];
+ static private int[] jj_la1_0;
+ static private int[] jj_la1_1;
+ static {
+ jj_la1_0();
+ jj_la1_1();
+ }
+ private static void jj_la1_0() {
+ jj_la1_0 = new int[] {0x0,0x0,0x0,0x0,0x48c10000,0x0,0x8c10000,0x0,};
+ }
+ private static void jj_la1_1() {
+ jj_la1_1 = new int[] {0x8000,0x879b,0x8000,0x79b,0xd004,0x1000,0x0,0xd000,};
+ }
+
+ public SpigletParser(java.io.InputStream stream) {
+ this(stream, null);
+ }
+ public SpigletParser(java.io.InputStream stream, String encoding) {
+ if (jj_initialized_once) {
+ System.out.println("ERROR: Second call to constructor of static parser. You must");
+ System.out.println(" either use ReInit() or set the JavaCC option STATIC to false");
+ System.out.println(" during parser generation.");
+ throw new Error();
+ }
+ jj_initialized_once = true;
+ try { jj_input_stream = new JavaCharStream(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); }
+ token_source = new SpigletParserTokenManager(jj_input_stream);
+ token = new Token();
+ jj_ntk = -1;
+ jj_gen = 0;
+ for (int i = 0; i < 8; i++) jj_la1[i] = -1;
+ }
+
+ static public void ReInit(java.io.InputStream stream) {
+ ReInit(stream, null);
+ }
+ static public void ReInit(java.io.InputStream stream, String encoding) {
+ try { jj_input_stream.ReInit(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); }
+ token_source.ReInit(jj_input_stream);
+ token = new Token();
+ jj_ntk = -1;
+ jj_gen = 0;
+ for (int i = 0; i < 8; i++) jj_la1[i] = -1;
+ }
+
+ public SpigletParser(java.io.Reader stream) {
+ if (jj_initialized_once) {
+ System.out.println("ERROR: Second call to constructor of static parser. You must");
+ System.out.println(" either use ReInit() or set the JavaCC option STATIC to false");
+ System.out.println(" during parser generation.");
+ throw new Error();
+ }
+ jj_initialized_once = true;
+ jj_input_stream = new JavaCharStream(stream, 1, 1);
+ token_source = new SpigletParserTokenManager(jj_input_stream);
+ token = new Token();
+ jj_ntk = -1;
+ jj_gen = 0;
+ for (int i = 0; i < 8; i++) jj_la1[i] = -1;
+ }
+
+ static public void ReInit(java.io.Reader stream) {
+ jj_input_stream.ReInit(stream, 1, 1);
+ token_source.ReInit(jj_input_stream);
+ token = new Token();
+ jj_ntk = -1;
+ jj_gen = 0;
+ for (int i = 0; i < 8; i++) jj_la1[i] = -1;
+ }
+
+ public SpigletParser(SpigletParserTokenManager tm) {
+ if (jj_initialized_once) {
+ System.out.println("ERROR: Second call to constructor of static parser. You must");
+ System.out.println(" either use ReInit() or set the JavaCC option STATIC to false");
+ System.out.println(" during parser generation.");
+ throw new Error();
+ }
+ jj_initialized_once = true;
+ token_source = tm;
+ token = new Token();
+ jj_ntk = -1;
+ jj_gen = 0;
+ for (int i = 0; i < 8; i++) jj_la1[i] = -1;
+ }
+
+ public void ReInit(SpigletParserTokenManager tm) {
+ token_source = tm;
+ token = new Token();
+ jj_ntk = -1;
+ jj_gen = 0;
+ for (int i = 0; i < 8; i++) jj_la1[i] = -1;
+ }
+
+ static final private Token jj_consume_token(int kind) throws ParseException {
+ Token oldToken;
+ if ((oldToken = token).next != null) token = token.next;
+ else token = token.next = token_source.getNextToken();
+ jj_ntk = -1;
+ if (token.kind == kind) {
+ jj_gen++;
+ return token;
+ }
+ token = oldToken;
+ jj_kind = kind;
+ throw generateParseException();
+ }
+
+ static final public Token getNextToken() {
+ if (token.next != null) token = token.next;
+ else token = token.next = token_source.getNextToken();
+ jj_ntk = -1;
+ jj_gen++;
+ return token;
+ }
+
+ static final public Token getToken(int index) {
+ Token t = token;
+ for (int i = 0; i < index; i++) {
+ if (t.next != null) t = t.next;
+ else t = t.next = token_source.getNextToken();
+ }
+ return t;
+ }
+
+ static final private int jj_ntk() {
+ if ((jj_nt=token.next) == null)
+ return (jj_ntk = (token.next=token_source.getNextToken()).kind);
+ else
+ return (jj_ntk = jj_nt.kind);
+ }
+
+ static private java.util.Vector jj_expentries = new java.util.Vector();
+ static private int[] jj_expentry;
+ static private int jj_kind = -1;
+
+ static public ParseException generateParseException() {
+ jj_expentries.removeAllElements();
+ boolean[] la1tokens = new boolean[50];
+ for (int i = 0; i < 50; i++) {
+ la1tokens[i] = false;
+ }
+ if (jj_kind >= 0) {
+ la1tokens[jj_kind] = true;
+ jj_kind = -1;
+ }
+ for (int i = 0; i < 8; i++) {
+ if (jj_la1[i] == jj_gen) {
+ for (int j = 0; j < 32; j++) {
+ if ((jj_la1_0[i] & (1<<j)) != 0) {
+ la1tokens[j] = true;
+ }
+ if ((jj_la1_1[i] & (1<<j)) != 0) {
+ la1tokens[32+j] = true;
+ }
+ }
+ }
+ }
+ for (int i = 0; i < 50; i++) {
+ if (la1tokens[i]) {
+ jj_expentry = new int[1];
+ jj_expentry[0] = i;
+ jj_expentries.addElement(jj_expentry);
+ }
+ }
+ int[][] exptokseq = new int[jj_expentries.size()][];
+ for (int i = 0; i < jj_expentries.size(); i++) {
+ exptokseq[i] = (int[])jj_expentries.elementAt(i);
+ }
+ return new ParseException(token, exptokseq, tokenImage);
+ }
+
+ static final public void enable_tracing() {
+ }
+
+ static final public void disable_tracing() {
+ }
+
+}
+
+class JTBToolkit {
+ static NodeToken makeNodeToken(Token t) {
+ return new NodeToken(t.image.intern(), t.kind, t.beginLine, t.beginColumn, t.endLine, t.endColumn);
+ }
+}
diff --git a/src/spiglet/SpigletParserConstants.java b/src/spiglet/SpigletParserConstants.java
new file mode 100644
index 0000000..ba0cf9c
--- /dev/null
+++ b/src/spiglet/SpigletParserConstants.java
@@ -0,0 +1,106 @@
+package spiglet;
+/* Generated By:JavaCC: Do not edit this line. SpigletParserConstants.java */
+public interface SpigletParserConstants {
+
+ int EOF = 0;
+ int SINGLE_LINE_COMMENT = 6;
+ int FORMAL_COMMENT = 7;
+ int MULTI_LINE_COMMENT = 8;
+ int LPAREN = 9;
+ int RPAREN = 10;
+ int LBRACE = 11;
+ int RBRACE = 12;
+ int LSQPAREN = 13;
+ int RSQPAREN = 14;
+ int DOT = 15;
+ int LT = 16;
+ int LE = 17;
+ int GT = 18;
+ int GE = 19;
+ int NE = 20;
+ int EQ = 21;
+ int PLUS = 22;
+ int MINUS = 23;
+ int AND = 24;
+ int OR = 25;
+ int NOT = 26;
+ int TIMES = 27;
+ int MAIN = 28;
+ int CODE = 29;
+ int HALLOCATE = 30;
+ int END = 31;
+ int NOOP = 32;
+ int MOVE = 33;
+ int CALL = 34;
+ int ERROR = 35;
+ int PRINT = 36;
+ int BEGIN = 37;
+ int RETURN = 38;
+ int JUMP = 39;
+ int CJUMP = 40;
+ int HSTORE = 41;
+ int HLOAD = 42;
+ int MEM = 43;
+ int TEMP = 44;
+ int ARG = 45;
+ int INTEGER_LITERAL = 46;
+ int IDENTIFIER = 47;
+ int LETTER = 48;
+ int DIGIT = 49;
+
+ int DEFAULT = 0;
+
+ String[] tokenImage = {
+ "<EOF>",
+ "\" \"",
+ "\"\\t\"",
+ "\"\\n\"",
+ "\"\\r\"",
+ "\"\\f\"",
+ "<SINGLE_LINE_COMMENT>",
+ "<FORMAL_COMMENT>",
+ "<MULTI_LINE_COMMENT>",
+ "\"(\"",
+ "\")\"",
+ "\"{\"",
+ "\"}\"",
+ "\"[\"",
+ "\"]\"",
+ "\".\"",
+ "\"LT\"",
+ "\"LE\"",
+ "\"GT\"",
+ "\"GE\"",
+ "\"NE\"",
+ "\"EQ\"",
+ "\"PLUS\"",
+ "\"MINUS\"",
+ "\"AND\"",
+ "\"OR\"",
+ "\"NOT\"",
+ "\"TIMES\"",
+ "\"MAIN\"",
+ "\"CODE\"",
+ "\"HALLOCATE\"",
+ "\"END\"",
+ "\"NOOP\"",
+ "\"MOVE\"",
+ "\"CALL\"",
+ "\"ERROR\"",
+ "\"PRINT\"",
+ "\"BEGIN\"",
+ "\"RETURN\"",
+ "\"JUMP\"",
+ "\"CJUMP\"",
+ "\"HSTORE\"",
+ "\"HLOAD\"",
+ "\"MEM\"",
+ "\"TEMP\"",
+ "\"ARG\"",
+ "<INTEGER_LITERAL>",
+ "<IDENTIFIER>",
+ "<LETTER>",
+ "<DIGIT>",
+ };
+
+}
diff --git a/src/spiglet/SpigletParserTokenManager.java b/src/spiglet/SpigletParserTokenManager.java
new file mode 100644
index 0000000..544f39e
--- /dev/null
+++ b/src/spiglet/SpigletParserTokenManager.java
@@ -0,0 +1,924 @@
+package spiglet;
+/* Generated By:JavaCC: Do not edit this line. SpigletParserTokenManager.java */
+
+public class SpigletParserTokenManager implements SpigletParserConstants
+{
+ public static java.io.PrintStream debugStream = System.out;
+ public static void setDebugStream(java.io.PrintStream ds) { debugStream = ds; }
+private static final int jjStopStringLiteralDfa_0(int pos, long active0)
+{
+ switch (pos)
+ {
+ case 0:
+ if ((active0 & 0x3fffffff0000L) != 0L)
+ {
+ jjmatchedKind = 47;
+ return 4;
+ }
+ return -1;
+ case 1:
+ if ((active0 & 0x3ffffdc00000L) != 0L)
+ {
+ jjmatchedKind = 47;
+ jjmatchedPos = 1;
+ return 4;
+ }
+ if ((active0 & 0x23f0000L) != 0L)
+ return 4;
+ return -1;
+ case 2:
+ if ((active0 & 0x17ff78c00000L) != 0L)
+ {
+ jjmatchedKind = 47;
+ jjmatchedPos = 2;
+ return 4;
+ }
+ if ((active0 & 0x280085000000L) != 0L)
+ return 4;
+ return -1;
+ case 3:
+ if ((active0 & 0x77848800000L) != 0L)
+ {
+ jjmatchedKind = 47;
+ jjmatchedPos = 3;
+ return 4;
+ }
+ if ((active0 & 0x108730400000L) != 0L)
+ return 4;
+ return -1;
+ case 4:
+ if ((active0 & 0x53808800000L) != 0L)
+ return 4;
+ if ((active0 & 0x24040000000L) != 0L)
+ {
+ jjmatchedKind = 47;
+ jjmatchedPos = 4;
+ return 4;
+ }
+ return -1;
+ case 5:
+ if ((active0 & 0x24000000000L) != 0L)
+ return 4;
+ if ((active0 & 0x40000000L) != 0L)
+ {
+ jjmatchedKind = 47;
+ jjmatchedPos = 5;
+ return 4;
+ }
+ return -1;
+ case 6:
+ if ((active0 & 0x40000000L) != 0L)
+ {
+ jjmatchedKind = 47;
+ jjmatchedPos = 6;
+ return 4;
+ }
+ return -1;
+ case 7:
+ if ((active0 & 0x40000000L) != 0L)
+ {
+ jjmatchedKind = 47;
+ jjmatchedPos = 7;
+ return 4;
+ }
+ return -1;
+ default :
+ return -1;
+ }
+}
+private static final int jjStartNfa_0(int pos, long active0)
+{
+ return jjMoveNfa_0(jjStopStringLiteralDfa_0(pos, active0), pos + 1);
+}
+static private final int jjStopAtPos(int pos, int kind)
+{
+ jjmatchedKind = kind;
+ jjmatchedPos = pos;
+ return pos + 1;
+}
+static private final int jjStartNfaWithStates_0(int pos, int kind, int state)
+{
+ jjmatchedKind = kind;
+ jjmatchedPos = pos;
+ try { curChar = input_stream.readChar(); }
+ catch(java.io.IOException e) { return pos + 1; }
+ return jjMoveNfa_0(state, pos + 1);
+}
+static private final int jjMoveStringLiteralDfa0_0()
+{
+ switch(curChar)
+ {
+ case 40:
+ return jjStopAtPos(0, 9);
+ case 41:
+ return jjStopAtPos(0, 10);
+ case 46:
+ return jjStopAtPos(0, 15);
+ case 65:
+ return jjMoveStringLiteralDfa1_0(0x200001000000L);
+ case 66:
+ return jjMoveStringLiteralDfa1_0(0x2000000000L);
+ case 67:
+ return jjMoveStringLiteralDfa1_0(0x10420000000L);
+ case 69:
+ return jjMoveStringLiteralDfa1_0(0x880200000L);
+ case 71:
+ return jjMoveStringLiteralDfa1_0(0xc0000L);
+ case 72:
+ return jjMoveStringLiteralDfa1_0(0x60040000000L);
+ case 74:
+ return jjMoveStringLiteralDfa1_0(0x8000000000L);
+ case 76:
+ return jjMoveStringLiteralDfa1_0(0x30000L);
+ case 77:
+ return jjMoveStringLiteralDfa1_0(0x80210800000L);
+ case 78:
+ return jjMoveStringLiteralDfa1_0(0x104100000L);
+ case 79:
+ return jjMoveStringLiteralDfa1_0(0x2000000L);
+ case 80:
+ return jjMoveStringLiteralDfa1_0(0x1000400000L);
+ case 82:
+ return jjMoveStringLiteralDfa1_0(0x4000000000L);
+ case 84:
+ return jjMoveStringLiteralDfa1_0(0x100008000000L);
+ case 91:
+ return jjStopAtPos(0, 13);
+ case 93:
+ return jjStopAtPos(0, 14);
+ case 123:
+ return jjStopAtPos(0, 11);
+ case 125:
+ return jjStopAtPos(0, 12);
+ default :
+ return jjMoveNfa_0(0, 0);
+ }
+}
+static private final int jjMoveStringLiteralDfa1_0(long active0)
+{
+ try { curChar = input_stream.readChar(); }
+ catch(java.io.IOException e) {
+ jjStopStringLiteralDfa_0(0, active0);
+ return 1;
+ }
+ switch(curChar)
+ {
+ case 65:
+ return jjMoveStringLiteralDfa2_0(active0, 0x450000000L);
+ case 69:
+ if ((active0 & 0x20000L) != 0L)
+ return jjStartNfaWithStates_0(1, 17, 4);
+ else if ((active0 & 0x80000L) != 0L)
+ return jjStartNfaWithStates_0(1, 19, 4);
+ else if ((active0 & 0x100000L) != 0L)
+ return jjStartNfaWithStates_0(1, 20, 4);
+ return jjMoveStringLiteralDfa2_0(active0, 0x186000000000L);
+ case 73:
+ return jjMoveStringLiteralDfa2_0(active0, 0x8800000L);
+ case 74:
+ return jjMoveStringLiteralDfa2_0(active0, 0x10000000000L);
+ case 76:
+ return jjMoveStringLiteralDfa2_0(active0, 0x40000400000L);
+ case 78:
+ return jjMoveStringLiteralDfa2_0(active0, 0x81000000L);
+ case 79:
+ return jjMoveStringLiteralDfa2_0(active0, 0x324000000L);
+ case 81:
+ if ((active0 & 0x200000L) != 0L)
+ return jjStartNfaWithStates_0(1, 21, 4);
+ break;
+ case 82:
+ if ((active0 & 0x2000000L) != 0L)
+ return jjStartNfaWithStates_0(1, 25, 4);
+ return jjMoveStringLiteralDfa2_0(active0, 0x201800000000L);
+ case 83:
+ return jjMoveStringLiteralDfa2_0(active0, 0x20000000000L);
+ case 84:
+ if ((active0 & 0x10000L) != 0L)
+ return jjStartNfaWithStates_0(1, 16, 4);
+ else if ((active0 & 0x40000L) != 0L)
+ return jjStartNfaWithStates_0(1, 18, 4);
+ break;
+ case 85:
+ return jjMoveStringLiteralDfa2_0(active0, 0x8000000000L);
+ default :
+ break;
+ }
+ return jjStartNfa_0(0, active0);
+}
+static private final int jjMoveStringLiteralDfa2_0(long old0, long active0)
+{
+ if (((active0 &= old0)) == 0L)
+ return jjStartNfa_0(0, old0);
+ try { curChar = input_stream.readChar(); }
+ catch(java.io.IOException e) {
+ jjStopStringLiteralDfa_0(1, active0);
+ return 2;
+ }
+ switch(curChar)
+ {
+ case 68:
+ if ((active0 & 0x1000000L) != 0L)
+ return jjStartNfaWithStates_0(2, 24, 4);
+ else if ((active0 & 0x80000000L) != 0L)
+ return jjStartNfaWithStates_0(2, 31, 4);
+ return jjMoveStringLiteralDfa3_0(active0, 0x20000000L);
+ case 71:
+ if ((active0 & 0x200000000000L) != 0L)
+ return jjStartNfaWithStates_0(2, 45, 4);
+ return jjMoveStringLiteralDfa3_0(active0, 0x2000000000L);
+ case 73:
+ return jjMoveStringLiteralDfa3_0(active0, 0x1010000000L);
+ case 76:
+ return jjMoveStringLiteralDfa3_0(active0, 0x440000000L);
+ case 77:
+ if ((active0 & 0x80000000000L) != 0L)
+ return jjStartNfaWithStates_0(2, 43, 4);
+ return jjMoveStringLiteralDfa3_0(active0, 0x108008000000L);
+ case 78:
+ return jjMoveStringLiteralDfa3_0(active0, 0x800000L);
+ case 79:
+ return jjMoveStringLiteralDfa3_0(active0, 0x40100000000L);
+ case 82:
+ return jjMoveStringLiteralDfa3_0(active0, 0x800000000L);
+ case 84:
+ if ((active0 & 0x4000000L) != 0L)
+ return jjStartNfaWithStates_0(2, 26, 4);
+ return jjMoveStringLiteralDfa3_0(active0, 0x24000000000L);
+ case 85:
+ return jjMoveStringLiteralDfa3_0(active0, 0x10000400000L);
+ case 86:
+ return jjMoveStringLiteralDfa3_0(active0, 0x200000000L);
+ default :
+ break;
+ }
+ return jjStartNfa_0(1, active0);
+}
+static private final int jjMoveStringLiteralDfa3_0(long old0, long active0)
+{
+ if (((active0 &= old0)) == 0L)
+ return jjStartNfa_0(1, old0);
+ try { curChar = input_stream.readChar(); }
+ catch(java.io.IOException e) {
+ jjStopStringLiteralDfa_0(2, active0);
+ return 3;
+ }
+ switch(curChar)
+ {
+ case 65:
+ return jjMoveStringLiteralDfa4_0(active0, 0x40000000000L);
+ case 69:
+ if ((active0 & 0x20000000L) != 0L)
+ return jjStartNfaWithStates_0(3, 29, 4);
+ else if ((active0 & 0x200000000L) != 0L)
+ return jjStartNfaWithStates_0(3, 33, 4);
+ return jjMoveStringLiteralDfa4_0(active0, 0x8000000L);
+ case 73:
+ return jjMoveStringLiteralDfa4_0(active0, 0x2000000000L);
+ case 76:
+ if ((active0 & 0x400000000L) != 0L)
+ return jjStartNfaWithStates_0(3, 34, 4);
+ return jjMoveStringLiteralDfa4_0(active0, 0x40000000L);
+ case 77:
+ return jjMoveStringLiteralDfa4_0(active0, 0x10000000000L);
+ case 78:
+ if ((active0 & 0x10000000L) != 0L)
+ return jjStartNfaWithStates_0(3, 28, 4);
+ return jjMoveStringLiteralDfa4_0(active0, 0x1000000000L);
+ case 79:
+ return jjMoveStringLiteralDfa4_0(active0, 0x20800000000L);
+ case 80:
+ if ((active0 & 0x100000000L) != 0L)
+ return jjStartNfaWithStates_0(3, 32, 4);
+ else if ((active0 & 0x8000000000L) != 0L)
+ return jjStartNfaWithStates_0(3, 39, 4);
+ else if ((active0 & 0x100000000000L) != 0L)
+ return jjStartNfaWithStates_0(3, 44, 4);
+ break;
+ case 83:
+ if ((active0 & 0x400000L) != 0L)
+ return jjStartNfaWithStates_0(3, 22, 4);
+ break;
+ case 85:
+ return jjMoveStringLiteralDfa4_0(active0, 0x4000800000L);
+ default :
+ break;
+ }
+ return jjStartNfa_0(2, active0);
+}
+static private final int jjMoveStringLiteralDfa4_0(long old0, long active0)
+{
+ if (((active0 &= old0)) == 0L)
+ return jjStartNfa_0(2, old0);
+ try { curChar = input_stream.readChar(); }
+ catch(java.io.IOException e) {
+ jjStopStringLiteralDfa_0(3, active0);
+ return 4;
+ }
+ switch(curChar)
+ {
+ case 68:
+ if ((active0 & 0x40000000000L) != 0L)
+ return jjStartNfaWithStates_0(4, 42, 4);
+ break;
+ case 78:
+ if ((active0 & 0x2000000000L) != 0L)
+ return jjStartNfaWithStates_0(4, 37, 4);
+ break;
+ case 79:
+ return jjMoveStringLiteralDfa5_0(active0, 0x40000000L);
+ case 80:
+ if ((active0 & 0x10000000000L) != 0L)
+ return jjStartNfaWithStates_0(4, 40, 4);
+ break;
+ case 82:
+ if ((active0 & 0x800000000L) != 0L)
+ return jjStartNfaWithStates_0(4, 35, 4);
+ return jjMoveStringLiteralDfa5_0(active0, 0x24000000000L);
+ case 83:
+ if ((active0 & 0x800000L) != 0L)
+ return jjStartNfaWithStates_0(4, 23, 4);
+ else if ((active0 & 0x8000000L) != 0L)
+ return jjStartNfaWithStates_0(4, 27, 4);
+ break;
+ case 84:
+ if ((active0 & 0x1000000000L) != 0L)
+ return jjStartNfaWithStates_0(4, 36, 4);
+ break;
+ default :
+ break;
+ }
+ return jjStartNfa_0(3, active0);
+}
+static private final int jjMoveStringLiteralDfa5_0(long old0, long active0)
+{
+ if (((active0 &= old0)) == 0L)
+ return jjStartNfa_0(3, old0);
+ try { curChar = input_stream.readChar(); }
+ catch(java.io.IOException e) {
+ jjStopStringLiteralDfa_0(4, active0);
+ return 5;
+ }
+ switch(curChar)
+ {
+ case 67:
+ return jjMoveStringLiteralDfa6_0(active0, 0x40000000L);
+ case 69:
+ if ((active0 & 0x20000000000L) != 0L)
+ return jjStartNfaWithStates_0(5, 41, 4);
+ break;
+ case 78:
+ if ((active0 & 0x4000000000L) != 0L)
+ return jjStartNfaWithStates_0(5, 38, 4);
+ break;
+ default :
+ break;
+ }
+ return jjStartNfa_0(4, active0);
+}
+static private final int jjMoveStringLiteralDfa6_0(long old0, long active0)
+{
+ if (((active0 &= old0)) == 0L)
+ return jjStartNfa_0(4, old0);
+ try { curChar = input_stream.readChar(); }
+ catch(java.io.IOException e) {
+ jjStopStringLiteralDfa_0(5, active0);
+ return 6;
+ }
+ switch(curChar)
+ {
+ case 65:
+ return jjMoveStringLiteralDfa7_0(active0, 0x40000000L);
+ default :
+ break;
+ }
+ return jjStartNfa_0(5, active0);
+}
+static private final int jjMoveStringLiteralDfa7_0(long old0, long active0)
+{
+ if (((active0 &= old0)) == 0L)
+ return jjStartNfa_0(5, old0);
+ try { curChar = input_stream.readChar(); }
+ catch(java.io.IOException e) {
+ jjStopStringLiteralDfa_0(6, active0);
+ return 7;
+ }
+ switch(curChar)
+ {
+ case 84:
+ return jjMoveStringLiteralDfa8_0(active0, 0x40000000L);
+ default :
+ break;
+ }
+ return jjStartNfa_0(6, active0);
+}
+static private final int jjMoveStringLiteralDfa8_0(long old0, long active0)
+{
+ if (((active0 &= old0)) == 0L)
+ return jjStartNfa_0(6, old0);
+ try { curChar = input_stream.readChar(); }
+ catch(java.io.IOException e) {
+ jjStopStringLiteralDfa_0(7, active0);
+ return 8;
+ }
+ switch(curChar)
+ {
+ case 69:
+ if ((active0 & 0x40000000L) != 0L)
+ return jjStartNfaWithStates_0(8, 30, 4);
+ break;
+ default :
+ break;
+ }
+ return jjStartNfa_0(7, active0);
+}
+static private final void jjCheckNAdd(int state)
+{
+ if (jjrounds[state] != jjround)
+ {
+ jjstateSet[jjnewStateCnt++] = state;
+ jjrounds[state] = jjround;
+ }
+}
+static private final void jjAddStates(int start, int end)
+{
+ do {
+ jjstateSet[jjnewStateCnt++] = jjnextStates[start];
+ } while (start++ != end);
+}
+static private final void jjCheckNAddTwoStates(int state1, int state2)
+{
+ jjCheckNAdd(state1);
+ jjCheckNAdd(state2);
+}
+static private final void jjCheckNAddStates(int start, int end)
+{
+ do {
+ jjCheckNAdd(jjnextStates[start]);
+ } while (start++ != end);
+}
+static private final void jjCheckNAddStates(int start)
+{
+ jjCheckNAdd(jjnextStates[start]);
+ jjCheckNAdd(jjnextStates[start + 1]);
+}
+static final long[] jjbitVec0 = {
+ 0x1ff00000fffffffeL, 0xffffffffffffc000L, 0xffffffffL, 0x600000000000000L
+};
+static final long[] jjbitVec2 = {
+ 0x0L, 0x0L, 0x0L, 0xff7fffffff7fffffL
+};
+static final long[] jjbitVec3 = {
+ 0x0L, 0xffffffffffffffffL, 0xffffffffffffffffL, 0xffffffffffffffffL
+};
+static final long[] jjbitVec4 = {
+ 0xffffffffffffffffL, 0xffffffffffffffffL, 0xffffL, 0x0L
+};
+static final long[] jjbitVec5 = {
+ 0xffffffffffffffffL, 0xffffffffffffffffL, 0x0L, 0x0L
+};
+static final long[] jjbitVec6 = {
+ 0x3fffffffffffL, 0x0L, 0x0L, 0x0L
+};
+static final long[] jjbitVec7 = {
+ 0xfffffffffffffffeL, 0xffffffffffffffffL, 0xffffffffffffffffL, 0xffffffffffffffffL
+};
+static final long[] jjbitVec8 = {
+ 0x0L, 0x0L, 0xffffffffffffffffL, 0xffffffffffffffffL
+};
+static private final int jjMoveNfa_0(int startState, int curPos)
+{
+ int[] nextStates;
+ int startsAt = 0;
+ jjnewStateCnt = 24;
+ int i = 1;
+ jjstateSet[0] = startState;
+ int j, kind = 0x7fffffff;
+ for (;;)
+ {
+ if (++jjround == 0x7fffffff)
+ ReInitRounds();
+ if (curChar < 64)
+ {
+ long l = 1L << curChar;
+ MatchLoop: do
+ {
+ switch(jjstateSet[--i])
+ {
+ case 0:
+ if ((0x3fe000000000000L & l) != 0L)
+ {
+ if (kind > 46)
+ kind = 46;
+ jjCheckNAdd(1);
+ }
+ else if (curChar == 47)
+ jjAddStates(0, 2);
+ else if (curChar == 36)
+ {
+ if (kind > 47)
+ kind = 47;
+ jjCheckNAdd(4);
+ }
+ else if (curChar == 48)
+ {
+ if (kind > 46)
+ kind = 46;
+ }
+ break;
+ case 1:
+ if ((0x3ff000000000000L & l) == 0L)
+ break;
+ if (kind > 46)
+ kind = 46;
+ jjCheckNAdd(1);
+ break;
+ case 2:
+ if (curChar == 48 && kind > 46)
+ kind = 46;
+ break;
+ case 3:
+ if (curChar != 36)
+ break;
+ if (kind > 47)
+ kind = 47;
+ jjCheckNAdd(4);
+ break;
+ case 4:
+ if ((0x3ff001000000000L & l) == 0L)
+ break;
+ if (kind > 47)
+ kind = 47;
+ jjCheckNAdd(4);
+ break;
+ case 5:
+ if (curChar == 47)
+ jjAddStates(0, 2);
+ break;
+ case 6:
+ if (curChar == 47)
+ jjCheckNAddStates(3, 5);
+ break;
+ case 7:
+ if ((0xffffffffffffdbffL & l) != 0L)
+ jjCheckNAddStates(3, 5);
+ break;
+ case 8:
+ if ((0x2400L & l) != 0L && kind > 6)
+ kind = 6;
+ break;
+ case 9:
+ if (curChar == 10 && kind > 6)
+ kind = 6;
+ break;
+ case 10:
+ if (curChar == 13)
+ jjstateSet[jjnewStateCnt++] = 9;
+ break;
+ case 11:
+ if (curChar == 42)
+ jjCheckNAddTwoStates(12, 13);
+ break;
+ case 12:
+ if ((0xfffffbffffffffffL & l) != 0L)
+ jjCheckNAddTwoStates(12, 13);
+ break;
+ case 13:
+ if (curChar == 42)
+ jjCheckNAddStates(6, 8);
+ break;
+ case 14:
+ if ((0xffff7bffffffffffL & l) != 0L)
+ jjCheckNAddTwoStates(15, 13);
+ break;
+ case 15:
+ if ((0xfffffbffffffffffL & l) != 0L)
+ jjCheckNAddTwoStates(15, 13);
+ break;
+ case 16:
+ if (curChar == 47 && kind > 7)
+ kind = 7;
+ break;
+ case 17:
+ if (curChar == 42)
+ jjstateSet[jjnewStateCnt++] = 11;
+ break;
+ case 18:
+ if (curChar == 42)
+ jjCheckNAddTwoStates(19, 20);
+ break;
+ case 19:
+ if ((0xfffffbffffffffffL & l) != 0L)
+ jjCheckNAddTwoStates(19, 20);
+ break;
+ case 20:
+ if (curChar == 42)
+ jjCheckNAddStates(9, 11);
+ break;
+ case 21:
+ if ((0xffff7bffffffffffL & l) != 0L)
+ jjCheckNAddTwoStates(22, 20);
+ break;
+ case 22:
+ if ((0xfffffbffffffffffL & l) != 0L)
+ jjCheckNAddTwoStates(22, 20);
+ break;
+ case 23:
+ if (curChar == 47 && kind > 8)
+ kind = 8;
+ break;
+ default : break;
+ }
+ } while(i != startsAt);
+ }
+ else if (curChar < 128)
+ {
+ long l = 1L << (curChar & 077);
+ MatchLoop: do
+ {
+ switch(jjstateSet[--i])
+ {
+ case 0:
+ case 4:
+ if ((0x7fffffe87fffffeL & l) == 0L)
+ break;
+ if (kind > 47)
+ kind = 47;
+ jjCheckNAdd(4);
+ break;
+ case 7:
+ jjAddStates(3, 5);
+ break;
+ case 12:
+ jjCheckNAddTwoStates(12, 13);
+ break;
+ case 14:
+ case 15:
+ jjCheckNAddTwoStates(15, 13);
+ break;
+ case 19:
+ jjCheckNAddTwoStates(19, 20);
+ break;
+ case 21:
+ case 22:
+ jjCheckNAddTwoStates(22, 20);
+ break;
+ default : break;
+ }
+ } while(i != startsAt);
+ }
+ else
+ {
+ int hiByte = (int)(curChar >> 8);
+ int i1 = hiByte >> 6;
+ long l1 = 1L << (hiByte & 077);
+ int i2 = (curChar & 0xff) >> 6;
+ long l2 = 1L << (curChar & 077);
+ MatchLoop: do
+ {
+ switch(jjstateSet[--i])
+ {
+ case 0:
+ case 4:
+ if (!jjCanMove_0(hiByte, i1, i2, l1, l2))
+ break;
+ if (kind > 47)
+ kind = 47;
+ jjCheckNAdd(4);
+ break;
+ case 7:
+ if (jjCanMove_1(hiByte, i1, i2, l1, l2))
+ jjAddStates(3, 5);
+ break;
+ case 12:
+ if (jjCanMove_1(hiByte, i1, i2, l1, l2))
+ jjCheckNAddTwoStates(12, 13);
+ break;
+ case 14:
+ case 15:
+ if (jjCanMove_1(hiByte, i1, i2, l1, l2))
+ jjCheckNAddTwoStates(15, 13);
+ break;
+ case 19:
+ if (jjCanMove_1(hiByte, i1, i2, l1, l2))
+ jjCheckNAddTwoStates(19, 20);
+ break;
+ case 21:
+ case 22:
+ if (jjCanMove_1(hiByte, i1, i2, l1, l2))
+ jjCheckNAddTwoStates(22, 20);
+ break;
+ default : break;
+ }
+ } while(i != startsAt);
+ }
+ if (kind != 0x7fffffff)
+ {
+ jjmatchedKind = kind;
+ jjmatchedPos = curPos;
+ kind = 0x7fffffff;
+ }
+ ++curPos;
+ if ((i = jjnewStateCnt) == (startsAt = 24 - (jjnewStateCnt = startsAt)))
+ return curPos;
+ try { curChar = input_stream.readChar(); }
+ catch(java.io.IOException e) { return curPos; }
+ }
+}
+static final int[] jjnextStates = {
+ 6, 17, 18, 7, 8, 10, 13, 14, 16, 20, 21, 23,
+};
+private static final boolean jjCanMove_0(int hiByte, int i1, int i2, long l1, long l2)
+{
+ switch(hiByte)
+ {
+ case 0:
+ return ((jjbitVec2[i2] & l2) != 0L);
+ case 48:
+ return ((jjbitVec3[i2] & l2) != 0L);
+ case 49:
+ return ((jjbitVec4[i2] & l2) != 0L);
+ case 51:
+ return ((jjbitVec5[i2] & l2) != 0L);
+ case 61:
+ return ((jjbitVec6[i2] & l2) != 0L);
+ default :
+ if ((jjbitVec0[i1] & l1) != 0L)
+ return true;
+ return false;
+ }
+}
+private static final boolean jjCanMove_1(int hiByte, int i1, int i2, long l1, long l2)
+{
+ switch(hiByte)
+ {
+ case 0:
+ return ((jjbitVec8[i2] & l2) != 0L);
+ default :
+ if ((jjbitVec7[i1] & l1) != 0L)
+ return true;
+ return false;
+ }
+}
+public static final String[] jjstrLiteralImages = {
+"", null, null, null, null, null, null, null, null, "\50", "\51", "\173",
+"\175", "\133", "\135", "\56", "\114\124", "\114\105", "\107\124", "\107\105",
+"\116\105", "\105\121", "\120\114\125\123", "\115\111\116\125\123", "\101\116\104",
+"\117\122", "\116\117\124", "\124\111\115\105\123", "\115\101\111\116",
+"\103\117\104\105", "\110\101\114\114\117\103\101\124\105", "\105\116\104", "\116\117\117\120",
+"\115\117\126\105", "\103\101\114\114", "\105\122\122\117\122", "\120\122\111\116\124",
+"\102\105\107\111\116", "\122\105\124\125\122\116", "\112\125\115\120", "\103\112\125\115\120",
+"\110\123\124\117\122\105", "\110\114\117\101\104", "\115\105\115", "\124\105\115\120", "\101\122\107",
+null, null, null, null, };
+public static final String[] lexStateNames = {
+ "DEFAULT",
+};
+static final long[] jjtoToken = {
+ 0xfffffffffe01L,
+};
+static final long[] jjtoSkip = {
+ 0x1feL,
+};
+static final long[] jjtoSpecial = {
+ 0x1c0L,
+};
+static protected JavaCharStream input_stream;
+static private final int[] jjrounds = new int[24];
+static private final int[] jjstateSet = new int[48];
+static protected char curChar;
+public SpigletParserTokenManager(JavaCharStream stream){
+ if (input_stream != null)
+ throw new TokenMgrError("ERROR: Second call to constructor of static lexer. You must use ReInit() to initialize the static variables.", TokenMgrError.STATIC_LEXER_ERROR);
+ input_stream = stream;
+}
+public SpigletParserTokenManager(JavaCharStream stream, int lexState){
+ this(stream);
+ SwitchTo(lexState);
+}
+static public void ReInit(JavaCharStream stream)
+{
+ jjmatchedPos = jjnewStateCnt = 0;
+ curLexState = defaultLexState;
+ input_stream = stream;
+ ReInitRounds();
+}
+static private final void ReInitRounds()
+{
+ int i;
+ jjround = 0x80000001;
+ for (i = 24; i-- > 0;)
+ jjrounds[i] = 0x80000000;
+}
+static public void ReInit(JavaCharStream stream, int lexState)
+{
+ ReInit(stream);
+ SwitchTo(lexState);
+}
+static public void SwitchTo(int lexState)
+{
+ if (lexState >= 1 || lexState < 0)
+ throw new TokenMgrError("Error: Ignoring invalid lexical state : " + lexState + ". State unchanged.", TokenMgrError.INVALID_LEXICAL_STATE);
+ else
+ curLexState = lexState;
+}
+
+static protected Token jjFillToken()
+{
+ Token t = Token.newToken(jjmatchedKind);
+ t.kind = jjmatchedKind;
+ String im = jjstrLiteralImages[jjmatchedKind];
+ t.image = (im == null) ? input_stream.GetImage() : im;
+ t.beginLine = input_stream.getBeginLine();
+ t.beginColumn = input_stream.getBeginColumn();
+ t.endLine = input_stream.getEndLine();
+ t.endColumn = input_stream.getEndColumn();
+ return t;
+}
+
+static int curLexState = 0;
+static int defaultLexState = 0;
+static int jjnewStateCnt;
+static int jjround;
+static int jjmatchedPos;
+static int jjmatchedKind;
+
+public static Token getNextToken()
+{
+ int kind;
+ Token specialToken = null;
+ Token matchedToken;
+ int curPos = 0;
+
+ EOFLoop :
+ for (;;)
+ {
+ try
+ {
+ curChar = input_stream.BeginToken();
+ }
+ catch(java.io.IOException e)
+ {
+ jjmatchedKind = 0;
+ matchedToken = jjFillToken();
+ matchedToken.specialToken = specialToken;
+ return matchedToken;
+ }
+
+ try { input_stream.backup(0);
+ while (curChar <= 32 && (0x100003600L & (1L << curChar)) != 0L)
+ curChar = input_stream.BeginToken();
+ }
+ catch (java.io.IOException e1) { continue EOFLoop; }
+ jjmatchedKind = 0x7fffffff;
+ jjmatchedPos = 0;
+ curPos = jjMoveStringLiteralDfa0_0();
+ if (jjmatchedKind != 0x7fffffff)
+ {
+ if (jjmatchedPos + 1 < curPos)
+ input_stream.backup(curPos - jjmatchedPos - 1);
+ if ((jjtoToken[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L)
+ {
+ matchedToken = jjFillToken();
+ matchedToken.specialToken = specialToken;
+ return matchedToken;
+ }
+ else
+ {
+ if ((jjtoSpecial[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L)
+ {
+ matchedToken = jjFillToken();
+ if (specialToken == null)
+ specialToken = matchedToken;
+ else
+ {
+ matchedToken.specialToken = specialToken;
+ specialToken = (specialToken.next = matchedToken);
+ }
+ }
+ continue EOFLoop;
+ }
+ }
+ int error_line = input_stream.getEndLine();
+ int error_column = input_stream.getEndColumn();
+ String error_after = null;
+ boolean EOFSeen = false;
+ try { input_stream.readChar(); input_stream.backup(1); }
+ catch (java.io.IOException e1) {
+ EOFSeen = true;
+ error_after = curPos <= 1 ? "" : input_stream.GetImage();
+ if (curChar == '\n' || curChar == '\r') {
+ error_line++;
+ error_column = 0;
+ }
+ else
+ error_column++;
+ }
+ if (!EOFSeen) {
+ input_stream.backup(1);
+ error_after = curPos <= 1 ? "" : input_stream.GetImage();
+ }
+ throw new TokenMgrError(EOFSeen, curLexState, error_line, error_column, error_after, curChar, TokenMgrError.LEXICAL_ERROR);
+ }
+}
+
+}
diff --git a/src/spiglet/Token.java b/src/spiglet/Token.java
new file mode 100644
index 0000000..c8c8ea0
--- /dev/null
+++ b/src/spiglet/Token.java
@@ -0,0 +1,80 @@
+package spiglet;
+/* Generated By:JavaCC: Do not edit this line. Token.java Version 3.0 */
+/**
+ * Describes the input token stream.
+ */
+
+public class Token {
+
+ /**
+ * An integer that describes the kind of this token. This numbering
+ * system is determined by JavaCCParser, and a table of these numbers is
+ * stored in the file ...Constants.java.
+ */
+ public int kind;
+
+ /**
+ * beginLine and beginColumn describe the position of the first character
+ * of this token; endLine and endColumn describe the position of the
+ * last character of this token.
+ */
+ public int beginLine, beginColumn, endLine, endColumn;
+
+ /**
+ * The string image of the token.
+ */
+ public String image;
+
+ /**
+ * A reference to the next regular (non-special) token from the input
+ * stream. If this is the last token from the input stream, or if the
+ * token manager has not read tokens beyond this one, this field is
+ * set to null. This is true only if this token is also a regular
+ * token. Otherwise, see below for a description of the contents of
+ * this field.
+ */
+ public Token next;
+
+ /**
+ * This field is used to access special tokens that occur prior to this
+ * token, but after the immediately preceding regular (non-special) token.
+ * If there are no such special tokens, this field is set to null.
+ * When there are more than one such special token, this field refers
+ * to the last of these special tokens, which in turn refers to the next
+ * previous special token through its specialToken field, and so on
+ * until the first special token (whose specialToken field is null).
+ * The next fields of special tokens refer to other special tokens that
+ * immediately follow it (without an intervening regular token). If there
+ * is no such token, this field is null.
+ */
+ public Token specialToken;
+
+ /**
+ * Returns the image.
+ */
+ public String toString()
+ {
+ return image;
+ }
+
+ /**
+ * Returns a new Token object, by default. However, if you want, you
+ * can create and return subclass objects based on the value of ofKind.
+ * Simply add the cases to the switch for all those special cases.
+ * For example, if you have a subclass of Token called IDToken that
+ * you want to create if ofKind is ID, simlpy add something like :
+ *
+ * case MyParserConstants.ID : return new IDToken();
+ *
+ * to the following switch statement. Then you can cast matchedToken
+ * variable to the appropriate type and use it in your lexical actions.
+ */
+ public static final Token newToken(int ofKind)
+ {
+ switch(ofKind)
+ {
+ default : return new Token();
+ }
+ }
+
+}
diff --git a/src/spiglet/TokenMgrError.java b/src/spiglet/TokenMgrError.java
new file mode 100644
index 0000000..9c148e0
--- /dev/null
+++ b/src/spiglet/TokenMgrError.java
@@ -0,0 +1,132 @@
+package spiglet;
+/* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 3.0 */
+public class TokenMgrError extends Error
+{
+ /*
+ * Ordinals for various reasons why an Error of this type can be thrown.
+ */
+
+ /**
+ * Lexical error occured.
+ */
+ static final int LEXICAL_ERROR = 0;
+
+ /**
+ * An attempt wass made to create a second instance of a static token manager.
+ */
+ static final int STATIC_LEXER_ERROR = 1;
+
+ /**
+ * Tried to change to an invalid lexical state.
+ */
+ static final int INVALID_LEXICAL_STATE = 2;
+
+ /**
+ * Detected (and bailed out of) an infinite loop in the token manager.
+ */
+ static final int LOOP_DETECTED = 3;
+
+ /**
+ * Indicates the reason why the exception is thrown. It will have
+ * one of the above 4 values.
+ */
+ int errorCode;
+
+ /**
+ * Replaces unprintable characters by their espaced (or unicode escaped)
+ * equivalents in the given string
+ */
+ protected static final String addEscapes(String str) {
+ StringBuffer retval = new StringBuffer();
+ char ch;
+ for (int i = 0; i < str.length(); i++) {
+ switch (str.charAt(i))
+ {
+ case 0 :
+ continue;
+ case '\b':
+ retval.append("\\b");
+ continue;
+ case '\t':
+ retval.append("\\t");
+ continue;
+ case '\n':
+ retval.append("\\n");
+ continue;
+ case '\f':
+ retval.append("\\f");
+ continue;
+ case '\r':
+ retval.append("\\r");
+ continue;
+ case '\"':
+ retval.append("\\\"");
+ continue;
+ case '\'':
+ retval.append("\\\'");
+ continue;
+ case '\\':
+ retval.append("\\\\");
+ continue;
+ default:
+ if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) {
+ String s = "0000" + Integer.toString(ch, 16);
+ retval.append("\\u" + s.substring(s.length() - 4, s.length()));
+ } else {
+ retval.append(ch);
+ }
+ continue;
+ }
+ }
+ return retval.toString();
+ }
+
+ /**
+ * Returns a detailed message for the Error when it is thrown by the
+ * token manager to indicate a lexical error.
+ * Parameters :
+ * EOFSeen : indicates if EOF caused the lexicl error
+ * curLexState : lexical state in which this error occured
+ * errorLine : line number when the error occured
+ * errorColumn : column number when the error occured
+ * errorAfter : prefix that was seen before this error occured
+ * curchar : the offending character
+ * Note: You can customize the lexical error message by modifying this method.
+ */
+ protected static String LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar) {
+ return("Lexical error at line " +
+ errorLine + ", column " +
+ errorColumn + ". Encountered: " +
+ (EOFSeen ? "<EOF> " : ("\"" + addEscapes(String.valueOf(curChar)) + "\"") + " (" + (int)curChar + "), ") +
+ "after : \"" + addEscapes(errorAfter) + "\"");
+ }
+
+ /**
+ * You can also modify the body of this method to customize your error messages.
+ * For example, cases like LOOP_DETECTED and INVALID_LEXICAL_STATE are not
+ * of end-users concern, so you can return something like :
+ *
+ * "Internal Error : Please file a bug report .... "
+ *
+ * from this method for such cases in the release version of your parser.
+ */
+ public String getMessage() {
+ return super.getMessage();
+ }
+
+ /*
+ * Constructors of various flavors follow.
+ */
+
+ public TokenMgrError() {
+ }
+
+ public TokenMgrError(String message, int reason) {
+ super(message);
+ errorCode = reason;
+ }
+
+ public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar, int reason) {
+ this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason);
+ }
+}
diff --git a/src/spiglet/spiglet2kanga/Main.java b/src/spiglet/spiglet2kanga/Main.java
new file mode 100644
index 0000000..e6e15f6
--- /dev/null
+++ b/src/spiglet/spiglet2kanga/Main.java
@@ -0,0 +1,39 @@
+package spiglet.spiglet2kanga;
+
+import spiglet.ParseException;
+import spiglet.SpigletParser;
+import spiglet.TokenMgrError;
+import spiglet.syntaxtree.Node;
+import spiglet.visitor.GJDepthFirst;
+
+
+
+
+public class Main {
+
+ public static void main(String[] args) {
+ try {
+ Node root = new SpigletParser(System.in).Goal();
+ /*
+ * TODO: Implement your own Visitors and other classes.
+ *
+ */
+ GJDepthFirst v = new GJDepthFirst<Object,Object>() {
+ };
+ //Traverse the Abstract Grammar Tree
+ root.accept(v,null);
+ }
+ catch(TokenMgrError e){
+ //Handle Lexical Errors
+ e.printStackTrace();
+ }
+ catch (ParseException e){
+ //Handle Grammar Errors
+ e.printStackTrace();
+ }
+ catch(Exception e){
+ e.printStackTrace();
+ }
+
+ }
+} \ No newline at end of file
diff --git a/src/spiglet/syntaxtree/BinOp.java b/src/spiglet/syntaxtree/BinOp.java
new file mode 100644
index 0000000..9d8b9ec
--- /dev/null
+++ b/src/spiglet/syntaxtree/BinOp.java
@@ -0,0 +1,37 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package spiglet.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> Operator()
+ * f1 -> Temp()
+ * f2 -> SimpleExp()
+ */
+public class BinOp implements Node {
+ public Operator f0;
+ public Temp f1;
+ public SimpleExp f2;
+
+ public BinOp(Operator n0, Temp n1, SimpleExp n2) {
+ f0 = n0;
+ f1 = n1;
+ f2 = n2;
+ }
+
+ public void accept(spiglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(spiglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(spiglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(spiglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/spiglet/syntaxtree/CJumpStmt.java b/src/spiglet/syntaxtree/CJumpStmt.java
new file mode 100644
index 0000000..9bee49f
--- /dev/null
+++ b/src/spiglet/syntaxtree/CJumpStmt.java
@@ -0,0 +1,43 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package spiglet.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "CJUMP"
+ * f1 -> Temp()
+ * f2 -> Label()
+ */
+public class CJumpStmt implements Node {
+ public NodeToken f0;
+ public Temp f1;
+ public Label f2;
+
+ public CJumpStmt(NodeToken n0, Temp n1, Label n2) {
+ f0 = n0;
+ f1 = n1;
+ f2 = n2;
+ }
+
+ public CJumpStmt(Temp n0, Label n1) {
+ f0 = new NodeToken("CJUMP");
+ f1 = n0;
+ f2 = n1;
+ }
+
+ public void accept(spiglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(spiglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(spiglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(spiglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/spiglet/syntaxtree/Call.java b/src/spiglet/syntaxtree/Call.java
new file mode 100644
index 0000000..ba64469
--- /dev/null
+++ b/src/spiglet/syntaxtree/Call.java
@@ -0,0 +1,51 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package spiglet.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "CALL"
+ * f1 -> SimpleExp()
+ * f2 -> "("
+ * f3 -> ( Temp() )*
+ * f4 -> ")"
+ */
+public class Call implements Node {
+ public NodeToken f0;
+ public SimpleExp f1;
+ public NodeToken f2;
+ public NodeListOptional f3;
+ public NodeToken f4;
+
+ public Call(NodeToken n0, SimpleExp n1, NodeToken n2, NodeListOptional n3, NodeToken n4) {
+ f0 = n0;
+ f1 = n1;
+ f2 = n2;
+ f3 = n3;
+ f4 = n4;
+ }
+
+ public Call(SimpleExp n0, NodeListOptional n1) {
+ f0 = new NodeToken("CALL");
+ f1 = n0;
+ f2 = new NodeToken("(");
+ f3 = n1;
+ f4 = new NodeToken(")");
+ }
+
+ public void accept(spiglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(spiglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(spiglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(spiglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/spiglet/syntaxtree/ErrorStmt.java b/src/spiglet/syntaxtree/ErrorStmt.java
new file mode 100644
index 0000000..3f1ff3f
--- /dev/null
+++ b/src/spiglet/syntaxtree/ErrorStmt.java
@@ -0,0 +1,35 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package spiglet.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "ERROR"
+ */
+public class ErrorStmt implements Node {
+ public NodeToken f0;
+
+ public ErrorStmt(NodeToken n0) {
+ f0 = n0;
+ }
+
+ public ErrorStmt() {
+ f0 = new NodeToken("ERROR");
+ }
+
+ public void accept(spiglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(spiglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(spiglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(spiglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/spiglet/syntaxtree/Exp.java b/src/spiglet/syntaxtree/Exp.java
new file mode 100644
index 0000000..41fd9ea
--- /dev/null
+++ b/src/spiglet/syntaxtree/Exp.java
@@ -0,0 +1,34 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package spiglet.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> Call()
+ * | HAllocate()
+ * | BinOp()
+ * | SimpleExp()
+ */
+public class Exp implements Node {
+ public NodeChoice f0;
+
+ public Exp(NodeChoice n0) {
+ f0 = n0;
+ }
+
+ public void accept(spiglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(spiglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(spiglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(spiglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/spiglet/syntaxtree/Goal.java b/src/spiglet/syntaxtree/Goal.java
new file mode 100644
index 0000000..6e662d0
--- /dev/null
+++ b/src/spiglet/syntaxtree/Goal.java
@@ -0,0 +1,51 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package spiglet.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "MAIN"
+ * f1 -> StmtList()
+ * f2 -> "END"
+ * f3 -> ( Procedure() )*
+ * f4 -> <EOF>
+ */
+public class Goal implements Node {
+ public NodeToken f0;
+ public StmtList f1;
+ public NodeToken f2;
+ public NodeListOptional f3;
+ public NodeToken f4;
+
+ public Goal(NodeToken n0, StmtList n1, NodeToken n2, NodeListOptional n3, NodeToken n4) {
+ f0 = n0;
+ f1 = n1;
+ f2 = n2;
+ f3 = n3;
+ f4 = n4;
+ }
+
+ public Goal(StmtList n0, NodeListOptional n1) {
+ f0 = new NodeToken("MAIN");
+ f1 = n0;
+ f2 = new NodeToken("END");
+ f3 = n1;
+ f4 = new NodeToken("");
+ }
+
+ public void accept(spiglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(spiglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(spiglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(spiglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/spiglet/syntaxtree/HAllocate.java b/src/spiglet/syntaxtree/HAllocate.java
new file mode 100644
index 0000000..61cdf0b
--- /dev/null
+++ b/src/spiglet/syntaxtree/HAllocate.java
@@ -0,0 +1,39 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package spiglet.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "HALLOCATE"
+ * f1 -> SimpleExp()
+ */
+public class HAllocate implements Node {
+ public NodeToken f0;
+ public SimpleExp f1;
+
+ public HAllocate(NodeToken n0, SimpleExp n1) {
+ f0 = n0;
+ f1 = n1;
+ }
+
+ public HAllocate(SimpleExp n0) {
+ f0 = new NodeToken("HALLOCATE");
+ f1 = n0;
+ }
+
+ public void accept(spiglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(spiglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(spiglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(spiglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/spiglet/syntaxtree/HLoadStmt.java b/src/spiglet/syntaxtree/HLoadStmt.java
new file mode 100644
index 0000000..6d27be2
--- /dev/null
+++ b/src/spiglet/syntaxtree/HLoadStmt.java
@@ -0,0 +1,47 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package spiglet.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "HLOAD"
+ * f1 -> Temp()
+ * f2 -> Temp()
+ * f3 -> IntegerLiteral()
+ */
+public class HLoadStmt implements Node {
+ public NodeToken f0;
+ public Temp f1;
+ public Temp f2;
+ public IntegerLiteral f3;
+
+ public HLoadStmt(NodeToken n0, Temp n1, Temp n2, IntegerLiteral n3) {
+ f0 = n0;
+ f1 = n1;
+ f2 = n2;
+ f3 = n3;
+ }
+
+ public HLoadStmt(Temp n0, Temp n1, IntegerLiteral n2) {
+ f0 = new NodeToken("HLOAD");
+ f1 = n0;
+ f2 = n1;
+ f3 = n2;
+ }
+
+ public void accept(spiglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(spiglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(spiglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(spiglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/spiglet/syntaxtree/HStoreStmt.java b/src/spiglet/syntaxtree/HStoreStmt.java
new file mode 100644
index 0000000..e4ac434
--- /dev/null
+++ b/src/spiglet/syntaxtree/HStoreStmt.java
@@ -0,0 +1,47 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package spiglet.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "HSTORE"
+ * f1 -> Temp()
+ * f2 -> IntegerLiteral()
+ * f3 -> Temp()
+ */
+public class HStoreStmt implements Node {
+ public NodeToken f0;
+ public Temp f1;
+ public IntegerLiteral f2;
+ public Temp f3;
+
+ public HStoreStmt(NodeToken n0, Temp n1, IntegerLiteral n2, Temp n3) {
+ f0 = n0;
+ f1 = n1;
+ f2 = n2;
+ f3 = n3;
+ }
+
+ public HStoreStmt(Temp n0, IntegerLiteral n1, Temp n2) {
+ f0 = new NodeToken("HSTORE");
+ f1 = n0;
+ f2 = n1;
+ f3 = n2;
+ }
+
+ public void accept(spiglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(spiglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(spiglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(spiglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/spiglet/syntaxtree/IntegerLiteral.java b/src/spiglet/syntaxtree/IntegerLiteral.java
new file mode 100644
index 0000000..ec17808
--- /dev/null
+++ b/src/spiglet/syntaxtree/IntegerLiteral.java
@@ -0,0 +1,31 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package spiglet.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> <INTEGER_LITERAL>
+ */
+public class IntegerLiteral implements Node {
+ public NodeToken f0;
+
+ public IntegerLiteral(NodeToken n0) {
+ f0 = n0;
+ }
+
+ public void accept(spiglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(spiglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(spiglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(spiglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/spiglet/syntaxtree/JumpStmt.java b/src/spiglet/syntaxtree/JumpStmt.java
new file mode 100644
index 0000000..74f26d3
--- /dev/null
+++ b/src/spiglet/syntaxtree/JumpStmt.java
@@ -0,0 +1,39 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package spiglet.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "JUMP"
+ * f1 -> Label()
+ */
+public class JumpStmt implements Node {
+ public NodeToken f0;
+ public Label f1;
+
+ public JumpStmt(NodeToken n0, Label n1) {
+ f0 = n0;
+ f1 = n1;
+ }
+
+ public JumpStmt(Label n0) {
+ f0 = new NodeToken("JUMP");
+ f1 = n0;
+ }
+
+ public void accept(spiglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(spiglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(spiglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(spiglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/spiglet/syntaxtree/Label.java b/src/spiglet/syntaxtree/Label.java
new file mode 100644
index 0000000..c05f209
--- /dev/null
+++ b/src/spiglet/syntaxtree/Label.java
@@ -0,0 +1,31 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package spiglet.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> <IDENTIFIER>
+ */
+public class Label implements Node {
+ public NodeToken f0;
+
+ public Label(NodeToken n0) {
+ f0 = n0;
+ }
+
+ public void accept(spiglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(spiglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(spiglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(spiglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/spiglet/syntaxtree/MoveStmt.java b/src/spiglet/syntaxtree/MoveStmt.java
new file mode 100644
index 0000000..0eafce3
--- /dev/null
+++ b/src/spiglet/syntaxtree/MoveStmt.java
@@ -0,0 +1,43 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package spiglet.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "MOVE"
+ * f1 -> Temp()
+ * f2 -> Exp()
+ */
+public class MoveStmt implements Node {
+ public NodeToken f0;
+ public Temp f1;
+ public Exp f2;
+
+ public MoveStmt(NodeToken n0, Temp n1, Exp n2) {
+ f0 = n0;
+ f1 = n1;
+ f2 = n2;
+ }
+
+ public MoveStmt(Temp n0, Exp n1) {
+ f0 = new NodeToken("MOVE");
+ f1 = n0;
+ f2 = n1;
+ }
+
+ public void accept(spiglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(spiglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(spiglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(spiglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/spiglet/syntaxtree/NoOpStmt.java b/src/spiglet/syntaxtree/NoOpStmt.java
new file mode 100644
index 0000000..a7d6514
--- /dev/null
+++ b/src/spiglet/syntaxtree/NoOpStmt.java
@@ -0,0 +1,35 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package spiglet.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "NOOP"
+ */
+public class NoOpStmt implements Node {
+ public NodeToken f0;
+
+ public NoOpStmt(NodeToken n0) {
+ f0 = n0;
+ }
+
+ public NoOpStmt() {
+ f0 = new NodeToken("NOOP");
+ }
+
+ public void accept(spiglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(spiglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(spiglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(spiglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/spiglet/syntaxtree/Node.java b/src/spiglet/syntaxtree/Node.java
new file mode 100644
index 0000000..5a04ac3
--- /dev/null
+++ b/src/spiglet/syntaxtree/Node.java
@@ -0,0 +1,16 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package spiglet.syntaxtree;
+
+/**
+ * The interface which all syntax tree classes must implement.
+ */
+public interface Node extends java.io.Serializable {
+ public void accept(spiglet.visitor.Visitor v);
+ public <R,A> R accept(spiglet.visitor.GJVisitor<R,A> v, A argu);
+ public <R> R accept(spiglet.visitor.GJNoArguVisitor<R> v);
+ public <A> void accept(spiglet.visitor.GJVoidVisitor<A> v, A argu);
+}
+
diff --git a/src/spiglet/syntaxtree/NodeChoice.java b/src/spiglet/syntaxtree/NodeChoice.java
new file mode 100644
index 0000000..eb5b377
--- /dev/null
+++ b/src/spiglet/syntaxtree/NodeChoice.java
@@ -0,0 +1,36 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package spiglet.syntaxtree;
+
+/**
+ * Represents a grammar choice, e.g. ( A | B )
+ */
+public class NodeChoice implements Node {
+ public NodeChoice(Node node) {
+ this(node, -1);
+ }
+
+ public NodeChoice(Node node, int whichChoice) {
+ choice = node;
+ which = whichChoice;
+ }
+
+ public void accept(spiglet.visitor.Visitor v) {
+ choice.accept(v);
+ }
+ public <R,A> R accept(spiglet.visitor.GJVisitor<R,A> v, A argu) {
+ return choice.accept(v,argu);
+ }
+ public <R> R accept(spiglet.visitor.GJNoArguVisitor<R> v) {
+ return choice.accept(v);
+ }
+ public <A> void accept(spiglet.visitor.GJVoidVisitor<A> v, A argu) {
+ choice.accept(v,argu);
+ }
+
+ public Node choice;
+ public int which;
+}
+
diff --git a/src/spiglet/syntaxtree/NodeList.java b/src/spiglet/syntaxtree/NodeList.java
new file mode 100644
index 0000000..6126ec5
--- /dev/null
+++ b/src/spiglet/syntaxtree/NodeList.java
@@ -0,0 +1,45 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package spiglet.syntaxtree;
+
+import java.util.Enumeration;
+import java.util.Vector;
+
+/**
+ * Represents a grammar list, e.g. ( A )+
+ */
+public class NodeList implements NodeListInterface {
+ public NodeList() {
+ nodes = new Vector<Node>();
+ }
+
+ public NodeList(Node firstNode) {
+ nodes = new Vector<Node>();
+ addNode(firstNode);
+ }
+
+ public void addNode(Node n) {
+ nodes.addElement(n);
+ }
+
+ public Enumeration<Node> elements() { return nodes.elements(); }
+ public Node elementAt(int i) { return nodes.elementAt(i); }
+ public int size() { return nodes.size(); }
+ public void accept(spiglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(spiglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(spiglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(spiglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+
+ public Vector<Node> nodes;
+}
+
diff --git a/src/spiglet/syntaxtree/NodeListInterface.java b/src/spiglet/syntaxtree/NodeListInterface.java
new file mode 100644
index 0000000..1244586
--- /dev/null
+++ b/src/spiglet/syntaxtree/NodeListInterface.java
@@ -0,0 +1,22 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package spiglet.syntaxtree;
+
+/**
+ * The interface which NodeList, NodeListOptional, and NodeSequence
+ * implement.
+ */
+public interface NodeListInterface extends Node {
+ public void addNode(Node n);
+ public Node elementAt(int i);
+ public java.util.Enumeration<Node> elements();
+ public int size();
+
+ public void accept(spiglet.visitor.Visitor v);
+ public <R,A> R accept(spiglet.visitor.GJVisitor<R,A> v, A argu);
+ public <R> R accept(spiglet.visitor.GJNoArguVisitor<R> v);
+ public <A> void accept(spiglet.visitor.GJVoidVisitor<A> v, A argu);
+}
+
diff --git a/src/spiglet/syntaxtree/NodeListOptional.java b/src/spiglet/syntaxtree/NodeListOptional.java
new file mode 100644
index 0000000..775f1ff
--- /dev/null
+++ b/src/spiglet/syntaxtree/NodeListOptional.java
@@ -0,0 +1,46 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package spiglet.syntaxtree;
+
+import java.util.Enumeration;
+import java.util.Vector;
+
+/**
+ * Represents an optional grammar list, e.g. ( A )*
+ */
+public class NodeListOptional implements NodeListInterface {
+ public NodeListOptional() {
+ nodes = new Vector<Node>();
+ }
+
+ public NodeListOptional(Node firstNode) {
+ nodes = new Vector<Node>();
+ addNode(firstNode);
+ }
+
+ public void addNode(Node n) {
+ nodes.addElement(n);
+ }
+
+ public Enumeration<Node> elements() { return nodes.elements(); }
+ public Node elementAt(int i) { return nodes.elementAt(i); }
+ public int size() { return nodes.size(); }
+ public boolean present() { return nodes.size() != 0; }
+ public void accept(spiglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(spiglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(spiglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(spiglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+
+ public Vector<Node> nodes;
+}
+
diff --git a/src/spiglet/syntaxtree/NodeOptional.java b/src/spiglet/syntaxtree/NodeOptional.java
new file mode 100644
index 0000000..01e83f2
--- /dev/null
+++ b/src/spiglet/syntaxtree/NodeOptional.java
@@ -0,0 +1,41 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package spiglet.syntaxtree;
+
+/**
+ * Represents an grammar optional node, e.g. ( A )? or [ A ]
+ */
+public class NodeOptional implements Node {
+ public NodeOptional() {
+ node = null;
+ }
+
+ public NodeOptional(Node n) {
+ addNode(n);
+ }
+
+ public void addNode(Node n) {
+ if ( node != null) // Oh oh!
+ throw new Error("Attempt to set optional node twice");
+
+ node = n;
+ }
+ public void accept(spiglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(spiglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(spiglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(spiglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+ public boolean present() { return node != null; }
+
+ public Node node;
+}
+
diff --git a/src/spiglet/syntaxtree/NodeSequence.java b/src/spiglet/syntaxtree/NodeSequence.java
new file mode 100644
index 0000000..4ea40e0
--- /dev/null
+++ b/src/spiglet/syntaxtree/NodeSequence.java
@@ -0,0 +1,46 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package spiglet.syntaxtree;
+
+import java.util.Enumeration;
+import java.util.Vector;
+
+/**
+ * Represents a sequence of nodes nested within a choice, list,
+ * optional list, or optional, e.g. ( A B )+ or [ C D E ]
+ */
+public class NodeSequence implements NodeListInterface {
+ public NodeSequence(int n) {
+ nodes = new Vector<Node>(n);
+ }
+
+ public NodeSequence(Node firstNode) {
+ nodes = new Vector<Node>();
+ addNode(firstNode);
+ }
+
+ public void addNode(Node n) {
+ nodes.addElement(n);
+ }
+
+ public Node elementAt(int i) { return nodes.elementAt(i); }
+ public Enumeration<Node> elements() { return nodes.elements(); }
+ public int size() { return nodes.size(); }
+ public void accept(spiglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(spiglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(spiglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(spiglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+
+ public Vector<Node> nodes;
+}
+
diff --git a/src/spiglet/syntaxtree/NodeToken.java b/src/spiglet/syntaxtree/NodeToken.java
new file mode 100644
index 0000000..ef5fd9a
--- /dev/null
+++ b/src/spiglet/syntaxtree/NodeToken.java
@@ -0,0 +1,88 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package spiglet.syntaxtree;
+
+import java.util.Enumeration;
+import java.util.Vector;
+/**
+ * Represents a single token in the grammar. If the "-tk" option
+ * is used, also contains a Vector of preceding special tokens.
+ */
+public class NodeToken implements Node {
+ public NodeToken(String s) {
+ this(s, -1, -1, -1, -1, -1); }
+
+ public NodeToken(String s, int kind, int beginLine, int beginColumn, int endLine, int endColumn) {
+ tokenImage = s;
+ specialTokens = null;
+ this.kind = kind;
+ this.beginLine = beginLine;
+ this.beginColumn = beginColumn;
+ this.endLine = endLine;
+ this.endColumn = endColumn;
+ }
+
+ public NodeToken getSpecialAt(int i) {
+ if ( specialTokens == null )
+ throw new java.util.NoSuchElementException("No specials in token");
+ return specialTokens.elementAt(i);
+ }
+
+ public int numSpecials() {
+ if ( specialTokens == null ) return 0;
+ return specialTokens.size();
+ }
+
+ public void addSpecial(NodeToken s) {
+ if ( specialTokens == null ) specialTokens = new Vector<NodeToken>();
+ specialTokens.addElement(s);
+ }
+
+ public void trimSpecials() {
+ if ( specialTokens == null ) return;
+ specialTokens.trimToSize();
+ }
+
+ public String toString() { return tokenImage; }
+
+ public String withSpecials() {
+ if ( specialTokens == null )
+ return tokenImage;
+
+ StringBuffer buf = new StringBuffer();
+
+ for ( Enumeration<NodeToken> e = specialTokens.elements(); e.hasMoreElements(); )
+ buf.append(e.nextElement().toString());
+
+ buf.append(tokenImage);
+ return buf.toString();
+ }
+
+ public void accept(spiglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(spiglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(spiglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(spiglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+
+ public String tokenImage;
+
+ // Stores a list of NodeTokens
+ public Vector<NodeToken> specialTokens;
+
+ // -1 for these ints means no position info is available.
+ public int beginLine, beginColumn, endLine, endColumn;
+
+ // Equal to the JavaCC token "kind" integer.
+ // -1 if not available.
+ public int kind;
+}
+
diff --git a/src/spiglet/syntaxtree/Operator.java b/src/spiglet/syntaxtree/Operator.java
new file mode 100644
index 0000000..c7f0a9e
--- /dev/null
+++ b/src/spiglet/syntaxtree/Operator.java
@@ -0,0 +1,34 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package spiglet.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "LT"
+ * | "PLUS"
+ * | "MINUS"
+ * | "TIMES"
+ */
+public class Operator implements Node {
+ public NodeChoice f0;
+
+ public Operator(NodeChoice n0) {
+ f0 = n0;
+ }
+
+ public void accept(spiglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(spiglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(spiglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(spiglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/spiglet/syntaxtree/PrintStmt.java b/src/spiglet/syntaxtree/PrintStmt.java
new file mode 100644
index 0000000..52db4d5
--- /dev/null
+++ b/src/spiglet/syntaxtree/PrintStmt.java
@@ -0,0 +1,39 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package spiglet.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "PRINT"
+ * f1 -> SimpleExp()
+ */
+public class PrintStmt implements Node {
+ public NodeToken f0;
+ public SimpleExp f1;
+
+ public PrintStmt(NodeToken n0, SimpleExp n1) {
+ f0 = n0;
+ f1 = n1;
+ }
+
+ public PrintStmt(SimpleExp n0) {
+ f0 = new NodeToken("PRINT");
+ f1 = n0;
+ }
+
+ public void accept(spiglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(spiglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(spiglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(spiglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/spiglet/syntaxtree/Procedure.java b/src/spiglet/syntaxtree/Procedure.java
new file mode 100644
index 0000000..7c38b8f
--- /dev/null
+++ b/src/spiglet/syntaxtree/Procedure.java
@@ -0,0 +1,51 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package spiglet.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> Label()
+ * f1 -> "["
+ * f2 -> IntegerLiteral()
+ * f3 -> "]"
+ * f4 -> StmtExp()
+ */
+public class Procedure implements Node {
+ public Label f0;
+ public NodeToken f1;
+ public IntegerLiteral f2;
+ public NodeToken f3;
+ public StmtExp f4;
+
+ public Procedure(Label n0, NodeToken n1, IntegerLiteral n2, NodeToken n3, StmtExp n4) {
+ f0 = n0;
+ f1 = n1;
+ f2 = n2;
+ f3 = n3;
+ f4 = n4;
+ }
+
+ public Procedure(Label n0, IntegerLiteral n1, StmtExp n2) {
+ f0 = n0;
+ f1 = new NodeToken("[");
+ f2 = n1;
+ f3 = new NodeToken("]");
+ f4 = n2;
+ }
+
+ public void accept(spiglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(spiglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(spiglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(spiglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/spiglet/syntaxtree/SimpleExp.java b/src/spiglet/syntaxtree/SimpleExp.java
new file mode 100644
index 0000000..155fd8a
--- /dev/null
+++ b/src/spiglet/syntaxtree/SimpleExp.java
@@ -0,0 +1,33 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package spiglet.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> Temp()
+ * | IntegerLiteral()
+ * | Label()
+ */
+public class SimpleExp implements Node {
+ public NodeChoice f0;
+
+ public SimpleExp(NodeChoice n0) {
+ f0 = n0;
+ }
+
+ public void accept(spiglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(spiglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(spiglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(spiglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/spiglet/syntaxtree/Stmt.java b/src/spiglet/syntaxtree/Stmt.java
new file mode 100644
index 0000000..2b0ce88
--- /dev/null
+++ b/src/spiglet/syntaxtree/Stmt.java
@@ -0,0 +1,38 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package spiglet.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> NoOpStmt()
+ * | ErrorStmt()
+ * | CJumpStmt()
+ * | JumpStmt()
+ * | HStoreStmt()
+ * | HLoadStmt()
+ * | MoveStmt()
+ * | PrintStmt()
+ */
+public class Stmt implements Node {
+ public NodeChoice f0;
+
+ public Stmt(NodeChoice n0) {
+ f0 = n0;
+ }
+
+ public void accept(spiglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(spiglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(spiglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(spiglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/spiglet/syntaxtree/StmtExp.java b/src/spiglet/syntaxtree/StmtExp.java
new file mode 100644
index 0000000..c3a495e
--- /dev/null
+++ b/src/spiglet/syntaxtree/StmtExp.java
@@ -0,0 +1,51 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package spiglet.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "BEGIN"
+ * f1 -> StmtList()
+ * f2 -> "RETURN"
+ * f3 -> SimpleExp()
+ * f4 -> "END"
+ */
+public class StmtExp implements Node {
+ public NodeToken f0;
+ public StmtList f1;
+ public NodeToken f2;
+ public SimpleExp f3;
+ public NodeToken f4;
+
+ public StmtExp(NodeToken n0, StmtList n1, NodeToken n2, SimpleExp n3, NodeToken n4) {
+ f0 = n0;
+ f1 = n1;
+ f2 = n2;
+ f3 = n3;
+ f4 = n4;
+ }
+
+ public StmtExp(StmtList n0, SimpleExp n1) {
+ f0 = new NodeToken("BEGIN");
+ f1 = n0;
+ f2 = new NodeToken("RETURN");
+ f3 = n1;
+ f4 = new NodeToken("END");
+ }
+
+ public void accept(spiglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(spiglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(spiglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(spiglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/spiglet/syntaxtree/StmtList.java b/src/spiglet/syntaxtree/StmtList.java
new file mode 100644
index 0000000..ef2fbb3
--- /dev/null
+++ b/src/spiglet/syntaxtree/StmtList.java
@@ -0,0 +1,31 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package spiglet.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> ( ( Label() )? Stmt() )*
+ */
+public class StmtList implements Node {
+ public NodeListOptional f0;
+
+ public StmtList(NodeListOptional n0) {
+ f0 = n0;
+ }
+
+ public void accept(spiglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(spiglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(spiglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(spiglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/spiglet/syntaxtree/Temp.java b/src/spiglet/syntaxtree/Temp.java
new file mode 100644
index 0000000..ea6cc24
--- /dev/null
+++ b/src/spiglet/syntaxtree/Temp.java
@@ -0,0 +1,39 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package spiglet.syntaxtree;
+
+/**
+ * Grammar production:
+ * f0 -> "TEMP"
+ * f1 -> IntegerLiteral()
+ */
+public class Temp implements Node {
+ public NodeToken f0;
+ public IntegerLiteral f1;
+
+ public Temp(NodeToken n0, IntegerLiteral n1) {
+ f0 = n0;
+ f1 = n1;
+ }
+
+ public Temp(IntegerLiteral n0) {
+ f0 = new NodeToken("TEMP");
+ f1 = n0;
+ }
+
+ public void accept(spiglet.visitor.Visitor v) {
+ v.visit(this);
+ }
+ public <R,A> R accept(spiglet.visitor.GJVisitor<R,A> v, A argu) {
+ return v.visit(this,argu);
+ }
+ public <R> R accept(spiglet.visitor.GJNoArguVisitor<R> v) {
+ return v.visit(this);
+ }
+ public <A> void accept(spiglet.visitor.GJVoidVisitor<A> v, A argu) {
+ v.visit(this,argu);
+ }
+}
+
diff --git a/src/spiglet/visitor/DepthFirstVisitor.java b/src/spiglet/visitor/DepthFirstVisitor.java
new file mode 100644
index 0000000..e9920b8
--- /dev/null
+++ b/src/spiglet/visitor/DepthFirstVisitor.java
@@ -0,0 +1,305 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package spiglet.visitor;
+import java.util.Enumeration;
+
+import spiglet.syntaxtree.BinOp;
+import spiglet.syntaxtree.CJumpStmt;
+import spiglet.syntaxtree.Call;
+import spiglet.syntaxtree.ErrorStmt;
+import spiglet.syntaxtree.Exp;
+import spiglet.syntaxtree.Goal;
+import spiglet.syntaxtree.HAllocate;
+import spiglet.syntaxtree.HLoadStmt;
+import spiglet.syntaxtree.HStoreStmt;
+import spiglet.syntaxtree.IntegerLiteral;
+import spiglet.syntaxtree.JumpStmt;
+import spiglet.syntaxtree.Label;
+import spiglet.syntaxtree.MoveStmt;
+import spiglet.syntaxtree.NoOpStmt;
+import spiglet.syntaxtree.Node;
+import spiglet.syntaxtree.NodeList;
+import spiglet.syntaxtree.NodeListOptional;
+import spiglet.syntaxtree.NodeOptional;
+import spiglet.syntaxtree.NodeSequence;
+import spiglet.syntaxtree.NodeToken;
+import spiglet.syntaxtree.Operator;
+import spiglet.syntaxtree.PrintStmt;
+import spiglet.syntaxtree.Procedure;
+import spiglet.syntaxtree.SimpleExp;
+import spiglet.syntaxtree.Stmt;
+import spiglet.syntaxtree.StmtExp;
+import spiglet.syntaxtree.StmtList;
+import spiglet.syntaxtree.Temp;
+
+/**
+ * Provides default methods which visit each node in the tree in depth-first
+ * order. Your visitors may extend this class.
+ */
+public class DepthFirstVisitor implements Visitor {
+ //
+ // Auto class visitors--probably don't need to be overridden.
+ //
+ public void visit(NodeList n) {
+ for ( Enumeration<Node> e = n.elements(); e.hasMoreElements(); )
+ e.nextElement().accept(this);
+ }
+
+ public void visit(NodeListOptional n) {
+ if ( n.present() )
+ for ( Enumeration<Node> e = n.elements(); e.hasMoreElements(); )
+ e.nextElement().accept(this);
+ }
+
+ public void visit(NodeOptional n) {
+ if ( n.present() )
+ n.node.accept(this);
+ }
+
+ public void visit(NodeSequence n) {
+ for ( Enumeration<Node> e = n.elements(); e.hasMoreElements(); )
+ e.nextElement().accept(this);
+ }
+
+ public void visit(NodeToken n) { }
+
+ //
+ // User-generated visitor methods below
+ //
+
+ /**
+ * f0 -> "MAIN"
+ * f1 -> StmtList()
+ * f2 -> "END"
+ * f3 -> ( Procedure() )*
+ * f4 -> <EOF>
+ */
+ public void visit(Goal n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ n.f3.accept(this);
+ n.f4.accept(this);
+ }
+
+ /**
+ * f0 -> ( ( Label() )? Stmt() )*
+ */
+ public void visit(StmtList n) {
+ n.f0.accept(this);
+ }
+
+ /**
+ * f0 -> Label()
+ * f1 -> "["
+ * f2 -> IntegerLiteral()
+ * f3 -> "]"
+ * f4 -> StmtExp()
+ */
+ public void visit(Procedure n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ n.f3.accept(this);
+ n.f4.accept(this);
+ }
+
+ /**
+ * f0 -> NoOpStmt()
+ * | ErrorStmt()
+ * | CJumpStmt()
+ * | JumpStmt()
+ * | HStoreStmt()
+ * | HLoadStmt()
+ * | MoveStmt()
+ * | PrintStmt()
+ */
+ public void visit(Stmt n) {
+ n.f0.accept(this);
+ }
+
+ /**
+ * f0 -> "NOOP"
+ */
+ public void visit(NoOpStmt n) {
+ n.f0.accept(this);
+ }
+
+ /**
+ * f0 -> "ERROR"
+ */
+ public void visit(ErrorStmt n) {
+ n.f0.accept(this);
+ }
+
+ /**
+ * f0 -> "CJUMP"
+ * f1 -> Temp()
+ * f2 -> Label()
+ */
+ public void visit(CJumpStmt n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ }
+
+ /**
+ * f0 -> "JUMP"
+ * f1 -> Label()
+ */
+ public void visit(JumpStmt n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ }
+
+ /**
+ * f0 -> "HSTORE"
+ * f1 -> Temp()
+ * f2 -> IntegerLiteral()
+ * f3 -> Temp()
+ */
+ public void visit(HStoreStmt n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ n.f3.accept(this);
+ }
+
+ /**
+ * f0 -> "HLOAD"
+ * f1 -> Temp()
+ * f2 -> Temp()
+ * f3 -> IntegerLiteral()
+ */
+ public void visit(HLoadStmt n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ n.f3.accept(this);
+ }
+
+ /**
+ * f0 -> "MOVE"
+ * f1 -> Temp()
+ * f2 -> Exp()
+ */
+ public void visit(MoveStmt n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ }
+
+ /**
+ * f0 -> "PRINT"
+ * f1 -> SimpleExp()
+ */
+ public void visit(PrintStmt n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ }
+
+ /**
+ * f0 -> Call()
+ * | HAllocate()
+ * | BinOp()
+ * | SimpleExp()
+ */
+ public void visit(Exp n) {
+ n.f0.accept(this);
+ }
+
+ /**
+ * f0 -> "BEGIN"
+ * f1 -> StmtList()
+ * f2 -> "RETURN"
+ * f3 -> SimpleExp()
+ * f4 -> "END"
+ */
+ public void visit(StmtExp n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ n.f3.accept(this);
+ n.f4.accept(this);
+ }
+
+ /**
+ * f0 -> "CALL"
+ * f1 -> SimpleExp()
+ * f2 -> "("
+ * f3 -> ( Temp() )*
+ * f4 -> ")"
+ */
+ public void visit(Call n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ n.f3.accept(this);
+ n.f4.accept(this);
+ }
+
+ /**
+ * f0 -> "HALLOCATE"
+ * f1 -> SimpleExp()
+ */
+ public void visit(HAllocate n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ }
+
+ /**
+ * f0 -> Operator()
+ * f1 -> Temp()
+ * f2 -> SimpleExp()
+ */
+ public void visit(BinOp n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ }
+
+ /**
+ * f0 -> "LT"
+ * | "PLUS"
+ * | "MINUS"
+ * | "TIMES"
+ */
+ public void visit(Operator n) {
+ n.f0.accept(this);
+ }
+
+ /**
+ * f0 -> Temp()
+ * | IntegerLiteral()
+ * | Label()
+ */
+ public void visit(SimpleExp n) {
+ n.f0.accept(this);
+ }
+
+ /**
+ * f0 -> "TEMP"
+ * f1 -> IntegerLiteral()
+ */
+ public void visit(Temp n) {
+ n.f0.accept(this);
+ n.f1.accept(this);
+ }
+
+ /**
+ * f0 -> <INTEGER_LITERAL>
+ */
+ public void visit(IntegerLiteral n) {
+ n.f0.accept(this);
+ }
+
+ /**
+ * f0 -> <IDENTIFIER>
+ */
+ public void visit(Label n) {
+ n.f0.accept(this);
+ }
+
+}
diff --git a/src/spiglet/visitor/GJDepthFirst.java b/src/spiglet/visitor/GJDepthFirst.java
new file mode 100644
index 0000000..c105eea
--- /dev/null
+++ b/src/spiglet/visitor/GJDepthFirst.java
@@ -0,0 +1,369 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package spiglet.visitor;
+import java.util.Enumeration;
+
+import spiglet.syntaxtree.BinOp;
+import spiglet.syntaxtree.CJumpStmt;
+import spiglet.syntaxtree.Call;
+import spiglet.syntaxtree.ErrorStmt;
+import spiglet.syntaxtree.Exp;
+import spiglet.syntaxtree.Goal;
+import spiglet.syntaxtree.HAllocate;
+import spiglet.syntaxtree.HLoadStmt;
+import spiglet.syntaxtree.HStoreStmt;
+import spiglet.syntaxtree.IntegerLiteral;
+import spiglet.syntaxtree.JumpStmt;
+import spiglet.syntaxtree.Label;
+import spiglet.syntaxtree.MoveStmt;
+import spiglet.syntaxtree.NoOpStmt;
+import spiglet.syntaxtree.Node;
+import spiglet.syntaxtree.NodeList;
+import spiglet.syntaxtree.NodeListOptional;
+import spiglet.syntaxtree.NodeOptional;
+import spiglet.syntaxtree.NodeSequence;
+import spiglet.syntaxtree.NodeToken;
+import spiglet.syntaxtree.Operator;
+import spiglet.syntaxtree.PrintStmt;
+import spiglet.syntaxtree.Procedure;
+import spiglet.syntaxtree.SimpleExp;
+import spiglet.syntaxtree.Stmt;
+import spiglet.syntaxtree.StmtExp;
+import spiglet.syntaxtree.StmtList;
+import spiglet.syntaxtree.Temp;
+
+/**
+ * Provides default methods which visit each node in the tree in depth-first
+ * order. Your visitors may extend this class.
+ */
+public class GJDepthFirst<R,A> implements GJVisitor<R,A> {
+ //
+ // Auto class visitors--probably don't need to be overridden.
+ //
+ public R visit(NodeList n, A argu) {
+ R _ret=null;
+ int _count=0;
+ for ( Enumeration<Node> e = n.elements(); e.hasMoreElements(); ) {
+ e.nextElement().accept(this,argu);
+ _count++;
+ }
+ return _ret;
+ }
+
+ public R visit(NodeListOptional n, A argu) {
+ if ( n.present() ) {
+ R _ret=null;
+ int _count=0;
+ for ( Enumeration<Node> e = n.elements(); e.hasMoreElements(); ) {
+ e.nextElement().accept(this,argu);
+ _count++;
+ }
+ return _ret;
+ }
+ else
+ return null;
+ }
+
+ public R visit(NodeOptional n, A argu) {
+ if ( n.present() )
+ return n.node.accept(this,argu);
+ else
+ return null;
+ }
+
+ public R visit(NodeSequence n, A argu) {
+ R _ret=null;
+ int _count=0;
+ for ( Enumeration<Node> e = n.elements(); e.hasMoreElements(); ) {
+ e.nextElement().accept(this,argu);
+ _count++;
+ }
+ return _ret;
+ }
+
+ public R visit(NodeToken n, A argu) { return null; }
+
+ //
+ // User-generated visitor methods below
+ //
+
+ /**
+ * f0 -> "MAIN"
+ * f1 -> StmtList()
+ * f2 -> "END"
+ * f3 -> ( Procedure() )*
+ * f4 -> <EOF>
+ */
+ public R visit(Goal n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ n.f3.accept(this, argu);
+ n.f4.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> ( ( Label() )? Stmt() )*
+ */
+ public R visit(StmtList n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> Label()
+ * f1 -> "["
+ * f2 -> IntegerLiteral()
+ * f3 -> "]"
+ * f4 -> StmtExp()
+ */
+ public R visit(Procedure n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ n.f3.accept(this, argu);
+ n.f4.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> NoOpStmt()
+ * | ErrorStmt()
+ * | CJumpStmt()
+ * | JumpStmt()
+ * | HStoreStmt()
+ * | HLoadStmt()
+ * | MoveStmt()
+ * | PrintStmt()
+ */
+ public R visit(Stmt n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "NOOP"
+ */
+ public R visit(NoOpStmt n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "ERROR"
+ */
+ public R visit(ErrorStmt n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "CJUMP"
+ * f1 -> Temp()
+ * f2 -> Label()
+ */
+ public R visit(CJumpStmt n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "JUMP"
+ * f1 -> Label()
+ */
+ public R visit(JumpStmt n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "HSTORE"
+ * f1 -> Temp()
+ * f2 -> IntegerLiteral()
+ * f3 -> Temp()
+ */
+ public R visit(HStoreStmt n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ n.f3.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "HLOAD"
+ * f1 -> Temp()
+ * f2 -> Temp()
+ * f3 -> IntegerLiteral()
+ */
+ public R visit(HLoadStmt n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ n.f3.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "MOVE"
+ * f1 -> Temp()
+ * f2 -> Exp()
+ */
+ public R visit(MoveStmt n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "PRINT"
+ * f1 -> SimpleExp()
+ */
+ public R visit(PrintStmt n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> Call()
+ * | HAllocate()
+ * | BinOp()
+ * | SimpleExp()
+ */
+ public R visit(Exp n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "BEGIN"
+ * f1 -> StmtList()
+ * f2 -> "RETURN"
+ * f3 -> SimpleExp()
+ * f4 -> "END"
+ */
+ public R visit(StmtExp n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ n.f3.accept(this, argu);
+ n.f4.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "CALL"
+ * f1 -> SimpleExp()
+ * f2 -> "("
+ * f3 -> ( Temp() )*
+ * f4 -> ")"
+ */
+ public R visit(Call n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ n.f3.accept(this, argu);
+ n.f4.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "HALLOCATE"
+ * f1 -> SimpleExp()
+ */
+ public R visit(HAllocate n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> Operator()
+ * f1 -> Temp()
+ * f2 -> SimpleExp()
+ */
+ public R visit(BinOp n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "LT"
+ * | "PLUS"
+ * | "MINUS"
+ * | "TIMES"
+ */
+ public R visit(Operator n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> Temp()
+ * | IntegerLiteral()
+ * | Label()
+ */
+ public R visit(SimpleExp n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "TEMP"
+ * f1 -> IntegerLiteral()
+ */
+ public R visit(Temp n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> <INTEGER_LITERAL>
+ */
+ public R visit(IntegerLiteral n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ return _ret;
+ }
+
+ /**
+ * f0 -> <IDENTIFIER>
+ */
+ public R visit(Label n, A argu) {
+ R _ret=null;
+ n.f0.accept(this, argu);
+ return _ret;
+ }
+
+}
diff --git a/src/spiglet/visitor/GJNoArguDepthFirst.java b/src/spiglet/visitor/GJNoArguDepthFirst.java
new file mode 100644
index 0000000..ebbd988
--- /dev/null
+++ b/src/spiglet/visitor/GJNoArguDepthFirst.java
@@ -0,0 +1,369 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package spiglet.visitor;
+import java.util.Enumeration;
+
+import spiglet.syntaxtree.BinOp;
+import spiglet.syntaxtree.CJumpStmt;
+import spiglet.syntaxtree.Call;
+import spiglet.syntaxtree.ErrorStmt;
+import spiglet.syntaxtree.Exp;
+import spiglet.syntaxtree.Goal;
+import spiglet.syntaxtree.HAllocate;
+import spiglet.syntaxtree.HLoadStmt;
+import spiglet.syntaxtree.HStoreStmt;
+import spiglet.syntaxtree.IntegerLiteral;
+import spiglet.syntaxtree.JumpStmt;
+import spiglet.syntaxtree.Label;
+import spiglet.syntaxtree.MoveStmt;
+import spiglet.syntaxtree.NoOpStmt;
+import spiglet.syntaxtree.Node;
+import spiglet.syntaxtree.NodeList;
+import spiglet.syntaxtree.NodeListOptional;
+import spiglet.syntaxtree.NodeOptional;
+import spiglet.syntaxtree.NodeSequence;
+import spiglet.syntaxtree.NodeToken;
+import spiglet.syntaxtree.Operator;
+import spiglet.syntaxtree.PrintStmt;
+import spiglet.syntaxtree.Procedure;
+import spiglet.syntaxtree.SimpleExp;
+import spiglet.syntaxtree.Stmt;
+import spiglet.syntaxtree.StmtExp;
+import spiglet.syntaxtree.StmtList;
+import spiglet.syntaxtree.Temp;
+
+/**
+ * Provides default methods which visit each node in the tree in depth-first
+ * order. Your visitors may extend this class.
+ */
+public class GJNoArguDepthFirst<R> implements GJNoArguVisitor<R> {
+ //
+ // Auto class visitors--probably don't need to be overridden.
+ //
+ public R visit(NodeList n) {
+ R _ret=null;
+ int _count=0;
+ for ( Enumeration<Node> e = n.elements(); e.hasMoreElements(); ) {
+ e.nextElement().accept(this);
+ _count++;
+ }
+ return _ret;
+ }
+
+ public R visit(NodeListOptional n) {
+ if ( n.present() ) {
+ R _ret=null;
+ int _count=0;
+ for ( Enumeration<Node> e = n.elements(); e.hasMoreElements(); ) {
+ e.nextElement().accept(this);
+ _count++;
+ }
+ return _ret;
+ }
+ else
+ return null;
+ }
+
+ public R visit(NodeOptional n) {
+ if ( n.present() )
+ return n.node.accept(this);
+ else
+ return null;
+ }
+
+ public R visit(NodeSequence n) {
+ R _ret=null;
+ int _count=0;
+ for ( Enumeration<Node> e = n.elements(); e.hasMoreElements(); ) {
+ e.nextElement().accept(this);
+ _count++;
+ }
+ return _ret;
+ }
+
+ public R visit(NodeToken n) { return null; }
+
+ //
+ // User-generated visitor methods below
+ //
+
+ /**
+ * f0 -> "MAIN"
+ * f1 -> StmtList()
+ * f2 -> "END"
+ * f3 -> ( Procedure() )*
+ * f4 -> <EOF>
+ */
+ public R visit(Goal n) {
+ R _ret=null;
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ n.f3.accept(this);
+ n.f4.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> ( ( Label() )? Stmt() )*
+ */
+ public R visit(StmtList n) {
+ R _ret=null;
+ n.f0.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> Label()
+ * f1 -> "["
+ * f2 -> IntegerLiteral()
+ * f3 -> "]"
+ * f4 -> StmtExp()
+ */
+ public R visit(Procedure n) {
+ R _ret=null;
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ n.f3.accept(this);
+ n.f4.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> NoOpStmt()
+ * | ErrorStmt()
+ * | CJumpStmt()
+ * | JumpStmt()
+ * | HStoreStmt()
+ * | HLoadStmt()
+ * | MoveStmt()
+ * | PrintStmt()
+ */
+ public R visit(Stmt n) {
+ R _ret=null;
+ n.f0.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "NOOP"
+ */
+ public R visit(NoOpStmt n) {
+ R _ret=null;
+ n.f0.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "ERROR"
+ */
+ public R visit(ErrorStmt n) {
+ R _ret=null;
+ n.f0.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "CJUMP"
+ * f1 -> Temp()
+ * f2 -> Label()
+ */
+ public R visit(CJumpStmt n) {
+ R _ret=null;
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "JUMP"
+ * f1 -> Label()
+ */
+ public R visit(JumpStmt n) {
+ R _ret=null;
+ n.f0.accept(this);
+ n.f1.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "HSTORE"
+ * f1 -> Temp()
+ * f2 -> IntegerLiteral()
+ * f3 -> Temp()
+ */
+ public R visit(HStoreStmt n) {
+ R _ret=null;
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ n.f3.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "HLOAD"
+ * f1 -> Temp()
+ * f2 -> Temp()
+ * f3 -> IntegerLiteral()
+ */
+ public R visit(HLoadStmt n) {
+ R _ret=null;
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ n.f3.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "MOVE"
+ * f1 -> Temp()
+ * f2 -> Exp()
+ */
+ public R visit(MoveStmt n) {
+ R _ret=null;
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "PRINT"
+ * f1 -> SimpleExp()
+ */
+ public R visit(PrintStmt n) {
+ R _ret=null;
+ n.f0.accept(this);
+ n.f1.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> Call()
+ * | HAllocate()
+ * | BinOp()
+ * | SimpleExp()
+ */
+ public R visit(Exp n) {
+ R _ret=null;
+ n.f0.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "BEGIN"
+ * f1 -> StmtList()
+ * f2 -> "RETURN"
+ * f3 -> SimpleExp()
+ * f4 -> "END"
+ */
+ public R visit(StmtExp n) {
+ R _ret=null;
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ n.f3.accept(this);
+ n.f4.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "CALL"
+ * f1 -> SimpleExp()
+ * f2 -> "("
+ * f3 -> ( Temp() )*
+ * f4 -> ")"
+ */
+ public R visit(Call n) {
+ R _ret=null;
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ n.f3.accept(this);
+ n.f4.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "HALLOCATE"
+ * f1 -> SimpleExp()
+ */
+ public R visit(HAllocate n) {
+ R _ret=null;
+ n.f0.accept(this);
+ n.f1.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> Operator()
+ * f1 -> Temp()
+ * f2 -> SimpleExp()
+ */
+ public R visit(BinOp n) {
+ R _ret=null;
+ n.f0.accept(this);
+ n.f1.accept(this);
+ n.f2.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "LT"
+ * | "PLUS"
+ * | "MINUS"
+ * | "TIMES"
+ */
+ public R visit(Operator n) {
+ R _ret=null;
+ n.f0.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> Temp()
+ * | IntegerLiteral()
+ * | Label()
+ */
+ public R visit(SimpleExp n) {
+ R _ret=null;
+ n.f0.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> "TEMP"
+ * f1 -> IntegerLiteral()
+ */
+ public R visit(Temp n) {
+ R _ret=null;
+ n.f0.accept(this);
+ n.f1.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> <INTEGER_LITERAL>
+ */
+ public R visit(IntegerLiteral n) {
+ R _ret=null;
+ n.f0.accept(this);
+ return _ret;
+ }
+
+ /**
+ * f0 -> <IDENTIFIER>
+ */
+ public R visit(Label n) {
+ R _ret=null;
+ n.f0.accept(this);
+ return _ret;
+ }
+
+}
diff --git a/src/spiglet/visitor/GJNoArguVisitor.java b/src/spiglet/visitor/GJNoArguVisitor.java
new file mode 100644
index 0000000..57dcc78
--- /dev/null
+++ b/src/spiglet/visitor/GJNoArguVisitor.java
@@ -0,0 +1,212 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package spiglet.visitor;
+import spiglet.syntaxtree.BinOp;
+import spiglet.syntaxtree.CJumpStmt;
+import spiglet.syntaxtree.Call;
+import spiglet.syntaxtree.ErrorStmt;
+import spiglet.syntaxtree.Exp;
+import spiglet.syntaxtree.Goal;
+import spiglet.syntaxtree.HAllocate;
+import spiglet.syntaxtree.HLoadStmt;
+import spiglet.syntaxtree.HStoreStmt;
+import spiglet.syntaxtree.IntegerLiteral;
+import spiglet.syntaxtree.JumpStmt;
+import spiglet.syntaxtree.Label;
+import spiglet.syntaxtree.MoveStmt;
+import spiglet.syntaxtree.NoOpStmt;
+import spiglet.syntaxtree.NodeList;
+import spiglet.syntaxtree.NodeListOptional;
+import spiglet.syntaxtree.NodeOptional;
+import spiglet.syntaxtree.NodeSequence;
+import spiglet.syntaxtree.NodeToken;
+import spiglet.syntaxtree.Operator;
+import spiglet.syntaxtree.PrintStmt;
+import spiglet.syntaxtree.Procedure;
+import spiglet.syntaxtree.SimpleExp;
+import spiglet.syntaxtree.Stmt;
+import spiglet.syntaxtree.StmtExp;
+import spiglet.syntaxtree.StmtList;
+import spiglet.syntaxtree.Temp;
+
+/**
+ * All GJ visitors with no argument must implement this interface.
+ */
+
+public interface GJNoArguVisitor<R> {
+
+ //
+ // GJ Auto class visitors with no argument
+ //
+
+ public R visit(NodeList n);
+ public R visit(NodeListOptional n);
+ public R visit(NodeOptional n);
+ public R visit(NodeSequence n);
+ public R visit(NodeToken n);
+
+ //
+ // User-generated visitor methods below
+ //
+
+ /**
+ * f0 -> "MAIN"
+ * f1 -> StmtList()
+ * f2 -> "END"
+ * f3 -> ( Procedure() )*
+ * f4 -> <EOF>
+ */
+ public R visit(Goal n);
+
+ /**
+ * f0 -> ( ( Label() )? Stmt() )*
+ */
+ public R visit(StmtList n);
+
+ /**
+ * f0 -> Label()
+ * f1 -> "["
+ * f2 -> IntegerLiteral()
+ * f3 -> "]"
+ * f4 -> StmtExp()
+ */
+ public R visit(Procedure n);
+
+ /**
+ * f0 -> NoOpStmt()
+ * | ErrorStmt()
+ * | CJumpStmt()
+ * | JumpStmt()
+ * | HStoreStmt()
+ * | HLoadStmt()
+ * | MoveStmt()
+ * | PrintStmt()
+ */
+ public R visit(Stmt n);
+
+ /**
+ * f0 -> "NOOP"
+ */
+ public R visit(NoOpStmt n);
+
+ /**
+ * f0 -> "ERROR"
+ */
+ public R visit(ErrorStmt n);
+
+ /**
+ * f0 -> "CJUMP"
+ * f1 -> Temp()
+ * f2 -> Label()
+ */
+ public R visit(CJumpStmt n);
+
+ /**
+ * f0 -> "JUMP"
+ * f1 -> Label()
+ */
+ public R visit(JumpStmt n);
+
+ /**
+ * f0 -> "HSTORE"
+ * f1 -> Temp()
+ * f2 -> IntegerLiteral()
+ * f3 -> Temp()
+ */
+ public R visit(HStoreStmt n);
+
+ /**
+ * f0 -> "HLOAD"
+ * f1 -> Temp()
+ * f2 -> Temp()
+ * f3 -> IntegerLiteral()
+ */
+ public R visit(HLoadStmt n);
+
+ /**
+ * f0 -> "MOVE"
+ * f1 -> Temp()
+ * f2 -> Exp()
+ */
+ public R visit(MoveStmt n);
+
+ /**
+ * f0 -> "PRINT"
+ * f1 -> SimpleExp()
+ */
+ public R visit(PrintStmt n);
+
+ /**
+ * f0 -> Call()
+ * | HAllocate()
+ * | BinOp()
+ * | SimpleExp()
+ */
+ public R visit(Exp n);
+
+ /**
+ * f0 -> "BEGIN"
+ * f1 -> StmtList()
+ * f2 -> "RETURN"
+ * f3 -> SimpleExp()
+ * f4 -> "END"
+ */
+ public R visit(StmtExp n);
+
+ /**
+ * f0 -> "CALL"
+ * f1 -> SimpleExp()
+ * f2 -> "("
+ * f3 -> ( Temp() )*
+ * f4 -> ")"
+ */
+ public R visit(Call n);
+
+ /**
+ * f0 -> "HALLOCATE"
+ * f1 -> SimpleExp()
+ */
+ public R visit(HAllocate n);
+
+ /**
+ * f0 -> Operator()
+ * f1 -> Temp()
+ * f2 -> SimpleExp()
+ */
+ public R visit(BinOp n);
+
+ /**
+ * f0 -> "LT"
+ * | "PLUS"
+ * | "MINUS"
+ * | "TIMES"
+ */
+ public R visit(Operator n);
+
+ /**
+ * f0 -> Temp()
+ * | IntegerLiteral()
+ * | Label()
+ */
+ public R visit(SimpleExp n);
+
+ /**
+ * f0 -> "TEMP"
+ * f1 -> IntegerLiteral()
+ */
+ public R visit(Temp n);
+
+ /**
+ * f0 -> <INTEGER_LITERAL>
+ */
+ public R visit(IntegerLiteral n);
+
+ /**
+ * f0 -> <IDENTIFIER>
+ */
+ public R visit(Label n);
+
+}
+
diff --git a/src/spiglet/visitor/GJVisitor.java b/src/spiglet/visitor/GJVisitor.java
new file mode 100644
index 0000000..f78417b
--- /dev/null
+++ b/src/spiglet/visitor/GJVisitor.java
@@ -0,0 +1,211 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package spiglet.visitor;
+import spiglet.syntaxtree.BinOp;
+import spiglet.syntaxtree.CJumpStmt;
+import spiglet.syntaxtree.Call;
+import spiglet.syntaxtree.ErrorStmt;
+import spiglet.syntaxtree.Exp;
+import spiglet.syntaxtree.Goal;
+import spiglet.syntaxtree.HAllocate;
+import spiglet.syntaxtree.HLoadStmt;
+import spiglet.syntaxtree.HStoreStmt;
+import spiglet.syntaxtree.IntegerLiteral;
+import spiglet.syntaxtree.JumpStmt;
+import spiglet.syntaxtree.Label;
+import spiglet.syntaxtree.MoveStmt;
+import spiglet.syntaxtree.NoOpStmt;
+import spiglet.syntaxtree.NodeList;
+import spiglet.syntaxtree.NodeListOptional;
+import spiglet.syntaxtree.NodeOptional;
+import spiglet.syntaxtree.NodeSequence;
+import spiglet.syntaxtree.NodeToken;
+import spiglet.syntaxtree.Operator;
+import spiglet.syntaxtree.PrintStmt;
+import spiglet.syntaxtree.Procedure;
+import spiglet.syntaxtree.SimpleExp;
+import spiglet.syntaxtree.Stmt;
+import spiglet.syntaxtree.StmtExp;
+import spiglet.syntaxtree.StmtList;
+import spiglet.syntaxtree.Temp;
+
+/**
+ * All GJ visitors must implement this interface.
+ */
+
+public interface GJVisitor<R,A> {
+
+ //
+ // GJ Auto class visitors
+ //
+
+ public R visit(NodeList n, A argu);
+ public R visit(NodeListOptional n, A argu);
+ public R visit(NodeOptional n, A argu);
+ public R visit(NodeSequence n, A argu);
+ public R visit(NodeToken n, A argu);
+
+ //
+ // User-generated visitor methods below
+ //
+
+ /**
+ * f0 -> "MAIN"
+ * f1 -> StmtList()
+ * f2 -> "END"
+ * f3 -> ( Procedure() )*
+ * f4 -> <EOF>
+ */
+ public R visit(Goal n, A argu);
+
+ /**
+ * f0 -> ( ( Label() )? Stmt() )*
+ */
+ public R visit(StmtList n, A argu);
+
+ /**
+ * f0 -> Label()
+ * f1 -> "["
+ * f2 -> IntegerLiteral()
+ * f3 -> "]"
+ * f4 -> StmtExp()
+ */
+ public R visit(Procedure n, A argu);
+
+ /**
+ * f0 -> NoOpStmt()
+ * | ErrorStmt()
+ * | CJumpStmt()
+ * | JumpStmt()
+ * | HStoreStmt()
+ * | HLoadStmt()
+ * | MoveStmt()
+ * | PrintStmt()
+ */
+ public R visit(Stmt n, A argu);
+
+ /**
+ * f0 -> "NOOP"
+ */
+ public R visit(NoOpStmt n, A argu);
+
+ /**
+ * f0 -> "ERROR"
+ */
+ public R visit(ErrorStmt n, A argu);
+
+ /**
+ * f0 -> "CJUMP"
+ * f1 -> Temp()
+ * f2 -> Label()
+ */
+ public R visit(CJumpStmt n, A argu);
+
+ /**
+ * f0 -> "JUMP"
+ * f1 -> Label()
+ */
+ public R visit(JumpStmt n, A argu);
+
+ /**
+ * f0 -> "HSTORE"
+ * f1 -> Temp()
+ * f2 -> IntegerLiteral()
+ * f3 -> Temp()
+ */
+ public R visit(HStoreStmt n, A argu);
+
+ /**
+ * f0 -> "HLOAD"
+ * f1 -> Temp()
+ * f2 -> Temp()
+ * f3 -> IntegerLiteral()
+ */
+ public R visit(HLoadStmt n, A argu);
+
+ /**
+ * f0 -> "MOVE"
+ * f1 -> Temp()
+ * f2 -> Exp()
+ */
+ public R visit(MoveStmt n, A argu);
+
+ /**
+ * f0 -> "PRINT"
+ * f1 -> SimpleExp()
+ */
+ public R visit(PrintStmt n, A argu);
+
+ /**
+ * f0 -> Call()
+ * | HAllocate()
+ * | BinOp()
+ * | SimpleExp()
+ */
+ public R visit(Exp n, A argu);
+
+ /**
+ * f0 -> "BEGIN"
+ * f1 -> StmtList()
+ * f2 -> "RETURN"
+ * f3 -> SimpleExp()
+ * f4 -> "END"
+ */
+ public R visit(StmtExp n, A argu);
+
+ /**
+ * f0 -> "CALL"
+ * f1 -> SimpleExp()
+ * f2 -> "("
+ * f3 -> ( Temp() )*
+ * f4 -> ")"
+ */
+ public R visit(Call n, A argu);
+
+ /**
+ * f0 -> "HALLOCATE"
+ * f1 -> SimpleExp()
+ */
+ public R visit(HAllocate n, A argu);
+
+ /**
+ * f0 -> Operator()
+ * f1 -> Temp()
+ * f2 -> SimpleExp()
+ */
+ public R visit(BinOp n, A argu);
+
+ /**
+ * f0 -> "LT"
+ * | "PLUS"
+ * | "MINUS"
+ * | "TIMES"
+ */
+ public R visit(Operator n, A argu);
+
+ /**
+ * f0 -> Temp()
+ * | IntegerLiteral()
+ * | Label()
+ */
+ public R visit(SimpleExp n, A argu);
+
+ /**
+ * f0 -> "TEMP"
+ * f1 -> IntegerLiteral()
+ */
+ public R visit(Temp n, A argu);
+
+ /**
+ * f0 -> <INTEGER_LITERAL>
+ */
+ public R visit(IntegerLiteral n, A argu);
+
+ /**
+ * f0 -> <IDENTIFIER>
+ */
+ public R visit(Label n, A argu);
+
+}
diff --git a/src/spiglet/visitor/GJVoidDepthFirst.java b/src/spiglet/visitor/GJVoidDepthFirst.java
new file mode 100644
index 0000000..f035e98
--- /dev/null
+++ b/src/spiglet/visitor/GJVoidDepthFirst.java
@@ -0,0 +1,315 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package spiglet.visitor;
+import java.util.Enumeration;
+
+import spiglet.syntaxtree.BinOp;
+import spiglet.syntaxtree.CJumpStmt;
+import spiglet.syntaxtree.Call;
+import spiglet.syntaxtree.ErrorStmt;
+import spiglet.syntaxtree.Exp;
+import spiglet.syntaxtree.Goal;
+import spiglet.syntaxtree.HAllocate;
+import spiglet.syntaxtree.HLoadStmt;
+import spiglet.syntaxtree.HStoreStmt;
+import spiglet.syntaxtree.IntegerLiteral;
+import spiglet.syntaxtree.JumpStmt;
+import spiglet.syntaxtree.Label;
+import spiglet.syntaxtree.MoveStmt;
+import spiglet.syntaxtree.NoOpStmt;
+import spiglet.syntaxtree.Node;
+import spiglet.syntaxtree.NodeList;
+import spiglet.syntaxtree.NodeListOptional;
+import spiglet.syntaxtree.NodeOptional;
+import spiglet.syntaxtree.NodeSequence;
+import spiglet.syntaxtree.NodeToken;
+import spiglet.syntaxtree.Operator;
+import spiglet.syntaxtree.PrintStmt;
+import spiglet.syntaxtree.Procedure;
+import spiglet.syntaxtree.SimpleExp;
+import spiglet.syntaxtree.Stmt;
+import spiglet.syntaxtree.StmtExp;
+import spiglet.syntaxtree.StmtList;
+import spiglet.syntaxtree.Temp;
+
+/**
+ * Provides default methods which visit each node in the tree in depth-first
+ * order. Your visitors may extend this class.
+ */
+public class GJVoidDepthFirst<A> implements GJVoidVisitor<A> {
+ //
+ // Auto class visitors--probably don't need to be overridden.
+ //
+ public void visit(NodeList n, A argu) {
+ int _count=0;
+ for ( Enumeration<Node> e = n.elements(); e.hasMoreElements(); ) {
+ e.nextElement().accept(this,argu);
+ _count++;
+ }
+ }
+
+ public void visit(NodeListOptional n, A argu) {
+ if ( n.present() ) {
+ int _count=0;
+ for ( Enumeration<Node> e = n.elements(); e.hasMoreElements(); ) {
+ e.nextElement().accept(this,argu);
+ _count++;
+ }
+ }
+ }
+
+ public void visit(NodeOptional n, A argu) {
+ if ( n.present() )
+ n.node.accept(this,argu);
+ }
+
+ public void visit(NodeSequence n, A argu) {
+ int _count=0;
+ for ( Enumeration<Node> e = n.elements(); e.hasMoreElements(); ) {
+ e.nextElement().accept(this,argu);
+ _count++;
+ }
+ }
+
+ public void visit(NodeToken n, A argu) {}
+
+ //
+ // User-generated visitor methods below
+ //
+
+ /**
+ * f0 -> "MAIN"
+ * f1 -> StmtList()
+ * f2 -> "END"
+ * f3 -> ( Procedure() )*
+ * f4 -> <EOF>
+ */
+ public void visit(Goal n, A argu) {
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ n.f3.accept(this, argu);
+ n.f4.accept(this, argu);
+ }
+
+ /**
+ * f0 -> ( ( Label() )? Stmt() )*
+ */
+ public void visit(StmtList n, A argu) {
+ n.f0.accept(this, argu);
+ }
+
+ /**
+ * f0 -> Label()
+ * f1 -> "["
+ * f2 -> IntegerLiteral()
+ * f3 -> "]"
+ * f4 -> StmtExp()
+ */
+ public void visit(Procedure n, A argu) {
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ n.f3.accept(this, argu);
+ n.f4.accept(this, argu);
+ }
+
+ /**
+ * f0 -> NoOpStmt()
+ * | ErrorStmt()
+ * | CJumpStmt()
+ * | JumpStmt()
+ * | HStoreStmt()
+ * | HLoadStmt()
+ * | MoveStmt()
+ * | PrintStmt()
+ */
+ public void visit(Stmt n, A argu) {
+ n.f0.accept(this, argu);
+ }
+
+ /**
+ * f0 -> "NOOP"
+ */
+ public void visit(NoOpStmt n, A argu) {
+ n.f0.accept(this, argu);
+ }
+
+ /**
+ * f0 -> "ERROR"
+ */
+ public void visit(ErrorStmt n, A argu) {
+ n.f0.accept(this, argu);
+ }
+
+ /**
+ * f0 -> "CJUMP"
+ * f1 -> Temp()
+ * f2 -> Label()
+ */
+ public void visit(CJumpStmt n, A argu) {
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ }
+
+ /**
+ * f0 -> "JUMP"
+ * f1 -> Label()
+ */
+ public void visit(JumpStmt n, A argu) {
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ }
+
+ /**
+ * f0 -> "HSTORE"
+ * f1 -> Temp()
+ * f2 -> IntegerLiteral()
+ * f3 -> Temp()
+ */
+ public void visit(HStoreStmt n, A argu) {
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ n.f3.accept(this, argu);
+ }
+
+ /**
+ * f0 -> "HLOAD"
+ * f1 -> Temp()
+ * f2 -> Temp()
+ * f3 -> IntegerLiteral()
+ */
+ public void visit(HLoadStmt n, A argu) {
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ n.f3.accept(this, argu);
+ }
+
+ /**
+ * f0 -> "MOVE"
+ * f1 -> Temp()
+ * f2 -> Exp()
+ */
+ public void visit(MoveStmt n, A argu) {
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ }
+
+ /**
+ * f0 -> "PRINT"
+ * f1 -> SimpleExp()
+ */
+ public void visit(PrintStmt n, A argu) {
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ }
+
+ /**
+ * f0 -> Call()
+ * | HAllocate()
+ * | BinOp()
+ * | SimpleExp()
+ */
+ public void visit(Exp n, A argu) {
+ n.f0.accept(this, argu);
+ }
+
+ /**
+ * f0 -> "BEGIN"
+ * f1 -> StmtList()
+ * f2 -> "RETURN"
+ * f3 -> SimpleExp()
+ * f4 -> "END"
+ */
+ public void visit(StmtExp n, A argu) {
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ n.f3.accept(this, argu);
+ n.f4.accept(this, argu);
+ }
+
+ /**
+ * f0 -> "CALL"
+ * f1 -> SimpleExp()
+ * f2 -> "("
+ * f3 -> ( Temp() )*
+ * f4 -> ")"
+ */
+ public void visit(Call n, A argu) {
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ n.f3.accept(this, argu);
+ n.f4.accept(this, argu);
+ }
+
+ /**
+ * f0 -> "HALLOCATE"
+ * f1 -> SimpleExp()
+ */
+ public void visit(HAllocate n, A argu) {
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ }
+
+ /**
+ * f0 -> Operator()
+ * f1 -> Temp()
+ * f2 -> SimpleExp()
+ */
+ public void visit(BinOp n, A argu) {
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ n.f2.accept(this, argu);
+ }
+
+ /**
+ * f0 -> "LT"
+ * | "PLUS"
+ * | "MINUS"
+ * | "TIMES"
+ */
+ public void visit(Operator n, A argu) {
+ n.f0.accept(this, argu);
+ }
+
+ /**
+ * f0 -> Temp()
+ * | IntegerLiteral()
+ * | Label()
+ */
+ public void visit(SimpleExp n, A argu) {
+ n.f0.accept(this, argu);
+ }
+
+ /**
+ * f0 -> "TEMP"
+ * f1 -> IntegerLiteral()
+ */
+ public void visit(Temp n, A argu) {
+ n.f0.accept(this, argu);
+ n.f1.accept(this, argu);
+ }
+
+ /**
+ * f0 -> <INTEGER_LITERAL>
+ */
+ public void visit(IntegerLiteral n, A argu) {
+ n.f0.accept(this, argu);
+ }
+
+ /**
+ * f0 -> <IDENTIFIER>
+ */
+ public void visit(Label n, A argu) {
+ n.f0.accept(this, argu);
+ }
+
+}
diff --git a/src/spiglet/visitor/GJVoidVisitor.java b/src/spiglet/visitor/GJVoidVisitor.java
new file mode 100644
index 0000000..ac47082
--- /dev/null
+++ b/src/spiglet/visitor/GJVoidVisitor.java
@@ -0,0 +1,212 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package spiglet.visitor;
+import spiglet.syntaxtree.BinOp;
+import spiglet.syntaxtree.CJumpStmt;
+import spiglet.syntaxtree.Call;
+import spiglet.syntaxtree.ErrorStmt;
+import spiglet.syntaxtree.Exp;
+import spiglet.syntaxtree.Goal;
+import spiglet.syntaxtree.HAllocate;
+import spiglet.syntaxtree.HLoadStmt;
+import spiglet.syntaxtree.HStoreStmt;
+import spiglet.syntaxtree.IntegerLiteral;
+import spiglet.syntaxtree.JumpStmt;
+import spiglet.syntaxtree.Label;
+import spiglet.syntaxtree.MoveStmt;
+import spiglet.syntaxtree.NoOpStmt;
+import spiglet.syntaxtree.NodeList;
+import spiglet.syntaxtree.NodeListOptional;
+import spiglet.syntaxtree.NodeOptional;
+import spiglet.syntaxtree.NodeSequence;
+import spiglet.syntaxtree.NodeToken;
+import spiglet.syntaxtree.Operator;
+import spiglet.syntaxtree.PrintStmt;
+import spiglet.syntaxtree.Procedure;
+import spiglet.syntaxtree.SimpleExp;
+import spiglet.syntaxtree.Stmt;
+import spiglet.syntaxtree.StmtExp;
+import spiglet.syntaxtree.StmtList;
+import spiglet.syntaxtree.Temp;
+
+/**
+ * All GJ void visitors must implement this interface.
+ */
+
+public interface GJVoidVisitor<A> {
+
+ //
+ // GJ void Auto class visitors
+ //
+
+ public void visit(NodeList n, A argu);
+ public void visit(NodeListOptional n, A argu);
+ public void visit(NodeOptional n, A argu);
+ public void visit(NodeSequence n, A argu);
+ public void visit(NodeToken n, A argu);
+
+ //
+ // User-generated visitor methods below
+ //
+
+ /**
+ * f0 -> "MAIN"
+ * f1 -> StmtList()
+ * f2 -> "END"
+ * f3 -> ( Procedure() )*
+ * f4 -> <EOF>
+ */
+ public void visit(Goal n, A argu);
+
+ /**
+ * f0 -> ( ( Label() )? Stmt() )*
+ */
+ public void visit(StmtList n, A argu);
+
+ /**
+ * f0 -> Label()
+ * f1 -> "["
+ * f2 -> IntegerLiteral()
+ * f3 -> "]"
+ * f4 -> StmtExp()
+ */
+ public void visit(Procedure n, A argu);
+
+ /**
+ * f0 -> NoOpStmt()
+ * | ErrorStmt()
+ * | CJumpStmt()
+ * | JumpStmt()
+ * | HStoreStmt()
+ * | HLoadStmt()
+ * | MoveStmt()
+ * | PrintStmt()
+ */
+ public void visit(Stmt n, A argu);
+
+ /**
+ * f0 -> "NOOP"
+ */
+ public void visit(NoOpStmt n, A argu);
+
+ /**
+ * f0 -> "ERROR"
+ */
+ public void visit(ErrorStmt n, A argu);
+
+ /**
+ * f0 -> "CJUMP"
+ * f1 -> Temp()
+ * f2 -> Label()
+ */
+ public void visit(CJumpStmt n, A argu);
+
+ /**
+ * f0 -> "JUMP"
+ * f1 -> Label()
+ */
+ public void visit(JumpStmt n, A argu);
+
+ /**
+ * f0 -> "HSTORE"
+ * f1 -> Temp()
+ * f2 -> IntegerLiteral()
+ * f3 -> Temp()
+ */
+ public void visit(HStoreStmt n, A argu);
+
+ /**
+ * f0 -> "HLOAD"
+ * f1 -> Temp()
+ * f2 -> Temp()
+ * f3 -> IntegerLiteral()
+ */
+ public void visit(HLoadStmt n, A argu);
+
+ /**
+ * f0 -> "MOVE"
+ * f1 -> Temp()
+ * f2 -> Exp()
+ */
+ public void visit(MoveStmt n, A argu);
+
+ /**
+ * f0 -> "PRINT"
+ * f1 -> SimpleExp()
+ */
+ public void visit(PrintStmt n, A argu);
+
+ /**
+ * f0 -> Call()
+ * | HAllocate()
+ * | BinOp()
+ * | SimpleExp()
+ */
+ public void visit(Exp n, A argu);
+
+ /**
+ * f0 -> "BEGIN"
+ * f1 -> StmtList()
+ * f2 -> "RETURN"
+ * f3 -> SimpleExp()
+ * f4 -> "END"
+ */
+ public void visit(StmtExp n, A argu);
+
+ /**
+ * f0 -> "CALL"
+ * f1 -> SimpleExp()
+ * f2 -> "("
+ * f3 -> ( Temp() )*
+ * f4 -> ")"
+ */
+ public void visit(Call n, A argu);
+
+ /**
+ * f0 -> "HALLOCATE"
+ * f1 -> SimpleExp()
+ */
+ public void visit(HAllocate n, A argu);
+
+ /**
+ * f0 -> Operator()
+ * f1 -> Temp()
+ * f2 -> SimpleExp()
+ */
+ public void visit(BinOp n, A argu);
+
+ /**
+ * f0 -> "LT"
+ * | "PLUS"
+ * | "MINUS"
+ * | "TIMES"
+ */
+ public void visit(Operator n, A argu);
+
+ /**
+ * f0 -> Temp()
+ * | IntegerLiteral()
+ * | Label()
+ */
+ public void visit(SimpleExp n, A argu);
+
+ /**
+ * f0 -> "TEMP"
+ * f1 -> IntegerLiteral()
+ */
+ public void visit(Temp n, A argu);
+
+ /**
+ * f0 -> <INTEGER_LITERAL>
+ */
+ public void visit(IntegerLiteral n, A argu);
+
+ /**
+ * f0 -> <IDENTIFIER>
+ */
+ public void visit(Label n, A argu);
+
+}
+
diff --git a/src/spiglet/visitor/Visitor.java b/src/spiglet/visitor/Visitor.java
new file mode 100644
index 0000000..b3a1af6
--- /dev/null
+++ b/src/spiglet/visitor/Visitor.java
@@ -0,0 +1,212 @@
+//
+// Generated by JTB 1.3.2
+//
+
+package spiglet.visitor;
+import spiglet.syntaxtree.BinOp;
+import spiglet.syntaxtree.CJumpStmt;
+import spiglet.syntaxtree.Call;
+import spiglet.syntaxtree.ErrorStmt;
+import spiglet.syntaxtree.Exp;
+import spiglet.syntaxtree.Goal;
+import spiglet.syntaxtree.HAllocate;
+import spiglet.syntaxtree.HLoadStmt;
+import spiglet.syntaxtree.HStoreStmt;
+import spiglet.syntaxtree.IntegerLiteral;
+import spiglet.syntaxtree.JumpStmt;
+import spiglet.syntaxtree.Label;
+import spiglet.syntaxtree.MoveStmt;
+import spiglet.syntaxtree.NoOpStmt;
+import spiglet.syntaxtree.NodeList;
+import spiglet.syntaxtree.NodeListOptional;
+import spiglet.syntaxtree.NodeOptional;
+import spiglet.syntaxtree.NodeSequence;
+import spiglet.syntaxtree.NodeToken;
+import spiglet.syntaxtree.Operator;
+import spiglet.syntaxtree.PrintStmt;
+import spiglet.syntaxtree.Procedure;
+import spiglet.syntaxtree.SimpleExp;
+import spiglet.syntaxtree.Stmt;
+import spiglet.syntaxtree.StmtExp;
+import spiglet.syntaxtree.StmtList;
+import spiglet.syntaxtree.Temp;
+
+/**
+ * All void visitors must implement this interface.
+ */
+
+public interface Visitor {
+
+ //
+ // void Auto class visitors
+ //
+
+ public void visit(NodeList n);
+ public void visit(NodeListOptional n);
+ public void visit(NodeOptional n);
+ public void visit(NodeSequence n);
+ public void visit(NodeToken n);
+
+ //
+ // User-generated visitor methods below
+ //
+
+ /**
+ * f0 -> "MAIN"
+ * f1 -> StmtList()
+ * f2 -> "END"
+ * f3 -> ( Procedure() )*
+ * f4 -> <EOF>
+ */
+ public void visit(Goal n);
+
+ /**
+ * f0 -> ( ( Label() )? Stmt() )*
+ */
+ public void visit(StmtList n);
+
+ /**
+ * f0 -> Label()
+ * f1 -> "["
+ * f2 -> IntegerLiteral()
+ * f3 -> "]"
+ * f4 -> StmtExp()
+ */
+ public void visit(Procedure n);
+
+ /**
+ * f0 -> NoOpStmt()
+ * | ErrorStmt()
+ * | CJumpStmt()
+ * | JumpStmt()
+ * | HStoreStmt()
+ * | HLoadStmt()
+ * | MoveStmt()
+ * | PrintStmt()
+ */
+ public void visit(Stmt n);
+
+ /**
+ * f0 -> "NOOP"
+ */
+ public void visit(NoOpStmt n);
+
+ /**
+ * f0 -> "ERROR"
+ */
+ public void visit(ErrorStmt n);
+
+ /**
+ * f0 -> "CJUMP"
+ * f1 -> Temp()
+ * f2 -> Label()
+ */
+ public void visit(CJumpStmt n);
+
+ /**
+ * f0 -> "JUMP"
+ * f1 -> Label()
+ */
+ public void visit(JumpStmt n);
+
+ /**
+ * f0 -> "HSTORE"
+ * f1 -> Temp()
+ * f2 -> IntegerLiteral()
+ * f3 -> Temp()
+ */
+ public void visit(HStoreStmt n);
+
+ /**
+ * f0 -> "HLOAD"
+ * f1 -> Temp()
+ * f2 -> Temp()
+ * f3 -> IntegerLiteral()
+ */
+ public void visit(HLoadStmt n);
+
+ /**
+ * f0 -> "MOVE"
+ * f1 -> Temp()
+ * f2 -> Exp()
+ */
+ public void visit(MoveStmt n);
+
+ /**
+ * f0 -> "PRINT"
+ * f1 -> SimpleExp()
+ */
+ public void visit(PrintStmt n);
+
+ /**
+ * f0 -> Call()
+ * | HAllocate()
+ * | BinOp()
+ * | SimpleExp()
+ */
+ public void visit(Exp n);
+
+ /**
+ * f0 -> "BEGIN"
+ * f1 -> StmtList()
+ * f2 -> "RETURN"
+ * f3 -> SimpleExp()
+ * f4 -> "END"
+ */
+ public void visit(StmtExp n);
+
+ /**
+ * f0 -> "CALL"
+ * f1 -> SimpleExp()
+ * f2 -> "("
+ * f3 -> ( Temp() )*
+ * f4 -> ")"
+ */
+ public void visit(Call n);
+
+ /**
+ * f0 -> "HALLOCATE"
+ * f1 -> SimpleExp()
+ */
+ public void visit(HAllocate n);
+
+ /**
+ * f0 -> Operator()
+ * f1 -> Temp()
+ * f2 -> SimpleExp()
+ */
+ public void visit(BinOp n);
+
+ /**
+ * f0 -> "LT"
+ * | "PLUS"
+ * | "MINUS"
+ * | "TIMES"
+ */
+ public void visit(Operator n);
+
+ /**
+ * f0 -> Temp()
+ * | IntegerLiteral()
+ * | Label()
+ */
+ public void visit(SimpleExp n);
+
+ /**
+ * f0 -> "TEMP"
+ * f1 -> IntegerLiteral()
+ */
+ public void visit(Temp n);
+
+ /**
+ * f0 -> <INTEGER_LITERAL>
+ */
+ public void visit(IntegerLiteral n);
+
+ /**
+ * f0 -> <IDENTIFIER>
+ */
+ public void visit(Label n);
+
+}
+