OK first off: The answer IS NOT using the Microsoft ScriptControl! I don't WANT to use that! The goal is a custom built Expression Parser/Evaluator.
Now onto the algorithms. The most common one is called a "recursive descent parser", this is the one I implemented in my Library.
I think you can see where this is going... I'm kind of advertising my own library and I hope it isn't against the rules, but I remember scouring the web for hours in search of this exact thing in my earlier programming days (before I was able to even fathom writing my own), so I thought maybe somebody might like it for their programs. Before you get to excited, it doesn't work with batch programs (although I'll probably add a new command for that or something). Once installed properly (this is the part I need to work on, it has a few dependencies...), however, it will work in VBScript.
In any case, my Parser uses what I think is a neat technique- all it knows about is the parsing, all the knowledge about operators and functions is available through separate plugins, of which I have two kinds: an Evaluation Plugin, which can provide functions and operator support to the library, and a "Core Plugin" which allows for new kinds of formula tokens to be parsed in a custom fashion (for example, this is how I implemented core support for environment variables in %variable% form.
It also features intrinsic support for arrays, using curly brackets, as in {1,2,3}. The Core routines transform this into a call to a Plugin provided function, "Array()", which creates the array and pushes it onto the evaluation stack. However, the most interesting aspect is that it also allows for the use of operators on these lists, as in "{1,6}*{5,12}" being {{5,12},{30,72}}- a List of Lists.
In addition, the Core Plugin provides a HUGE number of functions that almost make the creation of external plugins unnecessary! I'd include a list but frankly I don't think anybody is going to reply to this thread anyway.
Does anybody have any suggestions? What kind of thing would you like a expression parser to support? I've managed to implement every idea I can think of! operators? Functions? new syntax? Anything! Interested in acquiring this library for use in one of your programs? I need BETA testers! a programmer shouldn't be testing his own code! It's just WRONG!
I have included a Screenshot to prove this program exists. If you look at the screen shot, you'll notice that the second execute of that entire expression took a little over 0.008 seconds. Not bad, I think. (it is a 1.6Ghz CPU though).
So....
Go ahead and comment on it! If anybody wants I can TRY to package it up but I've had mixed success getting the installer to work consistently.
Thanks for any comments (good, or even bad (I know, I'm weird))!
[recovering space - attachment deleted by admin]