Re: [Pyparsing] Operator Precedence and Associativity.
Brought to you by:
ptmcg
From: Ralph C. <ra...@in...> - 2006-09-15 11:00:36
|
Hi Paul, > This discussion from c.l.py > (http://www.velocityreviews.com/forums/t335296-basic-tokenizer.html - > about 2 years ago) might also shed some light on this topic, > especially the comments (and posted code) from Andrea Griffini. He > pointed out the '^' left-associativity bug in fourFn.py which I was > able to fix in a subsequent release. Thanks, I had already found that, and you're right, it helped concoct the right pyparsing grammar, as in fourFn.py. The issue is I don't want [1, '+', 2, '+', 3] returned, but [[1, '+', 2], '+', 3] which doesn't seem possible without post-parsing manipulation. That is, the `classic' parse tree of an infix algebraic expression isn't achievable. > I like the graphical rending of the parse tree. :) Yes, it just occurred to me when I was sitting there with the text all on one line. Not hard to do, either, with vim's Ctrl-Y in insert mode. Cheers, Ralph. |