I wonder if this some kind of sorting issue. PLY normally tries to sort the productions in order by line-number. Maybe things are getting sorted in a weird order and the grammar is starting with an unexpected rule. That's the only thing I can think of offhand.
Cheers, Dave On Feb 20, 2009, at 9:19 AM, eliben wrote: > > I'm using Python 2.5 > With pre-generated optional methods, PLY prints out lots of > "unreachable" warnings during parser construction, like these: > > WARNING: Symbol 'expression_statement' is unreachable > WARNING: Symbol 'initializer' is unreachable > WARNING: Symbol 'init_declarator_list' is unreachable > WARNING: Symbol 'init_declarator_list_opt' is unreachable > WARNING: Symbol 'pp_directive' is unreachable > > And then parsing fails. > > 1) I see that the methods I generate appear in the dir() of my class. > 2) Also, for these methods hasattr(<method>, '__call__') is True. > > If you want you can pull the pycparser code: > svn checkout http://pycparser.googlecode.com/svn/trunk/ pycparser- > read- > only > > And just run one of the examples or tests with PLY-3. > > Eli > > > On Feb 20, 4:35 pm, David Beazley <[email protected]> wrote: >> There are some subtle differences between PLY-3.0 and PLY-2.5, but >> I'm >> not how they would impact this code. The changes that I can think of >> offhand: >> >> 1. Instead of looking for a __dict__ attribute, PLY-3.0 extracts >> names using the dir() function. >> >> 2. To test for callable objects, PLY uses hasattr(x,"__call__") >> instead of using callable(). >> >> What version of Python are you using for this? Are the optional >> methods just not showing up at all? >> >> Cheers, >> Dave >> >> On Feb 20, 2009, at 8:23 AM, eliben wrote: >> >> >> >>> Hi Dave, >> >>> My pycparser project (http://code.google.com/p/pycparser/) runs >>> flawlessly with PLY-3.0, except for the auto-generation of _opt >>> productions, as I described >>> here:http://groups.google.com/group/ply-hack/t/c448a7cbbce6cc3a >> >>> Does PLY-3 act differently in this respect somehow? >> >>> I create the new production functions "on the fly", but before >>> calling >>> ply.yacc.yacc, so for it they look like normal functions, or don't >>> they? What has changed? >> >>> Thanks in advance >>> 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 -~----------~----~----~----~------~----~------~--~---
