获取JAVA中javascript的所有变量
我使用 rhino 和 Java 平台脚本来允许用户扩展我的应用程序。
然而,用户可以编写一些情况,例如 (ASTO.value>440) || (ASTO.bellowNormal)
等等... 问题是在使用 ScriptEngine 从我的 JAVA 应用程序运行脚本之前 我想获取所有变量的名称!因为我应该知道脚本运行需要哪些变量...... 我知道正则表达式可以完成这项工作,但我不确定...... 请有人能帮我找出 java 正则表达式来获取变量,我真的很感激它。
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 job but i amnt sure...
Please i somebody could help me figure out the java regexp to get the variables i would really appriciate it..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我找到了解决方案
cx.getDebuggableView(结果).getParamAndVarCount()
但它不会返回未声明的变量:(
I found a solution
cx.getDebuggableView(result).getParamAndVarCount()
But it doesnt return undeclared variables:(
我们正在做一些非常相似的事情,尽管它是用 Scala 编写的,我只能给你一些提示...
listArg[Math.floor(4 / listArg[ ZeroArg]['f3'])]
描述设计的变量...
我有
We're doing something very similar although it is written in Scala and I can only give you some hints...
listArg[Math.floor(4 / listArg[zeroArg]['f3'])]
Variables that describe the design...
I'm having a problem with performance so any help would be appreciated.
有点晚了,但您可能对此感兴趣:http:// /ramkulkarni.com/blog/understanding-ast-created-by-mozilla-rhino-parser/
a little late but you might be interested in this: http://ramkulkarni.com/blog/understanding-ast-created-by-mozilla-rhino-parser/