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
40f52c12
Commit
40f52c12
authored
Aug 05, 2008
by
Dag Sverre Seljebotn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Treating cython: comments as regular comments when not at top
parent
b629f965
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
14 additions
and
5 deletions
+14
-5
Cython/Compiler/Lexicon.py
Cython/Compiler/Lexicon.py
+2
-2
Cython/Compiler/Parsing.py
Cython/Compiler/Parsing.py
+1
-2
Cython/Compiler/Scanning.py
Cython/Compiler/Scanning.py
+8
-0
tests/compile/c_options.pyx
tests/compile/c_options.pyx
+3
-0
tests/errors/e_options.pyx
tests/errors/e_options.pyx
+0
-1
No files found.
Cython/Compiler/Lexicon.py
View file @
40f52c12
...
...
@@ -97,13 +97,13 @@ def make_lexicon():
#(stringlit, 'STRING'),
(
beginstring
,
Method
(
'begin_string_action'
)),
(
option_comment
,
'option_comment'
),
(
option_comment
,
Method
(
'option_comment'
)
),
(
comment
,
IGNORE
),
(
spaces
,
IGNORE
),
(
escaped_newline
,
IGNORE
),
State
(
'INDENT'
,
[
(
option_comment
+
lineterm
,
'option_comment'
),
(
option_comment
+
lineterm
,
Method
(
'option_comment'
)
),
(
Opt
(
spaces
)
+
Opt
(
comment
)
+
lineterm
,
IGNORE
),
(
indentation
,
Method
(
'indentation_action'
)),
(
Eof
,
Method
(
'eof_action'
))
...
...
Cython/Compiler/Parsing.py
View file @
40f52c12
...
...
@@ -507,8 +507,6 @@ def p_atom(s):
elif
sy
==
'NULL'
:
s
.
next
()
return
ExprNodes
.
NullNode
(
pos
)
elif
sy
==
'option_comment'
:
s
.
error
(
"#cython option comments only allowed at beginning of file"
)
else
:
s
.
error
(
"Expected an identifier or literal"
)
...
...
@@ -2342,6 +2340,7 @@ def p_module(s, pxd, full_module_name):
level
=
'module'
option_comments
=
p_option_comments
(
s
)
s
.
parse_option_comments
=
False
body
=
p_statement_list
(
s
,
Ctx
(
level
=
level
),
first_statement
=
1
)
if
s
.
sy
!=
'EOF'
:
s
.
error
(
"Syntax error in statement [%s,%s]"
%
(
...
...
Cython/Compiler/Scanning.py
View file @
40f52c12
...
...
@@ -303,6 +303,7 @@ class PyrexScanner(Scanner):
self
.
compile_time_env
=
initial_compile_time_env
()
self
.
compile_time_eval
=
1
self
.
compile_time_expr
=
0
self
.
parse_option_comments
=
True
self
.
source_encoding
=
source_encoding
self
.
trace
=
trace_scanner
self
.
indentation_stack
=
[
0
]
...
...
@@ -311,6 +312,13 @@ class PyrexScanner(Scanner):
self
.
begin
(
'INDENT'
)
self
.
sy
=
''
self
.
next
()
def
option_comment
(
self
,
text
):
# #cython:-comments should be treated as literals until
# parse_option_comments is set to False, at which point
# they should be ignored.
if
self
.
parse_option_comments
:
self
.
produce
(
'option_comment'
,
text
)
def
current_level
(
self
):
return
self
.
indentation_stack
[
-
1
]
...
...
tests/compile/c_options.pyx
View file @
40f52c12
...
...
@@ -10,6 +10,9 @@ def f(object[int, 2] buf):
@
cy
.
boundscheck
(
True
)
def
g
(
object
[
int
,
2
]
buf
):
# Please leave this comment,
#cython: this should have no special meaning
# even if the above line doesn't follow indentation.
print
buf
[
3
,
2
]
def
h
(
object
[
int
,
2
]
buf
):
...
...
tests/errors/e_options.pyx
View file @
40f52c12
...
...
@@ -17,6 +17,5 @@ _ERRORS = u"""
2:0: Expected "=" in option "nonexistant"
3:0: Unknown option: "some"
10:0: Must pass a boolean value for option "boundscheck"
14:0: #cython option comments only allowed at beginning of file
"""
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