|
From: <fwi...@us...> - 2009-01-05 21:05:09
|
Revision: 5856
http://jython.svn.sourceforge.net/jython/?rev=5856&view=rev
Author: fwierzbicki
Date: 2009-01-05 21:05:05 +0000 (Mon, 05 Jan 2009)
Log Message:
-----------
use text instead of getText() to handle null.
Modified Paths:
--------------
branches/jy3k/grammar/Python.g
Modified: branches/jy3k/grammar/Python.g
===================================================================
--- branches/jy3k/grammar/Python.g 2009-01-05 19:58:51 UTC (rev 5855)
+++ branches/jy3k/grammar/Python.g 2009-01-05 21:05:05 UTC (rev 5856)
@@ -908,7 +908,7 @@
//except_clause: 'except' [test ['as' NAME]]
except_clause
: EXCEPT (test[expr_contextType.Load] (AS NAME)?)? COLON suite[!$suite.isEmpty() && $suite::continueIllegal]
- -> ^(EXCEPT<ExceptHandler>[$EXCEPT, actions.castExpr($test.tree), $NAME.getText(),
+ -> ^(EXCEPT<ExceptHandler>[$EXCEPT, actions.castExpr($test.tree), $NAME.text,
actions.castStmts($suite.stypes)])
;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fwi...@us...> - 2009-01-07 04:01:32
|
Revision: 5861
http://jython.svn.sourceforge.net/jython/?rev=5861&view=rev
Author: fwierzbicki
Date: 2009-01-07 04:01:27 +0000 (Wed, 07 Jan 2009)
Log Message:
-----------
added nonlocal
Modified Paths:
--------------
branches/jy3k/grammar/Python.g
Modified: branches/jy3k/grammar/Python.g
===================================================================
--- branches/jy3k/grammar/Python.g 2009-01-07 01:21:04 UTC (rev 5860)
+++ branches/jy3k/grammar/Python.g 2009-01-07 04:01:27 UTC (rev 5861)
@@ -577,14 +577,15 @@
}
;
-//small_stmt: (expr_stmt | print_stmt | del_stmt | pass_stmt | flow_stmt |
-// import_stmt | global_stmt | assert_stmt)
+//small_stmt: (expr_stmt | del_stmt | pass_stmt | flow_stmt |
+// import_stmt | global_stmt | nonlocal_stmt | assert_stmt)
small_stmt : expr_stmt
| del_stmt
| pass_stmt
| flow_stmt
| import_stmt
| global_stmt
+ | nonlocal_stmt
| assert_stmt
;
@@ -785,6 +786,12 @@
-> ^(GLOBAL<Global>[$GLOBAL, actions.makeNames($n)])
;
+//nonlocal_stmt: 'nonlocal' NAME (',' NAME)*
+nonlocal_stmt
+ : NONLOCAL n+=NAME (COMMA n+=NAME)*
+ -> ^(NONLOCAL<Global>[$NONLOCAL, actions.makeNames($n)])
+ ;
+
//assert_stmt: 'assert' test [',' test]
assert_stmt
: ASSERT t1=test[expr_contextType.Load] (COMMA t2=test[expr_contextType.Load])?
@@ -897,9 +904,9 @@
}
;
-//with_var: ('as' | NAME) expr
+//with_var: 'as' expr
with_var returns [expr etype]
- : (AS | NAME) expr[expr_contextType.Store]
+ : AS expr[expr_contextType.Store]
{
$etype = actions.castExpr($expr.tree);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fwi...@us...> - 2009-01-07 23:57:43
|
Revision: 5871
http://jython.svn.sourceforge.net/jython/?rev=5871&view=rev
Author: fwierzbicki
Date: 2009-01-07 23:57:33 +0000 (Wed, 07 Jan 2009)
Log Message:
-----------
update grammar comments.
Modified Paths:
--------------
branches/jy3k/grammar/Python.g
Modified: branches/jy3k/grammar/Python.g
===================================================================
--- branches/jy3k/grammar/Python.g 2009-01-07 21:21:48 UTC (rev 5870)
+++ branches/jy3k/grammar/Python.g 2009-01-07 23:57:33 UTC (rev 5871)
@@ -430,7 +430,10 @@
}
;
-//funcdef: [decorators] 'def' NAME parameters ':' suite
+//XXX: maybe see if we can factor decorators out like this...
+//decorated: decorators (classdef | funcdef)
+
+//funcdef: 'def' NAME parameters ['->' test] ':' suite
funcdef
@init { stmt stype = null; }
@after { $funcdef.tree = stype; }
@@ -741,7 +744,7 @@
}
;
-//import_as_name: NAME [('as' | NAME) NAME]
+//import_as_name: NAME ['as' NAME]
import_as_name returns [alias atype]
@after {
$import_as_name.tree = $atype;
@@ -795,7 +798,7 @@
-> ^(ASSERT<Assert>[$ASSERT, actions.castExpr($t1.tree), actions.castExpr($t2.tree)])
;
-//compound_stmt: if_stmt | while_stmt | for_stmt | try_stmt | funcdef | classdef
+//compound_stmt: if_stmt | while_stmt | for_stmt | try_stmt | with_stmt | funcdef | classdef | decorated
compound_stmt
: if_stmt
| while_stmt
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fwi...@us...> - 2009-01-08 15:45:34
|
Revision: 5878
http://jython.svn.sourceforge.net/jython/?rev=5878&view=rev
Author: fwierzbicki
Date: 2009-01-08 15:45:27 +0000 (Thu, 08 Jan 2009)
Log Message:
-----------
Better arg parsing.
Modified Paths:
--------------
branches/jy3k/grammar/Python.g
Modified: branches/jy3k/grammar/Python.g
===================================================================
--- branches/jy3k/grammar/Python.g 2009-01-08 07:40:01 UTC (rev 5877)
+++ branches/jy3k/grammar/Python.g 2009-01-08 15:45:27 UTC (rev 5878)
@@ -458,13 +458,13 @@
;
//not in CPython's Grammar file
-tdefparameter[List defaults] returns [arg etype]
+tdefparameter[List defaults] returns [arg atype]
@after {
- $tdefparameter.tree = $etype;
+ $tdefparameter.tree = $atype;
}
: tfpdef[expr_contextType.Param] (ASSIGN test[expr_contextType.Load])?
{
- $etype = actions.castArg($tfpdef.tree);
+ $atype = actions.castArg($tfpdef.tree);
if ($ASSIGN != null) {
defaults.add($test.tree);
} else if (!defaults.isEmpty()) {
@@ -501,18 +501,18 @@
//tfpdef: NAME [':' test]
tfpdef[expr_contextType ctype]
- : NAME (COLON test[ctype])?
- -> ^(NAME<arg>[$NAME, $NAME.text, null])
+ : NAME (COLON test[expr_contextType.Load])?
+ -> ^(NAME<arg>[$NAME, $NAME.text, actions.castExpr($test.tree)])
;
//not in CPython's Grammar file
-vdefparameter[List defaults] returns [expr etype]
+vdefparameter[List defaults] returns [arg atype]
@after {
- $vdefparameter.tree = $etype;
+ $vdefparameter.tree = $atype;
}
: vfpdef[expr_contextType.Param] (ASSIGN test[expr_contextType.Load])?
{
- $etype = actions.castExpr($vfpdef.tree);
+ $atype = actions.castArg($vfpdef.tree);
if ($ASSIGN != null) {
defaults.add($test.tree);
} else if (!defaults.isEmpty()) {
@@ -549,11 +549,8 @@
//vfpdef: NAME
vfpdef[expr_contextType ctype]
-@after {
- actions.checkAssign(actions.castExpr($vfpdef.tree));
-}
: NAME
- -> ^(NAME<Name>[$NAME, $NAME.text, ctype])
+ -> ^(NAME<arg>[$NAME, $NAME.text, null])
;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fwi...@us...> - 2009-01-08 15:53:03
|
Revision: 5879
http://jython.svn.sourceforge.net/jython/?rev=5879&view=rev
Author: fwierzbicki
Date: 2009-01-08 15:52:56 +0000 (Thu, 08 Jan 2009)
Log Message:
-----------
Remove support for 'l'/'L' at the end of INT and 'u'/'U' at the beginning of
STRING
Modified Paths:
--------------
branches/jy3k/grammar/Python.g
Modified: branches/jy3k/grammar/Python.g
===================================================================
--- branches/jy3k/grammar/Python.g 2009-01-08 15:45:27 UTC (rev 5878)
+++ branches/jy3k/grammar/Python.g 2009-01-08 15:52:56 UTC (rev 5879)
@@ -1239,8 +1239,6 @@
-> ^(NAME<Name>[$NAME, $NAME.text, $expr::ctype])
| INT
-> ^(INT<Num>[$INT, actions.makeInt($INT)])
- | LONGINT
- -> ^(LONGINT<Num>[$LONGINT, actions.makeInt($LONGINT)])
| FLOAT
-> ^(FLOAT<Num>[$FLOAT, actions.makeFloat($FLOAT)])
| COMPLEX
@@ -1697,10 +1695,6 @@
| DIGITS ('.' (DIGITS (Exponent)?)? | Exponent)
;
-LONGINT
- : INT ('l'|'L')
- ;
-
fragment
Exponent
: ('e' | 'E') ( '+' | '-' )? DIGITS
@@ -1729,7 +1723,7 @@
* should make us exit loop not continue.
*/
STRING
- : ('r'|'u'|'ur'|'R'|'U'|'UR'|'uR'|'Ur')?
+ : ('r'|'R')?
( '\'\'\'' (options {greedy=false;}:TRIAPOS)* '\'\'\''
| '"""' (options {greedy=false;}:TRIQUOTE)* '"""'
| '"' (ESC|~('\\'|'\n'|'"'))* '"'
@@ -1743,7 +1737,7 @@
;
STRINGPART
- : {partial}?=> ('r'|'u'|'ur'|'R'|'U'|'UR'|'uR'|'Ur')?
+ : {partial}?=> ('r'|'R')?
( '\'\'\'' ~('\'\'\'')*
| '"""' ~('"""')*
)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fwi...@us...> - 2009-01-08 16:38:20
|
Revision: 5881
http://jython.svn.sourceforge.net/jython/?rev=5881&view=rev
Author: fwierzbicki
Date: 2009-01-08 16:38:16 +0000 (Thu, 08 Jan 2009)
Log Message:
-----------
Prune BACKQUOTE and <> from grammar.
Modified Paths:
--------------
branches/jy3k/grammar/Python.g
Modified: branches/jy3k/grammar/Python.g
===================================================================
--- branches/jy3k/grammar/Python.g 2009-01-08 16:12:44 UTC (rev 5880)
+++ branches/jy3k/grammar/Python.g 2009-01-08 16:38:16 UTC (rev 5881)
@@ -1008,14 +1008,13 @@
)
;
-//comp_op: '<'|'>'|'=='|'>='|'<='|'<>'|'!='|'in'|'not' 'in'|'is'|'is' 'not'
+//comp_op: '<'|'>'|'=='|'>='|'<='|'!='|'in'|'not' 'in'|'is'|'is' 'not'
comp_op returns [cmpopType op]
: LESS {$op = cmpopType.Lt;}
| GREATER {$op = cmpopType.Gt;}
| EQUAL {$op = cmpopType.Eq;}
| GREATEREQUAL {$op = cmpopType.GtE;}
| LESSEQUAL {$op = cmpopType.LtE;}
- | ALT_NOTEQUAL {$op = cmpopType.NotEq;}
| NOTEQUAL {$op = cmpopType.NotEq;}
| IN {$op = cmpopType.In;}
| NOT IN {$op = cmpopType.NotIn;}
@@ -1627,8 +1626,6 @@
PERCENT : '%' ;
-BACKQUOTE : '`' ;
-
LCURLY : '{' {implicitLineJoiningLevel++;} ;
RCURLY : '}' {implicitLineJoiningLevel--;} ;
@@ -1641,8 +1638,6 @@
NOTEQUAL : '!=' ;
-ALT_NOTEQUAL: '<>' ;
-
LESSEQUAL : '<=' ;
LEFTSHIFT : '<<' ;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
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.
|
|
From: <fwi...@us...> - 2009-01-09 03:19:54
|
Revision: 5894
http://jython.svn.sourceforge.net/jython/?rev=5894&view=rev
Author: fwierzbicki
Date: 2009-01-09 03:19:43 +0000 (Fri, 09 Jan 2009)
Log Message:
-----------
groundwork for dict and set comprehensions
Modified Paths:
--------------
branches/jy3k/grammar/Python.g
Modified: branches/jy3k/grammar/Python.g
===================================================================
--- branches/jy3k/grammar/Python.g 2009-01-08 22:54:04 UTC (rev 5893)
+++ branches/jy3k/grammar/Python.g 2009-01-09 03:19:43 UTC (rev 5894)
@@ -1226,9 +1226,8 @@
)
RBRACK
| LCURLY
- (dictmaker
- -> ^(LCURLY<Dict>[$LCURLY, actions.castExprs($dictmaker.keys),
- actions.castExprs($dictmaker.values)])
+ (dictorsetmaker[$LCURLY]
+ -> dictorsetmaker
|
-> ^(LCURLY<Dict>[$LCURLY, new ArrayList<expr>(), new ArrayList<expr>()])
)
@@ -1250,8 +1249,8 @@
//listmaker: test ( list_for | (',' test)* [','] )
listmaker[Token lbrack]
@init {
+ expr etype = null;
List gens = new ArrayList();
- expr etype = null;
}
@after {
$listmaker.tree = etype;
@@ -1287,7 +1286,7 @@
^(COMMA<Tuple>[$testlist_comp.start, actions.castExprs($t), $expr::ctype])
-> test
)
- | (gen_for[gens]
+ | (comp_for[gens]
{
Collections.reverse(gens);
List<comprehension> c = gens;
@@ -1409,15 +1408,22 @@
| test[ctype]
;
-//dictmaker: test ':' test (',' test ':' test)* [',']
-dictmaker returns [List keys, List values]
+//dictorsetmaker: ( (test ':' test (comp_for | (',' test ':' test)* [','])) |
+// (test (comp_for | (',' test)* [','])) )
+dictorsetmaker[Token lcurly]
+@init {
+ expr etype = null;
+ List gens = new ArrayList();
+}
+@after {
+ $dictorsetmaker.tree = etype;
+}
: 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;
- }
+ {
+ etype = new Dict($lcurly, actions.castExprs($k), actions.castExprs($v));
+ }
;
//classdef: 'class' NAME ['(' [testlist] ')'] ':' suite
@@ -1444,7 +1450,9 @@
}
;
-//arglist: (argument ',')* (argument [',']| '*' test [',' '**' test] | '**' test)
+//arglist: (argument ',')* (argument [',']
+// |'*' test (',' argument)* [',' '**' test]
+// |'**' test)
arglist returns [List args, List keywords, expr starargs, expr kwargs]
@init {
List arguments = new ArrayList();
@@ -1477,7 +1485,7 @@
}
;
-//argument: test [gen_for] | test '=' test # Really [keyword '='] test
+//argument: test [comp_for] | test '=' test # Really [keyword '='] test
argument[List arguments, List kws, List gens, boolean first] returns [boolean genarg]
: t1=test[expr_contextType.Load]
((ASSIGN t2=test[expr_contextType.Load])
@@ -1487,10 +1495,10 @@
exprs.add(actions.castExpr($t2.tree));
$kws.add(exprs);
}
- | gen_for[$gens]
+ | comp_for[$gens]
{
if (!first) {
- actions.errorGenExpNotSoleArg($gen_for.tree);
+ actions.errorGenExpNotSoleArg($comp_for.tree);
}
$genarg = true;
Collections.reverse($gens);
@@ -1532,27 +1540,27 @@
}
;
-//gen_iter: gen_for | gen_if
-gen_iter [List gens, List ifs]
- : gen_for[gens]
- | gen_if[gens, ifs]
+//comp_iter: comp_for | comp_if
+comp_iter [List gens, List ifs]
+ : comp_for[gens]
+ | comp_if[gens, ifs]
;
-//gen_for: 'for' exprlist 'in' or_test [gen_iter]
-gen_for [List gens]
+//comp_for: 'for' exprlist 'in' or_test [comp_iter]
+comp_for [List gens]
@init {
List ifs = new ArrayList();
}
- : FOR exprlist[expr_contextType.Store] IN or_test[expr_contextType.Load] gen_iter[gens, ifs]?
+ : FOR exprlist[expr_contextType.Store] IN or_test[expr_contextType.Load] comp_iter[gens, ifs]?
{
Collections.reverse(ifs);
gens.add(new comprehension($FOR, $exprlist.etype, actions.castExpr($or_test.tree), ifs));
}
;
-//gen_if: 'if' old_test [gen_iter]
-gen_if[List gens, List ifs]
- : IF test[expr_contextType.Load] gen_iter[gens, ifs]?
+//comp_if: 'if' test_nocond [comp_iter]
+comp_if[List gens, List ifs]
+ : IF test[expr_contextType.Load] comp_iter[gens, ifs]?
{
ifs.add(actions.castExpr($test.tree));
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fwi...@us...> - 2009-01-09 03:59:20
|
Revision: 5895
http://jython.svn.sourceforge.net/jython/?rev=5895&view=rev
Author: fwierzbicki
Date: 2009-01-09 03:59:16 +0000 (Fri, 09 Jan 2009)
Log Message:
-----------
Set support
Modified Paths:
--------------
branches/jy3k/grammar/Python.g
Modified: branches/jy3k/grammar/Python.g
===================================================================
--- branches/jy3k/grammar/Python.g 2009-01-09 03:19:43 UTC (rev 5894)
+++ branches/jy3k/grammar/Python.g 2009-01-09 03:59:16 UTC (rev 5895)
@@ -130,6 +130,7 @@
import org.python.antlr.ast.Pass;
import org.python.antlr.ast.Raise;
import org.python.antlr.ast.Return;
+import org.python.antlr.ast.Set;
import org.python.antlr.ast.Slice;
import org.python.antlr.ast.Str;
import org.python.antlr.ast.Subscript;
@@ -1226,12 +1227,12 @@
)
RBRACK
| LCURLY
- (dictorsetmaker[$LCURLY]
- -> dictorsetmaker
- |
- -> ^(LCURLY<Dict>[$LCURLY, new ArrayList<expr>(), new ArrayList<expr>()])
- )
- RCURLY
+ (dictorsetmaker[$LCURLY]
+ -> dictorsetmaker
+ |
+ -> ^(LCURLY<Dict>[$LCURLY, new ArrayList<expr>(), new ArrayList<expr>()])
+ )
+ RCURLY
| NAME
-> ^(NAME<Name>[$NAME, $NAME.text, $expr::ctype])
| INT
@@ -1418,12 +1419,18 @@
@after {
$dictorsetmaker.tree = etype;
}
- : k+=test[expr_contextType.Load] COLON v+=test[expr_contextType.Load]
+ : (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));
}
+ | t+=test[$expr::ctype] (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.
|
|
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.
|
|
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.
|
|
From: <fwi...@us...> - 2009-01-09 04:32:45
|
Revision: 5898
http://jython.svn.sourceforge.net/jython/?rev=5898&view=rev
Author: fwierzbicki
Date: 2009-01-09 04:32:35 +0000 (Fri, 09 Jan 2009)
Log Message:
-----------
list_for, list_if, list_iter no longer needed.
Modified Paths:
--------------
branches/jy3k/grammar/Python.g
Modified: branches/jy3k/grammar/Python.g
===================================================================
--- branches/jy3k/grammar/Python.g 2009-01-09 04:24:28 UTC (rev 5897)
+++ branches/jy3k/grammar/Python.g 2009-01-09 04:32:35 UTC (rev 5898)
@@ -1249,7 +1249,7 @@
-> ^(BYTES<Bytes>[actions.extractStringToken($B), actions.extractBytes($B, encoding)])
;
-//listmaker: test ( list_for | (',' test)* [','] )
+//listmaker: test ( comp_for | (',' test)* [','] )
listmaker[Token lbrack]
@init {
expr etype = null;
@@ -1259,7 +1259,7 @@
$listmaker.tree = etype;
}
: t+=test[$expr::ctype]
- (list_for[gens]
+ (comp_for[gens]
{
Collections.reverse(gens);
List<comprehension> c = gens;
@@ -1538,32 +1538,6 @@
)
;
-//list_iter: list_for | list_if
-list_iter [List gens, List ifs]
- : list_for[gens]
- | list_if[gens, ifs]
- ;
-
-//list_for: 'for' exprlist 'in' testlist_safe [list_iter]
-list_for [List gens]
-@init {
- List ifs = new ArrayList();
-}
- : FOR exprlist[expr_contextType.Store] IN testlist[expr_contextType.Load] (list_iter[gens, ifs])?
- {
- Collections.reverse(ifs);
- gens.add(new comprehension($FOR, $exprlist.etype, actions.castExpr($testlist.tree), ifs));
- }
- ;
-
-//list_if: 'if' test [list_iter]
-list_if[List gens, List ifs]
- : IF test[expr_contextType.Load] (list_iter[gens, ifs])?
- {
- ifs.add(actions.castExpr($test.tree));
- }
- ;
-
//comp_iter: comp_for | comp_if
comp_iter [List gens, List ifs]
: comp_for[gens]
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fwi...@us...> - 2009-01-11 22:36:08
|
Revision: 5921
http://jython.svn.sourceforge.net/jython/?rev=5921&view=rev
Author: fwierzbicki
Date: 2009-01-11 22:36:00 +0000 (Sun, 11 Jan 2009)
Log Message:
-----------
sham star_expr just to save the spot, causes an ambiguity with arglist so can't
implement it just yet.
Modified Paths:
--------------
branches/jy3k/grammar/Python.g
Modified: branches/jy3k/grammar/Python.g
===================================================================
--- branches/jy3k/grammar/Python.g 2009-01-11 22:26:38 UTC (rev 5920)
+++ branches/jy3k/grammar/Python.g 2009-01-11 22:36:00 UTC (rev 5921)
@@ -1043,7 +1043,7 @@
| comparison[ctype]
;
-//comparison: expr (comp_op expr)*
+//comparison: star_expr (comp_op star_expr)*
comparison[expr_contextType ctype]
@init {
List cmps = new ArrayList();
@@ -1054,8 +1054,8 @@
actions.castExprs($right));
}
}
- : left=expr[ctype]
- ( ( comp_op right+=expr[ctype] {cmps.add($comp_op.op);}
+ : left=star_expr[ctype]
+ ( ( comp_op right+=star_expr[ctype] {cmps.add($comp_op.op);}
)+
|
-> $left
@@ -1076,6 +1076,10 @@
| IS NOT {$op = cmpopType.IsNot;}
;
+//star_expr: ['*'] expr
+star_expr[expr_contextType ect]
+ : expr[ect]
+ ;
//expr: xor_expr ('|' xor_expr)*
expr[expr_contextType ect]
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
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.
|