Parsing Arthmetic symbols as variable in JEP

27 views
Skip to first unread message

ashesh

unread,
Dec 6, 2011, 2:07:33 AM12/6/11
to Jep Java Users
Hi All,

i have a requirement in which i need to parse an expression which
contains symbols like + and -.When i parse thru using XJEP the parser
splits the lines and read it as following:

Formula = abs(SMK_APDM~LT-WL+A~WL_BL)
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@node
=abs(SMK_APDM_LT-WL+A_WL_BL)
symbolTable = SMK_APDM_LT: null
A_WL_BL: null
e: 2.718281828459045 (Constant)
pi: 3.141592653589793 (Constant)
WL: null

Search for testName =SMK_APDM_LT
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
Search for testName =A_WL_BL
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
Search for testName =WL
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
assignment must have value = SMK_APDM_LT: null
A_WL_BL: null
e: 2.718281828459045 (Constant)
pi: 3.141592653589793 (Constant)
WL: null

testName=SMK_APDM_LT

As you can see the parser splits the Formula where it find - and + and
look for test name.
I want the parser to conside it as one one Continuous name and dont
split it.

Any suggestion would be highly appreciable.

Regards
Ashesh

Richard

unread,
Dec 6, 2011, 2:37:29 PM12/6/11
to Jep Java Users
Dear Ashesh,

I see your using the Jep 2.4 version with the XJep extensions.
Changing the parsing phase is much harder in 2.4 than in the latest
3.4 version which has a ConfigurableParser which allows syntax to be
easily changed. http://www.singularsys.com/jep/doc/html/confparser.html

In 2.4 to change the syntax you would need to modify the JavaCC source
files /org/nfunk/jep/Parser.jjt.

Changing the parsing behaviour of + and - are likely to prove tricky.
You might be able to quote the expressions
abs("SMK_APDM~LT-WL+A~WL_BL")
or use some other symbol in place of + and -. Quite a range of unicode
characters can be used in identifiers.

Rich

Reply all
Reply to author
Forward
0 new messages