Hello,

> Don't you already implement it for parser tables in PLY 2.5 ? I
> suppose it can be implemented the same way.

I thought so as well. However, I recently renamed a grammar rule and forgot to 
remove my parse table file. When running my program I got a KeyError on the 
name of the renamed (old) grammar rule name. I then figured the outdated check 
was simply not implemented...

I decided to check out the source code of Ply's yacc and found this:

(lines 1610-1622):

        if isinstance(module,types.ModuleType):
            parsetab = module
        else:
            exec "import %s as parsetab" % module

        if (optimize) or (Signature.digest() == parsetab._lr_signature):
            _lr_action = parsetab._lr_action
            _lr_goto   = parsetab._lr_goto
            _lr_productions = parsetab._lr_productions
            _lr_method = parsetab._lr_method
            return 1
        else:
            return 0

What we see is that the parse table file is imported and then, if 'optimize' is 
enabled, it doesn't even matter if the digest matches or not... I think this is 
a bug in the implementation? I think the 'or' in line 2615 should be an 'and'?

I have some other questions:
 - Why is the import executed, even if we don't use optimized mode?
 - The signature is updated with __tabversion__, method, the start symbol, 
precedence rules and the doc-strings of grammar rules. I'm missing the token 
list and the names of the grammar rules. Why is this? (There may be other 
things missing?)
 - The first time lr_read_tables is called (line 2705) in the yacc function, 
the signature only contains the __tabversion__, method and start symbol. I 
wonder if it can ever match the signature stored in the parse table file? (note 
that due to the 'or' in line 2615, the signature check if not even checked if 
optimize is enabled)

These are the questions I have after a quick glance at the code...

NOTE: source code I checked is for Ply 2.5

Dennis



eliben wrote:

>On Sep 26, 3:16 pm, David Beazley <[EMAIL PROTECTED]> wrote:
>  
>
>>Yes, this would be a good feature to add to PLY-2.6.   I'll have to think of 
>>some new scheme for knowing when to run the update.  Right now PLY relies on 
>>MD5 signatures, but this
>>being deprecated in Python 3.0 so I'll have to come up with an alternative 
>>(maybe I'll do some kind of thing with hash keys).  
>>
>>    
>>
>
>Don't you already implement it for parser tables in PLY 2.5 ? I
>suppose it can be implemented the same way.
>
>  
>
>>Also, I just noticed that I probably completely ignored the original message 
>>about this dated July 4.  Sorry about that--I was in the hospital waiting for 
>>the arrival of my first child.  
>>Needless to say, it's been a crazy summer :-).
>>
>>    
>>
>
>Congrats !!
>
>Eli
>>
>  
>


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"ply-hack" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/ply-hack?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to