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
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
Show 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():
...
@@ -97,13 +97,13 @@ def make_lexicon():
#(stringlit, 'STRING'),
#(stringlit, 'STRING'),
(
beginstring
,
Method
(
'begin_string_action'
)),
(
beginstring
,
Method
(
'begin_string_action'
)),
(
option_comment
,
'option_comment'
),
(
option_comment
,
Method
(
'option_comment'
)
),
(
comment
,
IGNORE
),
(
comment
,
IGNORE
),
(
spaces
,
IGNORE
),
(
spaces
,
IGNORE
),
(
escaped_newline
,
IGNORE
),
(
escaped_newline
,
IGNORE
),
State
(
'INDENT'
,
[
State
(
'INDENT'
,
[
(
option_comment
+
lineterm
,
'option_comment'
),
(
option_comment
+
lineterm
,
Method
(
'option_comment'
)
),
(
Opt
(
spaces
)
+
Opt
(
comment
)
+
lineterm
,
IGNORE
),
(
Opt
(
spaces
)
+
Opt
(
comment
)
+
lineterm
,
IGNORE
),
(
indentation
,
Method
(
'indentation_action'
)),
(
indentation
,
Method
(
'indentation_action'
)),
(
Eof
,
Method
(
'eof_action'
))
(
Eof
,
Method
(
'eof_action'
))
...
...
Cython/Compiler/Parsing.py
View file @
40f52c12
...
@@ -507,8 +507,6 @@ def p_atom(s):
...
@@ -507,8 +507,6 @@ def p_atom(s):
elif
sy
==
'NULL'
:
elif
sy
==
'NULL'
:
s
.
next
()
s
.
next
()
return
ExprNodes
.
NullNode
(
pos
)
return
ExprNodes
.
NullNode
(
pos
)
elif
sy
==
'option_comment'
:
s
.
error
(
"#cython option comments only allowed at beginning of file"
)
else
:
else
:
s
.
error
(
"Expected an identifier or literal"
)
s
.
error
(
"Expected an identifier or literal"
)
...
@@ -2342,6 +2340,7 @@ def p_module(s, pxd, full_module_name):
...
@@ -2342,6 +2340,7 @@ def p_module(s, pxd, full_module_name):
level
=
'module'
level
=
'module'
option_comments
=
p_option_comments
(
s
)
option_comments
=
p_option_comments
(
s
)
s
.
parse_option_comments
=
False
body
=
p_statement_list
(
s
,
Ctx
(
level
=
level
),
first_statement
=
1
)
body
=
p_statement_list
(
s
,
Ctx
(
level
=
level
),
first_statement
=
1
)
if
s
.
sy
!=
'EOF'
:
if
s
.
sy
!=
'EOF'
:
s
.
error
(
"Syntax error in statement [%s,%s]"
%
(
s
.
error
(
"Syntax error in statement [%s,%s]"
%
(
...
...
Cython/Compiler/Scanning.py
View file @
40f52c12
...
@@ -303,6 +303,7 @@ class PyrexScanner(Scanner):
...
@@ -303,6 +303,7 @@ class PyrexScanner(Scanner):
self
.
compile_time_env
=
initial_compile_time_env
()
self
.
compile_time_env
=
initial_compile_time_env
()
self
.
compile_time_eval
=
1
self
.
compile_time_eval
=
1
self
.
compile_time_expr
=
0
self
.
compile_time_expr
=
0
self
.
parse_option_comments
=
True
self
.
source_encoding
=
source_encoding
self
.
source_encoding
=
source_encoding
self
.
trace
=
trace_scanner
self
.
trace
=
trace_scanner
self
.
indentation_stack
=
[
0
]
self
.
indentation_stack
=
[
0
]
...
@@ -312,6 +313,13 @@ class PyrexScanner(Scanner):
...
@@ -312,6 +313,13 @@ class PyrexScanner(Scanner):
self
.
sy
=
''
self
.
sy
=
''
self
.
next
()
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
):
def
current_level
(
self
):
return
self
.
indentation_stack
[
-
1
]
return
self
.
indentation_stack
[
-
1
]
...
...
tests/compile/c_options.pyx
View file @
40f52c12
...
@@ -10,6 +10,9 @@ def f(object[int, 2] buf):
...
@@ -10,6 +10,9 @@ def f(object[int, 2] buf):
@
cy
.
boundscheck
(
True
)
@
cy
.
boundscheck
(
True
)
def
g
(
object
[
int
,
2
]
buf
):
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
]
print
buf
[
3
,
2
]
def
h
(
object
[
int
,
2
]
buf
):
def
h
(
object
[
int
,
2
]
buf
):
...
...
tests/errors/e_options.pyx
View file @
40f52c12
...
@@ -17,6 +17,5 @@ _ERRORS = u"""
...
@@ -17,6 +17,5 @@ _ERRORS = u"""
2:0: Expected "=" in option "nonexistant"
2:0: Expected "=" in option "nonexistant"
3:0: Unknown option: "some"
3:0: Unknown option: "some"
10:0: Must pass a boolean value for option "boundscheck"
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