s.context.future_directives.add(directive)
return Nodes.PassStatNode(pos)
elif kind == 'cimport':
- for (name_pos, name, as_name, kind) in imported_names:
- local_name = as_name or name
- if local_name == "*" and False:
- module = s.context.find_module(dotted_name)
- for type in module.type_entries:
- s.add_type_name(type.name)
- else:
- s.add_type_name(local_name)
return Nodes.FromCImportStatNode(pos,
module_name = dotted_name,
imported_names = imported_names)
rhs = None
if s.sy == 'IDENT':
name = EncodedString(s.systring)
- if is_type:
- s.add_type_name(name)
if empty:
error(s.position(), "Declarator should be empty")
s.next()
if s.sy == 'IDENT':
name = s.systring
s.next()
- s.add_type_name(name)
cname = p_opt_cname(s)
else:
name = None
s.next()
name = p_ident(s)
cname = p_opt_cname(s)
- s.add_type_name(name)
attributes = None
if s.sy == ':':
s.next()
as_name = p_ident(s)
else:
as_name = class_name
- s.add_type_name(as_name)
objstruct_name = None
typeobj_name = None
base_class_module = None
return None
def p_code(s, level=None):
- s.add_type_name("object")
- s.add_type_name("Py_buffer")
body = p_statement_list(s, Ctx(level = level), first_statement = 1)
if s.sy != 'EOF':
s.error("Syntax error in statement [%s,%s]" % (
return result
def p_module(s, pxd, full_module_name):
- s.add_type_name("object")
- s.add_type_name("Py_buffer")
pos = s.position()
doc = p_doc_string(s)
if pxd:
class PyrexScanner(Scanner):
# context Context Compilation context
- # type_names set Identifiers to be treated as type names
# included_files [string] Files included with 'include' statement
# compile_time_env dict Environment for conditional compilation
# compile_time_eval boolean In a true conditional compilation context
Scanner.__init__(self, get_lexicon(), file, filename)
if parent_scanner:
self.context = parent_scanner.context
- self.type_names = parent_scanner.type_names
self.included_files = parent_scanner.included_files
self.compile_time_env = parent_scanner.compile_time_env
self.compile_time_eval = parent_scanner.compile_time_eval
self.compile_time_expr = parent_scanner.compile_time_expr
else:
self.context = context
- self.type_names = scope.type_names
self.included_files = scope.included_files
self.compile_time_env = initial_compile_time_env()
self.compile_time_eval = 1
# This method should be added to Plex
self.queue.insert(0, (token, value))
- def add_type_name(self, name):
- self.type_names[name] = 1
-
- def looking_at_type_name(self):
- return self.sy == 'IDENT' and self.systring in self.type_names
-
def error(self, message, pos = None, fatal = True):
if pos is None:
pos = self.position()