I thought I would throw one thing out there.   In the version of PLY 
that I'm putting together for the next release, I've enhanced the
debugging capabilities greatly by allowing Logging objects to be
passed in (see Python's built-in logging module for details). With
this, more debugging information is available and it's produced at
different levels that can be contolled. 

Cheers,
Dave


On Fri 30/01/09  6:36 AM , "D.Hendriks (Dennis)" [email protected] sent:
> Hello,
> if you try the 'examples/calc/calc.py' example distributed with Ply:
> you get something like this:
> $ python calc.py
> yacc: Generating LALR parsing table...
> calc > 3+4
> 7
> Now, if you change this line:
> yacc.parse(s) 
> into this line:
> yacc.parse(s, debug=2) 
> You get:
> $ python calc.py
> yacc: Generating LALR parsing table...
> calc > 3+4
> state 0
> action 3
> . LexToken(NUMBER,3,1,0)                                     shift
> state 3
> state 3
> action -9
> NUMBER . LexToken(+,'+',1,1)                                 reduce
> 9
> state 6
> action 12
> expression . LexToken(+,'+',1,1)                             shift
> state 12
> state 12
> action 3
> expression + . LexToken(NUMBER,4,1,2)                        shift
> state 3
> state 3
> action -9
> expression + NUMBER . $end                                   reduce
> 9
> state 18
> action -3
> expression + expression . $end                               reduce
> 3
> state 6
> action -2
> expression . $end                                            reduce
> 2
> 7
> state 4
> action 0
> So, this way you can see the state of the parser. It's great for
> debugging.
> Hope this answers your question.
> Dennis
> Nuno Lopes wrote:  
> 
> Hello all, Is there a way to find out which state we are in?  For
> debugging purposes for instance when we are popping a state. I
> couldn't find info on this on the website neither on this ml. Thanks
> -- Nuno Lopes   
> > 
> 



--~--~---------~--~----~------------~-------~--~----~
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