Scripting for JAVA - a problem to solve
- by Parhs
Hello.. I had no luck to find a good way to achieve the following:
suppose i let the user to write a condition using javascript
INS5 || ASTO.valueBetween(10,210) ... etc....
I tried to find a way to get the variables name...from JAVA...
Rhino library didnt help a lot...
However i found that handling exceptions i could get all the identifiers!
Everything is great but one little problem.....
How teh heck i can replace these identifiers with the numeric id of each var ?
eg INS to be _234 ASTO to be _331 ?
I want to to this replace because the name may change...
I could do it using a replace but i know that this isnt easy because...
1) replacing _23 with MPLAH may replace also _234...(this could be fixed with regexp somehow..)
2)what if _23 is in a comment section ? rare to happen but possible /* _23 fdsafd ktl */ it should be replaced...
3)what if is a name of a function ??? _32() {} rare but shouldnt be replaced
4) what if it is enclosed in "" or ''???
And i am sure that there should me a lot more cases.....
any ideas ?
thank yoyu for your time