Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
3aa90569
Commit
3aa90569
authored
Aug 22, 2014
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Py3 Grammar NAME -> PY_NAME
parent
2745e9ce
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
21 deletions
+21
-21
Cython/Parser/Grammar
Cython/Parser/Grammar
+21
-21
No files found.
Cython/Parser/Grammar
View file @
3aa90569
...
...
@@ -19,19 +19,19 @@ single_input: NEWLINE | simple_stmt | compound_stmt NEWLINE
file_input: (NEWLINE | stmt)* ENDMARKER
eval_input: testlist NEWLINE* ENDMARKER
decorator: '@' dotted_
name
[ '(' [arglist] ')' ] NEWLINE
decorator: '@' dotted_
PY_NAME
[ '(' [arglist] ')' ] NEWLINE
decorators: decorator+
decorated: decorators (classdef | funcdef)
funcdef: 'def' NAME parameters ['->' test] ':' suite
funcdef: 'def'
PY_
NAME parameters ['->' test] ':' suite
parameters: '(' [typedargslist] ')'
typedargslist: (tfpdef ['=' test] (',' tfpdef ['=' test])* [','
['*' [tfpdef] (',' tfpdef ['=' test])* [',' '**' tfpdef] | '**' tfpdef]]
| '*' [tfpdef] (',' tfpdef ['=' test])* [',' '**' tfpdef] | '**' tfpdef)
tfpdef: NAME [':' test]
tfpdef:
PY_
NAME [':' test]
varargslist: (vfpdef ['=' test] (',' vfpdef ['=' test])* [','
['*' [vfpdef] (',' vfpdef ['=' test])* [',' '**' vfpdef] | '**' vfpdef]]
| '*' [vfpdef] (',' vfpdef ['=' test])* [',' '**' vfpdef] | '**' vfpdef)
vfpdef: NAME
vfpdef:
PY_
NAME
stmt: simple_stmt | compound_stmt
simple_stmt: small_stmt (';' small_stmt)* [';'] NEWLINE
...
...
@@ -51,18 +51,18 @@ continue_stmt: 'continue'
return_stmt: 'return' [testlist]
yield_stmt: yield_expr
raise_stmt: 'raise' [test ['from' test]]
import_stmt: import_
name
| import_from
import_
name: 'import' dotted_as_name
s
import_stmt: import_
PY_NAME
| import_from
import_
PY_NAME: 'import' dotted_as_PY_NAME
s
# note below: the ('.' | '...') is necessary because '...' is tokenized as ELLIPSIS
import_from: ('from' (('.' | '...')* dotted_
name
| ('.' | '...')+)
'import' ('*' | '(' import_as_
names ')' | import_as_name
s))
import_as_
name: NAME ['as'
NAME]
dotted_as_
name: dotted_name ['as'
NAME]
import_as_
names: import_as_name (',' import_as_name
)* [',']
dotted_as_
names: dotted_as_name (',' dotted_as_name
)*
dotted_
name: NAME ('.'
NAME)*
global_stmt: 'global'
NAME (','
NAME)*
nonlocal_stmt: 'nonlocal'
NAME (','
NAME)*
import_from: ('from' (('.' | '...')* dotted_
PY_NAME
| ('.' | '...')+)
'import' ('*' | '(' import_as_
PY_NAMEs ')' | import_as_PY_NAME
s))
import_as_
PY_NAME: PY_NAME ['as' PY_
NAME]
dotted_as_
PY_NAME: dotted_PY_NAME ['as' PY_
NAME]
import_as_
PY_NAMEs: import_as_PY_NAME (',' import_as_PY_NAME
)* [',']
dotted_as_
PY_NAMEs: dotted_as_PY_NAME (',' dotted_as_PY_NAME
)*
dotted_
PY_NAME: PY_NAME ('.' PY_
NAME)*
global_stmt: 'global'
PY_NAME (',' PY_
NAME)*
nonlocal_stmt: 'nonlocal'
PY_NAME (',' PY_
NAME)*
assert_stmt: 'assert' test [',' test]
compound_stmt: if_stmt | while_stmt | for_stmt | try_stmt | with_stmt | funcdef | classdef | decorated
...
...
@@ -77,7 +77,7 @@ try_stmt: ('try' ':' suite
with_stmt: 'with' with_item (',' with_item)* ':' suite
with_item: test ['as' expr]
# NB compile.c makes sure that the default except clause is last
except_clause: 'except' [test ['as' NAME]]
except_clause: 'except' [test ['as'
PY_
NAME]]
suite: simple_stmt | NEWLINE INDENT stmt+ DEDENT
test: or_test ['if' or_test 'else' test] | lambdef
...
...
@@ -103,9 +103,9 @@ power: atom trailer* ['**' factor]
atom: ('(' [yield_expr|testlist_comp] ')' |
'[' [testlist_comp] ']' |
'{' [dictorsetmaker] '}' |
NAME | NUMBER | STRING+ | '...' | 'None' | 'True' | 'False')
PY_
NAME | NUMBER | STRING+ | '...' | 'None' | 'True' | 'False')
testlist_comp: (test|star_expr) ( comp_for | (',' (test|star_expr))* [','] )
trailer: '(' [arglist] ')' | '[' subscriptlist ']' | '.' NAME
trailer: '(' [arglist] ')' | '[' subscriptlist ']' | '.'
PY_
NAME
subscriptlist: subscript (',' subscript)* [',']
subscript: test | [test] ':' [test] [sliceop]
sliceop: ':' [test]
...
...
@@ -114,13 +114,13 @@ testlist: test (',' test)* [',']
dictorsetmaker: ( (test ':' test (comp_for | (',' test ':' test)* [','])) |
(test (comp_for | (',' test)* [','])) )
classdef: 'class' NAME ['(' [arglist] ')'] ':' suite
classdef: 'class'
PY_
NAME ['(' [arglist] ')'] ':' suite
arglist: (argument ',')* (argument [',']
|'*' test (',' argument)* [',' '**' test]
|'**' test)
# The reason that keywords are test nodes instead of
NAME is that using
NAME
# results in an ambiguity. ast.c makes sure it's a NAME.
# The reason that keywords are test nodes instead of
PY_NAME is that using PY_
NAME
# results in an ambiguity. ast.c makes sure it's a
PY_
NAME.
argument: test [comp_for] | test '=' test # Really [keyword '='] test
comp_iter: comp_for | comp_if
comp_for: 'for' exprlist 'in' or_test [comp_iter]
...
...
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