From: Robert Bradshaw Date: Thu, 14 May 2009 07:58:11 +0000 (-0700) Subject: Compiler directive fixes, add c99 complex directive X-Git-Tag: 0.11.2.rc1~10^2~21 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=e8e3a368d3595fe7f096fd4528d361e8dfb8851e;p=cython.git Compiler directive fixes, add c99 complex directive --- diff --git a/Cython/Compiler/Options.py b/Cython/Compiler/Options.py index faaec3cd..4c1493c0 100644 --- a/Cython/Compiler/Options.py +++ b/Cython/Compiler/Options.py @@ -64,7 +64,9 @@ option_defaults = { 'cdivision': True, # Will be False in 0.12 'cdivision_warnings': False, 'always_allow_keywords': False, - 'wraparound' : True + 'wraparound' : True, + 'c99_complex' : False, + 'a': 4, } # Override types possibilities above, if needed @@ -95,6 +97,11 @@ def parse_option_value(name, value): if value == "True": return True elif value == "False": return False else: raise ValueError("%s directive must be set to True or False" % name) + elif type is int: + try: + return int(value) + except ValueError: + raise ValueError("%s directive must be set to an integer" % name) else: assert False diff --git a/Cython/Compiler/Parsing.py b/Cython/Compiler/Parsing.py index cf679d07..7fcf13ab 100644 --- a/Cython/Compiler/Parsing.py +++ b/Cython/Compiler/Parsing.py @@ -2488,7 +2488,7 @@ def p_code(s, level=None): repr(s.sy), repr(s.systring))) return body -COMPILER_DIRECTIVE_COMMENT_RE = re.compile(r"^#\s*cython:\s*([a-z_]+)\s*=(.*)$") +COMPILER_DIRECTIVE_COMMENT_RE = re.compile(r"^#\s*cython:\s*(\w+)\s*=(.*)$") def p_compiler_directive_comments(s): result = {} @@ -2498,10 +2498,10 @@ def p_compiler_directive_comments(s): name = m.group(1) try: value = Options.parse_option_value(str(name), str(m.group(2).strip())) + if value is not None: # can be False! + result[name] = value except ValueError, e: s.error(e.args[0], fatal=False) - if value is not None: # can be False! - result[name] = value s.next() return result