/** * 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. */ private boolean parse(final String code, final int tolerance) { assert code != null; boolean parsed = false; parser = null; error = null; // Create the parser and attempt to parse the text as a top-level statement. try { parser = SourceUnit.create("groovysh-script", code, tolerance); parser.parse(); parsed = true; } // We report errors other than unexpected EOF to the user. catch (CompilationFailedException e) { if (parser.getErrorCollector().getErrorCount() > 1 || !parser.failedWithUnexpectedEOF()) { error = e; } } catch (Exception e) { error = e; } return parsed; }
|| !parser.failedWithUnexpectedEOF()) { error = e;
/** * 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. */ private boolean parse(final String code, final int tolerance) { assert code != null; boolean parsed = false; parser = null; error = null; // Create the parser and attempt to parse the text as a top-level statement. try { parser = SourceUnit.create("groovysh-script", code, tolerance); parser.parse(); parsed = true; } // We report errors other than unexpected EOF to the user. catch (CompilationFailedException e) { if (parser.getErrorCollector().getErrorCount() > 1 || !parser.failedWithUnexpectedEOF()) { error = e; } } catch (Exception e) { error = e; } return parsed; }
/** * 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. */ private boolean parse(final String code, final int tolerance) { assert code != null; boolean parsed = false; parser = null; error = null; // Create the parser and attempt to parse the text as a top-level statement. try { parser = SourceUnit.create("groovysh-script", code, tolerance); parser.parse(); parsed = true; } // We report errors other than unexpected EOF to the user. catch (CompilationFailedException e) { if (parser.getErrorCollector().getErrorCount() > 1 || !parser.failedWithUnexpectedEOF()) { error = e; } } catch (Exception e) { error = e; } return parsed; }
/** * 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. */ private boolean parse(final String code, final int tolerance) { assert code != null; boolean parsed = false; parser = null; error = null; // Create the parser and attempt to parse the text as a top-level statement. try { parser = SourceUnit.create("groovysh-script", code, tolerance); parser.parse(); parsed = true; } // We report errors other than unexpected EOF to the user. catch (CompilationFailedException e) { if (parser.getErrorCollector().getErrorCount() > 1 || !parser.failedWithUnexpectedEOF()) { error = e; } } catch (Exception e) { error = e; } return parsed; }