82
82
),
83
83
),
84
84
(
85
- 'ifelsestmtc' ,
86
- (
87
- 'testexpr' ,
88
- 'c_stmts_opt' ,
89
- 'JUMP_FORWARD' ,
90
- 'else_suite' ,
91
- 'come_froms'
92
- ),
85
+ "ifelsestmtc" ,
86
+ ("testexpr" , "c_stmts_opt" , "JUMP_FORWARD" , "else_suite" , "come_froms" ),
93
87
),
94
88
(
95
89
"ifelsestmt" ,
155
149
156
150
157
151
def ifelsestmt (self , lhs , n , rule , tree , tokens , first , last ):
158
-
159
152
if (last + 1 ) < n and tokens [last + 1 ] == "COME_FROM_LOOP" and lhs != "ifelsestmtc" :
160
153
# ifelsestmt jumped outside of loop. No good.
161
154
return True
@@ -176,10 +169,7 @@ def ifelsestmt(self, lhs, n, rule, tree, tokens, first, last):
176
169
stmts = tree [1 ]
177
170
if stmts in ("c_stmts" ,) and len (stmts ) == 1 :
178
171
raise_stmt1 = stmts [0 ]
179
- if (
180
- raise_stmt1 == "raise_stmt1" and
181
- raise_stmt1 [0 ] in ("LOAD_ASSERT" ,)
182
- ):
172
+ if raise_stmt1 == "raise_stmt1" and raise_stmt1 [0 ] in ("LOAD_ASSERT" ,):
183
173
return True
184
174
185
175
# Make sure all the offsets from the "come froms" at the
@@ -277,17 +267,18 @@ def ifelsestmt(self, lhs, n, rule, tree, tokens, first, last):
277
267
# only if we are trying to match or reduce an "if"
278
268
# statement of the kind that can occur only inside a
279
269
# loop construct.
270
+
280
271
if lhs in ("ifelsestmtl" , "ifelsestmtc" ):
281
272
jump_false = jmp
282
273
if (
283
- tree [2 ].kind == "JUMP_FORWARD"
274
+ tree [2 ].kind in ( "JUMP_FORWARD" , "JUMP_ABSOLUTE" )
284
275
and jump_false == "jmp_false"
285
276
and len (else_suite ) == 1
286
277
):
287
278
suite_stmts = else_suite [0 ]
288
279
continue_stmt = suite_stmts [0 ]
289
280
if (
290
- suite_stmts == "suite_stmts"
281
+ suite_stmts in ( "suite_stmts" , "c_stmts" )
291
282
and len (suite_stmts ) == 1
292
283
and continue_stmt == "continue"
293
284
and jump_false [0 ].attr == continue_stmt [0 ].attr
0 commit comments