Validating expression

37 views
Skip to first unread message

ॐकार

unread,
Dec 9, 2009, 2:21:50 AM12/9/09
to Jep Java Users
Hi All!
Im new in JEP.
I just got how to write expression & evaluate it.
But I wanna know how to validate expression? means its in right format
or not...
Im getting expression from user, no separate variables...
So I cant add variables to parser.
How to check for validity?

Nathan Funk

unread,
Dec 9, 2009, 10:18:13 PM12/9/09
to Jep Java Users
You can allow undeclared variables while parsing the expression (see
http://www.singularsys.com/jep/doc/html/variables.html#undeclared).

I am not sure what you mean by validate. The parser will report an
error while parsing if the syntax is invalid. For example "1*" doesn't
parse.

If you want to check whether the variables used in the expression are
among a set group of variable names, you would need to check the
variable table after parsing to see which variables were found in the
expression. See http://www.singularsys.com/jep/doc/html/variables.html#obtainingalist
for details on this.

I hope this helps. Let us know if you are still unclear.

Nathan
Reply all
Reply to author
Forward
0 new messages