From: <fwi...@us...> - 2008-08-25 18:44:52
|
Revision: 5245 http://jython.svn.sourceforge.net/jython/?rev=5245&view=rev Author: fwierzbicki Date: 2008-08-25 18:44:46 +0000 (Mon, 25 Aug 2008) Log Message: ----------- Fix build.xml (oops) Fix Generator Expression assignments and multi-statement simple_stmt. Modified Paths: -------------- branches/nowalker/build.xml branches/nowalker/grammar/Python.g branches/nowalker/src/org/python/antlr/GrammarActions.java Modified: branches/nowalker/build.xml =================================================================== --- branches/nowalker/build.xml 2008-08-25 15:25:24 UTC (rev 5244) +++ branches/nowalker/build.xml 2008-08-25 18:44:46 UTC (rev 5245) @@ -318,7 +318,9 @@ change to grammar files. If you are working on the grammars you might want to comment this out, as a clean is really only needed if you change the tokens defined in Python.g (and cleans make the build slow) --> + <antcall target="clean"/> <!-- force jarjar build --> + <property name="jarjar.needed" value="true" /> </target> <target name ="prepare-output" depends="init,needed-check,clean-if-antlr-needed,make-output-dirs"/> Modified: branches/nowalker/grammar/Python.g =================================================================== --- branches/nowalker/grammar/Python.g 2008-08-25 15:25:24 UTC (rev 5244) +++ branches/nowalker/grammar/Python.g 2008-08-25 18:44:46 UTC (rev 5245) @@ -279,8 +279,18 @@ //file_input: (NEWLINE | stmt)* ENDMARKER file_input - : (NEWLINE | s+=stmt)+ -> ^(PYNODE<Module>[$file_input.start, actions.makeStmts($s)]) - | -> ^(PYNODE<Module>[$file_input.start, new stmtType[0\]]) +@init { + modType mtype = null; + List stypes = new ArrayList(); +} +@after { + $file_input.tree = mtype; +} + : (NEWLINE + | stmt {stypes.addAll($stmt.stypes);} + )* { + mtype = new Module($file_input.start, actions.makeStmts(stypes)); + } ; //eval_input: testlist NEWLINE* ENDMARKER @@ -424,14 +434,21 @@ ; //stmt: simple_stmt | compound_stmt -stmt : simple_stmt - | compound_stmt - ; +stmt returns [List stypes] + : simple_stmt {$stypes = $simple_stmt.stypes;} + | compound_stmt { + $stypes = new ArrayList(); + $stypes.add($compound_stmt.tree); + } + ; //simple_stmt: small_stmt (';' small_stmt)* [';'] NEWLINE -simple_stmt : small_stmt (options {greedy=true;}:SEMI small_stmt)* (SEMI)? NEWLINE - -> small_stmt+ - ; +simple_stmt returns [List stypes] + : s+=small_stmt (options {greedy=true;}:SEMI s+=small_stmt)* (SEMI)? NEWLINE { + $stypes = $s; + } + ; + //small_stmt: (expr_stmt | print_stmt | del_stmt | pass_stmt | flow_stmt | // import_stmt | global_stmt | exec_stmt | assert_stmt) small_stmt : expr_stmt @@ -760,8 +777,13 @@ //suite: simple_stmt | NEWLINE INDENT stmt+ DEDENT suite returns [List stypes] - : ss+=simple_stmt {$stypes = $ss;} - | NEWLINE! INDENT (s+=stmt)+ DEDENT {$stypes = $s;} +@init { + $stypes = new ArrayList(); +} + : simple_stmt {$stypes = $simple_stmt.stypes;} + | NEWLINE! INDENT + (stmt {$stypes.addAll($stmt.stypes);} + )+ DEDENT ; //test: or_test ['if' or_test 'else' test] | lambdef Modified: branches/nowalker/src/org/python/antlr/GrammarActions.java =================================================================== --- branches/nowalker/src/org/python/antlr/GrammarActions.java 2008-08-25 15:25:24 UTC (rev 5244) +++ branches/nowalker/src/org/python/antlr/GrammarActions.java 2008-08-25 18:44:46 UTC (rev 5245) @@ -296,8 +296,11 @@ if (tree instanceof Context) { ((Context)tree).setContext(context); } - for (int i=0; i<tree.getChildCount(); i++) { - if (!(tree instanceof ListComp) && !(tree instanceof GeneratorExp)) { + if (tree instanceof GeneratorExp) { + GeneratorExp g = (GeneratorExp)tree; + recurseSetContext(g.elt, context); + } else if (!(tree instanceof ListComp)) { + for (int i=0; i<tree.getChildCount(); i++) { recurseSetContext(tree.getChild(i), context); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |