From: <fwi...@us...> - 2008-08-21 03:47:34
|
Revision: 5230 http://jython.svn.sourceforge.net/jython/?rev=5230&view=rev Author: fwierzbicki Date: 2008-08-21 03:47:32 +0000 (Thu, 21 Aug 2008) Log Message: ----------- bugfix on exception and on assign value expr_contextType. Modified Paths: -------------- branches/nowalker/grammar/Python.g branches/nowalker/src/org/python/antlr/GrammarActions.java Modified: branches/nowalker/grammar/Python.g =================================================================== --- branches/nowalker/grammar/Python.g 2008-08-21 03:23:28 UTC (rev 5229) +++ branches/nowalker/grammar/Python.g 2008-08-21 03:47:32 UTC (rev 5230) @@ -754,7 +754,7 @@ ; //except_clause: 'except' [test [',' test]] -except_clause : EXCEPT (t1=test[expr_contextType.Load] (COMMA t2=test[expr_contextType.Load])?)? COLON suite +except_clause : EXCEPT (t1=test[expr_contextType.Load] (COMMA t2=test[expr_contextType.Store])?)? COLON suite -> ^(EXCEPT<excepthandlerType>[$EXCEPT, (exprType)$t1.tree, (exprType)$t2.tree, actions.makeStmts($suite.stmts), $EXCEPT.getLine(), $EXCEPT.getCharPositionInLine()]) ; Modified: branches/nowalker/src/org/python/antlr/GrammarActions.java =================================================================== --- branches/nowalker/src/org/python/antlr/GrammarActions.java 2008-08-21 03:23:28 UTC (rev 5229) +++ branches/nowalker/src/org/python/antlr/GrammarActions.java 2008-08-21 03:47:32 UTC (rev 5230) @@ -2,6 +2,7 @@ import org.antlr.runtime.CommonToken; import org.antlr.runtime.Token; +import org.antlr.runtime.tree.Tree; import org.python.core.Py; import org.python.core.PyComplex; @@ -293,21 +294,18 @@ exprType makeAssignValue(List rhs) { exprType value = (exprType)rhs.get(rhs.size() -1); - maybeSetContext(value, expr_contextType.Load); - if (value instanceof Tuple) { - exprType[] elts = ((Tuple)value).elts; - for (int i=0;i<elts.length;i++) { - maybeSetContext(elts[i], expr_contextType.Load); - } - } + recurseSetContext(value, expr_contextType.Load); return value; } - void maybeSetContext(PythonTree tree, expr_contextType context) { + void recurseSetContext(Tree tree, expr_contextType context) { if (tree instanceof Context) { //XXX: for Tuples, etc -- will need to recursively set to expr_contextType.Load. ((Context)tree).setContext(context); } + for (int i=0; i<tree.getChildCount(); i++) { + recurseSetContext(tree.getChild(i), context); + } } argumentsType makeArgumentsType(Token t, List params, Token snameToken, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |