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
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
cython
Commits
fc0bfb4d
Commit
fc0bfb4d
authored
May 03, 2009
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
removed various invalid syntax combinations for the c(p)def statement (#280)
parent
defbb401
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
12 deletions
+34
-12
Cython/Compiler/Parsing.py
Cython/Compiler/Parsing.py
+15
-12
tests/errors/cdef_syntax.pyx
tests/errors/cdef_syntax.pyx
+10
-0
tests/errors/cpdef_syntax.pyx
tests/errors/cpdef_syntax.pyx
+9
-0
No files found.
Cython/Compiler/Parsing.py
View file @
fc0bfb4d
...
@@ -1691,6 +1691,8 @@ def p_c_simple_base_type(s, self_flag, nonempty):
...
@@ -1691,6 +1691,8 @@ def p_c_simple_base_type(s, self_flag, nonempty):
longness
=
0
longness
=
0
module_path
=
[]
module_path
=
[]
pos
=
s
.
position
()
pos
=
s
.
position
()
if
not
s
.
sy
==
'IDENT'
:
error
(
pos
,
"Expected an identifier, found '%s'"
%
s
.
sy
)
if
looking_at_base_type
(
s
):
if
looking_at_base_type
(
s
):
#print "p_c_simple_base_type: looking_at_base_type at", s.position()
#print "p_c_simple_base_type: looking_at_base_type at", s.position()
is_basic
=
1
is_basic
=
1
...
@@ -2068,31 +2070,30 @@ def p_cdef_statement(s, ctx):
...
@@ -2068,31 +2070,30 @@ def p_cdef_statement(s, ctx):
elif
s
.
sy
==
'import'
:
elif
s
.
sy
==
'import'
:
s
.
next
()
s
.
next
()
return
p_cdef_extern_block
(
s
,
pos
,
ctx
)
return
p_cdef_extern_block
(
s
,
pos
,
ctx
)
if
p_nogil
(
s
):
el
if
p_nogil
(
s
):
ctx
.
nogil
=
1
ctx
.
nogil
=
1
if
s
.
sy
==
':'
:
if
ctx
.
overridable
:
error
(
pos
,
"cdef blocks cannot be declared cpdef"
)
return
p_cdef_block
(
s
,
ctx
)
elif
s
.
sy
==
':'
:
if
ctx
.
overridable
:
error
(
pos
,
"cdef blocks cannot be declared cpdef"
)
return
p_cdef_block
(
s
,
ctx
)
return
p_cdef_block
(
s
,
ctx
)
elif
s
.
sy
==
'class'
:
elif
s
.
sy
==
'class'
:
if
ctx
.
level
not
in
(
'module'
,
'module_pxd'
):
if
ctx
.
level
not
in
(
'module'
,
'module_pxd'
):
error
(
pos
,
"Extension type definition not allowed here"
)
error
(
pos
,
"Extension type definition not allowed here"
)
#if ctx.api
:
if
ctx
.
overridable
:
# error(pos, "'api' not allowed with extension class
")
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
in
(
"struct"
,
"union"
,
"enum"
,
"packed"
):
elif
s
.
sy
==
'IDENT'
and
s
.
systring
in
(
"struct"
,
"union"
,
"enum"
,
"packed"
):
if
ctx
.
level
not
in
(
'module'
,
'module_pxd'
):
if
ctx
.
level
not
in
(
'module'
,
'module_pxd'
):
error
(
pos
,
"C struct/union/enum definition not allowed here"
)
error
(
pos
,
"C struct/union/enum definition not allowed here"
)
#if ctx.visibility == 'public':
if
ctx
.
overridable
:
# error(pos, "Public struct/union/enum definition not implemented")
error
(
pos
,
"C struct/union/enum cannot be declared cpdef"
)
#if ctx.api:
# error(pos, "'api' not allowed with '%s'" % s.systring)
if
s
.
systring
==
"enum"
:
if
s
.
systring
==
"enum"
:
return
p_c_enum_definition
(
s
,
pos
,
ctx
)
return
p_c_enum_definition
(
s
,
pos
,
ctx
)
else
:
else
:
return
p_c_struct_or_union_definition
(
s
,
pos
,
ctx
)
return
p_c_struct_or_union_definition
(
s
,
pos
,
ctx
)
elif
s
.
sy
==
'pass'
:
node
=
p_pass_statement
(
s
)
s
.
expect_newline
(
'Expected a newline'
)
return
node
else
:
else
:
return
p_c_func_or_var_declaration
(
s
,
pos
,
ctx
)
return
p_c_func_or_var_declaration
(
s
,
pos
,
ctx
)
...
@@ -2100,6 +2101,8 @@ def p_cdef_block(s, ctx):
...
@@ -2100,6 +2101,8 @@ def p_cdef_block(s, ctx):
return
p_suite
(
s
,
ctx
(
cdef_flag
=
1
))
return
p_suite
(
s
,
ctx
(
cdef_flag
=
1
))
def
p_cdef_extern_block
(
s
,
pos
,
ctx
):
def
p_cdef_extern_block
(
s
,
pos
,
ctx
):
if
ctx
.
overridable
:
error
(
pos
,
"cdef extern blocks cannot be declared cpdef"
)
include_file
=
None
include_file
=
None
s
.
expect
(
'from'
)
s
.
expect
(
'from'
)
if
s
.
sy
==
'*'
:
if
s
.
sy
==
'*'
:
...
...
tests/errors/cdef_syntax.pyx
0 → 100644
View file @
fc0bfb4d
cdef
pass
cdef
void
cdef
nogil
class
test
:
pass
_ERRORS
=
u"""
2: 5: Expected an identifier, found 'pass'
3: 9: Empty declarator
4:11: Expected ':'
"""
tests/errors/cpdef_syntax.pyx
0 → 100644
View file @
fc0bfb4d
cpdef
nogil
:
pass
cpdef
nogil
class
test
:
pass
_ERRORS
=
u"""
2: 6: cdef blocks cannot be declared cpdef
3: 6: cdef blocks cannot be declared cpdef
3:12: Expected ':'
"""
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