From ecd248edaa8eea17718c8a65eb5f208fe84acf93 Mon Sep 17 00:00:00 2001 From: Robert Bradshaw Date: Tue, 11 Nov 2008 12:26:03 -0800 Subject: [PATCH] more bootstrap tweaks --- Cython/Compiler/Lexicon.py | 3 ++- Cython/Compiler/Nodes.py | 3 ++- Cython/Compiler/Scanning.py | 10 +++++++--- Cython/Plex/Scanners.pxd | 6 ++++-- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/Cython/Compiler/Lexicon.py b/Cython/Compiler/Lexicon.py index 6b13ecd5..53e70c64 100644 --- a/Cython/Compiler/Lexicon.py +++ b/Cython/Compiler/Lexicon.py @@ -7,6 +7,7 @@ raw_prefixes = "rR" string_prefixes = "cCuUbB" +IDENT = 'IDENT' def make_lexicon(): from Cython.Plex import \ @@ -82,7 +83,7 @@ def make_lexicon(): comment = Str("#") + Rep(AnyBut("\n")) return Lexicon([ - (name, 'IDENT'), + (name, IDENT), (intliteral, 'INT'), (fltconst, 'FLOAT'), (imagconst, 'IMAG'), diff --git a/Cython/Compiler/Nodes.py b/Cython/Compiler/Nodes.py index 59f00c94..67e67049 100644 --- a/Cython/Compiler/Nodes.py +++ b/Cython/Compiler/Nodes.py @@ -756,7 +756,8 @@ class CVarDefNode(StatNode): entry = dest_scope.declare_cfunction(name, type, declarator.pos, cname = cname, visibility = self.visibility, in_pxd = self.in_pxd, api = self.api) - entry.pxd_locals = self.pxd_locals + if entry is not None: + entry.pxd_locals = self.pxd_locals else: if self.in_pxd and self.visibility != 'extern': error(self.pos, diff --git a/Cython/Compiler/Scanning.py b/Cython/Compiler/Scanning.py index 797ba7b8..b19d67f7 100644 --- a/Cython/Compiler/Scanning.py +++ b/Cython/Compiler/Scanning.py @@ -11,11 +11,14 @@ import stat import sys from time import time +import cython +cython.declare(EncodedString=object, string_prefixes=object, raw_prefixes=object, IDENT=object) + from Cython import Plex, Utils from Cython.Plex.Scanners import Scanner from Cython.Plex.Errors import UnrecognizedInput from Errors import CompileError, error -from Lexicon import string_prefixes, raw_prefixes, make_lexicon +from Lexicon import string_prefixes, raw_prefixes, make_lexicon, IDENT from StringEncoding import EncodedString @@ -168,6 +171,7 @@ def build_resword_dict(): d[word] = 1 return d +cython.declare(resword_dict=object) resword_dict = build_resword_dict() #------------------------------------------------------------------ @@ -407,7 +411,7 @@ class PyrexScanner(Scanner): sy, systring = self.read() except UnrecognizedInput: self.error("Unrecognized character") - if sy == 'IDENT': + if sy == IDENT: if systring in resword_dict: sy = systring else: @@ -447,7 +451,7 @@ class PyrexScanner(Scanner): self.expected(what, message) def expect_keyword(self, what, message = None): - if self.sy == 'IDENT' and self.systring == what: + if self.sy == IDENT and self.systring == what: self.next() else: self.expected(what, message) diff --git a/Cython/Plex/Scanners.pxd b/Cython/Plex/Scanners.pxd index 1416ce0d..e20b80fa 100644 --- a/Cython/Plex/Scanners.pxd +++ b/Cython/Plex/Scanners.pxd @@ -1,6 +1,7 @@ import cython cdef class Scanner: + cdef public lexicon cdef public stream cdef public name @@ -20,12 +21,13 @@ cdef class Scanner: cdef public bint trace cdef public cur_char cdef public input_state - - cdef public level # int? + + cdef public level cpdef next_char(self): cdef: long input_state + cpdef read(self) cpdef run_machine_inlined(self): cdef: -- 2.26.2