Anyone have a spin math expression parser?
jazzed
Posts: 11,803
I'm working on an application that needs an expression parser. I've done recursive decent parsing in C and Visual Basic a few times for each language. I guess you could say I'm exhausted and looking for options. If nothing is available, I'll just go do it. TIA.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
--Steve
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
--Steve
Comments
Actually, that's not quite true. Some two character operators like "//" are handled locally.
Post Edited (Mike Green) : 9/15/2008 2:54:18 AM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
--Steve
each precedence level; you can clearly see that by which functions scan for which operators and which recursive
functions they then call.
This calls "term", then looks for either a "+" or "-". If found, it looks for another term after that.
Once it has both terms, it adds (or subtracts) them, then goes back and looks for another "+" or "-".
If there's no "+" or "-", it returns its current value. "term" is the next level which looks for "factor"s
separated by "*", "/", or "//", the next higher precedence operator group.
At first glance I saw parts of the boolean parser chain but no arithmetic. I see it all now. Hope you don't mind if I extract what I need which does not include the basic language processing and adopt it to my application. Thanks.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
--Steve
Wish I knew who contributed what ... and because of that I'll end up porting one of my designs from C anyway ... just not tonight. For the time being this will help with proof of concept until I have more time.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
--Steve