From: <fwi...@us...> - 2009-01-05 13:16:51
|
Revision: 5848 http://jython.svn.sourceforge.net/jython/?rev=5848&view=rev Author: fwierzbicki Date: 2009-01-05 13:16:44 +0000 (Mon, 05 Jan 2009) Log Message: ----------- Initial switchover to 3.0 Python.asdl. Doesn't compiler yet. Modified Paths: -------------- branches/jy3k/ast/Python.asdl branches/jy3k/grammar/Python.g branches/jy3k/grammar/PythonPartial.g branches/jy3k/src/org/python/antlr/ast/ClassDef.java branches/jy3k/src/org/python/antlr/ast/Ellipsis.java branches/jy3k/src/org/python/antlr/ast/ExceptHandler.java branches/jy3k/src/org/python/antlr/ast/FunctionDef.java branches/jy3k/src/org/python/antlr/ast/Raise.java branches/jy3k/src/org/python/antlr/ast/VisitorBase.java branches/jy3k/src/org/python/antlr/ast/VisitorIF.java branches/jy3k/src/org/python/antlr/ast/arguments.java Added Paths: ----------- branches/jy3k/src/org/python/antlr/ast/Bytes.java branches/jy3k/src/org/python/antlr/ast/DictComp.java branches/jy3k/src/org/python/antlr/ast/Nonlocal.java branches/jy3k/src/org/python/antlr/ast/Set.java branches/jy3k/src/org/python/antlr/ast/SetComp.java branches/jy3k/src/org/python/antlr/ast/Starred.java branches/jy3k/src/org/python/antlr/ast/arg.java Removed Paths: ------------- branches/jy3k/src/org/python/antlr/ast/Exec.java branches/jy3k/src/org/python/antlr/ast/Print.java branches/jy3k/src/org/python/antlr/ast/Repr.java Modified: branches/jy3k/ast/Python.asdl =================================================================== --- branches/jy3k/ast/Python.asdl 2009-01-05 07:12:43 UTC (rev 5847) +++ branches/jy3k/ast/Python.asdl 2009-01-05 13:16:44 UTC (rev 5848) @@ -1,6 +1,6 @@ --- ASDL's five builtin types are identifier, int, string, object, bool +-- ASDL's four builtin types are identifier, int, string, object -module Python version "$Revision: 62047 $" +module Python version "$Revision: 67616 $" { mod = Module(stmt* body) | Interactive(stmt* body) @@ -10,26 +10,27 @@ | Suite(stmt* body) stmt = FunctionDef(identifier name, arguments args, - stmt* body, expr* decorator_list) - | ClassDef(identifier name, expr* bases, stmt* body, expr *decorator_list) + stmt* body, expr* decorator_list, expr? returns) + | ClassDef(identifier name, + expr* bases, + keyword* keywords, + expr? starargs, + expr? kwargs, + stmt* body, + expr *decorator_list) | Return(expr? value) | Delete(expr* targets) | Assign(expr* targets, expr value) | AugAssign(expr target, operator op, expr value) - -- not sure if bool is allowed, can always use int - | Print(expr? dest, expr* values, bool nl) - -- use 'orelse' because else is a keyword in target languages | For(expr target, expr iter, stmt* body, stmt* orelse) | While(expr test, stmt* body, stmt* orelse) | If(expr test, stmt* body, stmt* orelse) | With(expr context_expr, expr? optional_vars, stmt* body) - -- 'type' is a bad name - -- changed to 'type' to excepttype for Jython - | Raise(expr? excepttype, expr? inst, expr? tback) + | Raise(expr? exc, expr? cause) | TryExcept(stmt* body, excepthandler* handlers, stmt* orelse) | TryFinally(stmt* body, stmt* finalbody) | Assert(expr test, expr? msg) @@ -37,12 +38,8 @@ | Import(alias* names) | ImportFrom(identifier module, alias* names, int? level) - -- Doesn't capture requirement that locals must be - -- defined if globals is - -- still supports use as a function! - | Exec(expr body, expr? globals, expr? locals) - | Global(identifier* names) + | Nonlocal(identifier* names) | Expr(expr value) | Pass | Break | Continue @@ -57,7 +54,10 @@ | Lambda(arguments args, expr body) | IfExp(expr test, expr body, expr orelse) | Dict(expr* keys, expr* values) + | Set(expr* elts) | ListComp(expr elt, comprehension* generators) + | SetComp(expr elt, comprehension* generators) + | DictComp(expr key, expr value, comprehension* generators) | GeneratorExp(expr elt, comprehension* generators) -- the grammar constrains where yield expressions can occur | Yield(expr? value) @@ -66,14 +66,16 @@ | Compare(expr left, cmpop* ops, expr* comparators) | Call(expr func, expr* args, keyword* keywords, expr? starargs, expr? kwargs) - | Repr(expr value) | Num(object n) -- a number as a PyObject. | Str(string s) -- need to specify raw, unicode, etc? + | Bytes(string s) + | Ellipsis -- other literals? bools? -- the following expression can appear in assignment context | Attribute(expr value, identifier attr, expr_context ctx) | Subscript(expr value, slice slice, expr_context ctx) + | Starred(expr value, expr_context ctx) | Name(identifier id, expr_context ctx) | List(expr* elts, expr_context ctx) | Tuple(expr* elts, expr_context ctx) @@ -83,7 +85,7 @@ expr_context = Load | Store | Del | AugLoad | AugStore | Param - slice = Ellipsis | Slice(expr? lower, expr? upper, expr? step) + slice = Slice(expr? lower, expr? upper, expr? step) | ExtSlice(slice* dims) | Index(expr value) @@ -100,11 +102,14 @@ -- not sure what to call the first argument for raise and except -- changed to 'type' to excepttype for Jython - excepthandler = ExceptHandler(expr? excepttype, expr? name, stmt* body) + excepthandler = ExceptHandler(expr? excepttype, identifier? name, stmt* body) attributes (int lineno, int col_offset) - arguments = (expr* args, identifier? vararg, - identifier? kwarg, expr* defaults) + arguments = (arg* args, identifier? vararg, expr? varargannotation, + arg* kwonlyargs, identifier? kwarg, + expr? kwargannotation, expr* defaults, + expr* kw_defaults) + arg = (identifier arg, expr? annotation) -- keyword arguments supplied to call keyword = (identifier arg, expr value) @@ -112,3 +117,4 @@ -- import name with optional 'as' alias. alias = (identifier name, identifier? asname) } + Modified: branches/jy3k/grammar/Python.g =================================================================== --- branches/jy3k/grammar/Python.g 2009-01-05 07:12:43 UTC (rev 5847) +++ branches/jy3k/grammar/Python.g 2009-01-05 13:16:44 UTC (rev 5848) @@ -105,7 +105,6 @@ import org.python.antlr.ast.Ellipsis; import org.python.antlr.ast.ErrorMod; import org.python.antlr.ast.ExceptHandler; -import org.python.antlr.ast.Exec; import org.python.antlr.ast.Expr; import org.python.antlr.ast.Expression; import org.python.antlr.ast.expr_contextType; @@ -127,7 +126,6 @@ import org.python.antlr.ast.Num; import org.python.antlr.ast.operatorType; import org.python.antlr.ast.Pass; -import org.python.antlr.ast.Print; import org.python.antlr.ast.Raise; import org.python.antlr.ast.Repr; import org.python.antlr.ast.Return; @@ -393,7 +391,6 @@ | OR | ORELSE | PASS - | PRINT | RAISE | RETURN | TRY @@ -545,13 +542,11 @@ //small_stmt: (expr_stmt | print_stmt | del_stmt | pass_stmt | flow_stmt | // import_stmt | global_stmt | exec_stmt | assert_stmt) small_stmt : expr_stmt - | print_stmt | del_stmt | pass_stmt | flow_stmt | import_stmt | global_stmt - | exec_stmt | assert_stmt ; @@ -615,60 +610,6 @@ | DOUBLESLASHEQUAL {$op = operatorType.FloorDiv;} ; -//print_stmt: 'print' ( [ test (',' test)* [','] ] | -// '>>' test [ (',' test)+ [','] ] ) -print_stmt - : PRINT - (t1=printlist - -> ^(PRINT<Print>[$PRINT, null, actions.castExprs($t1.elts), $t1.newline]) - | RIGHTSHIFT t2=printlist2 - -> ^(PRINT<Print>[$PRINT, actions.castExpr($t2.elts.get(0)), actions.castExprs($t2.elts, 1), $t2.newline]) - | - -> ^(PRINT<Print>[$PRINT, null, new ArrayList<expr>(), false]) - ) - ; - -//not in CPython's Grammar file -printlist returns [boolean newline, List elts] - : (test[null] COMMA) => - t+=test[expr_contextType.Load] (options {k=2;}: COMMA t+=test[expr_contextType.Load])* - (trailcomma=COMMA)? - { - $elts=$t; - if ($trailcomma == null) { - $newline = true; - } else { - $newline = false; - } - } - | t+=test[expr_contextType.Load] - { - $elts=$t; - $newline = true; - } - ; - -//XXX: would be nice if printlist and printlist2 could be merged. -//not in CPython's Grammar file -printlist2 returns [boolean newline, List elts] - : (test[null] COMMA test[null]) => - t+=test[expr_contextType.Load] (options {k=2;}: COMMA t+=test[expr_contextType.Load])* - (trailcomma=COMMA)? - { $elts=$t; - if ($trailcomma == null) { - $newline = true; - } else { - $newline = false; - } - } - | t+=test[expr_contextType.Load] - { - $elts=$t; - $newline = true; - } - ; - - //del_stmt: 'del' exprlist del_stmt : DELETE del_list @@ -807,21 +748,6 @@ -> ^(GLOBAL<Global>[$GLOBAL, actions.makeNames($n)]) ; -//exec_stmt: 'exec' expr ['in' test [',' test]] -exec_stmt -@init { - stmt stype = null; -} -@after { - $exec_stmt.tree = stype; -} - : EXEC expr[expr_contextType.Load] (IN t1=test[expr_contextType.Load] - (COMMA t2=test[expr_contextType.Load])?)? - { - stype = new Exec($EXEC, actions.castExpr($expr.tree), actions.castExpr($t1.tree), actions.castExpr($t2.tree)); - } - ; - //assert_stmt: 'assert' test [',' test] assert_stmt : ASSERT t1=test[expr_contextType.Load] (COMMA t2=test[expr_contextType.Load])? @@ -1619,7 +1545,6 @@ LAMBDA : 'lambda' ; ORELSE : 'else' ; PASS : 'pass' ; -PRINT : 'print' ; RAISE : 'raise' ; RETURN : 'return' ; TRY : 'try' ; Modified: branches/jy3k/grammar/PythonPartial.g =================================================================== --- branches/jy3k/grammar/PythonPartial.g 2009-01-05 07:12:43 UTC (rev 5847) +++ branches/jy3k/grammar/PythonPartial.g 2009-01-05 13:16:44 UTC (rev 5848) @@ -152,13 +152,11 @@ ; small_stmt : expr_stmt - | print_stmt | del_stmt | pass_stmt | flow_stmt | import_stmt | global_stmt - | exec_stmt | assert_stmt ; @@ -196,13 +194,6 @@ | DOUBLESLASHEQUAL ; -print_stmt : PRINT (printlist | RIGHTSHIFT printlist)? - ; - -printlist returns [boolean newline] - : test (options {k=2;}: COMMA test)* (COMMA)? - ; - del_stmt : DELETE exprlist ; @@ -262,9 +253,6 @@ global_stmt : GLOBAL NAME (COMMA NAME)* ; -exec_stmt : EXEC expr (IN test (COMMA test)?)? - ; - assert_stmt : ASSERT test (COMMA test)? ; Added: branches/jy3k/src/org/python/antlr/ast/Bytes.java =================================================================== --- branches/jy3k/src/org/python/antlr/ast/Bytes.java (rev 0) +++ branches/jy3k/src/org/python/antlr/ast/Bytes.java 2009-01-05 13:16:44 UTC (rev 5848) @@ -0,0 +1,147 @@ +// Autogenerated AST node +package org.python.antlr.ast; +import org.antlr.runtime.CommonToken; +import org.antlr.runtime.Token; +import org.python.antlr.AST; +import org.python.antlr.PythonTree; +import org.python.antlr.adapter.AstAdapters; +import org.python.antlr.base.excepthandler; +import org.python.antlr.base.expr; +import org.python.antlr.base.mod; +import org.python.antlr.base.slice; +import org.python.antlr.base.stmt; +import org.python.core.ArgParser; +import org.python.core.AstList; +import org.python.core.Py; +import org.python.core.PyObject; +import org.python.core.PyString; +import org.python.core.PyType; +import org.python.expose.ExposedGet; +import org.python.expose.ExposedMethod; +import org.python.expose.ExposedNew; +import org.python.expose.ExposedSet; +import org.python.expose.ExposedType; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.ArrayList; + +@ExposedType(name = "_ast.Bytes", base = AST.class) +public class Bytes extends expr { +public static final PyType TYPE = PyType.fromClass(Bytes.class); + private Object s; + public Object getInternalS() { + return s; + } + @ExposedGet(name = "s") + public PyObject getS() { + return (PyObject)s; + } + @ExposedSet(name = "s") + public void setS(PyObject s) { + this.s = AstAdapters.py2string(s); + } + + + private final static PyString[] fields = + new PyString[] {new PyString("s")}; + @ExposedGet(name = "_fields") + public PyString[] get_fields() { return fields; } + + private final static PyString[] attributes = + new PyString[] {new PyString("lineno"), new PyString("col_offset")}; + @ExposedGet(name = "_attributes") + public PyString[] get_attributes() { return attributes; } + + public Bytes(PyType subType) { + super(subType); + } + public Bytes() { + this(TYPE); + } + @ExposedNew + @ExposedMethod + public void Bytes___init__(PyObject[] args, String[] keywords) { + ArgParser ap = new ArgParser("Bytes", args, keywords, new String[] + {"s", "lineno", "col_offset"}, 1); + setS(ap.getPyObject(0)); + int lin = ap.getInt(1, -1); + if (lin != -1) { + setLineno(lin); + } + + int col = ap.getInt(2, -1); + if (col != -1) { + setLineno(col); + } + + } + + public Bytes(PyObject s) { + setS(s); + } + + public Bytes(Token token, Object s) { + super(token); + this.s = s; + } + + public Bytes(Integer ttype, Token token, Object s) { + super(ttype, token); + this.s = s; + } + + public Bytes(PythonTree tree, Object s) { + super(tree); + this.s = s; + } + + @ExposedGet(name = "repr") + public String toString() { + return "Bytes"; + } + + public String toStringTree() { + StringBuffer sb = new StringBuffer("Bytes("); + sb.append("s="); + sb.append(dumpThis(s)); + sb.append(","); + sb.append(")"); + return sb.toString(); + } + + public <R> R accept(VisitorIF<R> visitor) throws Exception { + return visitor.visitBytes(this); + } + + public void traverse(VisitorIF visitor) throws Exception { + } + + private int lineno = -1; + @ExposedGet(name = "lineno") + public int getLineno() { + if (lineno != -1) { + return lineno; + } + return getLine(); + } + + @ExposedSet(name = "lineno") + public void setLineno(int num) { + lineno = num; + } + + private int col_offset = -1; + @ExposedGet(name = "col_offset") + public int getCol_offset() { + if (col_offset != -1) { + return col_offset; + } + return getCharPositionInLine(); + } + + @ExposedSet(name = "col_offset") + public void setCol_offset(int num) { + col_offset = num; + } + +} Modified: branches/jy3k/src/org/python/antlr/ast/ClassDef.java =================================================================== --- branches/jy3k/src/org/python/antlr/ast/ClassDef.java 2009-01-05 07:12:43 UTC (rev 5847) +++ branches/jy3k/src/org/python/antlr/ast/ClassDef.java 2009-01-05 13:16:44 UTC (rev 5848) @@ -55,6 +55,45 @@ this.bases = AstAdapters.py2exprList(bases); } + private java.util.List<keyword> keywords; + public java.util.List<keyword> getInternalKeywords() { + return keywords; + } + @ExposedGet(name = "keywords") + public PyObject getKeywords() { + return new AstList(keywords, AstAdapters.keywordAdapter); + } + @ExposedSet(name = "keywords") + public void setKeywords(PyObject keywords) { + this.keywords = AstAdapters.py2keywordList(keywords); + } + + private expr starargs; + public expr getInternalStarargs() { + return starargs; + } + @ExposedGet(name = "starargs") + public PyObject getStarargs() { + return starargs; + } + @ExposedSet(name = "starargs") + public void setStarargs(PyObject starargs) { + this.starargs = AstAdapters.py2expr(starargs); + } + + private expr kwargs; + public expr getInternalKwargs() { + return kwargs; + } + @ExposedGet(name = "kwargs") + public PyObject getKwargs() { + return kwargs; + } + @ExposedSet(name = "kwargs") + public void setKwargs(PyObject kwargs) { + this.kwargs = AstAdapters.py2expr(kwargs); + } + private java.util.List<stmt> body; public java.util.List<stmt> getInternalBody() { return body; @@ -83,7 +122,8 @@ private final static PyString[] fields = - new PyString[] {new PyString("name"), new PyString("bases"), new PyString("body"), new + new PyString[] {new PyString("name"), new PyString("bases"), new PyString("keywords"), new + PyString("starargs"), new PyString("kwargs"), new PyString("body"), new PyString("decorator_list")}; @ExposedGet(name = "_fields") public PyString[] get_fields() { return fields; } @@ -103,32 +143,41 @@ @ExposedMethod public void ClassDef___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("ClassDef", args, keywords, new String[] - {"name", "bases", "body", "decorator_list", "lineno", "col_offset"}, 4); + {"name", "bases", "keywords", "starargs", "kwargs", "body", "decorator_list", "lineno", + "col_offset"}, 7); setName(ap.getPyObject(0)); setBases(ap.getPyObject(1)); - setBody(ap.getPyObject(2)); - setDecorator_list(ap.getPyObject(3)); - int lin = ap.getInt(4, -1); + setKeywords(ap.getPyObject(2)); + setStarargs(ap.getPyObject(3)); + setKwargs(ap.getPyObject(4)); + setBody(ap.getPyObject(5)); + setDecorator_list(ap.getPyObject(6)); + int lin = ap.getInt(7, -1); if (lin != -1) { setLineno(lin); } - int col = ap.getInt(5, -1); + int col = ap.getInt(8, -1); if (col != -1) { setLineno(col); } } - public ClassDef(PyObject name, PyObject bases, PyObject body, PyObject decorator_list) { + public ClassDef(PyObject name, PyObject bases, PyObject keywords, PyObject starargs, PyObject + kwargs, PyObject body, PyObject decorator_list) { setName(name); setBases(bases); + setKeywords(keywords); + setStarargs(starargs); + setKwargs(kwargs); setBody(body); setDecorator_list(decorator_list); } - public ClassDef(Token token, String name, java.util.List<expr> bases, java.util.List<stmt> - body, java.util.List<expr> decorator_list) { + public ClassDef(Token token, String name, java.util.List<expr> bases, java.util.List<keyword> + keywords, expr starargs, expr kwargs, java.util.List<stmt> body, java.util.List<expr> + decorator_list) { super(token); this.name = name; this.bases = bases; @@ -138,6 +187,17 @@ for(PythonTree t : this.bases) { addChild(t); } + this.keywords = keywords; + if (keywords == null) { + this.keywords = new ArrayList<keyword>(); + } + for(PythonTree t : this.keywords) { + addChild(t); + } + this.starargs = starargs; + addChild(starargs); + this.kwargs = kwargs; + addChild(kwargs); this.body = body; if (body == null) { this.body = new ArrayList<stmt>(); @@ -155,7 +215,8 @@ } public ClassDef(Integer ttype, Token token, String name, java.util.List<expr> bases, - java.util.List<stmt> body, java.util.List<expr> decorator_list) { + java.util.List<keyword> keywords, expr starargs, expr kwargs, java.util.List<stmt> body, + java.util.List<expr> decorator_list) { super(ttype, token); this.name = name; this.bases = bases; @@ -165,6 +226,17 @@ for(PythonTree t : this.bases) { addChild(t); } + this.keywords = keywords; + if (keywords == null) { + this.keywords = new ArrayList<keyword>(); + } + for(PythonTree t : this.keywords) { + addChild(t); + } + this.starargs = starargs; + addChild(starargs); + this.kwargs = kwargs; + addChild(kwargs); this.body = body; if (body == null) { this.body = new ArrayList<stmt>(); @@ -181,8 +253,9 @@ } } - public ClassDef(PythonTree tree, String name, java.util.List<expr> bases, java.util.List<stmt> - body, java.util.List<expr> decorator_list) { + public ClassDef(PythonTree tree, String name, java.util.List<expr> bases, + java.util.List<keyword> keywords, expr starargs, expr kwargs, java.util.List<stmt> body, + java.util.List<expr> decorator_list) { super(tree); this.name = name; this.bases = bases; @@ -192,6 +265,17 @@ for(PythonTree t : this.bases) { addChild(t); } + this.keywords = keywords; + if (keywords == null) { + this.keywords = new ArrayList<keyword>(); + } + for(PythonTree t : this.keywords) { + addChild(t); + } + this.starargs = starargs; + addChild(starargs); + this.kwargs = kwargs; + addChild(kwargs); this.body = body; if (body == null) { this.body = new ArrayList<stmt>(); @@ -221,6 +305,15 @@ sb.append("bases="); sb.append(dumpThis(bases)); sb.append(","); + sb.append("keywords="); + sb.append(dumpThis(keywords)); + sb.append(","); + sb.append("starargs="); + sb.append(dumpThis(starargs)); + sb.append(","); + sb.append("kwargs="); + sb.append(dumpThis(kwargs)); + sb.append(","); sb.append("body="); sb.append(dumpThis(body)); sb.append(","); @@ -242,6 +335,16 @@ t.accept(visitor); } } + if (keywords != null) { + for (PythonTree t : keywords) { + if (t != null) + t.accept(visitor); + } + } + if (starargs != null) + starargs.accept(visitor); + if (kwargs != null) + kwargs.accept(visitor); if (body != null) { for (PythonTree t : body) { if (t != null) Added: branches/jy3k/src/org/python/antlr/ast/DictComp.java =================================================================== --- branches/jy3k/src/org/python/antlr/ast/DictComp.java (rev 0) +++ branches/jy3k/src/org/python/antlr/ast/DictComp.java 2009-01-05 13:16:44 UTC (rev 5848) @@ -0,0 +1,225 @@ +// Autogenerated AST node +package org.python.antlr.ast; +import org.antlr.runtime.CommonToken; +import org.antlr.runtime.Token; +import org.python.antlr.AST; +import org.python.antlr.PythonTree; +import org.python.antlr.adapter.AstAdapters; +import org.python.antlr.base.excepthandler; +import org.python.antlr.base.expr; +import org.python.antlr.base.mod; +import org.python.antlr.base.slice; +import org.python.antlr.base.stmt; +import org.python.core.ArgParser; +import org.python.core.AstList; +import org.python.core.Py; +import org.python.core.PyObject; +import org.python.core.PyString; +import org.python.core.PyType; +import org.python.expose.ExposedGet; +import org.python.expose.ExposedMethod; +import org.python.expose.ExposedNew; +import org.python.expose.ExposedSet; +import org.python.expose.ExposedType; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.ArrayList; + +@ExposedType(name = "_ast.DictComp", base = AST.class) +public class DictComp extends expr { +public static final PyType TYPE = PyType.fromClass(DictComp.class); + private expr key; + public expr getInternalKey() { + return key; + } + @ExposedGet(name = "key") + public PyObject getKey() { + return key; + } + @ExposedSet(name = "key") + public void setKey(PyObject key) { + this.key = AstAdapters.py2expr(key); + } + + private expr value; + public expr getInternalValue() { + return value; + } + @ExposedGet(name = "value") + public PyObject getValue() { + return value; + } + @ExposedSet(name = "value") + public void setValue(PyObject value) { + this.value = AstAdapters.py2expr(value); + } + + private java.util.List<comprehension> generators; + public java.util.List<comprehension> getInternalGenerators() { + return generators; + } + @ExposedGet(name = "generators") + public PyObject getGenerators() { + return new AstList(generators, AstAdapters.comprehensionAdapter); + } + @ExposedSet(name = "generators") + public void setGenerators(PyObject generators) { + this.generators = AstAdapters.py2comprehensionList(generators); + } + + + private final static PyString[] fields = + new PyString[] {new PyString("key"), new PyString("value"), new PyString("generators")}; + @ExposedGet(name = "_fields") + public PyString[] get_fields() { return fields; } + + private final static PyString[] attributes = + new PyString[] {new PyString("lineno"), new PyString("col_offset")}; + @ExposedGet(name = "_attributes") + public PyString[] get_attributes() { return attributes; } + + public DictComp(PyType subType) { + super(subType); + } + public DictComp() { + this(TYPE); + } + @ExposedNew + @ExposedMethod + public void DictComp___init__(PyObject[] args, String[] keywords) { + ArgParser ap = new ArgParser("DictComp", args, keywords, new String[] + {"key", "value", "generators", "lineno", "col_offset"}, 3); + setKey(ap.getPyObject(0)); + setValue(ap.getPyObject(1)); + setGenerators(ap.getPyObject(2)); + int lin = ap.getInt(3, -1); + if (lin != -1) { + setLineno(lin); + } + + int col = ap.getInt(4, -1); + if (col != -1) { + setLineno(col); + } + + } + + public DictComp(PyObject key, PyObject value, PyObject generators) { + setKey(key); + setValue(value); + setGenerators(generators); + } + + public DictComp(Token token, expr key, expr value, java.util.List<comprehension> generators) { + super(token); + this.key = key; + addChild(key); + this.value = value; + addChild(value); + this.generators = generators; + if (generators == null) { + this.generators = new ArrayList<comprehension>(); + } + for(PythonTree t : this.generators) { + addChild(t); + } + } + + public DictComp(Integer ttype, Token token, expr key, expr value, java.util.List<comprehension> + generators) { + super(ttype, token); + this.key = key; + addChild(key); + this.value = value; + addChild(value); + this.generators = generators; + if (generators == null) { + this.generators = new ArrayList<comprehension>(); + } + for(PythonTree t : this.generators) { + addChild(t); + } + } + + public DictComp(PythonTree tree, expr key, expr value, java.util.List<comprehension> + generators) { + super(tree); + this.key = key; + addChild(key); + this.value = value; + addChild(value); + this.generators = generators; + if (generators == null) { + this.generators = new ArrayList<comprehension>(); + } + for(PythonTree t : this.generators) { + addChild(t); + } + } + + @ExposedGet(name = "repr") + public String toString() { + return "DictComp"; + } + + public String toStringTree() { + StringBuffer sb = new StringBuffer("DictComp("); + sb.append("key="); + sb.append(dumpThis(key)); + sb.append(","); + sb.append("value="); + sb.append(dumpThis(value)); + sb.append(","); + sb.append("generators="); + sb.append(dumpThis(generators)); + sb.append(","); + sb.append(")"); + return sb.toString(); + } + + public <R> R accept(VisitorIF<R> visitor) throws Exception { + return visitor.visitDictComp(this); + } + + public void traverse(VisitorIF visitor) throws Exception { + if (key != null) + key.accept(visitor); + if (value != null) + value.accept(visitor); + if (generators != null) { + for (PythonTree t : generators) { + if (t != null) + t.accept(visitor); + } + } + } + + private int lineno = -1; + @ExposedGet(name = "lineno") + public int getLineno() { + if (lineno != -1) { + return lineno; + } + return getLine(); + } + + @ExposedSet(name = "lineno") + public void setLineno(int num) { + lineno = num; + } + + private int col_offset = -1; + @ExposedGet(name = "col_offset") + public int getCol_offset() { + if (col_offset != -1) { + return col_offset; + } + return getCharPositionInLine(); + } + + @ExposedSet(name = "col_offset") + public void setCol_offset(int num) { + col_offset = num; + } + +} Modified: branches/jy3k/src/org/python/antlr/ast/Ellipsis.java =================================================================== --- branches/jy3k/src/org/python/antlr/ast/Ellipsis.java 2009-01-05 07:12:43 UTC (rev 5847) +++ branches/jy3k/src/org/python/antlr/ast/Ellipsis.java 2009-01-05 13:16:44 UTC (rev 5848) @@ -26,14 +26,15 @@ import java.util.ArrayList; @ExposedType(name = "_ast.Ellipsis", base = AST.class) -public class Ellipsis extends slice { +public class Ellipsis extends expr { public static final PyType TYPE = PyType.fromClass(Ellipsis.class); private final static PyString[] fields = new PyString[0]; @ExposedGet(name = "_fields") public PyString[] get_fields() { return fields; } - private final static PyString[] attributes = new PyString[0]; + private final static PyString[] attributes = + new PyString[] {new PyString("lineno"), new PyString("col_offset")}; @ExposedGet(name = "_attributes") public PyString[] get_attributes() { return attributes; } @@ -44,7 +45,17 @@ @ExposedMethod public void Ellipsis___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("Ellipsis", args, keywords, new String[] - {}, 0); + {"lineno", "col_offset"}, 0); + int lin = ap.getInt(0, -1); + if (lin != -1) { + setLineno(lin); + } + + int col = ap.getInt(1, -1); + if (col != -1) { + setLineno(col); + } + } public Ellipsis() { @@ -80,4 +91,32 @@ public void traverse(VisitorIF visitor) throws Exception { } + private int lineno = -1; + @ExposedGet(name = "lineno") + public int getLineno() { + if (lineno != -1) { + return lineno; + } + return getLine(); + } + + @ExposedSet(name = "lineno") + public void setLineno(int num) { + lineno = num; + } + + private int col_offset = -1; + @ExposedGet(name = "col_offset") + public int getCol_offset() { + if (col_offset != -1) { + return col_offset; + } + return getCharPositionInLine(); + } + + @ExposedSet(name = "col_offset") + public void setCol_offset(int num) { + col_offset = num; + } + } Modified: branches/jy3k/src/org/python/antlr/ast/ExceptHandler.java =================================================================== --- branches/jy3k/src/org/python/antlr/ast/ExceptHandler.java 2009-01-05 07:12:43 UTC (rev 5847) +++ branches/jy3k/src/org/python/antlr/ast/ExceptHandler.java 2009-01-05 13:16:44 UTC (rev 5848) @@ -41,17 +41,18 @@ this.excepttype = AstAdapters.py2expr(excepttype); } - private expr name; - public expr getInternalName() { + private String name; + public String getInternalName() { return name; } @ExposedGet(name = "name") public PyObject getName() { - return name; + if (name == null) return Py.None; + return new PyString(name); } @ExposedSet(name = "name") public void setName(PyObject name) { - this.name = AstAdapters.py2expr(name); + this.name = AstAdapters.py2identifier(name); } private java.util.List<stmt> body; @@ -110,12 +111,11 @@ setBody(body); } - public ExceptHandler(Token token, expr excepttype, expr name, java.util.List<stmt> body) { + public ExceptHandler(Token token, expr excepttype, String name, java.util.List<stmt> body) { super(token); this.excepttype = excepttype; addChild(excepttype); this.name = name; - addChild(name); this.body = body; if (body == null) { this.body = new ArrayList<stmt>(); @@ -125,13 +125,12 @@ } } - public ExceptHandler(Integer ttype, Token token, expr excepttype, expr name, + public ExceptHandler(Integer ttype, Token token, expr excepttype, String name, java.util.List<stmt> body) { super(ttype, token); this.excepttype = excepttype; addChild(excepttype); this.name = name; - addChild(name); this.body = body; if (body == null) { this.body = new ArrayList<stmt>(); @@ -141,12 +140,11 @@ } } - public ExceptHandler(PythonTree tree, expr excepttype, expr name, java.util.List<stmt> body) { + public ExceptHandler(PythonTree tree, expr excepttype, String name, java.util.List<stmt> body) { super(tree); this.excepttype = excepttype; addChild(excepttype); this.name = name; - addChild(name); this.body = body; if (body == null) { this.body = new ArrayList<stmt>(); @@ -183,8 +181,6 @@ public void traverse(VisitorIF visitor) throws Exception { if (excepttype != null) excepttype.accept(visitor); - if (name != null) - name.accept(visitor); if (body != null) { for (PythonTree t : body) { if (t != null) Deleted: branches/jy3k/src/org/python/antlr/ast/Exec.java =================================================================== --- branches/jy3k/src/org/python/antlr/ast/Exec.java 2009-01-05 07:12:43 UTC (rev 5847) +++ branches/jy3k/src/org/python/antlr/ast/Exec.java 2009-01-05 13:16:44 UTC (rev 5848) @@ -1,204 +0,0 @@ -// Autogenerated AST node -package org.python.antlr.ast; -import org.antlr.runtime.CommonToken; -import org.antlr.runtime.Token; -import org.python.antlr.AST; -import org.python.antlr.PythonTree; -import org.python.antlr.adapter.AstAdapters; -import org.python.antlr.base.excepthandler; -import org.python.antlr.base.expr; -import org.python.antlr.base.mod; -import org.python.antlr.base.slice; -import org.python.antlr.base.stmt; -import org.python.core.ArgParser; -import org.python.core.AstList; -import org.python.core.Py; -import org.python.core.PyObject; -import org.python.core.PyString; -import org.python.core.PyType; -import org.python.expose.ExposedGet; -import org.python.expose.ExposedMethod; -import org.python.expose.ExposedNew; -import org.python.expose.ExposedSet; -import org.python.expose.ExposedType; -import java.io.DataOutputStream; -import java.io.IOException; -import java.util.ArrayList; - -@ExposedType(name = "_ast.Exec", base = AST.class) -public class Exec extends stmt { -public static final PyType TYPE = PyType.fromClass(Exec.class); - private expr body; - public expr getInternalBody() { - return body; - } - @ExposedGet(name = "body") - public PyObject getBody() { - return body; - } - @ExposedSet(name = "body") - public void setBody(PyObject body) { - this.body = AstAdapters.py2expr(body); - } - - private expr globals; - public expr getInternalGlobals() { - return globals; - } - @ExposedGet(name = "globals") - public PyObject getGlobals() { - return globals; - } - @ExposedSet(name = "globals") - public void setGlobals(PyObject globals) { - this.globals = AstAdapters.py2expr(globals); - } - - private expr locals; - public expr getInternalLocals() { - return locals; - } - @ExposedGet(name = "locals") - public PyObject getLocals() { - return locals; - } - @ExposedSet(name = "locals") - public void setLocals(PyObject locals) { - this.locals = AstAdapters.py2expr(locals); - } - - - private final static PyString[] fields = - new PyString[] {new PyString("body"), new PyString("globals"), new PyString("locals")}; - @ExposedGet(name = "_fields") - public PyString[] get_fields() { return fields; } - - private final static PyString[] attributes = - new PyString[] {new PyString("lineno"), new PyString("col_offset")}; - @ExposedGet(name = "_attributes") - public PyString[] get_attributes() { return attributes; } - - public Exec(PyType subType) { - super(subType); - } - public Exec() { - this(TYPE); - } - @ExposedNew - @ExposedMethod - public void Exec___init__(PyObject[] args, String[] keywords) { - ArgParser ap = new ArgParser("Exec", args, keywords, new String[] - {"body", "globals", "locals", "lineno", "col_offset"}, 3); - setBody(ap.getPyObject(0)); - setGlobals(ap.getPyObject(1)); - setLocals(ap.getPyObject(2)); - int lin = ap.getInt(3, -1); - if (lin != -1) { - setLineno(lin); - } - - int col = ap.getInt(4, -1); - if (col != -1) { - setLineno(col); - } - - } - - public Exec(PyObject body, PyObject globals, PyObject locals) { - setBody(body); - setGlobals(globals); - setLocals(locals); - } - - public Exec(Token token, expr body, expr globals, expr locals) { - super(token); - this.body = body; - addChild(body); - this.globals = globals; - addChild(globals); - this.locals = locals; - addChild(locals); - } - - public Exec(Integer ttype, Token token, expr body, expr globals, expr locals) { - super(ttype, token); - this.body = body; - addChild(body); - this.globals = globals; - addChild(globals); - this.locals = locals; - addChild(locals); - } - - public Exec(PythonTree tree, expr body, expr globals, expr locals) { - super(tree); - this.body = body; - addChild(body); - this.globals = globals; - addChild(globals); - this.locals = locals; - addChild(locals); - } - - @ExposedGet(name = "repr") - public String toString() { - return "Exec"; - } - - public String toStringTree() { - StringBuffer sb = new StringBuffer("Exec("); - sb.append("body="); - sb.append(dumpThis(body)); - sb.append(","); - sb.append("globals="); - sb.append(dumpThis(globals)); - sb.append(","); - sb.append("locals="); - sb.append(dumpThis(locals)); - sb.append(","); - sb.append(")"); - return sb.toString(); - } - - public <R> R accept(VisitorIF<R> visitor) throws Exception { - return visitor.visitExec(this); - } - - public void traverse(VisitorIF visitor) throws Exception { - if (body != null) - body.accept(visitor); - if (globals != null) - globals.accept(visitor); - if (locals != null) - locals.accept(visitor); - } - - private int lineno = -1; - @ExposedGet(name = "lineno") - public int getLineno() { - if (lineno != -1) { - return lineno; - } - return getLine(); - } - - @ExposedSet(name = "lineno") - public void setLineno(int num) { - lineno = num; - } - - private int col_offset = -1; - @ExposedGet(name = "col_offset") - public int getCol_offset() { - if (col_offset != -1) { - return col_offset; - } - return getCharPositionInLine(); - } - - @ExposedSet(name = "col_offset") - public void setCol_offset(int num) { - col_offset = num; - } - -} Modified: branches/jy3k/src/org/python/antlr/ast/FunctionDef.java =================================================================== --- branches/jy3k/src/org/python/antlr/ast/FunctionDef.java 2009-01-05 07:12:43 UTC (rev 5847) +++ branches/jy3k/src/org/python/antlr/ast/FunctionDef.java 2009-01-05 13:16:44 UTC (rev 5848) @@ -81,10 +81,23 @@ this.decorator_list = AstAdapters.py2exprList(decorator_list); } + private expr returns; + public expr getInternalReturns() { + return returns; + } + @ExposedGet(name = "returns") + public PyObject getReturns() { + return returns; + } + @ExposedSet(name = "returns") + public void setReturns(PyObject returns) { + this.returns = AstAdapters.py2expr(returns); + } + private final static PyString[] fields = new PyString[] {new PyString("name"), new PyString("args"), new PyString("body"), new - PyString("decorator_list")}; + PyString("decorator_list"), new PyString("returns")}; @ExposedGet(name = "_fields") public PyString[] get_fields() { return fields; } @@ -103,32 +116,35 @@ @ExposedMethod public void FunctionDef___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("FunctionDef", args, keywords, new String[] - {"name", "args", "body", "decorator_list", "lineno", "col_offset"}, 4); + {"name", "args", "body", "decorator_list", "returns", "lineno", "col_offset"}, 5); setName(ap.getPyObject(0)); setArgs(ap.getPyObject(1)); setBody(ap.getPyObject(2)); setDecorator_list(ap.getPyObject(3)); - int lin = ap.getInt(4, -1); + setReturns(ap.getPyObject(4)); + int lin = ap.getInt(5, -1); if (lin != -1) { setLineno(lin); } - int col = ap.getInt(5, -1); + int col = ap.getInt(6, -1); if (col != -1) { setLineno(col); } } - public FunctionDef(PyObject name, PyObject args, PyObject body, PyObject decorator_list) { + public FunctionDef(PyObject name, PyObject args, PyObject body, PyObject decorator_list, + PyObject returns) { setName(name); setArgs(args); setBody(body); setDecorator_list(decorator_list); + setReturns(returns); } public FunctionDef(Token token, String name, arguments args, java.util.List<stmt> body, - java.util.List<expr> decorator_list) { + java.util.List<expr> decorator_list, expr returns) { super(token); this.name = name; this.args = args; @@ -146,10 +162,12 @@ for(PythonTree t : this.decorator_list) { addChild(t); } + this.returns = returns; + addChild(returns); } public FunctionDef(Integer ttype, Token token, String name, arguments args, - java.util.List<stmt> body, java.util.List<expr> decorator_list) { + java.util.List<stmt> body, java.util.List<expr> decorator_list, expr returns) { super(ttype, token); this.name = name; this.args = args; @@ -167,10 +185,12 @@ for(PythonTree t : this.decorator_list) { addChild(t); } + this.returns = returns; + addChild(returns); } public FunctionDef(PythonTree tree, String name, arguments args, java.util.List<stmt> body, - java.util.List<expr> decorator_list) { + java.util.List<expr> decorator_list, expr returns) { super(tree); this.name = name; this.args = args; @@ -188,6 +208,8 @@ for(PythonTree t : this.decorator_list) { addChild(t); } + this.returns = returns; + addChild(returns); } @ExposedGet(name = "repr") @@ -209,6 +231,9 @@ sb.append("decorator_list="); sb.append(dumpThis(decorator_list)); sb.append(","); + sb.append("returns="); + sb.append(dumpThis(returns)); + sb.append(","); sb.append(")"); return sb.toString(); } @@ -232,6 +257,8 @@ t.accept(visitor); } } + if (returns != null) + returns.accept(visitor); } private int lineno = -1; Added: branches/jy3k/src/org/python/antlr/ast/Nonlocal.java =================================================================== --- branches/jy3k/src/org/python/antlr/ast/Nonlocal.java (rev 0) +++ branches/jy3k/src/org/python/antlr/ast/Nonlocal.java 2009-01-05 13:16:44 UTC (rev 5848) @@ -0,0 +1,147 @@ +// Autogenerated AST node +package org.python.antlr.ast; +import org.antlr.runtime.CommonToken; +import org.antlr.runtime.Token; +import org.python.antlr.AST; +import org.python.antlr.PythonTree; +import org.python.antlr.adapter.AstAdapters; +import org.python.antlr.base.excepthandler; +import org.python.antlr.base.expr; +import org.python.antlr.base.mod; +import org.python.antlr.base.slice; +import org.python.antlr.base.stmt; +import org.python.core.ArgParser; +import org.python.core.AstList; +import org.python.core.Py; +import org.python.core.PyObject; +import org.python.core.PyString; +import org.python.core.PyType; +import org.python.expose.ExposedGet; +import org.python.expose.ExposedMethod; +import org.python.expose.ExposedNew; +import org.python.expose.ExposedSet; +import org.python.expose.ExposedType; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.ArrayList; + +@ExposedType(name = "_ast.Nonlocal", base = AST.class) +public class Nonlocal extends stmt { +public static final PyType TYPE = PyType.fromClass(Nonlocal.class); + private java.util.List<String> names; + public java.util.List<String> getInternalNames() { + return names; + } + @ExposedGet(name = "names") + public PyObject getNames() { + return new AstList(names, AstAdapters.identifierAdapter); + } + @ExposedSet(name = "names") + public void setNames(PyObject names) { + this.names = AstAdapters.py2identifierList(names); + } + + + private final static PyString[] fields = + new PyString[] {new PyString("names")}; + @ExposedGet(name = "_fields") + public PyString[] get_fields() { return fields; } + + private final static PyString[] attributes = + new PyString[] {new PyString("lineno"), new PyString("col_offset")}; + @ExposedGet(name = "_attributes") + public PyString[] get_attributes() { return attributes; } + + public Nonlocal(PyType subType) { + super(subType); + } + public Nonlocal() { + this(TYPE); + } + @ExposedNew + @ExposedMethod + public void Nonlocal___init__(PyObject[] args, String[] keywords) { + ArgParser ap = new ArgParser("Nonlocal", args, keywords, new String[] + {"names", "lineno", "col_offset"}, 1); + setNames(ap.getPyObject(0)); + int lin = ap.getInt(1, -1); + if (lin != -1) { + setLineno(lin); + } + + int col = ap.getInt(2, -1); + if (col != -1) { + setLineno(col); + } + + } + + public Nonlocal(PyObject names) { + setNames(names); + } + + public Nonlocal(Token token, java.util.List<String> names) { + super(token); + this.names = names; + } + + public Nonlocal(Integer ttype, Token token, java.util.List<String> names) { + super(ttype, token); + this.names = names; + } + + public Nonlocal(PythonTree tree, java.util.List<String> names) { + super(tree); + this.names = names; + } + + @ExposedGet(name = "repr") + public String toString() { + return "Nonlocal"; + } + + public String toStringTree() { + StringBuffer sb = new StringBuffer("Nonlocal("); + sb.append("names="); + sb.append(dumpThis(names)); + sb.append(","); + sb.append(")"); + return sb.toString(); + } + + public <R> R accept(VisitorIF<R> visitor) throws Exception { + return visitor.visitNonlocal(this); + } + + public void traverse(VisitorIF visitor) throws Exception { + } + + private int lineno = -1; + @ExposedGet(name = "lineno") + public int getLineno() { + if (lineno != -1) { + return lineno; + } + return getLine(); + } + + @ExposedSet(name = "lineno") + public void setLineno(int num) { + lineno = num; + } + + private int col_offset = -1; + @ExposedGet(name = "col_offset") + public int getCol_offset() { + if (col_offset != -1) { + return col_offset; + } + return getCharPositionInLine(); + } + + @ExposedSet(name = "col_offset") + public void setCol_offset(int num) { + col_offset = num; + } + +} Deleted: branches/jy3k/src/org/python/antlr/ast/Print.java =================================================================== --- branches/jy3k/src/org/python/antlr/ast/Print.java 2009-01-05 07:12:43 UTC (rev 5847) +++ branches/jy3k/src/org/python/antlr/ast/Print.java 2009-01-05 13:16:44 UTC (rev 5848) @@ -1,219 +0,0 @@ -// Autogenerated AST node -package org.python.antlr.ast; -import org.antlr.runtime.CommonToken; -import org.antlr.runtime.Token; -import org.python.antlr.AST; -import org.python.antlr.PythonTree; -import org.python.antlr.adapter.AstAdapters; -import org.python.antlr.base.excepthandler; -import org.python.antlr.base.expr; -import org.python.antlr.base.mod; -import org.python.antlr.base.slice; -import org.python.antlr.base.stmt; -import org.python.core.ArgParser; -import org.python.core.AstList; -import org.python.core.Py; -import org.python.core.PyObject; -import org.python.core.PyString; -import org.python.core.PyType; -import org.python.expose.ExposedGet; -import org.python.expose.ExposedMethod; -import org.python.expose.ExposedNew; -import org.python.expose.ExposedSet; -import org.python.expose.ExposedType; -import java.io.DataOutputStream; -import java.io.IOException; -import java.util.ArrayList; - -@ExposedType(name = "_ast.Print", base = AST.class) -public class Print extends stmt { -public static final PyType TYPE = PyType.fromClass(Print.class); - private expr dest; - public expr getInternalDest() { - return dest; - } - @ExposedGet(name = "dest") - public PyObject getDest() { - return dest; - } - @ExposedSet(name = "dest") - public void setDest(PyObject dest) { - this.dest = AstAdapters.py2expr(dest); - } - - private java.util.List<expr> values; - public java.util.List<expr> getInternalValues() { - return values; - } - @ExposedGet(name = "values") - public PyObject getValues() { - return new AstList(values, AstAdapters.exprAdapter); - } - @ExposedSet(name = "values") - public void setValues(PyObject values) { - this.values = AstAdapters.py2exprList(values); - } - - private Boolean nl; - public Boolean getInternalNl() { - return nl; - } - @ExposedGet(name = "nl") - public PyObject getNl() { - if (nl) return Py.True; - return Py.False; - } - @ExposedSet(name = "nl") - public void setNl(PyObject nl) { - this.nl = AstAdapters.py2bool(nl); - } - - - private final static PyString[] fields = - new PyString[] {new PyString("dest"), new PyString("values"), new PyString("nl")}; - @ExposedGet(name = "_fields") - public PyString[] get_fields() { return fields; } - - private final static PyString[] attributes = - new PyString[] {new PyString("lineno"), new PyString("col_offset")}; - @ExposedGet(name = "_attributes") - public PyString[] get_attributes() { return attributes; } - - public Print(PyType subType) { - super(subType); - } - public Print() { - this(TYPE); - } - @ExposedNew - @ExposedMethod - public void Print___init__(PyObject[] args, String[] keywords) { - ArgParser ap = new ArgParser("Print", args, keywords, new String[] - {"dest", "values", "nl", "lineno", "col_offset"}, 3); - setDest(ap.getPyObject(0)); - setValues(ap.getPyObject(1)); - setNl(ap.getPyObject(2)); - int lin = ap.getInt(3, -1); - if (lin != -1) { - setLineno(lin); - } - - int col = ap.getInt(4, -1); - if (col != -1) { - setLineno(col); - } - - } - - public Print(PyObject dest, PyObject values, PyObject nl) { - setDest(dest); - setValues(values); - setNl(nl); - } - - public Print(Token token, expr dest, java.util.List<expr> values, Boolean nl) { - super(token); - this.dest = dest; - addChild(dest); - this.values = values; - if (values == null) { - this.values = new ArrayList<expr>(); - } - for(PythonTree t : this.values) { - addChild(t); - } - this.nl = nl; - } - - public Print(Integer ttype, Token token, expr dest, java.util.List<expr> values, Boolean nl) { - super(ttype, token); - this.dest = dest; - addChild(dest); - this.values = values; - if (values == null) { - this.values = new ArrayList<expr>(); - } - for(PythonTree t : this.values) { - addChild(t); - } - this.nl = nl; - } - - public Print(PythonTree tree, expr dest, java.util.List<expr> values, Boolean nl) { - super(tree); - this.dest = dest; - addChild(dest); - this.values = values; - if (values == null) { - this.values = new ArrayList<expr>(); - } - for(PythonTree t : this.values) { - addChild(t); - } - this.nl = nl; - } - - @ExposedGet(name = "repr") - public String toString() { - return "Print"; - } - - public String toStringTree() { - StringBuffer sb = new StringBuffer("Print("); - sb.append("dest="); - sb.append(dumpThis(dest)); - sb.append(","); - sb.append("values="); - sb.append(dumpThis(values)); - sb.append(","); - sb.append("nl="); - sb.append(dumpThis(nl)); - sb.append(","); - sb.append(")"); - return sb.toString(); - } - - public <R> R accept(VisitorIF<R> visitor) throws Exception { - return visitor.visitPrint(this); - } - - public void traverse(VisitorIF visitor) throws Exception { - if (dest != null) - dest.accept(visitor); - if (values != null) { - for (PythonTree t : values) { - if (t != null) - t.accept(visitor); - } - } - } - - private int lineno = -1; - @ExposedGet(name = "lineno") - public int getLineno() { - if (lineno != -1) { - return lineno; - } - return getLine(); - } - - @ExposedSet(name = "lineno") - public void setLineno(int num) { - lineno = num; - } - - private int col_offset = -1; - @ExposedGet(name = "col_offset") - public int getCol_offset() { - if (col_offset != -1) { - return col_offset; - } - return getCharPositionInLine(); - } - - @ExposedSet(name = "col_offset") - public void setCol_offset(int num) { - col_offset = num; - } - -} Modified: branches/jy3k/src/org/python/antlr/ast/Raise.java =================================================================== --- branches/jy3k/src/org/python/antlr/ast/Raise.java 2009-01-05 07:12:43 UTC (rev 5847) +++ branches/jy3k/src/org/python/antlr/ast/Raise.java 2009-01-05 13:16:44 UTC (rev 5848) @@ -28,48 +28,35 @@ @ExposedType(name = "_ast.Raise", base = AST.class) public class Raise extends stmt { public static final PyType TYPE = PyType.fromClass(Raise.class); - private expr excepttype; - public expr getInternalExcepttype() { - return excepttype; + private expr exc; + public expr getInternalExc() { + return exc; } - @ExposedGet(name = "excepttype") - public PyObject getExcepttype() { - return excepttype; + @ExposedGet(name = "exc") + public PyObject getExc() { + return exc; } - @ExposedSet(name = "excepttype") - public void setExcepttype(PyObject excepttype) { - this.excepttype = AstAdapters.py2expr(excepttype); + @ExposedSet(name = "exc") + public void setExc(PyObject exc) { + this.exc = AstAdapters.py2expr(exc); } - private expr inst; - public expr getInternalInst() { - return inst; + private expr cause; + public expr getInternalCause() { + return cause; } - @ExposedGet(name = "inst") - public PyObject getInst() { - return inst; + @ExposedGet(name = "cause") + public PyObject getCause() { + return cause; } - @ExposedSet(name = "inst") - public void setInst(PyObject inst) { - this.inst = AstAdapters.py2expr(inst); + @ExposedSet(name = "cause") + public void setCause(PyObject cause) { + this.cause = AstAdapters.py2expr(cause); } - private expr tback; - public expr getInternalTback() { - return tback; - } - @ExposedGet(name = "tback") - public PyObject getTback() { - return tback; - } - @ExposedSet(name = "tback") - public void setTback(PyObject tback) { - this.tback = AstAdapters.py2expr(tback); - } - private final static PyString[] fields = - new PyString[] {new PyString("excepttype"), new PyString("inst"), new PyString("tback")}; + new PyString[] {new PyString("exc"), new PyString("cause")}; @ExposedGet(name = "_fields") public PyString[] get_fields() { return fields; } @@ -88,56 +75,48 @@ @ExposedMethod public void Raise___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("Raise", args, keywords, new String[] - {"excepttype", "inst", "tback", "lineno", "col_offset"}, 3); - setExcepttype(ap.getPyObject(0)); - setInst(ap.getPyObject(1)); - setTback(ap.getPyObject(2)); - int lin = ap.getInt(3, -1); + {"exc", "cause", "lineno", "col_offset"}, 2); + setExc(ap.getPyObject(0)); + setCause(ap.getPyObject(1)); + int lin = ap.getInt(2, -1); if (lin != -1) { setLineno(lin); } - int col = ap.getInt(4, -1); + int col = ap.getInt(3, -1); if (col != -1) { setLineno(col); } } - public Raise(PyObject excepttype, PyObject inst, PyObject tback) { - setExcepttype(excepttype); - setInst(inst); - setTback(tback); + public Raise(PyObject exc, PyObject cause) { + setExc(exc); + setCause(cause); } - public Raise(Token token, expr excepttype, expr inst, expr tback) { + public Raise(Token token, expr exc, expr cause) { super(token); - this.excepttype = excepttype; - addChild(excepttype); - this.inst = inst; - addChild(inst); - this.tback = tback; - addChild(tback); + this.exc = exc; + addChild(exc); + this.cause = cause; + addChild(cause); } - public Rais... [truncated message content] |