summaryrefslogtreecommitdiff
path: root/src/minijava
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 /src/minijava
downloadminijava-748308e11e6791284b302f61e5bc0d99a0957b6a.tar.xz
First commit
Diffstat (limited to 'src/minijava')
-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
77 files changed, 11900 insertions, 0 deletions
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);
+
+}
+