From: <fwi...@us...> - 2009-01-12 01:21:50
|
Revision: 5922 http://jython.svn.sourceforge.net/jython/?rev=5922&view=rev Author: fwierzbicki Date: 2009-01-12 01:21:45 +0000 (Mon, 12 Jan 2009) Log Message: ----------- added test_nocond and lambdef_nocond rules. Modified Paths: -------------- branches/jy3k/grammar/Python.g Modified: branches/jy3k/grammar/Python.g =================================================================== --- branches/jy3k/grammar/Python.g 2009-01-11 22:36:00 UTC (rev 5921) +++ branches/jy3k/grammar/Python.g 2009-01-12 01:21:45 UTC (rev 5922) @@ -1006,6 +1006,11 @@ | lambdef ; +test_nocond[expr_contextType ctype] + : or_test[ctype] + | lambdef_nocond + ; + //or_test: and_test ('or' and_test)* or_test[expr_contextType ctype] @after { @@ -1375,6 +1380,24 @@ } ; +//lambdef_nocond: 'lambda' [varargslist] ':' test_nocond +lambdef_nocond +@init { + expr etype = null; +} +@after { + $lambdef_nocond.tree = etype; +} + : LAMBDA (varargslist)? COLON test_nocond[expr_contextType.Load] + { + arguments a = $varargslist.args; + if (a == null) { + a = new arguments($LAMBDA, new ArrayList<arg>(), null, null, new ArrayList<arg>(), null, null, new ArrayList<expr>(), new ArrayList<expr>()); + } + etype = new Lambda($LAMBDA, a, actions.castExpr($test_nocond.tree)); + } + ; + //trailer: '(' [arglist] ')' | '[' subscriptlist ']' | '.' NAME trailer [Token begin, PythonTree tree] : LPAREN @@ -1616,9 +1639,9 @@ //comp_if: 'if' test_nocond [comp_iter] comp_if[List gens, List ifs] - : IF test[expr_contextType.Load] comp_iter[gens, ifs]? + : IF test_nocond[expr_contextType.Load] comp_iter[gens, ifs]? { - ifs.add(actions.castExpr($test.tree)); + ifs.add(actions.castExpr($test_nocond.tree)); } ; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |