[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: BeanShell : Separating parsing from evaluation
- To: Rémi Bastide <bastide@cict.fr>
- Subject: Re: BeanShell : Separating parsing from evaluation
- From: Pat <pat@pat.net>
- Date: Fri, 19 Nov 1999 14:23:16 -0600
- Approved: pat@pat.net
- Cc: users@beanshell.org, developers@beanshell.org
- In-Reply-To: <000501bf2f57$7d3be240$0f3031c1@univtlse1.fr>; from Rémi Bastide on Mon, Nov 15, 1999 at 11:52:19AM +0100
- Mail-Followup-To: Rémi Bastide <bastide@cict.fr>,users@beanshell.org, developers@beanshell.org
- References: <19991113013504.56827@pat.net> <000501bf2f57$7d3be240$0f3031c1@univtlse1.fr>
- Reply-To: pat@pat.net
On Mon, Nov 15, 1999 at 11:52:19AM +0100, Rémi Bastide wrote:
> Hi Pat,
>
> Thanks for your continuous improvement of BeanShell, which has become a very
> important piece of our research product.
>
> I wonder of difficult it would be to separate in BeanShell the parsing of an
> expression from its evaluation. This would be very valuable in our app,
> where an expression is entered once by the user, and then evaluated a number
> of times.
>
> I dream to be able to do this :
>
> bsh.Interpreter i = ...
> String anExpression = ...
> ParsedExpression e; // Opaque class to represent an evaluable expression
> pre-parsed by BeanShell
>
> try {
> e = i.parse(anExpression);
> } catch (bsh.ParseError e) {
> // The expression is syntaxically incorrect
> return false;
> }
I believe this is exactly what is accomplished by evaluating the method
delcaration in the interpreter.. and then later using that interpreter to
invoke the method with arguments...
e.g.
interpreter.eval("foo(a,b) { ... } ");
// later
interpreter.eval("foo(1,2)");
The internal form of the parsed method is a BSHMethodDeclaration node, not
the original text.
Variable resolution from the enclosing context (probably the root interpreter
context in your case) will happen at invocation time.
Does this make sense? Or am I missing your point.
Pat