I am using rhino and Scripting for the Java Platform in order to allow the user extend my application.
However the user can write some cases eg (ASTO.value>440) || (ASTO.bellowNormal)
etc...
The problem is that before running the script from my JAVA application using ScriptEngine
i want to get the names of all the variables! Because i should know which variables are required for the script to run...
I know that a regular expression would do the jo开发者_Go百科b but i amnt sure...
Please i somebody could help me figure out the java regexp to get the variables i would really appriciate it..
I found a solution cx.getDebuggableView(result).getParamAndVarCount() But it doesnt return undeclared variables:(
We're doing something very similar although it is written in Scala and I can only give you some hints...
- Tests are really important
- This is one of our more complex tests:
listArg[Math.floor(4 / listArg[zeroArg]['f3'])]
Variables that describe the design...
// chars after which there may be an environment variable used private val NewScopeChars = List('[', '(', '/', '*', '+', '-', ',') // chars that signal the end of a variable name private val SepChars = '.' :: ' ' :: ';' :: ']' :: ')' :: NewScopeChars private val ExcludeStrings = List("new", "Math") private val LiteralPrefixes = "'" :: "\"" :: (0 to 9).map(_.toString).toList
I'm having a problem with performance so any help would be appreciated.
a little late but you might be interested in this: http://ramkulkarni.com/blog/understanding-ast-created-by-mozilla-rhino-parser/
精彩评论