Perl Monk, Perl Meditation | |
PerlMonks |
Re: Operator Precedence Parserby hv (Prior) |
on Jun 10, 2006 at 08:51 UTC ( [id://554597]=note: print w/replies, xml ) | Need Help?? |
I don't know if I triggered L~R's hunt, but I was asking in the CB about modules for expression parsing and he expressed an interest. I was looking for something that would be supplied with a) the string to parse, and b) the parse rules - a set of functions, binary and unary operators, and atoms. Something like this:
Nobody in the CB could suggest anything at the time, so I wrote my own constructing a Tree::Simple tree as output. I found it surprisingly hard to write, even treating '(', ',' and ')' as builtins (for the function(arg, list) support), and ignoring the type information - I wrote and threw away hundreds of lines of code in at least half a dozen trial implementations before finally coming up with something workable if not particularly pretty. If your parser can easily be extended to handle function calls I'll have a go at adapting it for my application. Hugo
In Section
Meditations
|
|