Click here to Skip to main content
15,899,825 members
Please Sign up or sign in to vote.
1.00/5 (1 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

This Code Project article
math / function / boolean /string expression evaluator[^]
may also be helpful.
 
Share this answer
 
This might be of some help: http://www.jarloo.com/c-formula-evaluator/[^]. It uses regular expressions to parse the text.
 
Share this answer
 
Comments
ProEnggSoft 5-Apr-12 0:04am    
Good link. +5

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900