return raw_string
-class AnnotationItem:
+class AnnotationItem(object):
def __init__(self, style, text, tag="", size=0):
self.style = style
self.putln("__Pyx_FinishRefcountContext();")
-class PyrexCodeWriter:
+class PyrexCodeWriter(object):
# f file output file
# level int indentation level
_END_POS = ((unichr(sys.maxunicode)*10),())
-class ControlFlow:
+class ControlFlow(object):
def __init__(self, start_pos, incoming, parent):
self.start_pos = start_pos
from Errors import CompileError
-class EmptyScope:
+class EmptyScope(object):
def lookup(self, name):
return None
print t.dump()
return t
-class CompilationData:
+class CompilationData(object):
# Bundles the information that is passed from transform to transform.
# (For now, this is only)
# result CompilationResult
pass
-class Context:
+class Context(object):
# This class encapsulates the context needed for compiling
# one or more Cython implementation files along with their
# associated and imported declaration files. It includes
self.full_module_name = full_module_name
self.cwd = cwd
-class CompilationOptions:
+class CompilationOptions(object):
"""
Options to the Cython compiler:
self.obj_only = 0
-class CompilationResult:
+class CompilationResult(object):
"""
Results from the Cython compiler:
if self.else_clause is not None:
self.else_clause.annotate(code)
-class LoopNode:
+class LoopNode(object):
def analyse_control_flow(self, env):
env.start_branching(self.pos)
self.name_nodes.append(node)
-class SkipDeclarations:
+class SkipDeclarations(object):
"""
Variable and function declarations can often have a deep tree structure,
and yet most transformations don't need to descend to this depth.
"cimport", "by", "with", "cpdef", "DEF", "IF", "ELIF", "ELSE"
]
-class Method:
+class Method(object):
def __init__(self, name):
self.name = name
#------------------------------------------------------------------
-class CompileTimeScope:
+class CompileTimeScope(object):
def __init__(self, outer = None):
self.entries = {}
#------------------------------------------------------------------
-class SourceDescriptor:
+class SourceDescriptor(object):
"""
A SourceDescriptor should be considered immutable.
"""
possible_identifier = re.compile(ur"(?![0-9])\w+$", re.U).match
nice_identifier = re.compile('^[a-zA-Z0-0_]+$').match
-class BufferAux:
+class BufferAux(object):
writable_needed = False
def __init__(self, buffer_info_var, stridevars, shapevars,
def __repr__(self):
return "<BufferAux %r>" % self.__dict__
-class Entry:
+class Entry(object):
# A symbol table entry in a Scope or ModuleNamespace.
#
# name string Python name of entity
error(pos, "'%s' does not match previous declaration" % self.name)
error(self.pos, "Previous declaration is here")
-class Scope:
+class Scope(object):
# name string Unqualified name
# outer_scope Scope or None Enclosing scope
# entries {string : Entry} Python name to entry, non-types
t = self.run_pipeline([NormalizeTree(None)], u"pass")
self.assert_(len(t.stats) == 0)
-class TestWithTransform:#(TransformTest): Disabled
+class TestWithTransform(object): # (TransformTest): # Disabled!
def test_simplified(self):
t = self.run_pipeline([WithTransform(None)], u"""
import StringEncoding
import sys
-class Signature:
+class Signature(object):
# Method slot signature descriptor.
#
# has_dummy_arg boolean
return None
-class SlotDescriptor:
+class SlotDescriptor(object):
# Abstract base class for type slot descriptors.
#
# slot_name string Member name of the slot in the type object
_code = 'misc'
-class TS_Misc_Suite:
+class TS_Misc_Suite(object):
def DoScript(self, _object, _attributes={}, **_arguments):
"""DoScript: Execute an MPW command, any command that could be executed from the command line can be sent as a script.
#
#=======================================================================
-class Action:
+class Action(object):
def same_as(self, other):
return self is other
for state2 in state_set_2.keys():
add_to_epsilon_closure(state_set, state2)
-class StateMap:
+class StateMap(object):
"""
Helper class used by nfa_to_dfa() to map back and forth between
sets of states from the old machine and states of the new machine.
DUMP_NFA = 1
DUMP_DFA = 2
-class State:
+class State(object):
"""
This class is used as part of a Plex.Lexicon specification to
introduce a user-defined state.
self.name = name
self.tokens = tokens
-class Lexicon:
+class Lexicon(object):
"""
Lexicon(specification) builds a lexical analyser from the given
|specification|. The specification consists of a list of
LOWEST_PRIORITY = -sys.maxint
-class Machine:
+class Machine(object):
"""A collection of Nodes representing an NFA or DFA."""
states = None # [Node]
next_state_number = 1
for s in self.states:
s.dump(file)
-class Node:
+class Node(object):
"""A state of an NFA or DFA."""
transitions = None # TransitionMap
action = None # Action
def get_action_priority(self):
return self.action_priority
-# def merge_actions(self, other_state):
-# """Merge actions of other state into this state according
-# to their priorities."""
-# action = other_state.get_action()
-# priority = other_state.get_action_priority()
-# self.set_action(action, priority)
-
def is_accepting(self):
return self.action is not None
file.write(" %s [priority %d]\n" % (action, priority))
-class FastMachine:
+class FastMachine(object):
"""
FastMachine is a deterministic machine represented in a way that
allows fast scanning.
return repr(c1)
else:
return "%s..%s" % (repr(c1), repr(c2))
-##
-## (Superseded by Machines.FastMachine)
-##
-## class StateTableMachine:
-## """
-## StateTableMachine is an alternative representation of a Machine
-## that can be run more efficiently.
-## """
-## initial_states = None # {state_name:state_index}
-## states = None # [([state] indexed by char code, Action)]
-
-## special_map = {'bol':256, 'eol':257, 'eof':258}
-
-## def __init__(self, m):
-## """
-## Initialise StateTableMachine from Machine |m|.
-## """
-## initial_states = self.initial_states = {}
-## states = self.states = [None]
-## old_to_new = {}
-## i = 1
-## for old_state in m.states:
-## new_state = ([0] * 259, old_state.get_action())
-## states.append(new_state)
-## old_to_new[old_state] = i # new_state
-## i = i + 1
-## for name, old_state in m.initial_states.items():
-## initial_states[name] = old_to_new[old_state]
-## for old_state in m.states:
-## new_state_index = old_to_new[old_state]
-## new_table = states[new_state_index][0]
-## transitions = old_state.transitions
-## for c, old_targets in transitions.items():
-## if old_targets:
-## old_target = old_targets[0]
-## new_target_index = old_to_new[old_target]
-## if len(c) == 1:
-## a = ord(c)
-## else:
-## a = self.special_map[c]
-## new_table[a] = states[new_target_index]
-
-## def dump(self, f):
-## f.write("Plex.StateTableMachine:\n")
-## f.write(" Initial states:\n")
-## for name, index in self.initial_states.items():
-## f.write(" %s: State %d\n" % (
-## repr(name), id(self.states[index])))
-## for i in xrange(1, len(self.states)):
-## table, action = self.states[i]
-## f.write(" State %d:" % i)
-## if action:
-## f.write("%s" % action)
-## f.write("\n")
-## f.write(" %s\n" % map(id,table))
-
-
-
-
-
-
# Abstract classes
#
-class RE:
+class RE(object):
"""RE is the base class for regular expression constructors.
The following operators are defined on REs:
import cython
-class Scanner:
+class Scanner(object):
"""
A Scanner is used to read tokens from a stream of characters
using the token set specified by a Plex.Lexicon.
"""
return REParser(s).parse_re()
-class REParser:
+class REParser(object):
def __init__(self, s):
self.s = s
from sys import maxint
from types import TupleType
-class TransitionMap:
+class TransitionMap(object):
"""
A TransitionMap maps an input event to a set of states.
An input event is one of: a range of character codes,