Also how would you use code like this:

def t_ccode_lbrace(t):
    r'\{'
    t.lexer.level +=1

def t_ccode_rbrace(t):
    r'\}'
    t.lexer.level -=1


to implement an 'if', do you have to use 'ast' like in GardenSnake

On Oct 12, 5:58 pm, matio <[email protected]> wrote:
> thanks, one last question, how would you print out a string containing
> characters like "\n"?
>
> On Oct 11, 8:35 pm, Andrew Dalke <[email protected]> wrote:
>
> > On Oct 11, 2009, at 7:12 PM, matio wrote:
>
> > > def t_NAME(t):
> > >     r'[a-zA-Z_][a-zA-Z0-9_]*'
> > >     t.value = reserved.get(t.value, 'NAME')
> > >     return t
> >    ...
> > > is run it says:
>
> > > Syntax error at 'NAME'
>
> > That's because you changed all NAME tokens to have the value of NAME.  
> > You really want to change the type. Change "t.value" to "t.type" so  
> > the assignment becomes
>
> >       t.type = reserved.get(t.value, 'NAME')
>
> >                                 Andrew
> >                                 [email protected]
--~--~---------~--~----~------------~-------~--~----~
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