0

In beanshell script executed from java code:

How can I parse (only check syntaxis) a beanshell script without evaluate it?

There is a page in manual about it but I don't understand how to make a method to only parse a string with script: http://www.beanshell.org/manual/parser.html

Thanks in advance

iberck
  • 2,372
  • 5
  • 31
  • 41

1 Answers1

0

Answer my own question, in the source code of Parser.java is the solution: http://grepcode.com/file/repo1.maven.org/maven2/org.beanshell/bsh/2.0b5/bsh/Parser.java

So, with this method you can parse a string in bsh

public static void parseBsh(String script) throws ParseException {
    StringReader reader = new StringReader(script);
    Parser parser = new Parser(reader);
    while (!parser.Line()) {
        parser.popNode();
    }
}
iberck
  • 2,372
  • 5
  • 31
  • 41