Modified lex to allow rules to be attached to token strings

This commit is contained in:
David Beazley 2016-09-12 14:24:03 -05:00
parent 41ee4aff04
commit dc08a1b466

View File

@ -74,7 +74,11 @@ class LexerMetaDict(OrderedDict):
'''
def __setitem__(self, key, value):
if key in self and not isinstance(value, property):
raise AttributeError('Name %s redefined' % (key))
if isinstance(self[key], str) and callable(value):
value.pattern = self[key]
else:
raise AttributeError('Name %s redefined' % (key))
super().__setitem__(key, value)
class LexerMeta(type):