- An input event is one of: a range of character codes,
- the empty string (representing an epsilon move), or one
+ An input event is one of: a range of character codes,
+ the empty string (representing an epsilon move), or one
[code_0, states_0, code_1, states_1, code_2, states_2,
..., code_n-1, states_n-1, code_n]
[code_0, states_0, code_1, states_1, code_2, states_2,
..., code_n-1, states_n-1, code_n]
Mappings for the special events '', BOL, EOL, EOF are
kept separately in a dictionary.
"""
Mappings for the special events '', BOL, EOL, EOF are
kept separately in a dictionary.
"""
def __init__(self, map = None, special = None):
if not map:
map = [-maxint, {}, maxint]
def __init__(self, map = None, special = None):
if not map:
map = [-maxint, {}, maxint]
def add(self, event, new_state,
TupleType = tuple):
"""
def add(self, event, new_state,
TupleType = tuple):
"""
def get_epsilon(self,
none = None):
"""
Return the mapping for epsilon, or None.
"""
return self.special.get('', none)
def get_epsilon(self,
none = None):
"""
Return the mapping for epsilon, or None.
"""
return self.special.get('', none)
# ------------------- Private methods --------------------
def split(self, code,
len = len, maxint = maxint):
"""
# ------------------- Private methods --------------------
def split(self, code,
len = len, maxint = maxint):
"""
- Search the list for the position of the split point for |code|,
- inserting a new split point if necessary. Returns index |i| such
+ Search the list for the position of the split point for |code|,
+ inserting a new split point if necessary. Returns index |i| such
def get_special(self, event):
"""
Get state set for special event, adding a new entry if necessary.
def get_special(self, event):
"""
Get state set for special event, adding a new entry if necessary.
def dump_range(self, code0, code1, set, file):
if set:
if code0 == -maxint:
def dump_range(self, code0, code1, set, file):
if set:
if code0 == -maxint:
self.dump_char(code1 - 1))
self.dump_trans(k, set, file)
self.dump_char(code1 - 1))
self.dump_trans(k, set, file)
def dump_trans(self, key, set, file):
file.write(" %s --> %s\n" % (key, self.dump_set(set)))
def dump_trans(self, key, set, file):
file.write(" %s --> %s\n" % (key, self.dump_set(set)))