On Sep 30, 2009, at 7:01 AM, A.T.Hofkamp wrote:
> > 0beron wrote: >> Is there any way I can mess with the internals of an existing parser >> object to 'prime' it to be in a different starting state? Ie let PLY >> load the cached tables, create a parser, and then just tweak the >> existing instance? > > I don't know about parser internals, but maybe you don't need to. > > You can make a new start symbol, and introduce new tokens that > select a rule > to 'jump' to the right rule, eg > > begin: FORTRAN top | EXPRESSION expression ; > > now you just need to inject the right token to select a part of the > grammar, > ahead of the real tokens. > Yes, this technique is what I was going to suggest. However, I'm looking at the PLY implementation and it doesn't seem like there is an easy way to inject a starting token. You could manually hack it by creating your own lexer object and passing that into the yacc.parse() function. However, I really ought to make a patch that simplifies this. Cheers, Dave --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
