From: <fwi...@us...> - 2008-04-18 19:03:35
|
Revision: 4355 http://jython.svn.sourceforge.net/jython/?rev=4355&view=rev Author: fwierzbicki Date: 2008-04-18 12:03:31 -0700 (Fri, 18 Apr 2008) Log Message: ----------- Better coverage of _ast. Made AST an interface so that enums (like expr_contextType) can pass instanceof(x, _ast.AST). Modified Paths: -------------- trunk/jython/Lib/_ast.py trunk/jython/ast/asdl_antlr.py trunk/jython/src/org/python/antlr/PythonTree.java trunk/jython/src/org/python/antlr/ast/boolopType.java trunk/jython/src/org/python/antlr/ast/cmpopType.java trunk/jython/src/org/python/antlr/ast/expr_contextType.java trunk/jython/src/org/python/antlr/ast/operatorType.java trunk/jython/src/org/python/antlr/ast/unaryopType.java Added Paths: ----------- trunk/jython/src/org/python/antlr/AST.java Modified: trunk/jython/Lib/_ast.py =================================================================== --- trunk/jython/Lib/_ast.py 2008-04-18 04:05:56 UTC (rev 4354) +++ trunk/jython/Lib/_ast.py 2008-04-18 19:03:31 UTC (rev 4355) @@ -1,9 +1,64 @@ from org.python.antlr.ast.boolopType import And,Or -from org.python.antlr.ast.operatorType import Add,Sub,Mult,Div,FloorDiv,Mod,LShift,RShift,BitOr,BitAnd,BitXor +from org.python.antlr.ast.operatorType import Add,Sub,Mult,Div,FloorDiv,Mod,LShift,RShift,BitOr,BitAnd,BitXor,Pow from org.python.antlr.ast.cmpopType import Eq,Gt,GtE,In,Is,IsNot,Lt,LtE,NotEq,NotIn from org.python.antlr.ast.unaryopType import Invert,Not,UAdd,USub from org.python.core.PyTableCode import PyCF_ONLY_AST +from org.python.antlr.ast.expr_contextType import Load, Store, Del, AugLoad, AugStore, Param +from org.python.antlr import AST + +from org.python.antlr.ast import Assert +from org.python.antlr.ast import Assign +from org.python.antlr.ast import Attribute +from org.python.antlr.ast import AugAssign +from org.python.antlr.ast import BinOp +from org.python.antlr.ast import BoolOp +from org.python.antlr.ast import Break +from org.python.antlr.ast import Call +from org.python.antlr.ast import ClassDef +from org.python.antlr.ast import Compare +from org.python.antlr.ast import Continue +from org.python.antlr.ast import Delete +from org.python.antlr.ast import Dict +from org.python.antlr.ast import Ellipsis +from org.python.antlr.ast import Exec +from org.python.antlr.ast import Expr +from org.python.antlr.ast import Expression +from org.python.antlr.ast import ExtSlice +from org.python.antlr.ast import For +from org.python.antlr.ast import FunctionDef +from org.python.antlr.ast import GeneratorExp +from org.python.antlr.ast import Global +from org.python.antlr.ast import If +from org.python.antlr.ast import IfExp +from org.python.antlr.ast import Import +from org.python.antlr.ast import ImportFrom +from org.python.antlr.ast import Index +from org.python.antlr.ast import Interactive +from org.python.antlr.ast import Lambda +from org.python.antlr.ast import List +from org.python.antlr.ast import ListComp +from org.python.antlr.ast import Module +from org.python.antlr.ast import Name +from org.python.antlr.ast import Num +from org.python.antlr.ast import Pass +from org.python.antlr.ast import Print +from org.python.antlr.ast import Raise +from org.python.antlr.ast import Repr +from org.python.antlr.ast import Return +from org.python.antlr.ast import Slice +from org.python.antlr.ast import Str +from org.python.antlr.ast import Subscript +from org.python.antlr.ast import Suite +from org.python.antlr.ast import TryExcept +from org.python.antlr.ast import TryFinally +from org.python.antlr.ast import Tuple +from org.python.antlr.ast import UnaryOp +#from org.python.antlr.ast import Unicode +from org.python.antlr.ast import While +from org.python.antlr.ast import With +from org.python.antlr.ast import Yield + import org.python.antlr.ast.aliasType as alias import org.python.antlr.ast.argumentsType as arguments import org.python.antlr.ast.boolopType as boolop @@ -18,4 +73,7 @@ import org.python.antlr.ast.sliceType as slice import org.python.antlr.ast.stmtType as stmt import org.python.antlr.ast.unaryopType as unaryop -import org.python.antlr.PythonTree as AST + +#Set to the same value as the CPython version we are targetting. +#note that this number comes from the revision number in CPython's repository. +__version__ = 43614 Modified: trunk/jython/ast/asdl_antlr.py =================================================================== --- trunk/jython/ast/asdl_antlr.py 2008-04-18 04:05:56 UTC (rev 4354) +++ trunk/jython/ast/asdl_antlr.py 2008-04-18 19:03:31 UTC (rev 4355) @@ -139,7 +139,9 @@ def simple_sum(self, sum, name, depth): self.open("%sType" % name, refersToPythonTree=0) - self.emit("public enum %(name)sType {" % locals(), depth) + self.emit('import org.python.antlr.AST;', depth) + self.emit('', 0) + self.emit("public enum %(name)sType implements AST {" % locals(), depth) self.emit("UNDEFINED,", depth + 1) for i in range(len(sum.types)): type = sum.types[i] Added: trunk/jython/src/org/python/antlr/AST.java =================================================================== --- trunk/jython/src/org/python/antlr/AST.java (rev 0) +++ trunk/jython/src/org/python/antlr/AST.java 2008-04-18 19:03:31 UTC (rev 4355) @@ -0,0 +1,3 @@ +package org.python.antlr; + +public interface AST {} Modified: trunk/jython/src/org/python/antlr/PythonTree.java =================================================================== --- trunk/jython/src/org/python/antlr/PythonTree.java 2008-04-18 04:05:56 UTC (rev 4354) +++ trunk/jython/src/org/python/antlr/PythonTree.java 2008-04-18 19:03:31 UTC (rev 4355) @@ -11,7 +11,7 @@ import org.python.antlr.ast.VisitorIF; -public class PythonTree extends CommonTree { +public class PythonTree extends CommonTree implements AST { public PythonTree(Token token) { super(token); Modified: trunk/jython/src/org/python/antlr/ast/boolopType.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/boolopType.java 2008-04-18 04:05:56 UTC (rev 4354) +++ trunk/jython/src/org/python/antlr/ast/boolopType.java 2008-04-18 19:03:31 UTC (rev 4355) @@ -1,7 +1,9 @@ // Autogenerated AST node package org.python.antlr.ast; -public enum boolopType { +import org.python.antlr.AST; + +public enum boolopType implements AST { UNDEFINED, And, Or, Modified: trunk/jython/src/org/python/antlr/ast/cmpopType.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/cmpopType.java 2008-04-18 04:05:56 UTC (rev 4354) +++ trunk/jython/src/org/python/antlr/ast/cmpopType.java 2008-04-18 19:03:31 UTC (rev 4355) @@ -1,7 +1,9 @@ // Autogenerated AST node package org.python.antlr.ast; -public enum cmpopType { +import org.python.antlr.AST; + +public enum cmpopType implements AST { UNDEFINED, Eq, NotEq, Modified: trunk/jython/src/org/python/antlr/ast/expr_contextType.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/expr_contextType.java 2008-04-18 04:05:56 UTC (rev 4354) +++ trunk/jython/src/org/python/antlr/ast/expr_contextType.java 2008-04-18 19:03:31 UTC (rev 4355) @@ -1,7 +1,9 @@ // Autogenerated AST node package org.python.antlr.ast; -public enum expr_contextType { +import org.python.antlr.AST; + +public enum expr_contextType implements AST { UNDEFINED, Load, Store, Modified: trunk/jython/src/org/python/antlr/ast/operatorType.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/operatorType.java 2008-04-18 04:05:56 UTC (rev 4354) +++ trunk/jython/src/org/python/antlr/ast/operatorType.java 2008-04-18 19:03:31 UTC (rev 4355) @@ -1,7 +1,9 @@ // Autogenerated AST node package org.python.antlr.ast; -public enum operatorType { +import org.python.antlr.AST; + +public enum operatorType implements AST { UNDEFINED, Add, Sub, Modified: trunk/jython/src/org/python/antlr/ast/unaryopType.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/unaryopType.java 2008-04-18 04:05:56 UTC (rev 4354) +++ trunk/jython/src/org/python/antlr/ast/unaryopType.java 2008-04-18 19:03:31 UTC (rev 4355) @@ -1,7 +1,9 @@ // Autogenerated AST node package org.python.antlr.ast; -public enum unaryopType { +import org.python.antlr.AST; + +public enum unaryopType implements AST { UNDEFINED, Invert, Not, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |