Commit 9db14a42 authored by gsamain's avatar gsamain

cypdef keyword in parsing

parent ccdee500
...@@ -2239,7 +2239,7 @@ def p_statement(s, ctx, first_statement = 0): ...@@ -2239,7 +2239,7 @@ def p_statement(s, ctx, first_statement = 0):
s.error('decorator not allowed here') s.error('decorator not allowed here')
s.level = ctx.level s.level = ctx.level
decorators = p_decorators(s) decorators = p_decorators(s)
if not ctx.allow_struct_enum_decorator and s.sy not in ('def', 'cdef', 'cpdef', 'ccdef', 'class'): if not ctx.allow_struct_enum_decorator and s.sy not in ('def', 'cdef', 'cpdef', 'class'):
if s.sy == 'IDENT' and s.systring == 'async': if s.sy == 'IDENT' and s.systring == 'async':
pass # handled below pass # handled below
else: else:
...@@ -2253,12 +2253,6 @@ def p_statement(s, ctx, first_statement = 0): ...@@ -2253,12 +2253,6 @@ def p_statement(s, ctx, first_statement = 0):
if s.sy == 'cdef': if s.sy == 'cdef':
cdef_flag = 1 cdef_flag = 1
s.next() s.next()
elif s.sy == 'ccdef':
cdef_flag = 1
nogil_flag = 1
s.next()
if s.systring not in ("class", "cppclass"):
s.error('ccdef statement only allowed for extension type or cppclass')
elif s.sy == 'cpdef': elif s.sy == 'cpdef':
s.level = ctx.level s.level = ctx.level
cdef_flag = 1 cdef_flag = 1
...@@ -3086,7 +3080,7 @@ def p_cdef_statement(s, ctx): ...@@ -3086,7 +3080,7 @@ def p_cdef_statement(s, ctx):
if ctx.overridable: if ctx.overridable:
error(pos, "Extension types cannot be declared cpdef") error(pos, "Extension types cannot be declared cpdef")
return p_c_class_definition(s, pos, ctx) return p_c_class_definition(s, pos, ctx)
elif s.sy == 'IDENT' and s.systring == 'cppclass': elif s.sy == 'IDENT' and s.systring in ('cppclass', 'cypclass'):
return p_cpp_class_definition(s, pos, ctx) return p_cpp_class_definition(s, pos, ctx)
elif s.sy == 'IDENT' and s.systring in struct_enum_union: elif s.sy == 'IDENT' and s.systring in struct_enum_union:
if ctx.level not in ('module', 'module_pxd'): if ctx.level not in ('module', 'module_pxd'):
...@@ -3756,7 +3750,8 @@ def p_template_definition(s): ...@@ -3756,7 +3750,8 @@ def p_template_definition(s):
return name, required return name, required
def p_cpp_class_definition(s, pos, ctx): def p_cpp_class_definition(s, pos, ctx):
# s.sy == 'cppclass' # s.sy in ('cppclass', 'cypclass')
cypclass = s.systring == 'cypclass'
s.next() s.next()
module_path = [] module_path = []
class_name = p_ident(s) class_name = p_ident(s)
...@@ -3813,7 +3808,7 @@ def p_cpp_class_definition(s, pos, ctx): ...@@ -3813,7 +3808,7 @@ def p_cpp_class_definition(s, pos, ctx):
visibility = ctx.visibility, visibility = ctx.visibility,
in_pxd = ctx.level == 'module_pxd', in_pxd = ctx.level == 'module_pxd',
attributes = attributes, attributes = attributes,
templates = templates, cypclass=nogil) templates = templates, cypclass=cypclass)
def p_cpp_class_attribute(s, ctx): def p_cpp_class_attribute(s, ctx):
decorators = None decorators = None
......
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