"t.type = reserved.get(t.value,'ID')" what is the 'ID' bit? Thanks for the help
On Oct 11, 2:11 pm, David Beazley <[email protected]> wrote: > On Oct 11, 2009, at 7:55 AM, Bruce Frederiksen wrote: > > > I'm going to go with specifying t_STRING after t_NAME, so that the > > word "string" is taken as a NAME. Try putting t_STRING before > > t_NAME... > > [snip] > > > # Tokens > > > t_NAME = r'[a-zA-Z_][a-zA-Z0-9_]*' > > t_STRING = r'"[a-zA-Z0-9]*"' > > t_STRDEF = 'string' > > I'm going to agree with this. The t_STRDEF token is being matched by > the t_NAME rule above it which is almost certainly causing this > problem. The original poster should look > athttp://www.dabeaz.com/ply/ply.html#ply_nn6 > and note the part about "reserved words." > > This problem comes up so often, I'm almost wondering if I should add > an extra validation check to PLY. It occurs to me that I could > modify lex to look for regexes that are made up of nothing but simple > characters (e.g., 'string' above) and then test them for matches > against the other regular expressions (e.g., t_NAME). If a match is > found, some kind of stern warning message could be issued about it. > > As the documentation states, it's really a bad idea to make separate > token rules for reserved words like 'string', 'if', 'else', etc. > > 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 -~----------~----~----~----~------~----~------~--~---
