I have a file that contains many lines of condition lines, and I need to read this file and convert the logical conditions line into actual code. There are several parameters, and each line of the condition checks whether one or more parameters matches the specified value or contains the specified value. For instance:
$parameterA = "value_1" AND ($parameterB CONTAIN "%value_2%" OR $parameterC = "value_3")
"=", "AND" and "OR" have the meanings of "==", "&" and "||". "%" is a wild card.
After converting the code to code, it should look like this:
if (obj.parameterA == "value_1" && (obj.parameterB.contains("value_2") || obj.parameterC == "value_3"))
return true;
else return false;
where "obj" is an instance of some class.
I searched for other posts here, and it seems that ANTLR might be a good choice. However, I have no experience with this, and I'm not sure how difficult it is to use it with Java. I just want to check if there are other good ideas before diving into all the details of ANTLR. Thank you so much for your help!
source
share