Skip to content

Commit a975a65

Browse files
author
nweinb
committed
Added NOPE keyword with break functionality that prints at the start
1 parent cd19ec1 commit a975a65

File tree

10 files changed

+1391
-1313
lines changed

10 files changed

+1391
-1313
lines changed

Grammar/Grammar

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ augassign: ('+=' | '-=' | '*=' | '@=' | '/=' | '%=' | '&=' | '|=' | '^=' |
9191
# For normal and annotated assignments, additional restrictions enforced by the interpreter
9292
del_stmt: 'del' exprlist
9393
pass_stmt: 'pass'
94-
flow_stmt: break_stmt | continue_stmt | return_stmt | raise_stmt | yield_stmt | almog_stmt
94+
flow_stmt: break_stmt | continue_stmt | return_stmt | raise_stmt | yield_stmt | almog_stmt | nope_stmt
9595
break_stmt: 'break'
9696
continue_stmt: 'continue'
9797
return_stmt: 'return' [testlist_star_expr]
@@ -100,6 +100,7 @@ raise_stmt: 'raise' [test ['from' test]]
100100
import_stmt: import_name | import_from
101101
import_name: 'import' dotted_as_names
102102
almog_stmt: 'almog'
103+
nope_stmt: 'nope'
103104
# note below: the ('.' | '...') is necessary because '...' is tokenized as ELLIPSIS
104105
import_from: ('from' (('.' | '...')* dotted_name | ('.' | '...')+)
105106
'import' ('*' | '(' import_as_names ')' | import_as_names))

Include/Python-ast.h

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/graminit.h

Lines changed: 63 additions & 62 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Lib/keyword.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
'is',
4343
'lambda',
4444
'nonlocal',
45+
'nope',
4546
'not',
4647
'or',
4748
'pass',

Lib/symbol.py

Lines changed: 63 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -43,68 +43,69 @@
4343
import_stmt = 284
4444
import_name = 285
4545
almog_stmt = 286
46-
import_from = 287
47-
import_as_name = 288
48-
dotted_as_name = 289
49-
import_as_names = 290
50-
dotted_as_names = 291
51-
dotted_name = 292
52-
global_stmt = 293
53-
nonlocal_stmt = 294
54-
assert_stmt = 295
55-
compound_stmt = 296
56-
async_stmt = 297
57-
if_stmt = 298
58-
while_stmt = 299
59-
for_stmt = 300
60-
try_stmt = 301
61-
with_stmt = 302
62-
with_item = 303
63-
except_clause = 304
64-
suite = 305
65-
namedexpr_test = 306
66-
test = 307
67-
test_nocond = 308
68-
lambdef = 309
69-
lambdef_nocond = 310
70-
or_test = 311
71-
and_test = 312
72-
not_test = 313
73-
comparison = 314
74-
comp_op = 315
75-
star_expr = 316
76-
expr = 317
77-
xor_expr = 318
78-
and_expr = 319
79-
shift_expr = 320
80-
arith_expr = 321
81-
term = 322
82-
factor = 323
83-
power = 324
84-
atom_expr = 325
85-
atom = 326
86-
testlist_comp = 327
87-
trailer = 328
88-
subscriptlist = 329
89-
subscript = 330
90-
sliceop = 331
91-
exprlist = 332
92-
testlist = 333
93-
dictorsetmaker = 334
94-
classdef = 335
95-
arglist = 336
96-
argument = 337
97-
comp_iter = 338
98-
sync_comp_for = 339
99-
comp_for = 340
100-
comp_if = 341
101-
encoding_decl = 342
102-
yield_expr = 343
103-
yield_arg = 344
104-
func_body_suite = 345
105-
func_type_input = 346
106-
func_type = 347
107-
typelist = 348
46+
nope_stmt = 287
47+
import_from = 288
48+
import_as_name = 289
49+
dotted_as_name = 290
50+
import_as_names = 291
51+
dotted_as_names = 292
52+
dotted_name = 293
53+
global_stmt = 294
54+
nonlocal_stmt = 295
55+
assert_stmt = 296
56+
compound_stmt = 297
57+
async_stmt = 298
58+
if_stmt = 299
59+
while_stmt = 300
60+
for_stmt = 301
61+
try_stmt = 302
62+
with_stmt = 303
63+
with_item = 304
64+
except_clause = 305
65+
suite = 306
66+
namedexpr_test = 307
67+
test = 308
68+
test_nocond = 309
69+
lambdef = 310
70+
lambdef_nocond = 311
71+
or_test = 312
72+
and_test = 313
73+
not_test = 314
74+
comparison = 315
75+
comp_op = 316
76+
star_expr = 317
77+
expr = 318
78+
xor_expr = 319
79+
and_expr = 320
80+
shift_expr = 321
81+
arith_expr = 322
82+
term = 323
83+
factor = 324
84+
power = 325
85+
atom_expr = 326
86+
atom = 327
87+
testlist_comp = 328
88+
trailer = 329
89+
subscriptlist = 330
90+
subscript = 331
91+
sliceop = 332
92+
exprlist = 333
93+
testlist = 334
94+
dictorsetmaker = 335
95+
classdef = 336
96+
arglist = 337
97+
argument = 338
98+
comp_iter = 339
99+
sync_comp_for = 340
100+
comp_for = 341
101+
comp_if = 342
102+
encoding_decl = 343
103+
yield_expr = 344
104+
yield_arg = 345
105+
func_body_suite = 346
106+
func_type_input = 347
107+
func_type = 348
108+
typelist = 349
108109
#--end constants--
109110

110111
sym_name = {}

Parser/Python.asdl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ module Python
4949
| Global(identifier* names)
5050
| Nonlocal(identifier* names)
5151
| Expr(expr value)
52-
| Pass | Break | Continue | Almog
52+
| Pass | Break | Continue | Almog | Nope
5353

5454
-- XXX Jython will be different
5555
-- col_offset is the byte offset in the utf8 string the parser uses

Python/Python-ast.c

Lines changed: 34 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/ast.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3553,6 +3553,9 @@ ast_for_flow_stmt(struct compiling *c, const node *n)
35533553
case almog_stmt:
35543554
return Almog(LINENO(n), n->n_col_offset,
35553555
n->n_end_lineno, n->n_end_col_offset, c->c_arena);
3556+
case nope_stmt:
3557+
return Nope(LINENO(n), n->n_col_offset,
3558+
n->n_end_lineno, n->n_end_col_offset, c->c_arena);
35563559
case yield_stmt: { /* will reduce to yield_expr */
35573560
expr_ty exp = ast_for_expr(c, CHILD(ch, 0));
35583561
if (!exp)

0 commit comments

Comments
 (0)