[Mono-list] Parser & Evaluator

Fabien Meghazi amigrave at gmail.com
Wed Jun 8 06:22:48 EDT 2005


Hi all,

I was about to post my question when I saw the thread "Javascript
eval() function in C#", I looked at it but I prefered to make seperate
thread as what I need is different.

In fact I'm trying to make a parser and evaluator of expressions. I
already got one but it was developped in a hurry and won't support
operators precedence.
Currently, it support standards operators, parenthesis, ... but it
also uses variables that are contained in a Hashtable.

Eg:

Hashtable h = new Hashtable();
h["number"] = 4;
Ev.Eval("3 + (5 * number)", h);

Depending on the context, I also use an EvalAsBool() function for some
conditions.

But now, I need to support operators precedence and I also want to add
functions support.

Eg:

Ev.EvalAsBool("name.IsInList(name_list) and access == 4", h);
(I use and instead of && because expressions are stored in an xml file)

This is why I would like to make an evaluator using a shift/reduce table.

I installed package mono-jay and tried the parser-cs.jay file but it's
kind complex as first example.

So my questions :

1) Do you think using jay for making this kind of evaluator is the good way
2) Does anyone knows where to get documentation about jay ? The only
documentation I found was the one in german on the unmodified java Jay
project website.

-- 
Fabien Meghazi
http://www.amigrave.com


More information about the Mono-list mailing list