/** * Attempts to parse the specified code with the specified tolerance. Updates the <code>parser * </code> and <code>error</code> members appropriately. Returns true if the text parsed, false * otherwise. The attempts to identify and suppress errors resulting from the unfinished source * text. * * <p><b>Note:</b> taken from {@link groovy.ui.InteractiveShell}. */ private static boolean parse(final String code, final int tolerance) { assert code != null; boolean parsed = false; // Create the parser and attempt to parse the text as a top-level statement. try { SourceUnit parser = SourceUnit.create("vrl-script", code, tolerance); parser.parse(); parsed = true; } // We report errors other than unexpected EOF to the user. catch (CompilationFailedException e) { // } catch (Exception e) { // } return parsed; }