From: bob mcwhirter <bob@we...> - 2001-12-12 04:13:18
I'm working on using BeanShell for evaluation of arbitrary java
expressions and statement blocks.
I currently have to parse everything myself first, before handing
to bsh, because I need to do some code-analysis first. Basically,
I need to know what variable references occur within the expression.
Additionally, I execute each expression many many times, with
different objects bound to the variable references each time.
Would it be possible for you to give us a CompiledScript class, which
would run everything through your front-end parser, creating your AST,
and saving it, avoiding having to parse the same string repeatedly.
Then, if it were Visitable, allowing me to drop in an ASTVisitor,
I could perform my analysis without having to parse the text myself to
build my own AST.
Anyhow, would this funtionality interest you? If so, I'd be glad to
contribute a patch. (I won't ask for anything I'm not willing to
personally code up.)
To sum up:
CompiledScript, which runs the parser to build the AST.
Interpreter.eval(CompiledScript script) to side-step the
parsing step, and use the pre-parsed AST for evaluation.
Additionally, for some reason, using 'import *;' is causing a lot
of "Mapping:..." output on the console.
Get latest updates about Open Source Projects, Conferences and News.