Jep Get Sub Group/Block

15 views
Skip to first unread message

Simone Di Nobile

unread,
Apr 28, 2016, 4:51:10 AM4/28/16
to Jep Java Users
Hi

I use JEP with StandardConfigurableParser to have a formula like this:

if ((  ( (P5525__V_MIN >= 30.0 || P5525__V_MAX <= 50.0) && (P0003__V_MIN >= 30.0 || P0003__V_MAX <= 50.0) ) && P0001__V_MAX > 3000.0 ), RESULT = 1, RESULT = 0)

ther is way to obtain the block oh this formula:
1) (P5525__V_MIN >= 30.0 || P5525__V_MAX <= 50.0) 
                                       &&
 2)  (P0003__V_MIN >= 30.0 || P0003__V_MAX <= 50.0)
                                       && 
 3) P0001__V_MAX > 3000.0 

???

Thanks

Richard Morris

unread,
May 3, 2016, 7:29:38 AM5/3/16
to Jep Java Users
Ways to manipulate expressions are discussed in the manipulating expressions documentation page


In particular the Node interface has the method Node jjtGetChild(int i) which gets the n-th child of a a node, in your case
 you can use

Node n2 = jep.parse("if ((  ( (P5525__V_MIN >= 30.0 || P5525__V_MAX <= 50.0) && (P0003__V_MIN >= 30.0 || P0003__V_MAX <= 50.0) ) && P0001__V_MAX > 3000.0 ), RESULT = 1, RESULT = 0)");
Node c1 = n2.jjtGetChild(0);
Node c2 = n2.jjtGetChild(1);
Node c3 = n2.jjtGetChild(2);
Node c1ll = c1.jjtGetChild(0).jjtGetChild(0);
Node c1lr = c1.jjtGetChild(0).jjtGetChild(1);
Node c1r = c1.jjtGetChild(1);
jep.println(c1ll);
jep.println(c1lr);
jep.println(c1r);


Hope that helps

Richard
Reply all
Reply to author
Forward
0 new messages