Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3c52c5a

Browse files
committed
Wrap long lines in the grammar
1 parent 3dafaab commit 3c52c5a

2 files changed

Lines changed: 40 additions & 25 deletions

File tree

Grammar/Grammar

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,23 @@ decorator: '@' dotted_name [ '(' [arglist] ')' ] NEWLINE
3232
decorators: decorator+
3333
funcdef: [decorators] 'def' NAME parameters ':' suite
3434
parameters: '(' [varargslist] ')'
35-
varargslist: (fpdef ['=' test] ',')* ('*' NAME [',' '**' NAME] | '**' NAME) | fpdef ['=' test] (',' fpdef ['=' test])* [',']
35+
varargslist: ((fpdef ['=' test] ',')*
36+
('*' NAME [',' '**' NAME] | '**' NAME) |
37+
fpdef ['=' test] (',' fpdef ['=' test])* [','])
3638
fpdef: NAME | '(' fplist ')'
3739
fplist: fpdef (',' fpdef)* [',']
3840

3941
stmt: simple_stmt | compound_stmt
4042
simple_stmt: small_stmt (';' small_stmt)* [';'] NEWLINE
41-
small_stmt: expr_stmt | print_stmt | del_stmt | pass_stmt | flow_stmt | import_stmt | global_stmt | exec_stmt | assert_stmt
42-
expr_stmt: testlist (augassign (yield_expr|testlist) | ('=' (yield_expr|testlist))*)
43-
augassign: '+=' | '-=' | '*=' | '/=' | '%=' | '&=' | '|=' | '^=' | '<<=' | '>>=' | '**=' | '//='
43+
small_stmt: (expr_stmt | print_stmt | del_stmt | pass_stmt | flow_stmt |
44+
import_stmt | global_stmt | exec_stmt | assert_stmt)
45+
expr_stmt: testlist (augassign (yield_expr|testlist) |
46+
('=' (yield_expr|testlist))*)
47+
augassign: ('+=' | '-=' | '*=' | '/=' | '%=' | '&=' | '|=' | '^=' |
48+
'<<=' | '>>=' | '**=' | '//=')
4449
# For normal assignments, additional restrictions enforced by the interpreter
45-
print_stmt: 'print' ( [ test (',' test)* [','] ] | '>>' test [ (',' test)+ [','] ] )
50+
print_stmt: 'print' ( [ test (',' test)* [','] ] |
51+
'>>' test [ (',' test)+ [','] ] )
4652
del_stmt: 'del' exprlist
4753
pass_stmt: 'pass'
4854
flow_stmt: break_stmt | continue_stmt | return_stmt | raise_stmt | yield_stmt
@@ -53,7 +59,8 @@ yield_stmt: yield_expr
5359
raise_stmt: 'raise' [test [',' test [',' test]]]
5460
import_stmt: import_name | import_from
5561
import_name: 'import' dotted_as_names
56-
import_from: 'from' dotted_name 'import' ('*' | '(' import_as_names ')' | import_as_names)
62+
import_from: ('from' ('.')* dotted_name
63+
'import' ('*' | '(' import_as_names ')' | import_as_names))
5764
import_as_name: NAME [NAME NAME]
5865
dotted_as_name: dotted_name [NAME NAME]
5966
import_as_names: import_as_name (',' import_as_name)* [',']
@@ -67,7 +74,11 @@ compound_stmt: if_stmt | while_stmt | for_stmt | try_stmt | funcdef | classdef
6774
if_stmt: 'if' test ':' suite ('elif' test ':' suite)* ['else' ':' suite]
6875
while_stmt: 'while' test ':' suite ['else' ':' suite]
6976
for_stmt: 'for' exprlist 'in' testlist ':' suite ['else' ':' suite]
70-
try_stmt: 'try' ':' suite ((except_clause ':' suite)+ ['else' ':' suite] ['finally' ':' suite] | 'finally' ':' suite)
77+
try_stmt: ('try' ':' suite
78+
((except_clause ':' suite)+
79+
['else' ':' suite]
80+
['finally' ':' suite] |
81+
'finally' ':' suite))
7182
# NB compile.c makes sure that the default except clause is last
7283
except_clause: 'except' [test [',' test]]
7384
suite: simple_stmt | NEWLINE INDENT stmt+ DEDENT
@@ -85,7 +96,11 @@ arith_expr: term (('+'|'-') term)*
8596
term: factor (('*'|'/'|'%'|'//') factor)*
8697
factor: ('+'|'-'|'~') factor | power
8798
power: atom trailer* ['**' factor]
88-
atom: '(' [yield_expr|testlist_gexp] ')' | '[' [listmaker] ']' | '{' [dictmaker] '}' | '`' testlist1 '`' | NAME | NUMBER | STRING+
99+
atom: ('(' [yield_expr|testlist_gexp] ')' |
100+
'[' [listmaker] ']' |
101+
'{' [dictmaker] '}' |
102+
'`' testlist1 '`' |
103+
NAME | NUMBER | STRING+)
89104
listmaker: test ( list_for | (',' test)* [','] )
90105
testlist_gexp: test ( gen_for | (',' test)* [','] )
91106
lambdef: 'lambda' [varargslist] ':' test
@@ -117,4 +132,3 @@ testlist1: test (',' test)*
117132
encoding_decl: NAME
118133

