Archive: expression evaluater in AVS source code


14th January 2008 13:10 UTC

expression evaluater in AVS source code
Anyone knows how to use the expression evaluator in the AVS source code. Now that it is open source I can use it in my own code, right? Is there any other alternative?


14th January 2008 14:29 UTC

Depends on your needs.

If you don't need efficiency then the better alternative is to simply write your own evaluator. AVS script is so primitive that writing an evaluator (slow one) is almost trivial (parser might be little trickier).
If you want portability, then reusing AVS source code is not an option. The code is non-portable mess.

Only use AVS source if portability is not a concern and you really need the evaluator to be fast. But even then it might be easier to translate the script into some intermediate form (llvm, C--) and let the compiler do the optimization.

If you want to evaluate simple arithmetic expression... then really, write your own code. It should be well below 100 lines.

Anyways, you can reuse the AVS code quite freely, I think they use BSD 3 license.


14th January 2008 14:58 UTC

i wanted something similar to AVS, arithmetic expressions and simple functions. And I want it to be cross platform. When I checked out the evallib code I noticed it used windows.h
does anyone know any other alternative? should be in c++


14th January 2008 15:14 UTC

Then, please, do not use AVS script syntax. You can do so much better than that.

There isn't really easy solution for you. I do not think that there is suitable scripting language already out there, so you probably have to implement your own. It's not that difficult if:
a) you don't use C/C++
b) efficiency is not a concern
c) language is simple enough

If you plan to stick with C/C++ then there are plenty of useful tools to help you. Take a look at yacc and bison. If you're comfortable with "modern" C++ then you should try Boost.Spirit.


14th January 2008 15:35 UTC

hey thanks!


18th January 2008 16:21 UTC

make one. flex(the new yacc) and bison make it trivial

use c++ and function pointers, i have some examples both with and without flex and bison, i have one that builds some trivial .exes too... but clearly not developed enough to be of any value.

just to warn you though most alternatives out there are much better if you don't care about speed. python would be a good place to start if you just want to get stuff done... not necessarily done quickly.


18th January 2008 17:27 UTC

I disagree, python doesn't have much advantage over C/C++ , especially if you're new to python.
All the cool kinds nowadays use OCaml (or other MLish language) to write compilers, interpreters and code analysis tools.


28th January 2008 10:24 UTC

Originally posted by Jaak
I disagree, python doesn't have much advantage over C/C++ , especially if you're new to python.
Erm... someone else already made an interpreter?

That makes it several orders of magnitude easier imo...