default         (3d ago)    changes to 'Add out/ directory to .hgignore'

diff --git a/build.xml b/build.xml
--- a/build.xml
+++ b/build.xml
@@ -145,8 +145,7 @@
             <pathelement path="${oracle.jar}" />
             <pathelement path="${extlibs.dir}/mysql-connector-java-5.1.6.jar" />
             <pathelement path="${extlibs.dir}/postgresql-8.3-603.jdbc4.jar" />
-            <pathelement path="${extlibs.dir}/antlr-2.7.7.jar" />
-            <pathelement path="${extlibs.dir}/antlr-3.1.3.jar" />
+            <pathelement path="${extlibs.dir}/antlr-3.5.2-complete.jar" />
             <pathelement path="${extlibs.dir}/stringtemplate-3.2.1.jar" />
             <pathelement path="${extlibs.dir}/commons-compress-1.9.jar"/>
             <pathelement path="${extlibs.dir}/asm-5.0.3.jar" />
@@ -573,7 +572,7 @@
         <taskdef name="jarjar" classname="com.tonicsystems.jarjar.JarJarTask" classpath="extlibs/jarjar-1.4.jar"/>
         <jarjar destfile="${dist.dir}/${jython.deploy.jar}">
             <zipfileset src="${dist.dir}/${jython.dev.jar}"/>
-            <zipfileset src="extlibs/antlr-runtime-3.1.3.jar"/>
+            <zipfileset src="extlibs/antlr-3.5.2-runtime.jar"/>
             <rule pattern="org.antlr.runtime.**" result="org.python.antlr.runtime.@1"/>
             <zipfileset src="extlibs/asm-5.0.3.jar"/>
             <zipfileset src="extlibs/asm-commons-5.0.3.jar"/>
diff --git a/extlibs/antlr-3.1.3.jar b/extlibs/antlr-3.1.3.jar
deleted file mode 100644
index 0ec52f864ebf29a8d3ba8fa21364c3ef687c7fdd..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
diff --git a/extlibs/antlr-3.5.2-complete.jar b/extlibs/antlr-3.5.2-complete.jar
new file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..260de7634889880167e5045e404774f1d3680b04
GIT binary patch
diff --git a/extlibs/antlr-3.5.2-runtime.jar b/extlibs/antlr-3.5.2-runtime.jar
new file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..d48e3e867968c7fe114e45168afb71c9a3cdf124
GIT binary patch
diff --git a/extlibs/antlr-runtime-3.1.3.jar b/extlibs/antlr-runtime-3.1.3.jar
deleted file mode 100644
index b0a9ea69f5c29097145a48c26e127972920db440..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
diff --git a/grammar/Python.g b/grammar/Python.g
--- a/grammar/Python.g
+++ b/grammar/Python.g
@@ -256,7 +256,7 @@
                 if (implicitLineJoiningLevel > 0) {
                     eofWhileNested = true;
                 }
-                return Token.EOF_TOKEN;
+                return getEOFToken();
             }
             try {
                 mTokens();
@@ -282,6 +282,19 @@
             }
         }
     }
