Evaluating script syntax

Kirby Files <[email protected]> Wed, 27 Aug 2008 15:21:36 -0400
Newsgroups gmane.comp.java.beanshell.user
Message-ID <[email protected]>
A really long time ago, I wrote code for the bsh v1.01 API which 
evaluated the syntax of a script without executing it. It went 
something like this:

   StringReader in = new StringReader( script );
   Interpreter parse = new Interpreter( in );
   boolean eof = false;
   while ( !(eof=parse.Line()) ) {}


After upgrading to v1.3 (several years after the beanshell project 
became defunct), I found that there was no equivalent to 
Interpreter.Line(). Is there any way to achieve the same result with 
this API?

The reason we do this is that BSH is the core of an online script 
editing framework. After an engineer edits a script and saves it, the 
script is immediately checked for correctness. If it fails to parse, 
the engineer is shown the offending line and given a chance to correct it.

Without such a feature, we have to wait and test the script by 
executing it for real. This is significantly harder to debug, 
particularly since many scriptfiles can be assembled into a larger 
executable.

Thanks,
   --kirby files

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/