Hmmm.  It's hard to say for certain.  However, I just tested the calculator 
example with an added power operator (right precedence) and it worked 
correctly.   There are some debugging modes for yacc.parse() that might be 
worth investigating here.  

        http://www.dabeaz.com/ply/ply.html#ply_nn46

Cheers,
Dave


On Nov 23, 2009, at 7:26 PM, Alex_Gaynor wrote:

> I've got a grammar with precedence:
> 
>    precedence = (
>        ("nonassoc", "COMPARISON"),
>        ("left", "AMPER", "VBAR", "CIRCUMFLEX"),
>        ("left", "PLUS", "MINUS"),
>        ("left", "STAR", "SLASH", "PERCENT"),
>        ("right", "UNARY"),
>        ("right", "POWER"),
>    )
> 
> Which I believe is correct.  However given: a ** b ** c; it parses it
> as:
> [('BinOpNode', ('BinOpNode', ('NameNode', 'a'), ('NameNode', 'b'),
> '**'), ('NameNode', 'c'), '**')]
> 
> Whereas I would expect:
> [('BinOpNode', ('NameNode', 'a'), ('BinOpNode', ('NameNode', 'b'),
> ('NameNode', 'c'), '**'), '**')]
> 
> Hopefully that syntax is clear.  Any suggestions as to why I'm getting
> an incorrect parse.
> 
> Alex
> 
> --
> 
> 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.
> 
> 

--

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