Parse parenthesized Boolean String Expressions with Java -
I need to evaluate the bracket expression found in a string. I need to deal with variable expressions So I need to find a way to parse it in Java in a Boolean expression to evaluate it in Java. I is an example for a string expression:
string boolexp 1 = "(right! (Wrong) & amp;; ((true) ^ ( F)) ") are possible operator brackets, and, or, XOR, No. Since this is already a Java-processed expression, I thought it was easy to parse it I could not think of an elegant solution, I have got some code online, but it either deals with other operators, without any bracket or even complex.
I use javascript Resolved:
String Boolexp 1 = "(! (Right!); & Amp;; (true) ^ (true))" Boolean result = (boolean) New script engine manager (). GetEngineByName ("JavaScript"). Eval (boolexpr1); It can not be expected that it can be easy.
Comments
Post a Comment