List of Variables used by Expression

Aug 21, 2007 at 12:56 PM
Edited Aug 21, 2007 at 12:58 PM
Thanks for such a Wonderful Creation!!!
It is a new concept of Expression Evaluator.
I am using FLEE Library for my application which has an Expression consisting a string as an Input.
After the Expression is evaluated I would like to know which variables are used in the given Expression in the order of precedence.

If my String may contain "(a-b)*(c-a) then I would like to have the list like Array={a,b,c} after the Expression is evaluated.
Note that Variables in the Input String are NOT recognized when passed to the Expression.

your Suggestion/guidance will be appreciated.

Thanks in Advance for any help.

Thanks & regards,
Aug 21, 2007 at 3:03 PM
>Note that Variables in the Input String are NOT recognized when passed to the Expression.
I'm not sure I understand what this means. Are you saying that you just want to be able to take an expression and recognize what variables it uses without actually trying to compile and evaluate it?
Aug 22, 2007 at 1:17 PM
Thanks for Immediate Reply.

In the Expression.vb Class,in Compile Function,after the following Stmt,ie
Dim topElement As ExpressionElement = Parse(expression, services)
and before emitting it to MSIL thru' DynamicMethod ie
Dim dm As New DynamicMethod(String.Empty, options.ResultType, New Type() {ownerType}, ownerType)
I would like to have the List of Variables used in the Expression in the order of precedence.
This will help me to select the variables for the Next Evaluation may or may not be for the same Expression.

Your Help is appreciated.

Thanks & regards,
Aug 22, 2007 at 10:18 PM
I think the thing I was trying to understand is whether you were saying that the variables aren't actually actually defined; you just want to get a list of the ones that the expression will use.

The code you mentioned is in the constructor of the expression which cannot return anything. Obviously, the expression won't compile if the variables don't actually exist.

I'm just wondering if you what you need is to parse the expression text and pick out the variable names instead. That is doable but requires a different approach.
Aug 23, 2007 at 3:14 PM
Edited Aug 23, 2007 at 3:21 PM
Aug 23, 2007 at 3:34 PM
Thanks for the clarification.
Can you elaborate on the approach how could I get the Variable List in the Order of Precence?
It will be Helpful for me to put in a different set of variables in the Next Evaluation.

Thanks for Valuable Guidance

Thanks & regards,
Aug 23, 2007 at 8:38 PM
Well, you have access to the grammar so you can use Grammatica to generate a parser for it. You can then hook in to the parser and be notified when it hits a variable name.

Your request is very similar to nanded's issue (see Identify Variables). It was helpful for me when he told me what he was trying to accomplish so that I could come up with the best approach.

Could you tell me what you are trying to accomplish?

Aug 31, 2007 at 4:18 PM
I've implemented a way to get the variables used in an expression in release Check out the Identify Variables discussion to see how to use it.