From: <fwi...@us...> - 2009-01-08 21:14:36
|
Revision: 5888 http://jython.svn.sourceforge.net/jython/?rev=5888&view=rev Author: fwierzbicki Date: 2009-01-08 21:14:30 +0000 (Thu, 08 Jan 2009) Log Message: ----------- preparing for more generalized comprehension rules the way Grammar/Grammar in CPython does it in 3.0. Modified Paths: -------------- branches/jy3k/grammar/Python.g Modified: branches/jy3k/grammar/Python.g =================================================================== --- branches/jy3k/grammar/Python.g 2009-01-08 19:53:52 UTC (rev 5887) +++ branches/jy3k/grammar/Python.g 2009-01-08 21:14:30 UTC (rev 5888) @@ -1204,17 +1204,16 @@ } ; -//atom: ('(' [yield_expr|testlist_gexp] ')' | -// '[' [listmaker] ']' | -// '{' [dictmaker] '}' | -// '`' testlist1 '`' | -// NAME | NUMBER | STRING+) +//atom: ('(' [yield_expr|testlist_comp] ')' | +// '[' [testlist_comp] ']' | +// '{' [dictorsetmaker] '}' | +// NAME | NUMBER | STRING+ | '...' | 'None' | 'True' | 'False') atom : LPAREN ( yield_expr -> yield_expr - | testlist_gexp - -> testlist_gexp + | testlist_comp + -> testlist_comp | -> ^(LPAREN<Tuple>[$LPAREN, new ArrayList<expr>(), $expr::ctype]) ) @@ -1271,21 +1270,21 @@ ) (COMMA)? ; -//testlist_gexp: test ( gen_for | (',' test)* [','] ) -testlist_gexp +//testlist_comp: test ( comp_for | (',' test)* [','] ) +testlist_comp @init { expr etype = null; List gens = new ArrayList(); } @after { if (etype != null) { - $testlist_gexp.tree = etype; + $testlist_comp.tree = etype; } } : t+=test[$expr::ctype] ( ((options {k=2;}: c1=COMMA t+=test[$expr::ctype])* (c2=COMMA)? -> { $c1 != null || $c2 != null }? - ^(COMMA<Tuple>[$testlist_gexp.start, actions.castExprs($t), $expr::ctype]) + ^(COMMA<Tuple>[$testlist_comp.start, actions.castExprs($t), $expr::ctype]) -> test ) | (gen_for[gens] @@ -1296,7 +1295,7 @@ if (e instanceof Context) { ((Context)e).setContext(expr_contextType.Load); } - etype = new GeneratorExp($testlist_gexp.start, actions.castExpr($t.get(0)), c); + etype = new GeneratorExp($testlist_comp.start, actions.castExpr($t.get(0)), c); } ) ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |