aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/tools/cython/Cython/Plex/Actions.py
diff options
context:
space:
mode:
authorAnton Samokhvalov <pg83@yandex.ru>2022-02-10 16:45:17 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:17 +0300
commitd3a398281c6fd1d3672036cb2d63f842d2cb28c5 (patch)
treedd4bd3ca0f36b817e96812825ffaf10d645803f2 /contrib/tools/cython/Cython/Plex/Actions.py
parent72cb13b4aff9bc9cf22e49251bc8fd143f82538f (diff)
downloadydb-d3a398281c6fd1d3672036cb2d63f842d2cb28c5.tar.gz
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 2 of 2.
Diffstat (limited to 'contrib/tools/cython/Cython/Plex/Actions.py')
-rw-r--r--contrib/tools/cython/Cython/Plex/Actions.py94
1 files changed, 47 insertions, 47 deletions
diff --git a/contrib/tools/cython/Cython/Plex/Actions.py b/contrib/tools/cython/Cython/Plex/Actions.py
index f372352443..c88176e716 100644
--- a/contrib/tools/cython/Cython/Plex/Actions.py
+++ b/contrib/tools/cython/Cython/Plex/Actions.py
@@ -1,110 +1,110 @@
# cython: auto_pickle=False
-#=======================================================================
-#
-# Python Lexical Analyser
-#
-# Actions for use in token specifications
-#
-#=======================================================================
-
-class Action(object):
+#=======================================================================
+#
+# Python Lexical Analyser
+#
+# Actions for use in token specifications
+#
+#=======================================================================
+
+class Action(object):
def perform(self, token_stream, text):
pass # abstract
-
+
def same_as(self, other):
return self is other
-
-
-class Return(Action):
+
+
+class Return(Action):
"""
Internal Plex action which causes |value| to
be returned as the value of the associated token
"""
-
+
def __init__(self, value):
self.value = value
-
+
def perform(self, token_stream, text):
return self.value
-
+
def same_as(self, other):
return isinstance(other, Return) and self.value == other.value
-
+
def __repr__(self):
return "Return(%s)" % repr(self.value)
-
-
-class Call(Action):
+
+
+class Call(Action):
"""
Internal Plex action which causes a function to be called.
"""
-
+
def __init__(self, function):
self.function = function
-
+
def perform(self, token_stream, text):
return self.function(token_stream, text)
-
+
def __repr__(self):
return "Call(%s)" % self.function.__name__
-
+
def same_as(self, other):
return isinstance(other, Call) and self.function is other.function
-
-
-class Begin(Action):
+
+
+class Begin(Action):
"""
Begin(state_name) is a Plex action which causes the Scanner to
enter the state |state_name|. See the docstring of Plex.Lexicon
for more information.
"""
-
+
def __init__(self, state_name):
self.state_name = state_name
-
+
def perform(self, token_stream, text):
token_stream.begin(self.state_name)
-
+
def __repr__(self):
return "Begin(%s)" % self.state_name
-
+
def same_as(self, other):
return isinstance(other, Begin) and self.state_name == other.state_name
-
-
-class Ignore(Action):
+
+
+class Ignore(Action):
"""
IGNORE is a Plex action which causes its associated token
to be ignored. See the docstring of Plex.Lexicon for more
information.
"""
-
+
def perform(self, token_stream, text):
return None
-
+
def __repr__(self):
return "IGNORE"
-IGNORE = Ignore()
-#IGNORE.__doc__ = Ignore.__doc__
-
+IGNORE = Ignore()
+#IGNORE.__doc__ = Ignore.__doc__
+
-class Text(Action):
+class Text(Action):
"""
TEXT is a Plex action which causes the text of a token to
be returned as the value of the token. See the docstring of
Plex.Lexicon for more information.
"""
-
+
def perform(self, token_stream, text):
return text
-
+
def __repr__(self):
return "TEXT"
-
-TEXT = Text()
-#TEXT.__doc__ = Text.__doc__
-
-
+
+TEXT = Text()
+#TEXT.__doc__ = Text.__doc__
+
+