| CODENOTIFIER | HelpYou are not signed inSign in |
Project: Jython
Revision: 5218
Author: fwierzbicki
Date: 20 Aug 2008 10:39:21
Changes:Diff:| ... | ...@@ -122,6 +122,7 @@ | |
| 122 | 122 | import org.python.antlr.ast.Context; |
| 123 | 123 | import org.python.antlr.ast.Continue; |
| 124 | 124 | import org.python.antlr.ast.Delete; |
| 125 | import org.python.antlr.ast.Dict; | |
| 125 | 126 | import org.python.antlr.ast.excepthandlerType; |
| 126 | 127 | import org.python.antlr.ast.Exec; |
| 127 | 128 | import org.python.antlr.ast.Expr; |
| ... | ...@@ -997,7 +998,11 @@ | |
| 997 | 998 | | -> ^(LBRACK<org.python.antlr.ast.List>[$LBRACK, new exprType[0\], $expr::ctype]) |
| 998 | 999 | ) |
| 999 | 1000 | RBRACK |
| 1000 | | LCURLY (dictmaker)? RCURLY -> ^(Dict LCURLY ^(Elts dictmaker)?) | |
| 1001 | | LCURLY | |
| 1002 | (dictmaker -> ^(LCURLY<Dict>[$LCURLY, actions.makeExprs($dictmaker.keys), actions.makeExprs($dictmaker.values)]) | |
| 1003 | | -> ^(LCURLY<Dict>[$LCURLY, new exprType[0\], new exprType[0\]]) | |
| 1004 | ) | |
| 1005 | RCURLY | |
| 1001 | 1006 | | BACKQUOTE testlist[expr_contextType.Load] BACKQUOTE -> ^(Repr BACKQUOTE testlist) |
| 1002 | 1007 | | NAME -> ^(PYNODE<Name>[$NAME, $NAME.text, $expr::ctype]) |
| 1003 | 1008 | | INT -> ^(PYNODE<Num>[$INT, actions.makeInt($INT)]) |
| ... | ...@@ -1123,15 +1128,18 @@ | |
| 1123 | 1128 | ; |
| 1124 | 1129 | |
| 1125 | 1130 | //testlist: test (',' test)* [','] |
| 1126 | testlist[expr_contextType ctype] returns [exprType etype] | |
| 1131 | testlist[expr_contextType ctype] | |
| 1132 | @init { | |
| 1133 | exprType etype = null; | |
| 1134 | } | |
| 1127 | 1135 | @after { |
| 1128 | $testlist.tree = $etype; | |
| 1136 | $testlist.tree = etype; | |
| 1129 | 1137 | } |
| 1130 | 1138 | : (test[expr_contextType.Load] COMMA) => t+=test[ctype] (options {k=2;}: c1=COMMA t+=test[ctype])* (c2=COMMA)? { |
| 1131 | $etype = new Tuple($testlist.start, actions.makeExprs($t), ctype); | |
| 1139 | etype = new Tuple($testlist.start, actions.makeExprs($t), ctype); | |
| 1132 | 1140 | } |
| 1133 | 1141 | | test[ctype] { |
| 1134 | $etype = (exprType)$test.tree; | |
| 1142 | etype = (exprType)$test.tree; | |
| 1135 | 1143 | } |
| 1136 | 1144 | ; |
| 1137 | 1145 | |
| ... | ...@@ -1139,10 +1147,14 @@ | |
| 1139 | 1147 | //testlist_safe: test [(',' test)+ [',']] |
| 1140 | 1148 | |
| 1141 | 1149 | //dictmaker: test ':' test (',' test ':' test)* [','] |
| 1142 | dictmaker : test[expr_contextType.Load] COLON test[expr_contextType.Load] | |
| 1143 | (options {k=2;}:COMMA test[expr_contextType.Load] COLON test[expr_contextType.Load])* (COMMA)? | |
| 1144 | -> test+ | |
| 1145 | ; | |
| 1150 | dictmaker returns [List keys, List values] | |
| 1151 | : k+=test[expr_contextType.Load] COLON v+=test[expr_contextType.Load] | |
| 1152 | (options {k=2;}:COMMA k+=test[expr_contextType.Load] COLON v+=test[expr_contextType.Load])* | |
| 1153 | (COMMA)? { | |
| 1154 | $keys = $k; | |
| 1155 | $values= $v; | |
| 1156 | } | |
| 1157 | ; | |
| 1146 | 1158 | |
| 1147 | 1159 | //classdef: 'class' NAME ['(' [testlist] ')'] ':' suite |
| 1148 | 1160 | classdef |
| ... | ...@@ -1153,7 +1165,7 @@ | |
| 1153 | 1165 | $classdef.tree = stype; |
| 1154 | 1166 | } |
| 1155 | 1167 | :CLASS NAME (LPAREN testlist[expr_contextType.Load]? RPAREN)? COLON suite { |
| 1156 | stype = new ClassDef($CLASS, $NAME.getText(), actions.makeBases($testlist.etype), actions.makeStmts($suite.stmts)); | |
| 1168 | stype = new ClassDef($CLASS, $NAME.getText(), actions.makeBases((exprType)$testlist.tree), actions.makeStmts($suite.stmts)); | |
| 1157 | 1169 | } |
| 1158 | 1170 | ; |
| 1159 | 1171 | |
| ... | ...@@ -1201,7 +1213,7 @@ | |
| 1201 | 1213 | |
| 1202 | 1214 | //list_for: 'for' exprlist 'in' testlist_safe [list_iter] |
| 1203 | 1215 | list_for : FOR exprlist[expr_contextType.Load] IN testlist[expr_contextType.Load] (list_iter)? |
| 1204 | -> ^(FOR<comprehensionType>[$FOR, $exprlist.etype, $testlist.etype, null]) | |
| 1216 | -> ^(FOR<comprehensionType>[$FOR, $exprlist.etype, (exprType)$testlist.tree, null]) | |
| 1205 | 1217 | ; |
| 1206 | 1218 | |
| 1207 | 1219 | //list_if: 'if' test [list_iter] |
| ... | ...@@ -1226,7 +1238,7 @@ | |
| 1226 | 1238 | |
| 1227 | 1239 | //yield_expr: 'yield' [testlist] |
| 1228 | 1240 | yield_expr : YIELD testlist[expr_contextType.Load]? |
| 1229 | -> ^(YIELD<Yield>[$YIELD, $testlist.etype]) | |
| 1241 | -> ^(YIELD<Yield>[$YIELD, (exprType)$testlist.tree]) | |
| 1230 | 1242 | ; |
| 1231 | 1243 | |
| 1232 | 1244 | //XXX: |