From: <fwi...@us...> - 2011-03-30 15:17:34
|
Revision: 7277 http://jython.svn.sourceforge.net/jython/?rev=7277&view=rev Author: fwierzbicki Date: 2011-03-30 15:17:27 +0000 (Wed, 30 Mar 2011) Log Message: ----------- Fix last of the rewrite astions that include -> ^(...) to be regular actions. Modified Paths: -------------- trunk/jython/grammar/Python.g trunk/jython/src/org/python/antlr/ast/Global.java trunk/jython/src/org/python/antlr/ast/ImportFrom.java Modified: trunk/jython/grammar/Python.g =================================================================== --- trunk/jython/grammar/Python.g 2011-03-30 02:58:28 UTC (rev 7276) +++ trunk/jython/grammar/Python.g 2011-03-30 15:17:27 UTC (rev 7277) @@ -901,19 +901,31 @@ //import_from: ('from' ('.'* dotted_name | '.'+) // 'import' ('*' | '(' import_as_names ')' | import_as_names)) import_from +@init { + stmt stype = null; +} +@after { + $import_from.tree = stype; +} : FROM (d+=DOT* dotted_name | d+=DOT+) IMPORT (STAR - -> ^(FROM<ImportFrom>[$FROM, actions.makeFromText($d, $dotted_name.names), - actions.makeModuleNameNode($d, $dotted_name.names), - actions.makeStarAlias($STAR), actions.makeLevel($d)]) + { + stype = new ImportFrom($FROM, actions.makeFromText($d, $dotted_name.names), + actions.makeModuleNameNode($d, $dotted_name.names), + actions.makeStarAlias($STAR), actions.makeLevel($d)); + } | i1=import_as_names - -> ^(FROM<ImportFrom>[$FROM, actions.makeFromText($d, $dotted_name.names), - actions.makeModuleNameNode($d, $dotted_name.names), - actions.makeAliases($i1.atypes), actions.makeLevel($d)]) + { + stype = new ImportFrom($FROM, actions.makeFromText($d, $dotted_name.names), + actions.makeModuleNameNode($d, $dotted_name.names), + actions.makeAliases($i1.atypes), actions.makeLevel($d)); + } | LPAREN i2=import_as_names COMMA? RPAREN - -> ^(FROM<ImportFrom>[$FROM, actions.makeFromText($d, $dotted_name.names), - actions.makeModuleNameNode($d, $dotted_name.names), - actions.makeAliases($i2.atypes), actions.makeLevel($d)]) + { + stype = new ImportFrom($FROM, actions.makeFromText($d, $dotted_name.names), + actions.makeModuleNameNode($d, $dotted_name.names), + actions.makeAliases($i2.atypes), actions.makeLevel($d)); + } ) ; @@ -971,8 +983,16 @@ //global_stmt: 'global' NAME (',' NAME)* global_stmt +@init { + stmt stype = null; +} +@after { + $global_stmt.tree = stype; +} : GLOBAL n+=NAME (COMMA n+=NAME)* - -> ^(GLOBAL<Global>[$GLOBAL, actions.makeNames($n), actions.makeNameNodes($n)]) + { + stype = new Global($GLOBAL, actions.makeNames($n), actions.makeNameNodes($n)); + } ; //exec_stmt: 'exec' expr ['in' test [',' test]] Modified: trunk/jython/src/org/python/antlr/ast/Global.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Global.java 2011-03-30 02:58:28 UTC (rev 7276) +++ trunk/jython/src/org/python/antlr/ast/Global.java 2011-03-30 15:17:27 UTC (rev 7277) @@ -88,8 +88,8 @@ this.names = names; } - public Global(Integer ttype, Token token, java.util.List<String> names, java.util.List<Name> nameNodes) { - super(ttype, token); + public Global(Token token, java.util.List<String> names, java.util.List<Name> nameNodes) { + super(token); this.names = names; this.nameNodes = nameNodes; } Modified: trunk/jython/src/org/python/antlr/ast/ImportFrom.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/ImportFrom.java 2011-03-30 02:58:28 UTC (rev 7276) +++ trunk/jython/src/org/python/antlr/ast/ImportFrom.java 2011-03-30 15:17:27 UTC (rev 7277) @@ -117,10 +117,10 @@ setLevel(level); } - public ImportFrom(int ttype, Token token, + public ImportFrom(Token token, String module, List<Name> moduleNames, List<alias> names, Integer level) { - super(ttype, token); + super(token); this.module = module; this.names = names; if (names == null) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |