From: <fwi...@us...> - 2009-01-09 04:24:31
|
Revision: 5897 http://jython.svn.sourceforge.net/jython/?rev=5897&view=rev Author: fwierzbicki Date: 2009-01-09 04:24:28 +0000 (Fri, 09 Jan 2009) Log Message: ----------- dict comprehensions Modified Paths: -------------- branches/jy3k/grammar/Python.g Modified: branches/jy3k/grammar/Python.g =================================================================== --- branches/jy3k/grammar/Python.g 2009-01-09 04:15:14 UTC (rev 5896) +++ branches/jy3k/grammar/Python.g 2009-01-09 04:24:28 UTC (rev 5897) @@ -104,6 +104,7 @@ import org.python.antlr.ast.Continue; import org.python.antlr.ast.Delete; import org.python.antlr.ast.Dict; +import org.python.antlr.ast.DictComp; import org.python.antlr.ast.Ellipsis; import org.python.antlr.ast.ErrorMod; import org.python.antlr.ast.ExceptHandler; @@ -1422,11 +1423,19 @@ } : (test[null] COLON) => k+=test[expr_contextType.Load] COLON v+=test[expr_contextType.Load] - (options {k=2;}:COMMA k+=test[expr_contextType.Load] COLON v+=test[expr_contextType.Load])* - (COMMA)? - { - etype = new Dict($lcurly, actions.castExprs($k), actions.castExprs($v)); - } + (comp_for[gens] + { + Collections.reverse(gens); + List<comprehension> c = gens; + etype = new DictComp($dictorsetmaker.start, actions.castExpr($k.get(0)), + actions.castExpr($v.get(0)),c); + } + | (options {k=2;}:COMMA k+=test[expr_contextType.Load] COLON v+=test[expr_contextType.Load])* + (COMMA)? + { + etype = new Dict($lcurly, actions.castExprs($k), actions.castExprs($v)); + } + ) | t+=test[$expr::ctype] (comp_for[gens] { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |