#(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'))
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")
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]" % (
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]
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]
@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):
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
"""