119134
yield_expr: 'yield' [testlist]
120-

Python/graminit.c

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,8 @@ static state states_25[3] = {
512512
static arc arcs_26_0[1] = {
513513
{74, 1},
514514
};
515-
static arc arcs_26_1[1] = {
515+
static arc arcs_26_1[2] = {
516+
{75, 1},
516517
{12, 2},
517518
};
518519
static arc arcs_26_2[1] = {
@@ -521,20 +522,20 @@ static arc arcs_26_2[1] = {
521522
static arc arcs_26_3[3] = {
522523
{28, 4},
523524
{13, 5},
524-
{75, 4},
525+
{76, 4},
525526
};
526527
static arc arcs_26_4[1] = {
527528
{0, 4},
528529
};
529530
static arc arcs_26_5[1] = {
530-
{75, 6},
531+
{76, 6},
531532
};
532533
static arc arcs_26_6[1] = {
533534
{15, 4},
534535
};
535536
static state states_26[7] = {
536537
{1, arcs_26_0},
537-
{1, arcs_26_1},
538+
{2, arcs_26_1},
538539
{1, arcs_26_2},
539540
{3, arcs_26_3},
540541
{1, arcs_26_4},
@@ -580,14 +581,14 @@ static state states_28[4] = {
580581
{1, arcs_28_3},
581582
};
582583
static arc arcs_29_0[1] = {
583-
{76, 1},
584+
{77, 1},
584585
};
585586
static arc arcs_29_1[2] = {
586587
{27, 2},
587588
{0, 1},
588589
};
589590
static arc arcs_29_2[2] = {
590-
{76, 1},
591+
{77, 1},
591592
{0, 2},
592593
};
593594
static state states_29[3] = {
@@ -596,7 +597,7 @@ static state states_29[3] = {
596597
{2, arcs_29_2},
597598
};
598599
static arc arcs_30_0[1] = {
599-
{77, 1},
600+
{78, 1},
600601
};
601602
static arc arcs_30_1[2] = {
602603
{27, 0},
@@ -610,7 +611,7 @@ static arc arcs_31_0[1] = {
610611
{19, 1},
611612
};
612613
static arc arcs_31_1[2] = {
613-
{78, 0},
614+
{75, 0},
614615
{0, 1},
615616
};
616617
static state states_31[2] = {
@@ -1251,7 +1252,7 @@ static state states_58[5] = {
12511252
static arc arcs_59_0[3] = {
12521253
{13, 1},
12531254
{136, 2},
1254-
{78, 3},
1255+
{75, 3},
12551256
};
12561257
static arc arcs_59_1[2] = {
12571258
{14, 4},
@@ -1298,12 +1299,12 @@ static state states_60[3] = {
12981299
{2, arcs_60_2},
12991300
};
13001301
static arc arcs_61_0[3] = {
1301-
{78, 1},
1302+
{75, 1},
13021303
{26, 2},
13031304
{21, 3},
13041305
};
13051306
static arc arcs_61_1[1] = {
1306-
{78, 4},
1307+
{75, 4},
13071308
};
13081309
static arc arcs_61_2[2] = {
13091310
{21, 3},
@@ -1315,7 +1316,7 @@ static arc arcs_61_3[3] = {
13151316
{0, 3},
13161317
};
13171318
static arc arcs_61_4[1] = {
1318-
{78, 6},
1319+
{75, 6},
13191320
};
13201321
static arc arcs_61_5[2] = {
13211322
{151, 6},
@@ -1809,11 +1810,11 @@ static dfa dfas[79] = {
18091810
{314, "lambdef", 0, 5, states_58,
18101811
"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\020\000\000"},
18111812
{315, "trailer", 0, 7, states_59,
1812-
"\000\040\000\000\000\000\000\000\000\100\000\000\000\000\000\000\000\001\000\000\000"},
1813+
"\000\040\000\000\000\000\000\000\000\010\000\000\000\000\000\000\000\001\000\000\000"},
18131814
{316, "subscriptlist", 0, 3, states_60,
1814-
"\000\040\050\000\000\000\000\000\000\100\000\000\000\002\000\140\010\111\023\000\000"},
1815+
"\000\040\050\000\000\000\000\000\000\010\000\000\000\002\000\140\010\111\023\000\000"},
18151816
{317, "subscript", 0, 7, states_61,
1816-
"\000\040\050\000\000\000\000\000\000\100\000\000\000\002\000\140\010\111\023\000\000"},
1817+
"\000\040\050\000\000\000\000\000\000\010\000\000\000\002\000\140\010\111\023\000\000"},
18171818
{318, "sliceop", 0, 3, states_62,
18181819
"\000\000\040\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
18191820
{319, "exprlist", 0, 3, states_63,
@@ -1925,10 +1926,10 @@ static label labels[161] = {
19251926
{1, "import"},
19261927
{286, 0},
19271928
{1, "from"},
1929+
{23, 0},
19281930
{285, 0},
19291931
{283, 0},
19301932
{284, 0},
1931-
{23, 0},
19321933
{1, "global"},
19331934
{1, "exec"},
19341935
{303, 0},

0 commit comments

Comments
 (0)