mirror of https://github.com/python/cpython
Wrap long lines in the grammar
This commit is contained in:
parent
3dafaabfb5
commit
3c52c5a888
|
@ -32,17 +32,23 @@ decorator: '@' dotted_name [ '(' [arglist] ')' ] NEWLINE
|
|||
decorators: decorator+
|
||||
funcdef: [decorators] 'def' NAME parameters ':' suite
|
||||
parameters: '(' [varargslist] ')'
|
||||
varargslist: (fpdef ['=' test] ',')* ('*' NAME [',' '**' NAME] | '**' NAME) | fpdef ['=' test] (',' fpdef ['=' test])* [',']
|
||||
varargslist: ((fpdef ['=' test] ',')*
|
||||
('*' NAME [',' '**' NAME] | '**' NAME) |
|
||||
fpdef ['=' test] (',' fpdef ['=' test])* [','])
|
||||
fpdef: NAME | '(' fplist ')'
|
||||
fplist: fpdef (',' fpdef)* [',']
|
||||
|
||||
stmt: simple_stmt | compound_stmt
|
||||
simple_stmt: small_stmt (';' small_stmt)* [';'] NEWLINE
|
||||
small_stmt: expr_stmt | print_stmt | del_stmt | pass_stmt | flow_stmt | import_stmt | global_stmt | exec_stmt | assert_stmt
|
||||
expr_stmt: testlist (augassign (yield_expr|testlist) | ('=' (yield_expr|testlist))*)
|
||||
augassign: '+=' | '-=' | '*=' | '/=' | '%=' | '&=' | '|=' | '^=' | '<<=' | '>>=' | '**=' | '//='
|
||||
small_stmt: (expr_stmt | print_stmt | del_stmt | pass_stmt | flow_stmt |
|
||||
import_stmt | global_stmt | exec_stmt | assert_stmt)
|
||||
expr_stmt: testlist (augassign (yield_expr|testlist) |
|
||||
('=' (yield_expr|testlist))*)
|
||||
augassign: ('+=' | '-=' | '*=' | '/=' | '%=' | '&=' | '|=' | '^=' |
|
||||
'<<=' | '>>=' | '**=' | '//=')
|
||||
# For normal assignments, additional restrictions enforced by the interpreter
|
||||
print_stmt: 'print' ( [ test (',' test)* [','] ] | '>>' test [ (',' test)+ [','] ] )
|
||||
print_stmt: 'print' ( [ test (',' test)* [','] ] |
|
||||
'>>' test [ (',' test)+ [','] ] )
|
||||
del_stmt: 'del' exprlist
|
||||
pass_stmt: 'pass'
|
||||
flow_stmt: break_stmt | continue_stmt | return_stmt | raise_stmt | yield_stmt
|
||||
|
@ -53,7 +59,8 @@ yield_stmt: yield_expr
|
|||
raise_stmt: 'raise' [test [',' test [',' test]]]
|
||||
import_stmt: import_name | import_from
|
||||
import_name: 'import' dotted_as_names
|
||||
import_from: 'from' dotted_name 'import' ('*' | '(' import_as_names ')' | import_as_names)
|
||||
import_from: ('from' ('.')* dotted_name
|
||||
'import' ('*' | '(' import_as_names ')' | import_as_names))
|
||||
import_as_name: NAME [NAME NAME]
|
||||
dotted_as_name: dotted_name [NAME NAME]
|
||||
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
|
|||
if_stmt: 'if' test ':' suite ('elif' test ':' suite)* ['else' ':' suite]
|
||||
while_stmt: 'while' test ':' suite ['else' ':' suite]
|
||||
for_stmt: 'for' exprlist 'in' testlist ':' suite ['else' ':' suite]
|
||||
try_stmt: 'try' ':' suite ((except_clause ':' suite)+ ['else' ':' suite] ['finally' ':' suite] | 'finally' ':' suite)
|
||||
try_stmt: ('try' ':' suite
|
||||
((except_clause ':' suite)+
|
||||
['else' ':' suite]
|
||||
['finally' ':' suite] |
|
||||
'finally' ':' suite))
|
||||
# NB compile.c makes sure that the default except clause is last
|
||||
except_clause: 'except' [test [',' test]]
|
||||
suite: simple_stmt | NEWLINE INDENT stmt+ DEDENT
|
||||
|
@ -85,7 +96,11 @@ arith_expr: term (('+'|'-') term)*
|
|||
term: factor (('*'|'/'|'%'|'//') factor)*
|
||||
factor: ('+'|'-'|'~') factor | power
|
||||
power: atom trailer* ['**' factor]
|
||||
atom: '(' [yield_expr|testlist_gexp] ')' | '[' [listmaker] ']' | '{' [dictmaker] '}' | '`' testlist1 '`' | NAME | NUMBER | STRING+
|
||||
atom: ('(' [yield_expr|testlist_gexp] ')' |
|
||||
'[' [listmaker] ']' |
|
||||
'{' [dictmaker] '}' |
|
||||
'`' testlist1 '`' |
|
||||
NAME | NUMBER | STRING+)
|
||||
listmaker: test ( list_for | (',' test)* [','] )
|
||||
testlist_gexp: test ( gen_for | (',' test)* [','] )
|
||||
lambdef: 'lambda' [varargslist] ':' test
|
||||
|
@ -117,4 +132,3 @@ testlist1: test (',' test)*
|
|||
encoding_decl: NAME
|
||||
|
||||
yield_expr: 'yield' [testlist]
|
||||
|
||||
|
|
|
@ -512,7 +512,8 @@ static state states_25[3] = {
|
|||
static arc arcs_26_0[1] = {
|
||||
{74, 1},
|
||||
};
|
||||
static arc arcs_26_1[1] = {
|
||||
static arc arcs_26_1[2] = {
|
||||
{75, 1},
|
||||
{12, 2},
|
||||
};
|
||||
static arc arcs_26_2[1] = {
|
||||
|
@ -521,20 +522,20 @@ static arc arcs_26_2[1] = {
|
|||
static arc arcs_26_3[3] = {
|
||||
{28, 4},
|
||||
{13, 5},
|
||||
{75, 4},
|
||||
{76, 4},
|
||||
};
|
||||
static arc arcs_26_4[1] = {
|
||||
{0, 4},
|
||||
};
|
||||
static arc arcs_26_5[1] = {
|
||||
{75, 6},
|
||||
{76, 6},
|
||||
};
|
||||
static arc arcs_26_6[1] = {
|
||||
{15, 4},
|
||||
};
|
||||
static state states_26[7] = {
|
||||
{1, arcs_26_0},
|
||||
{1, arcs_26_1},
|
||||
{2, arcs_26_1},
|
||||
{1, arcs_26_2},
|
||||
{3, arcs_26_3},
|
||||
{1, arcs_26_4},
|
||||
|
@ -580,14 +581,14 @@ static state states_28[4] = {
|
|||
{1, arcs_28_3},
|
||||
};
|
||||
static arc arcs_29_0[1] = {
|
||||
{76, 1},
|
||||
{77, 1},
|
||||
};
|
||||
static arc arcs_29_1[2] = {
|
||||
{27, 2},
|
||||
{0, 1},
|
||||
};
|
||||
static arc arcs_29_2[2] = {
|
||||
{76, 1},
|
||||
{77, 1},
|
||||
{0, 2},
|
||||
};
|
||||
static state states_29[3] = {
|
||||
|
@ -596,7 +597,7 @@ static state states_29[3] = {
|
|||
{2, arcs_29_2},
|
||||
};
|
||||
static arc arcs_30_0[1] = {
|
||||
{77, 1},
|
||||
{78, 1},
|
||||
};
|
||||
static arc arcs_30_1[2] = {
|
||||
{27, 0},
|
||||
|
@ -610,7 +611,7 @@ static arc arcs_31_0[1] = {
|
|||
{19, 1},
|
||||
};
|
||||
static arc arcs_31_1[2] = {
|
||||
{78, 0},
|
||||
{75, 0},
|
||||
{0, 1},
|
||||
};
|
||||
static state states_31[2] = {
|
||||
|
@ -1251,7 +1252,7 @@ static state states_58[5] = {
|
|||
static arc arcs_59_0[3] = {
|
||||
{13, 1},
|
||||
{136, 2},
|
||||
{78, 3},
|
||||
{75, 3},
|
||||
};
|
||||
static arc arcs_59_1[2] = {
|
||||
{14, 4},
|
||||
|
@ -1298,12 +1299,12 @@ static state states_60[3] = {
|
|||
{2, arcs_60_2},
|
||||
};
|
||||
static arc arcs_61_0[3] = {
|
||||
{78, 1},
|
||||
{75, 1},
|
||||
{26, 2},
|
||||
{21, 3},
|
||||
};
|
||||
static arc arcs_61_1[1] = {
|
||||
{78, 4},
|
||||
{75, 4},
|
||||
};
|
||||
static arc arcs_61_2[2] = {
|
||||
{21, 3},
|
||||
|
@ -1315,7 +1316,7 @@ static arc arcs_61_3[3] = {
|
|||
{0, 3},
|
||||
};
|
||||
static arc arcs_61_4[1] = {
|
||||
{78, 6},
|
||||
{75, 6},
|
||||
};
|
||||
static arc arcs_61_5[2] = {
|
||||
{151, 6},
|
||||
|
@ -1809,11 +1810,11 @@ static dfa dfas[79] = {
|
|||
{314, "lambdef", 0, 5, states_58,
|
||||
"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\020\000\000"},
|
||||
{315, "trailer", 0, 7, states_59,
|
||||
"\000\040\000\000\000\000\000\000\000\100\000\000\000\000\000\000\000\001\000\000\000"},
|
||||
"\000\040\000\000\000\000\000\000\000\010\000\000\000\000\000\000\000\001\000\000\000"},
|
||||
{316, "subscriptlist", 0, 3, states_60,
|
||||
"\000\040\050\000\000\000\000\000\000\100\000\000\000\002\000\140\010\111\023\000\000"},
|
||||
"\000\040\050\000\000\000\000\000\000\010\000\000\000\002\000\140\010\111\023\000\000"},
|
||||
{317, "subscript", 0, 7, states_61,
|
||||
"\000\040\050\000\000\000\000\000\000\100\000\000\000\002\000\140\010\111\023\000\000"},
|
||||
"\000\040\050\000\000\000\000\000\000\010\000\000\000\002\000\140\010\111\023\000\000"},
|
||||
{318, "sliceop", 0, 3, states_62,
|
||||
"\000\000\040\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
|
||||
{319, "exprlist", 0, 3, states_63,
|
||||
|
@ -1925,10 +1926,10 @@ static label labels[161] = {
|
|||
{1, "import"},
|
||||
{286, 0},
|
||||
{1, "from"},
|
||||
{23, 0},
|
||||
{285, 0},
|
||||
{283, 0},
|
||||
{284, 0},
|
||||
{23, 0},
|
||||
{1, "global"},
|
||||
{1, "exec"},
|
||||
{303, 0},
|
||||
|
|
Loading…
Reference in New Issue