Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Expression Evaluator (what features would YOU want?)  (Read 3370 times)

0 Members and 1 Guest are viewing this topic.

BC_Programmer

    Topic Starter

    Mastermind
  • Typing is no substitute for thinking.
  • Thanked: 1140
    • Yes
    • Yes
    • BC-Programming.com
  • Certifications: List
  • Computer: Specs
  • Experience: Beginner
  • OS: Windows 11
Expression Evaluator (what features would YOU want?)
« on: May 08, 2008, 11:28:28 AM »
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]
I was trying to dereference Null Pointers before it was cool.

Aegis



    Expert

    Thanked: 67
    • Yes
    • Yes
    • Brian's Mess Of A Web Page
  • Experience: Experienced
  • OS: Windows 10
Re: Expression Evaluator (what features would YOU want?)
« Reply #1 on: May 08, 2008, 12:03:24 PM »
Quote
using curly brackets, as in {1,2,3}.

Those are called 'braces.' 

I think it's a good project.


"For you, a thousand times over." - "The Kite Runner"

BC_Programmer

    Topic Starter

    Mastermind
  • Typing is no substitute for thinking.
  • Thanked: 1140
    • Yes
    • Yes
    • BC-Programming.com
  • Certifications: List
  • Computer: Specs
  • Experience: Beginner
  • OS: Windows 11
Re: Expression Evaluator (what features would YOU want?)
« Reply #2 on: May 08, 2008, 12:47:09 PM »
thanks! I kind of got the algorithms and stuff down pat since I had to write it twice. My first one was just a modification of an existing library, but then my working USB drive failed. I still had it and was working of my E:\ backup drive, and went to flash my CD burner's firmware, woops! sent it to the HD! :o Thankfully since I got to redesign it from scratch I actually KNOW what is going on in the code (most of the time), and I managed to implement something that was impossibly kludged in my first version, plugin-managed operators. Then I found the old library on my Laptops Hard Drive.  ::)

There is a problem though, I've simply added too much! I can't keep track of all the "progress points",(what I have to do in separate "domains" of the code) I already have a configuration dialog that shows a tab for each plugin, and loads a Custom Control that that plugin designated it's Settings Page- the dialog itself looks polished, but the controls I made are kind of elementary, almost seem like a tech demo. This project has been in the works for 2 years, and the original one 6 years.

Quote
using curly brackets, as in {1,2,3}.

Those are called 'braces.' 

I think it's a good project.

I had the name on the tip of my fingers as I typed! I couldn't remember the name though, so I just stuck in what they looked like.

One thing that might cause people to avoid it: It's programmed in VB6. I attempted a .NET conversion, but that will have to wait- I've written it twice already.

I think I'll freeze new features until I can iron out the bugs (all known bugs are in GUI code, not surprising to me), and release it with a "calculator" program. At some point I'll use it for it's intended purpose of a graphing program (again my second one- my first versions are always monolithic and full of gross hacks and kludges). That will be interesting, pair the features of the parser with a 3-D Z= graph.
I was trying to dereference Null Pointers before it was cool.