Commit af01f9aa authored by Robert Bradshaw's avatar Robert Bradshaw

Cleanup grammar

parent dc658c46
...@@ -146,6 +146,7 @@ yield_expr: 'yield' [testlist] ...@@ -146,6 +146,7 @@ yield_expr: 'yield' [testlist]
# Cython extensions # Cython extensions
type: NAME type: NAME
maybe_typed_name: NAME [('.' NAME)* NAME]
teplate_params: '[' NAME (',' NAME)* ']' teplate_params: '[' NAME (',' NAME)* ']'
address: '&' factor address: '&' factor
...@@ -153,11 +154,20 @@ cast: '<' type ['?'] '>' factor ...@@ -153,11 +154,20 @@ cast: '<' type ['?'] '>' factor
size_of: 'sizeof' '(' (type) ')' size_of: 'sizeof' '(' (type) ')'
new_expr: 'new' type '(' [arglist] ')' new_expr: 'new' type '(' [arglist] ')'
cdef_stmt: ('cdef' | 'cpdef') (classdef | cdef_decl | extern_block) cdef_stmt: ('cdef' | 'cpdef') (cvar_def | cdef_type_decl | extern_block)
cdef_decl: cvar_decl | struct | enum | fused | cppclass cdef_type_decl: ctype_decl | fused | cclass
ctype_decl: struct | enum | cppclass
# These two are similar but can't be used in an or clause
# as it would cause ambiguity in the LL(1) parser.
# Requires a type
cvar_decl: type NAME NEWLINE cvar_decl: type NAME NEWLINE
# Allows an assignment
cvar_def: maybe_typed_name NEWLINE
ctypedef_stmt: 'ctypedef' (cvar_decl | struct | enum) ctypedef_stmt: 'ctypedef' (cvar_decl | struct | enum)
cclass: classdef
fused: 'fused' NAME ':' NEWLINE INDENT ( type NEWLINE)+ DEDENT fused: 'fused' NAME ':' NEWLINE INDENT ( type NEWLINE)+ DEDENT
enum: 'enum' [NAME] (NEWLINE | ':' enum_suite) enum: 'enum' [NAME] (NEWLINE | ':' enum_suite)
enum_suite: NEWLINE INDENT (NAME ['=' NUMBER] NEWLINE | pass_stmt NEWLINE)+ DEDENT enum_suite: NEWLINE INDENT (NAME ['=' NUMBER] NEWLINE | pass_stmt NEWLINE)+ DEDENT
...@@ -165,7 +175,7 @@ struct: ('struct' | 'union') NAME (NEWLINE | (':' struct_suite)) ...@@ -165,7 +175,7 @@ struct: ('struct' | 'union') NAME (NEWLINE | (':' struct_suite))
struct_suite: NEWLINE INDENT (cvar_decl | pass_stmt NEWLINE)+ DEDENT struct_suite: NEWLINE INDENT (cvar_decl | pass_stmt NEWLINE)+ DEDENT
cppclass: 'cppclass' NAME [teplate_params] [cppclass_bases] (NEWLINE | ':' cppclass_suite) cppclass: 'cppclass' NAME [teplate_params] [cppclass_bases] (NEWLINE | ':' cppclass_suite)
cppclass_bases: '(' dotted_name (',' dotted_name [teplate_params])*')' cppclass_bases: '(' dotted_name (',' dotted_name [teplate_params])*')'
cppclass_suite: NEWLINE INDENT (cdef_decl | pass_stmt NEWLINE)+ DEDENT cppclass_suite: NEWLINE INDENT (cvar_decl | ctype_decl | pass_stmt NEWLINE)+ DEDENT
extern_block: 'extern' 'from' ('*' | STRING) ['namespace' STRING] ':' (pass_stmt | extern_suite) extern_block: 'extern' 'from' ('*' | STRING) ['namespace' STRING] ':' (pass_stmt | extern_suite)
extern_suite: NEWLINE INDENT (['cdef' | 'cpdef'] cdef_decl | ctypedef_stmt)+ DEDENT extern_suite: NEWLINE INDENT (['cdef' | 'cpdef'] (cvar_decl | cdef_type_decl) | ctypedef_stmt)+ DEDENT
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment