public void addError(String message) { MatcherContext matcherContext = (MatcherContext) getContext(); matcherContext.markError(); List parseErrors = matcherContext.getParseErrors(); parseErrors.add(new BasicParseError(matcherContext.getInputBuffer(), parseErrors.size(), message)); }
public void addError(String message) { MatcherContext matcherContext = (MatcherContext) getContext(); matcherContext.markError(); List parseErrors = matcherContext.getParseErrors(); parseErrors.add(new BasicParseError(matcherContext.getInputBuffer(), parseErrors.size(), message)); }
public boolean runMatcher() { try { if (matchHandler.match(this)) { if (parent != null) { parent.currentIndex = currentIndex; parent.currentChar = currentChar; } matcher = null; // "retire" this context return true; } matcher = null; // "retire" this context until is "activated" again by a getSubContext(...) on the parent return false; } catch (ParserRuntimeException e) { throw e; // don't wrap, just bubble up } catch (RecoveringParseRunner.TimeoutException e) { throw e; // don't wrap, just bubble up } catch (Throwable e) { throw new ParserRuntimeException(e, printParseError(new BasicParseError(inputBuffer, currentIndex, StringUtils.escape(String.format("Error while parsing %s '%s' at input position", matcher instanceof ActionMatcher ? "action" : "rule", getPath())))) + '\n' + e); } } }
public ParsingResult<V> run(InputBuffer inputBuffer) { checkArgNotNull(inputBuffer, "inputBuffer"); resetValueStack(); errorIndex = 0; // run without fast string matching to properly get the error location MatcherContext<V> rootContext = createRootContext(inputBuffer, this, false); boolean matched = match(rootContext); if (!matched) { getParseErrors().add(new BasicParseError(inputBuffer, errorIndex, null)); } return createParsingResult(matched, rootContext); }