Added getattr() support

This commit is contained in:
David Beazley 2018-09-06 07:59:39 -05:00
parent 3f7240b9a2
commit a33ff221e5
2 changed files with 9 additions and 1 deletions

View File

@ -1,3 +1,8 @@
Version 0.4
-----------
9/5/2018 Added support for getattr() and related functions on
productions.
Version 0.3
-----------
4/1/2018 Support for Lexer inheritance added. For example:

View File

@ -144,7 +144,10 @@ class YaccProduction:
raise AttributeError('No index attribute found')
def __getattr__(self, name):
if name in self._namemap:
return self._slice[self._namemap[name]].value
else:
raise AttributeError(f'No symbol {name}')
def __setattr__(self, name, value):
if name[0:1] == '_' or name not in self._namemap: