Click here to Skip to main content
14,265,813 members
Rate this:
Please Sign up or sign in to vote.
See more:
Hey all i was wondring if it is possible to parse text to an if statement and also have and, or, and xor added to so lets say if i have some tokens in a list as following:
if, someVarible, isequal, anothervarible, and /or/xor someVarible isequal aathirdvarible do something.

that should be translated into if(var1 == var2 &&/||/^ var1 == var3) { body }

at the moment i can make it work for a single statement/boolean expression but im really lost how i can check for multiply by using the reflections. it migth be more than 2 comparisons that is needed with both ands and ors so it must be able to call it recrusive. so if any one out there have a solution i would love to hear from you - thanks a lot.

-Jackie
Posted
Updated 3-Apr-12 15:01pm
v2
Rate this:
Please Sign up or sign in to vote.

Solution 1

This might be of some help: http://www.jarloo.com/c-formula-evaluator/[^]. It uses regular expressions to parse the text.
   
Comments
ProEnggSoft 5-Apr-12 0:04am
   
Good link. +5
Rate this:
Please Sign up or sign in to vote.

Solution 2

This Code Project article
math / function / boolean /string expression evaluator[^]
may also be helpful.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100