summaryrefslogtreecommitdiff
path: root/Cython/Compiler/Lexicon.py
diff options
context:
space:
mode:
authorDag Sverre Seljebotn <dagss@student.matnat.uio.no>2008-08-04 15:25:52 +0200
committerDag Sverre Seljebotn <dagss@student.matnat.uio.no>2008-08-04 15:25:52 +0200
commit2191ad0d35115b2910e736ce58dab6272a0bba3c (patch)
treeb48c3c36537b4de5d7a45b96d955a56d27ddd234 /Cython/Compiler/Lexicon.py
parent9f2c76647125a736cfac76c019448a91ed341050 (diff)
downloadcython-2191ad0d35115b2910e736ce58dab6272a0bba3c.tar.gz
Added global compilation option/pragma support to parser and command line
Diffstat (limited to 'Cython/Compiler/Lexicon.py')
-rw-r--r--Cython/Compiler/Lexicon.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/Cython/Compiler/Lexicon.py b/Cython/Compiler/Lexicon.py
index dade469e7..f1282c87b 100644
--- a/Cython/Compiler/Lexicon.py
+++ b/Cython/Compiler/Lexicon.py
@@ -66,6 +66,7 @@ def make_lexicon():
escapeseq = Str("\\") + (two_oct | three_oct | two_hex |
Str('u') + four_hex | Str('x') + two_hex | AnyChar)
+
deco = Str("@")
bra = Any("([{")
ket = Any(")]}")
@@ -74,9 +75,12 @@ def make_lexicon():
"+=", "-=", "*=", "/=", "%=", "|=", "^=", "&=",
"<<=", ">>=", "**=", "//=")
spaces = Rep1(Any(" \t\f"))
- comment = Str("#") + Rep(AnyBut("\n"))
escaped_newline = Str("\\\n")
lineterm = Eol + Opt(Str("\n"))
+
+ comment_start = Str("#")
+ comment = comment_start + Rep(AnyBut("\n"))
+ option_comment = comment_start + Str("cython:") + Rep(AnyBut("\n"))
return Lexicon([
(name, 'IDENT'),
@@ -93,11 +97,13 @@ def make_lexicon():
#(stringlit, 'STRING'),
(beginstring, Method('begin_string_action')),
+ (option_comment, 'option_comment'),
(comment, IGNORE),
(spaces, IGNORE),
(escaped_newline, IGNORE),
State('INDENT', [
+ (option_comment + lineterm, 'option_comment'),
(Opt(spaces) + Opt(comment) + lineterm, IGNORE),
(indentation, Method('indentation_action')),
(Eof, Method('eof_action'))