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
c99e907d
Commit
c99e907d
authored
Aug 22, 2014
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow Cython keywords to be used as names.
Only cdef, cpdef, and ctypedef are dissallowed.
parent
97dd8ad0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
16 deletions
+20
-16
Cython/Parser/Grammar
Cython/Parser/Grammar
+20
-16
No files found.
Cython/Parser/Grammar
View file @
c99e907d
...
...
@@ -22,10 +22,10 @@ eval_input: testlist NEWLINE* ENDMARKER
decorator: '@' dotted_name [ '(' [arglist] ')' ] NEWLINE
decorators: decorator+
decorated: decorators (classdef | funcdef)
funcdef: 'def' NAME parameters ':' suite
funcdef: 'def'
PY_
NAME parameters ':' suite
parameters: '(' [varargslist] ')'
varargslist: ((fpdef ['=' test] ',')*
('*'
NAME [',' '**' NAME] | '**'
NAME) |
('*'
PY_NAME [',' '**' PY_NAME] | '**' PY_
NAME) |
fpdef ['=' (test | '*')] (',' fpdef ['=' (test | '*')])* [',']
['.' '.' '.'])
fpdef: maybe_typed_name | '(' fplist ')'
...
...
@@ -54,19 +54,19 @@ import_stmt: import_name | import_from
import_name: ('import' | 'cimport') dotted_as_names
import_from: ('from' ('.'* dotted_name | '.'+)
('import' | 'cimport') ('*' | '(' import_as_names ')' | import_as_names))
import_as_name:
NAME ['as'
NAME]
dotted_as_name: dotted_name ['as' NAME]
import_as_name:
PY_NAME ['as' PY_
NAME]
dotted_as_name: dotted_name ['as'
PY_
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)*
dotted_name:
PY_NAME ('.' PY_
NAME)*
global_stmt: 'global'
PY_NAME (',' PY_
NAME)*
exec_stmt: 'exec' expr ['in' test [',' test]]
assert_stmt: 'assert' test [',' test]
compound_stmt: if_stmt | while_stmt | for_stmt | try_stmt | with_stmt | funcdef | classdef | decorated
if_stmt: 'if' test ':' suite ('elif' test ':' suite)* ['else' ':' suite]
while_stmt: 'while' test ':' suite ['else' ':' suite]
for_stmt: 'for' exprlist ('in' testlist | 'from' expr comp_op NAME comp_op expr ['by' expr])':' suite ['else' ':' suite]
for_stmt: 'for' exprlist ('in' testlist | 'from' expr comp_op
PY_
NAME comp_op expr ['by' expr])':' suite ['else' ':' suite]
try_stmt: ('try' ':' suite
((except_clause ':' suite)+
['else' ':' suite]
...
...
@@ -106,11 +106,11 @@ atom: ('(' [yield_expr|testlist_comp] ')' |
'{' [dictorsetmaker] '}' |
'`' testlist1 '`' |
new_expr |
NAME | NUMBER | STRING+)
PY_
NAME | NUMBER | STRING+)
listmaker: test ( list_for | (',' test)* [','] )
testlist_comp: test ( comp_for | (',' test)* [','] )
lambdef: 'lambda' [varargslist] ':' test
trailer: '(' [arglist] ')' | '[' subscriptlist ']' | '.' NAME
trailer: '(' [arglist] ')' | '[' subscriptlist ']' | '.'
PY_
NAME
subscriptlist: subscript (',' subscript)* [',']
subscript: '.' '.' '.' | test | [test] ':' [test] [sliceop]
sliceop: ':' [test]
...
...
@@ -119,7 +119,7 @@ testlist: test (',' test)* [',']
dictorsetmaker: ( (test ':' test (comp_for | (',' test ':' test)* [','])) |
(test (comp_for | (',' test)* [','])) )
classdef: 'class' NAME ['(' [testlist] ')'] ':' suite
classdef: 'class'
PY_
NAME ['(' [testlist] ')'] ':' suite
arglist: (argument ',')* (argument [',']
|'*' test (',' argument)* [',' '**' test]
...
...
@@ -150,8 +150,8 @@ signedness: 'unsigned' | 'signed'
longness: 'char' | 'short' | 'long' | 'long' 'long'
int_type: signedness [longness] | longness | [signedness] [longness] ('int' | 'double') | 'complex' # TODO: [unsigned] double doesn't make sens, but we need long double
type: ['const'] (NAME ('.' NAME)* | int_type) ['complex'] [type_qualifiers]
maybe_typed_name: ['const'] (NAME [('.' NAME)* ['complex'] [type_qualifiers] NAME] | int_type ['complex'] [type_qualifiers] NAME)
type: ['const'] (NAME ('.'
PY_
NAME)* | int_type) ['complex'] [type_qualifiers]
maybe_typed_name: ['const'] (NAME [('.'
PY_
NAME)* ['complex'] [type_qualifiers] NAME] | int_type ['complex'] [type_qualifiers] NAME)
teplate_params: '[' NAME (',' NAME)* ']'
type_qualifiers: type_qualifier+
type_qualifier: '*' | '**' | '&' | type_index
...
...
@@ -174,15 +174,16 @@ ctypedef_stmt: 'ctypedef' (cvar_decl | struct | enum)
# Requires a type
cvar_decl: [visibility] type cname (NEWLINE | cfunc)
# Allows an assignment
cvar_def: maybe_typed_name (['=' test] (',' NAME ['=' test])* NEWLINE | cfunc)
cvar_def: maybe_typed_name (['=' test] (','
PY_
NAME ['=' test])* NEWLINE | cfunc)
visibility: 'public' | 'api' | 'readonly' | 'extern'
cfunc: [teplate_params] parameters [gil_spec] [exception_value] (':' suite | NEWLINE)
exception_value: 'except' (['?'] expr | '*' | '+' [NAME])
exception_value: 'except' (['?'] expr | '*' | '+' [
PY_
NAME])
gil_spec: 'with' ('gil' | 'nogil') | 'nogil'
cname: NAME [STRING]
cclass: classdef
fused: 'fused' NAME ':' NEWLINE INDENT ( type NEWLINE)+ DEDENT
fused: 'fused'
PY_
NAME ':' NEWLINE INDENT ( type NEWLINE)+ DEDENT
enum: 'enum' [cname] (NEWLINE | ':' enum_suite)
enum_suite: NEWLINE INDENT (cname ['=' NUMBER] NEWLINE | pass_stmt NEWLINE)+ DEDENT
struct: ('struct' | 'union') cname (NEWLINE | (':' struct_suite))
...
...
@@ -194,4 +195,7 @@ cppclass_suite: NEWLINE INDENT (cvar_decl | ctype_decl | pass_stmt NEWLINE)+ DED
extern_block: 'extern' 'from' ('*' | STRING) ['namespace' STRING] [gil_spec] ':' (pass_stmt | extern_suite)
extern_suite: NEWLINE INDENT (['cdef' | 'cpdef'] (cvar_decl | cdef_type_decl) | ctypedef_stmt)+ DEDENT
cname: NAME [STRING]
cy_type_kwd: 'struct' | 'union' | 'fused' | 'cppclass' | 'int' | 'double' | 'complex'
cy_kwd: cy_type_kwd | signedness | longness | visibility | 'gil' | 'nogil' | 'namespace' | 'const' | 'by'
PY_NAME: NAME | cy_kwd
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