From: <fwi...@us...> - 2009-01-09 04:15:19
|
Revision: 5896 http://jython.svn.sourceforge.net/jython/?rev=5896&view=rev Author: fwierzbicki Date: 2009-01-09 04:15:14 +0000 (Fri, 09 Jan 2009) Log Message: ----------- Set comprehensions Modified Paths: -------------- branches/jy3k/grammar/Python.g Modified: branches/jy3k/grammar/Python.g =================================================================== --- branches/jy3k/grammar/Python.g 2009-01-09 03:59:16 UTC (rev 5895) +++ branches/jy3k/grammar/Python.g 2009-01-09 04:15:14 UTC (rev 5896) @@ -131,6 +131,7 @@ import org.python.antlr.ast.Raise; import org.python.antlr.ast.Return; import org.python.antlr.ast.Set; +import org.python.antlr.ast.SetComp; import org.python.antlr.ast.Slice; import org.python.antlr.ast.Str; import org.python.antlr.ast.Subscript; @@ -1426,11 +1427,18 @@ { etype = new Dict($lcurly, actions.castExprs($k), actions.castExprs($v)); } - | t+=test[$expr::ctype] (options {greedy=true;}:COMMA t+=test[$expr::ctype])* - (COMMA)? + | t+=test[$expr::ctype] + (comp_for[gens] { + Collections.reverse(gens); + List<comprehension> c = gens; + etype = new SetComp($dictorsetmaker.start, actions.castExpr($t.get(0)), c); + } + | (options {greedy=true;}:COMMA t+=test[$expr::ctype])* (COMMA)? + { etype = new Set($lcurly, actions.castExprs($t)); } + ) ; //classdef: 'class' NAME ['(' [testlist] ')'] ':' suite This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |