Open pxcluster opened 5 years ago
Without seeing some kind of concrete example, it's hard for me to say. I reviewed the source and the _lrtable attribute is set in just one place during class definition. I can't find any other place where it would be overwritten or disappear. SLY seems to be passing its tests. So, very strange indeed.
Dave,
Forget about this issue... Convinced that such "bug" is rather impossible, I continued my investigations. I became more and more skeptical about something wrong in the SLY package (which is something I would suspect last)... and I went back to my own code. And I finally found the error !!! It was in front of me but was unable to spot it for a few hours... Just an horrible and shameful mistake (like a typo). I wrongly instantiated my parser using the "Parser" class while it should have been "Myparser".
That explains why the lrtable was "absent" from the instantiated object (Parser), since all of the grammar was defined in the "Myparser" class... I was also lured to a wrong hypothesis as all classes are instantiated when each of the modules are loaded; meaning the Myparser class was properly instantiated as well as the Parser one; but each with a different created class !
Sorry for bothering you with such stupid error and thank you very much for your help.
Take care
Daniel Cordey
Dave,
I don't know if I miss something but I'm facing a very strange problem. I created a lexer (which works as expected) and a parser (called Myparser). I managed to write some rules and tried to parse some syntax, but banged on :
File "/usr/local/lib/python3.6/dist-packages/sly-0.4-py3.6.egg/sly/yacc.py", line 1849, in parse AttributeError: 'Parser' object has no attribute '_lrtable'
I did some checking in the source code and everything works as expected, except when I try to instantiate my parser ! The '_lrtable' is properly set during the 'class' instantiation (I check in ParserMeta.new), but once my object Myparser is instantiated, at least one class variables (Parser) dosen't seem to be inherited from the Parser class and is then missing. ParserMeta.new returns the class containing the '_lrtable' attribute, but it seems to be wipped out on the final objet. All other attributes seem to be there, but no '_lrtable'.
I known that my grammar is currently unstable and unfinished and I wonder if it could play a role...
What else could I investigate ? Anything I could try ?