+
+	/** Returns the EOF token (default), if you need
+	 *  to return a custom token instead override this method.
+	 */
+	public Token getEOFToken() {
+		Token eof = new CommonToken(input,Token.EOF,
+									Token.DEFAULT_CHANNEL,
+									input.index(),input.index());
+		eof.setLine(getLine());
+		eof.setCharPositionInLine(getCharPositionInLine());
+		return eof;
+	}
+
     @Override
     public void displayRecognitionError(String[] tokenNames, RecognitionException e) {
         //Do nothing. We will handle error display elsewhere.
@@ -994,7 +1007,7 @@
 
 //import_as_names: import_as_name (',' import_as_name)* [',']
 import_as_names
-    returns [List<alias> atypes]
+    returns [List atypes]
     : n+=import_as_name (COMMA! n+=import_as_name)*
     {
         $atypes = $n;
@@ -1028,7 +1041,7 @@
 
 //dotted_as_names: dotted_as_name (',' dotted_as_name)*
 dotted_as_names
-    returns [List<alias> atypes]
+    returns [List atypes]
     : d+=dotted_as_name (COMMA! d+=dotted_as_name)*
     {
         $atypes = $d;
@@ -1037,7 +1050,7 @@
 
 //dotted_name: NAME ('.' NAME)*
 dotted_name
-    returns [List<Name> names]
+    returns [List names]
     : NAME (DOT dn+=attr)*
     {
         $names = actions.makeDottedName($NAME, $dn);
diff --git a/grammar/PythonPartial.g b/grammar/PythonPartial.g
--- a/grammar/PythonPartial.g
+++ b/grammar/PythonPartial.g
@@ -133,7 +133,7 @@
                 if (implicitLineJoiningLevel > 0) {
                     eofWhileNested = true;
                 }
-                return Token.EOF_TOKEN;
+                return getEOFToken();
             }
             try {
                 mTokens();
diff --git a/src/org/python/antlr/GrammarActions.java b/src/org/python/antlr/GrammarActions.java
--- a/src/org/python/antlr/GrammarActions.java
+++ b/src/org/python/antlr/GrammarActions.java
@@ -6,6 +6,7 @@
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Arrays;
 
 import org.antlr.runtime.Token;
 import org.python.antlr.ast.Attribute;
@@ -86,12 +87,12 @@
         return result;
     }
 
-    List<Name> makeDottedName(Token top, List<PythonTree> attrs) {
+    List<Name> makeDottedName(Token top, List attrs) {
       List<Name> result = new ArrayList<Name>();
       result.add(new Name(top, top.getText(), expr_contextType.Load));
       if (attrs != null) {
-        for (PythonTree attr : attrs) {
-          Token token = attr.getToken();
+        for (Object attr : attrs) {
+          Token token = ((PythonTree)attr).getToken();
           result.add(new Name(token, token.getText(), expr_contextType.Load));
         }
       }
@@ -144,10 +145,10 @@
         return new Name(t, t.getText(), expr_contextType.Load);
     }
 
-    List<Name> makeNameNodes(List<Token> names) {
+    List<Name> makeNameNodes(List names) {
         List<Name> s = new ArrayList<Name>();
         for (int i=0; i<names.size(); i++) {
-            s.add(makeNameNode(names.get(i)));
+            s.add(makeNameNode((Token)names.get(i)));
         }
         return s;
     }
@@ -245,11 +246,11 @@
         return new While(t, test, b, o);
     }
 
-    stmt makeWith(Token t, List<With> items, List<stmt> body) {
+    stmt makeWith(Token t, List items, List<stmt> body) {
         int last = items.size() - 1;
         With result = null;
         for (int i = last; i>=0; i--) {
-            With current = items.get(i);
+            With current = (With)items.get(i);
             if (i != last) {
                 body = new ArrayList<stmt>();
                 body.add(result);
@@ -270,9 +271,9 @@
         return new For(t, target, iter, b, o);
     }
 
-    stmt makeTryExcept(Token t, List body, List<excepthandler> handlers, List orelse, List finBody) {
+    stmt makeTryExcept(Token t, List body, List<Object> handlers, List orelse, List finBody) {
         List<stmt> b = castStmts(body);
-        List<excepthandler> e = handlers;
+        List<excepthandler> e = Arrays.asList(handlers.toArray(new excepthandler[handlers.size()]));
         List<stmt> o = castStmts(orelse);
         stmt te = new TryExcept(t, b, e, o);
         if (finBody == null) {
diff --git a/src/org/python/antlr/PythonTokenSource.java b/src/org/python/antlr/PythonTokenSource.java
--- a/src/org/python/antlr/PythonTokenSource.java
+++ b/src/org/python/antlr/PythonTokenSource.java
@@ -171,14 +171,17 @@
             Token prev = stream.LT(-1);
             handleEOF((CommonToken)t, (CommonToken)prev);
             if (!inSingle) {
+                System.out.println(stackString());
+                System.out.println(t);
+                System.out.println(prev);
                 if (prev == null) {
                     generateNewline(t);
                 } else if (prev.getType() == PythonLexer.LEADING_WS) {
                     handleDedents(-1, (CommonToken)t);
                     generateNewline(t);
                 } else if (prev.getType() != PythonLexer.NEWLINE) {
+                    handleDedents(-1, (CommonToken)t);
                     generateNewline(t);
-                    handleDedents(-1, (CommonToken)t);
                 }
             } else {
                 handleDedents(-1, (CommonToken)t);
@@ -276,7 +279,7 @@
                 }
             }
         }
-        List<Token> hiddenTokens = stream.getTokens(lastTokenAddedIndex + 1,t.getTokenIndex() - 1);
+        List<Token> hiddenTokens = (List<Token>)stream.getTokens(lastTokenAddedIndex + 1,t.getTokenIndex() - 1);
         if (hiddenTokens != null) {
             tokens.addAll(hiddenTokens);
         }
diff --git a/src/org/python/indexer/demos/Styler.java b/src/org/python/indexer/demos/Styler.java
--- a/src/org/python/indexer/demos/Styler.java
+++ b/src/org/python/indexer/demos/Styler.java
@@ -151,7 +151,7 @@
             });
 
         Token tok;
-        while ((tok = lex.nextToken()) != Token.EOF_TOKEN) {
+        while ((tok = lex.nextToken()) != lex.getEOFToken()) {
             switch (tok.getType()) {
                 case PythonLexer.STRING: {
                     int beg = ((CommonToken)tok).getStartIndex();
