From: <fwi...@us...> - 2008-08-20 14:06:33
|
Revision: 5217 http://jython.svn.sourceforge.net/jython/?rev=5217&view=rev Author: fwierzbicki Date: 2008-08-20 14:06:30 +0000 (Wed, 20 Aug 2008) Log Message: ----------- Fix "del". Modified Paths: -------------- branches/nowalker/grammar/Python.g Modified: branches/nowalker/grammar/Python.g =================================================================== --- branches/nowalker/grammar/Python.g 2008-08-20 12:10:26 UTC (rev 5216) +++ branches/nowalker/grammar/Python.g 2008-08-20 14:06:30 UTC (rev 5217) @@ -547,8 +547,8 @@ //del_stmt: 'del' exprlist -del_stmt : DELETE exprlist2 - -> ^(DELETE<Delete>[$DELETE, actions.makeExprs($exprlist2.etypes)]) +del_stmt : DELETE del_list + -> ^(DELETE<Delete>[$DELETE, actions.makeExprs($del_list.etypes)]) ; //pass_stmt: 'pass' @@ -1115,10 +1115,10 @@ } ; -//XXX: I'm hoping I can get rid of this -- but for now I need an exprlist that does not produce tuples +//XXX: I'm hoping I can get rid of this and merge it back with exprlist -- but for now I need an exprlist that does not produce tuples // at least for del_stmt -exprlist2 returns [List etypes] - : e+=expr[expr_contextType.Load] (options {k=2;}: COMMA e+=expr[expr_contextType.Load])* (COMMA)? +del_list returns [List etypes] + : e+=expr[expr_contextType.Del] (options {k=2;}: COMMA e+=expr[expr_contextType.Del])* (COMMA)? {$etypes = $e;} ; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-08-20 14:39:23
|
Revision: 5218 http://jython.svn.sourceforge.net/jython/?rev=5218&view=rev Author: fwierzbicki Date: 2008-08-20 14:39:21 +0000 (Wed, 20 Aug 2008) Log Message: ----------- Dict support. Modified Paths: -------------- branches/nowalker/grammar/Python.g Modified: branches/nowalker/grammar/Python.g =================================================================== --- branches/nowalker/grammar/Python.g 2008-08-20 14:06:30 UTC (rev 5217) +++ branches/nowalker/grammar/Python.g 2008-08-20 14:39:21 UTC (rev 5218) @@ -122,6 +122,7 @@ import org.python.antlr.ast.Context; import org.python.antlr.ast.Continue; import org.python.antlr.ast.Delete; +import org.python.antlr.ast.Dict; import org.python.antlr.ast.excepthandlerType; import org.python.antlr.ast.Exec; import org.python.antlr.ast.Expr; @@ -997,7 +998,11 @@ | -> ^(LBRACK<org.python.antlr.ast.List>[$LBRACK, new exprType[0\], $expr::ctype]) ) RBRACK - | LCURLY (dictmaker)? RCURLY -> ^(Dict LCURLY ^(Elts dictmaker)?) + | LCURLY + (dictmaker -> ^(LCURLY<Dict>[$LCURLY, actions.makeExprs($dictmaker.keys), actions.makeExprs($dictmaker.values)]) + | -> ^(LCURLY<Dict>[$LCURLY, new exprType[0\], new exprType[0\]]) + ) + RCURLY | BACKQUOTE testlist[expr_contextType.Load] BACKQUOTE -> ^(Repr BACKQUOTE testlist) | NAME -> ^(PYNODE<Name>[$NAME, $NAME.text, $expr::ctype]) | INT -> ^(PYNODE<Num>[$INT, actions.makeInt($INT)]) @@ -1123,15 +1128,18 @@ ; //testlist: test (',' test)* [','] -testlist[expr_contextType ctype] returns [exprType etype] +testlist[expr_contextType ctype] +@init { + exprType etype = null; +} @after { - $testlist.tree = $etype; + $testlist.tree = etype; } : (test[expr_contextType.Load] COMMA) => t+=test[ctype] (options {k=2;}: c1=COMMA t+=test[ctype])* (c2=COMMA)? { - $etype = new Tuple($testlist.start, actions.makeExprs($t), ctype); + etype = new Tuple($testlist.start, actions.makeExprs($t), ctype); } | test[ctype] { - $etype = (exprType)$test.tree; + etype = (exprType)$test.tree; } ; @@ -1139,10 +1147,14 @@ //testlist_safe: test [(',' test)+ [',']] //dictmaker: test ':' test (',' test ':' test)* [','] -dictmaker : test[expr_contextType.Load] COLON test[expr_contextType.Load] - (options {k=2;}:COMMA test[expr_contextType.Load] COLON test[expr_contextType.Load])* (COMMA)? - -> test+ - ; +dictmaker returns [List keys, List values] + : 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)? { + $keys = $k; + $values= $v; + } + ; //classdef: 'class' NAME ['(' [testlist] ')'] ':' suite classdef @@ -1153,7 +1165,7 @@ $classdef.tree = stype; } :CLASS NAME (LPAREN testlist[expr_contextType.Load]? RPAREN)? COLON suite { - stype = new ClassDef($CLASS, $NAME.getText(), actions.makeBases($testlist.etype), actions.makeStmts($suite.stmts)); + stype = new ClassDef($CLASS, $NAME.getText(), actions.makeBases((exprType)$testlist.tree), actions.makeStmts($suite.stmts)); } ; @@ -1201,7 +1213,7 @@ //list_for: 'for' exprlist 'in' testlist_safe [list_iter] list_for : FOR exprlist[expr_contextType.Load] IN testlist[expr_contextType.Load] (list_iter)? - -> ^(FOR<comprehensionType>[$FOR, $exprlist.etype, $testlist.etype, null]) + -> ^(FOR<comprehensionType>[$FOR, $exprlist.etype, (exprType)$testlist.tree, null]) ; //list_if: 'if' test [list_iter] @@ -1226,7 +1238,7 @@ //yield_expr: 'yield' [testlist] yield_expr : YIELD testlist[expr_contextType.Load]? - -> ^(YIELD<Yield>[$YIELD, $testlist.etype]) + -> ^(YIELD<Yield>[$YIELD, (exprType)$testlist.tree]) ; //XXX: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-08-20 15:23:16
|
Revision: 5219 http://jython.svn.sourceforge.net/jython/?rev=5219&view=rev Author: fwierzbicki Date: 2008-08-20 15:23:14 +0000 (Wed, 20 Aug 2008) Log Message: ----------- Conditional Expression support. Modified Paths: -------------- branches/nowalker/grammar/Python.g Modified: branches/nowalker/grammar/Python.g =================================================================== --- branches/nowalker/grammar/Python.g 2008-08-20 14:39:21 UTC (rev 5218) +++ branches/nowalker/grammar/Python.g 2008-08-20 15:23:14 UTC (rev 5219) @@ -78,10 +78,6 @@ PYNODE; Interactive; Expression; - Test; - Body; - Dict; - IfExp; Ellipsis; ListComp; Repr; @@ -133,6 +129,7 @@ import org.python.antlr.ast.FunctionDef; import org.python.antlr.ast.Global; import org.python.antlr.ast.If; +import org.python.antlr.ast.IfExp; import org.python.antlr.ast.Import; import org.python.antlr.ast.ImportFrom; import org.python.antlr.ast.Index; @@ -778,8 +775,8 @@ //test: or_test ['if' or_test 'else' test] | lambdef test[expr_contextType ctype] :o1=or_test[ctype] - ( (IF or_test[expr_contextType.Load] ORELSE) => IF o2=or_test[ctype] ORELSE test[expr_contextType.Load] - -> ^(IfExp ^(Test $o2) ^(Body $o1) ^(ORELSE test)) + ( (IF or_test[expr_contextType.Load] ORELSE) => IF o2=or_test[expr_contextType.Load] ORELSE e=test[expr_contextType.Load] + -> ^(IF<IfExp>[$IF, (exprType)$o2.tree, (exprType)$o1.tree, (exprType)$e.tree]) | -> or_test ) | lambdef {debug("parsed lambdef");} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-08-20 15:37:05
|
Revision: 5220 http://jython.svn.sourceforge.net/jython/?rev=5220&view=rev Author: fwierzbicki Date: 2008-08-20 15:37:02 +0000 (Wed, 20 Aug 2008) Log Message: ----------- repr support. Modified Paths: -------------- branches/nowalker/grammar/Python.g Modified: branches/nowalker/grammar/Python.g =================================================================== --- branches/nowalker/grammar/Python.g 2008-08-20 15:23:14 UTC (rev 5219) +++ branches/nowalker/grammar/Python.g 2008-08-20 15:37:02 UTC (rev 5220) @@ -80,7 +80,6 @@ Expression; Ellipsis; ListComp; - Repr; Target; GeneratorExp; Ifs; @@ -88,7 +87,6 @@ GenFor; GenIf; - ListFor; ListIf; } @@ -139,10 +137,11 @@ import org.python.antlr.ast.Module; import org.python.antlr.ast.Name; import org.python.antlr.ast.Num; +import org.python.antlr.ast.operatorType; import org.python.antlr.ast.Pass; import org.python.antlr.ast.Print; import org.python.antlr.ast.Raise; -import org.python.antlr.ast.operatorType; +import org.python.antlr.ast.Repr; import org.python.antlr.ast.Return; import org.python.antlr.ast.Slice; import org.python.antlr.ast.sliceType; @@ -775,7 +774,7 @@ //test: or_test ['if' or_test 'else' test] | lambdef test[expr_contextType ctype] :o1=or_test[ctype] - ( (IF or_test[expr_contextType.Load] ORELSE) => IF o2=or_test[expr_contextType.Load] ORELSE e=test[expr_contextType.Load] + ( (IF or_test[expr_contextType.Load] ORELSE) => IF o2=or_test[ctype] ORELSE e=test[expr_contextType.Load] -> ^(IF<IfExp>[$IF, (exprType)$o2.tree, (exprType)$o1.tree, (exprType)$e.tree]) | -> or_test ) @@ -1000,7 +999,7 @@ | -> ^(LCURLY<Dict>[$LCURLY, new exprType[0\], new exprType[0\]]) ) RCURLY - | BACKQUOTE testlist[expr_contextType.Load] BACKQUOTE -> ^(Repr BACKQUOTE testlist) + | lb=BACKQUOTE testlist[expr_contextType.Load] rb=BACKQUOTE -> ^(BACKQUOTE<Repr>[$lb, (exprType)$testlist.tree]) | NAME -> ^(PYNODE<Name>[$NAME, $NAME.text, $expr::ctype]) | INT -> ^(PYNODE<Num>[$INT, actions.makeInt($INT)]) | LONGINT -> ^(PYNODE<Num>[$LONGINT, actions.makeInt($LONGINT)]) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-08-20 20:59:47
|
Revision: 5226 http://jython.svn.sourceforge.net/jython/?rev=5226&view=rev Author: fwierzbicki Date: 2008-08-20 20:59:44 +0000 (Wed, 20 Aug 2008) Log Message: ----------- gen expressions and list comps now actually work... Modified Paths: -------------- branches/nowalker/grammar/Python.g Modified: branches/nowalker/grammar/Python.g =================================================================== --- branches/nowalker/grammar/Python.g 2008-08-20 20:57:09 UTC (rev 5225) +++ branches/nowalker/grammar/Python.g 2008-08-20 20:59:44 UTC (rev 5226) @@ -78,7 +78,6 @@ PYNODE; Interactive; Expression; - GeneratorExp; } @header { @@ -116,6 +115,7 @@ import org.python.antlr.ast.ExtSlice; import org.python.antlr.ast.For; import org.python.antlr.ast.FunctionDef; +import org.python.antlr.ast.GeneratorExp; import org.python.antlr.ast.Global; import org.python.antlr.ast.If; import org.python.antlr.ast.IfExp; @@ -1026,14 +1026,24 @@ //testlist_gexp: test ( gen_for | (',' test)* [','] ) testlist_gexp @init { + exprType etype = null; List gens = new ArrayList(); } +@after { + if (etype != null) { + $testlist_gexp.tree = etype; + } +} : t+=test[expr_contextType.Load] ( ((options {k=2;}: c1=COMMA t+=test[expr_contextType.Load])* (c2=COMMA)? -> { $c1 != null || $c2 != null }? ^(PYNODE<Tuple>[$testlist_gexp.start, actions.makeExprs($t), $expr::ctype]) -> test ) - | ( gen_for[gens] -> ^(GeneratorExp test gen_for) + | ( gen_for[gens] { + Collections.reverse(gens); + comprehensionType[] c = (comprehensionType[])gens.toArray(new comprehensionType[gens.size()]); + etype = new GeneratorExp($gen_for.start, (exprType)$t.get(0), c); + } ) ) ; @@ -1219,7 +1229,7 @@ //list_for: 'for' exprlist 'in' testlist_safe [list_iter] list_for [List gens] - : FOR exprlist[expr_contextType.Load] IN testlist[expr_contextType.Load] (list_iter[gens])? { + : FOR exprlist[expr_contextType.Store] IN testlist[expr_contextType.Load] (list_iter[gens])? { exprType[] e; if ($list_iter.etype != null) { e = new exprType[]{$list_iter.etype}; @@ -1247,7 +1257,7 @@ //gen_for: 'for' exprlist 'in' or_test [gen_iter] gen_for [List gens] - :FOR exprlist[expr_contextType.Load] IN or_test[expr_contextType.Load] gen_iter[gens]? { + :FOR exprlist[expr_contextType.Store] IN or_test[expr_contextType.Load] gen_iter[gens]? { exprType[] e; if ($gen_iter.etype != null) { e = new exprType[]{$gen_iter.etype}; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-08-24 02:04:46
|
Revision: 5241 http://jython.svn.sourceforge.net/jython/?rev=5241&view=rev Author: fwierzbicki Date: 2008-08-24 02:04:43 +0000 (Sun, 24 Aug 2008) Log Message: ----------- Fix lambda without args. Modified Paths: -------------- branches/nowalker/grammar/Python.g Modified: branches/nowalker/grammar/Python.g =================================================================== --- branches/nowalker/grammar/Python.g 2008-08-23 23:03:59 UTC (rev 5240) +++ branches/nowalker/grammar/Python.g 2008-08-24 02:04:43 UTC (rev 5241) @@ -1092,9 +1092,21 @@ ; //lambdef: 'lambda' [varargslist] ':' test -lambdef: LAMBDA (varargslist)? COLON test[expr_contextType.Load] {debug("parsed lambda");} - -> ^(LAMBDA<Lambda>[$LAMBDA, $varargslist.args, (exprType)$test.tree]) - ; +lambdef +@init { + exprType etype = null; +} +@after { + $lambdef.tree = etype; +} + : LAMBDA (varargslist)? COLON test[expr_contextType.Load] { + argumentsType a = $varargslist.args; + if (a == null) { + a = new argumentsType($LAMBDA, new exprType[0], null, null, new exprType[0]); + } + etype = new Lambda($LAMBDA, a, (exprType)$test.tree); + } + ; //trailer: '(' [arglist] ')' | '[' subscriptlist ']' | '.' NAME trailer [Token begin]: LPAREN (arglist -> ^(LPAREN<Call>[$begin, null, actions.makeExprs($arglist.args), actions.makeKeywords($arglist.keywords), $arglist.starargs, $arglist.kwargs]) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-08-25 21:18:10
|
Revision: 5247 http://jython.svn.sourceforge.net/jython/?rev=5247&view=rev Author: fwierzbicki Date: 2008-08-25 21:18:03 +0000 (Mon, 25 Aug 2008) Log Message: ----------- Fix ** Modified Paths: -------------- branches/nowalker/grammar/Python.g Modified: branches/nowalker/grammar/Python.g =================================================================== --- branches/nowalker/grammar/Python.g 2008-08-25 20:36:04 UTC (rev 5246) +++ branches/nowalker/grammar/Python.g 2008-08-25 21:18:03 UTC (rev 5247) @@ -1021,36 +1021,39 @@ //power: atom trailer* ['**' factor] power returns [exprType etype] @after { - if ($etype != null) { - $power.tree = $etype; - } + $power.tree = $etype; } - : atom (t+=trailer[$atom.start])* (options {greedy=true;}:DOUBLESTAR factor)? { + : atom (t+=trailer[$atom.start])* (options {greedy=true;}:d=DOUBLESTAR factor)? { + //System.out.println("??? " + $d + " ??? " + $factor.tree); + $etype = (exprType)$atom.tree; if ($t != null) { - exprType current = (exprType)$atom.tree; //for(int i = $t.size() - 1; i > -1; i--) { for(int i = 0; i < $t.size(); i++) { Object o = $t.get(i); - if (current instanceof Context) { - ((Context)current).setContext(expr_contextType.Load); + if ($etype instanceof Context) { + ((Context)$etype).setContext(expr_contextType.Load); } //XXX: good place for an interface to avoid all of this instanceof if (o instanceof Call) { Call c = (Call)o; - c.func = current; - current = c; + c.func = $etype; + $etype = c; } else if (o instanceof Subscript) { Subscript c = (Subscript)o; - c.value = current; - current = c; + c.value = $etype; + $etype = c; } else if (o instanceof Attribute) { Attribute c = (Attribute)o; - c.value = current; - current = c; + c.value = $etype; + $etype = c; } } - $etype = (exprType)current; } + if ($d != null) { + List right = new ArrayList(); + right.add($factor.tree); + $etype = actions.makeBinOp($etype, operatorType.Pow, right); + } } ; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-08-26 19:37:36
|
Revision: 5252 http://jython.svn.sourceforge.net/jython/?rev=5252&view=rev Author: fwierzbicki Date: 2008-08-26 19:37:34 +0000 (Tue, 26 Aug 2008) Log Message: ----------- Another expr_contextType adjustment. Modified Paths: -------------- branches/nowalker/grammar/Python.g Modified: branches/nowalker/grammar/Python.g =================================================================== --- branches/nowalker/grammar/Python.g 2008-08-26 16:51:15 UTC (rev 5251) +++ branches/nowalker/grammar/Python.g 2008-08-26 19:37:34 UTC (rev 5252) @@ -1193,7 +1193,7 @@ @after { $listmaker.tree = etype; } - : t+=test[expr_contextType.Load] + : t+=test[$expr::ctype] (list_for[gens] { Collections.reverse(gens); @@ -1201,7 +1201,7 @@ (comprehensionType[])gens.toArray(new comprehensionType[gens.size()]); etype = new ListComp($listmaker.start, (exprType)$t.get(0), c); } - | (options {greedy=true;}:COMMA t+=test[expr_contextType.Load])* + | (options {greedy=true;}:COMMA t+=test[$expr::ctype])* { etype = new org.python.antlr.ast.List($lbrack, actions.makeExprs($t), $expr::ctype); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-08-27 02:47:59
|
Revision: 5256 http://jython.svn.sourceforge.net/jython/?rev=5256&view=rev Author: fwierzbicki Date: 2008-08-27 02:47:56 +0000 (Wed, 27 Aug 2008) Log Message: ----------- whitespace Modified Paths: -------------- branches/nowalker/grammar/Python.g Modified: branches/nowalker/grammar/Python.g =================================================================== --- branches/nowalker/grammar/Python.g 2008-08-27 02:38:35 UTC (rev 5255) +++ branches/nowalker/grammar/Python.g 2008-08-27 02:47:56 UTC (rev 5256) @@ -358,15 +358,16 @@ $decorator.tree = $etype; } : AT dotted_attr - ( LPAREN (arglist - { - $etype = actions.makeCall($LPAREN, $dotted_attr.etype, $arglist.args, - $arglist.keywords, $arglist.starargs, $arglist.kwargs); - } - |{ - $etype = actions.makeCall($LPAREN, $dotted_attr.etype); - } - ) + ( LPAREN + ( arglist + { + $etype = actions.makeCall($LPAREN, $dotted_attr.etype, $arglist.args, $arglist.keywords, + $arglist.starargs, $arglist.kwargs); + } + | { + $etype = actions.makeCall($LPAREN, $dotted_attr.etype); + } + ) RPAREN | { $etype = $dotted_attr.etype; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-08-27 19:51:19
|
Revision: 5258 http://jython.svn.sourceforge.net/jython/?rev=5258&view=rev Author: fwierzbicki Date: 2008-08-27 19:51:16 +0000 (Wed, 27 Aug 2008) Log Message: ----------- for not_test, replacing manual tree construction with ->. Modified Paths: -------------- branches/nowalker/grammar/Python.g Modified: branches/nowalker/grammar/Python.g =================================================================== --- branches/nowalker/grammar/Python.g 2008-08-27 16:07:35 UTC (rev 5257) +++ branches/nowalker/grammar/Python.g 2008-08-27 19:51:16 UTC (rev 5258) @@ -941,16 +941,9 @@ ; //not_test: 'not' not_test | comparison -not_test[expr_contextType ctype] returns [exprType etype] -@after { - if ($etype != null) { - $not_test.tree = $etype; - } -} +not_test[expr_contextType ctype] : NOT nt=not_test[ctype] - { - $etype = new UnaryOp($NOT, unaryopType.Not, (exprType)$nt.tree); - } + -> ^(NOT<UnaryOp>[$NOT, unaryopType.Not, (exprType)$nt.tree]) | comparison[ctype] ; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-08-27 20:09:41
|
Revision: 5259 http://jython.svn.sourceforge.net/jython/?rev=5259&view=rev Author: fwierzbicki Date: 2008-08-27 20:09:39 +0000 (Wed, 27 Aug 2008) Log Message: ----------- TODO comment. Modified Paths: -------------- branches/nowalker/grammar/Python.g Modified: branches/nowalker/grammar/Python.g =================================================================== --- branches/nowalker/grammar/Python.g 2008-08-27 19:51:16 UTC (rev 5258) +++ branches/nowalker/grammar/Python.g 2008-08-27 20:09:39 UTC (rev 5259) @@ -1123,6 +1123,7 @@ } : atom (t+=trailer[$atom.start, $atom.tree])* (options {greedy=true;}:d=DOUBLESTAR factor)? { + //XXX: This could be better. $etype = (exprType)$atom.tree; if ($t != null) { for(int i = 0; i < $t.size(); i++) { @@ -1130,7 +1131,6 @@ if ($etype instanceof Context) { ((Context)$etype).setContext(expr_contextType.Load); } - //XXX: good place for an interface to avoid all of this instanceof if (o instanceof Call) { Call c = (Call)o; c.func = $etype; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-08-27 20:35:56
|
Revision: 5260 http://jython.svn.sourceforge.net/jython/?rev=5260&view=rev Author: fwierzbicki Date: 2008-08-27 20:35:54 +0000 (Wed, 27 Aug 2008) Log Message: ----------- Removed XXX comments that no longer apply (special testlists don't seem to be needed). Removed unused c1 and c2 alias. Modified Paths: -------------- branches/nowalker/grammar/Python.g Modified: branches/nowalker/grammar/Python.g =================================================================== --- branches/nowalker/grammar/Python.g 2008-08-27 20:09:39 UTC (rev 5259) +++ branches/nowalker/grammar/Python.g 2008-08-27 20:35:54 UTC (rev 5260) @@ -1346,8 +1346,8 @@ } ; -//XXX: I'm hoping I can get rid of this and merge it back with exprlist -- but for now I need an exprlist that does not produce tuples -// at least for del_stmt +//not in CPython's Grammar file +//Needed as an exprlist that does not produce tuples for del_stmt. del_list returns [List etypes] : e+=expr[expr_contextType.Del] (options {k=2;}: COMMA e+=expr[expr_contextType.Del])* (COMMA)? { @@ -1364,7 +1364,7 @@ $testlist.tree = etype; } : (test[null] COMMA) - => t+=test[ctype] (options {k=2;}: c1=COMMA t+=test[ctype])* (c2=COMMA)? + => t+=test[ctype] (options {k=2;}: COMMA t+=test[ctype])* (COMMA)? { etype = new Tuple($testlist.start, actions.makeExprs($t), ctype); } @@ -1374,9 +1374,6 @@ } ; -//XXX: -//testlist_safe: test [(',' test)+ [',']] - //dictmaker: test ':' test (',' test ':' test)* [','] dictmaker returns [List keys, List values] : k+=test[expr_contextType.Load] COLON v+=test[expr_contextType.Load] @@ -1529,9 +1526,6 @@ -> ^(YIELD<Yield>[$YIELD, (exprType)$testlist.tree]) ; -//XXX: -//testlist1: test (',' test)* - AS : 'as' ; ASSERT : 'assert' ; BREAK : 'break' ; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-08-27 20:51:23
|
Revision: 5261 http://jython.svn.sourceforge.net/jython/?rev=5261&view=rev Author: fwierzbicki Date: 2008-08-27 20:51:19 +0000 (Wed, 27 Aug 2008) Log Message: ----------- simplify testlist. Modified Paths: -------------- branches/nowalker/grammar/Python.g Modified: branches/nowalker/grammar/Python.g =================================================================== --- branches/nowalker/grammar/Python.g 2008-08-27 20:35:54 UTC (rev 5260) +++ branches/nowalker/grammar/Python.g 2008-08-27 20:51:19 UTC (rev 5261) @@ -1357,21 +1357,10 @@ //testlist: test (',' test)* [','] testlist[expr_contextType ctype] -@init { - exprType etype = null; -} -@after { - $testlist.tree = etype; -} : (test[null] COMMA) => t+=test[ctype] (options {k=2;}: COMMA t+=test[ctype])* (COMMA)? - { - etype = new Tuple($testlist.start, actions.makeExprs($t), ctype); - } + -> ^(COMMA<Tuple>[$testlist.start, actions.makeExprs($t), ctype]) | test[ctype] - { - etype = (exprType)$test.tree; - } ; //dictmaker: test ':' test (',' test ':' test)* [','] This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |