from Cython.Compiler.Visitor import TreeVisitor
from Cython.Compiler.Nodes import *
++from Cython.Compiler.Symtab import TempName
"""
Serializes a Cython code tree to Cython code. This is primarily useful for
import ControlFlow
import __builtin__
+ class TempName(object):
+ """
+ Use instances of this class in order to provide a name for
+ anonymous, temporary functions. Each instance is considered
+ a seperate name, which are guaranteed not to clash with one
+ another or with names explicitly given as strings.
+
+ The argument to the constructor is simply a describing string
+ for debugging purposes and does not affect name clashes at all.
+
+ NOTE: Support for these TempNames are introduced on an as-needed
+ basis and will not "just work" everywhere. Places where they work:
+ - (none)
+ """
+ def __init__(self, description):
+ self.description = description
+
+ # Spoon-feed operators for documentation purposes
+ def __hash__(self):
+ return id(self)
+ def __cmp__(self, other):
+ return cmp(id(self), id(other))
+
possible_identifier = re.compile(ur"(?![0-9])\w+$", re.U).match
+nice_identifier = re.compile('^[a-zA-Z0-0_]+$').match
class Entry:
# A symbol table entry in a Scope or ModuleNamespace.
buf = StringIO(code.encode(encoding))
scanner = PyrexScanner(buf, code_source, source_encoding = encoding,
-- type_names = scope.type_names, context = context)
++ scope = scope, context = context)
tree = Parsing.p_module(scanner, 0, module_name)
return tree