--- /dev/null
+
+cdef class Action:
+ cdef perform(self, token_stream, text)
+ cpdef same_as(self, other)
+
+cdef class Return(Action):
+ cdef object value
+ cdef perform(self, token_stream, text)
+ cpdef same_as(self, other)
+
+cdef class Call(Action):
+ cdef object function
+ cdef perform(self, token_stream, text)
+ cpdef same_as(self, other)
+
+cdef class Begin(Action):
+ cdef object state_name
+ cdef perform(self, token_stream, text)
+ cpdef same_as(self, other)
+
+cdef class Ignore(Action):
+ cdef perform(self, token_stream, text)
+
+cdef class Text(Action):
+ cdef perform(self, token_stream, text)
class Action(object):
+ def perform(self, token_stream, text):
+ pass # abstract
+
def same_as(self, other):
return self is other
be returned as the value of the associated token
"""
- value = None
-
def __init__(self, value):
self.value = value
Internal Plex action which causes a function to be called.
"""
- function = None
-
def __init__(self, function):
self.function = function
for more information.
"""
- state_name = None
-
def __init__(self, state_name):
self.state_name = state_name
return "IGNORE"
IGNORE = Ignore()
-IGNORE.__doc__ = Ignore.__doc__
+#IGNORE.__doc__ = Ignore.__doc__
class Text(Action):
"""
return "TEXT"
TEXT = Text()
-TEXT.__doc__ = Text.__doc__
+#TEXT.__doc__ = Text.__doc__
import cython
+from Cython.Plex.Actions cimport Action
+
cdef class Scanner:
cdef public lexicon
@cython.locals(input_state=long)
cdef next_char(self)
+ @cython.locals(action=Action)
cdef tuple read(self)
cdef tuple scan_a_token(self)
cdef tuple position(self)
def compile_cython_modules(profile=False):
source_root = os.path.abspath(os.path.dirname(__file__))
compiled_modules = ["Cython.Plex.Scanners",
+ "Cython.Plex.Actions",
"Cython.Compiler.Scanning",
"Cython.Compiler.Parsing",
"Cython.Compiler.Visitor",