Modified lex to allow rules to be attached to token strings
This commit is contained in:
parent
41ee4aff04
commit
dc08a1b466
@ -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):
|
||||
|
Loading…
Reference in New Issue
Block a user