Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
d75211a1
Commit
d75211a1
authored
Dec 18, 2005
by
Neal Norwitz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Wrap long lines in the grammar
parent
65f7a74e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
25 deletions
+40
-25
Grammar/Grammar
Grammar/Grammar
+23
-9
Python/graminit.c
Python/graminit.c
+17
-16
No files found.
Grammar/Grammar
View file @
d75211a1
...
...
@@ -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]
Python/graminit.c
View file @
d75211a1
...
...
@@ -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
},
{
7
5
,
4
},
{
7
6
,
4
},
};
static
arc
arcs_26_4
[
1
]
=
{
{
0
,
4
},
};
static
arc
arcs_26_5
[
1
]
=
{
{
7
5
,
6
},
{
7
6
,
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
]
=
{
{
7
6
,
1
},
{
7
7
,
1
},
};
static
arc
arcs_29_1
[
2
]
=
{
{
27
,
2
},
{
0
,
1
},
};
static
arc
arcs_29_2
[
2
]
=
{
{
7
6
,
1
},
{
7
7
,
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
]
=
{
{
7
7
,
1
},
{
7
8
,
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
]
=
{
{
7
8
,
0
},
{
7
5
,
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
},
{
7
8
,
3
},
{
7
5
,
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
]
=
{
{
7
8
,
1
},
{
7
5
,
1
},
{
26
,
2
},
{
21
,
3
},
};
static
arc
arcs_61_1
[
1
]
=
{
{
7
8
,
4
},
{
7
5
,
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
]
=
{
{
7
8
,
6
},
{
7
5
,
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\
10
0\000\000\000\000\000\000\000\001\000\000\000
"
},
"
\000\040\000\000\000\000\000\000\000\
01
0\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\
10
0\000\000\000\002\000\140\010\111\023\000\000
"
},
"
\000\040\050\000\000\000\000\000\000\
01
0\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\
10
0\000\000\000\002\000\140\010\111\023\000\000
"
},
"
\000\040\050\000\000\000\000\000\000\
01
0\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
},
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment