@Override public void handleWarning(Source source, int line, int column, String msg) throws LexerException { if (msg.contains("Unnecessary escape character ")) { return; } if (msg.contains("#pragma")) { return; } super.handleWarning(source, line, column, msg); } });
protected void error(int line, int column, String msg) throws LexerException { if (listener != null) listener.handleError(this, line, column, msg); else throw new LexerException("Error at " + line + ":" + column + ": " + msg); }
/** * Pushes a Source onto the input stack. * * @see #getSource() * @see #pop_source() */ protected void push_source(Source source, boolean autopop) { source.init(this); source.setParent(this.source, autopop); // source.setListener(listener); if (listener != null) listener.handleSourceChange(this.source, "suspend"); this.source = source; if (listener != null) listener.handleSourceChange(this.source, "push"); }
p.addFeature(Feature.CSYNTAX); p.addInput(sl); pl = new PreprocessorListener(); p.setListener(pl); assertNotNull("CPP has listener", p.getListener()); assertTrue(testError(p)); assertTrue("Listener has errors", pl.getErrors() > 0);
pp.addFeature(Feature.LINEMARKERS); pp.addWarning(Warning.IMPORT); pp.setListener(new PreprocessorListener()); pp.addMacro("__JCPP__"); pp.getSystemIncludePath().add("/usr/local/include");
/** * Handles a warning. * * The behaviour of this method is defined by the * implementation. It may simply record the error message, or * it may throw an exception. */ public void handleWarning(Source source, int line, int column, String msg) throws LexerException { warnings++; print(source.getName() + ":" + line + ":" + column + ": warning: " + msg); }
public PreprocessorListener() { clear(); }
pp.addFeature(Feature.LINEMARKERS); pp.addWarning(Warning.IMPORT); pp.setListener(new PreprocessorListener()); pp.addMacro("__JCPP__"); pp.getSystemIncludePath().add("/usr/local/include");
/** * Handles an error. * * The behaviour of this method is defined by the * implementation. It may simply record the error message, or * it may throw an exception. */ public void handleError(Source source, int line, int column, String msg) throws LexerException { errors++; print(source.getName() + ":" + line + ":" + column + ": error: " + msg); }
public PreprocessorListener() { clear(); }
@Override public void handleWarning(Source source, int line, int column, String msg) throws LexerException { if (msg.contains("Unnecessary escape character ")) { return; } if (msg.contains("#pragma")) { return; } super.handleWarning(source, line, column, msg); } });
protected void error(int line, int column, String msg) throws LexerException { if (listener != null) listener.handleError(this, line, column, msg); else throw new LexerException("Error at " + line + ":" + column + ": " + msg); }
/** * Pops a Source from the input stack. * * @see #getSource() * @see #push_source(Source,boolean) */ protected void pop_source() throws IOException { if (listener != null) listener.handleSourceChange(this.source, "pop"); Source s = this.source; this.source = s.getParent(); /* Always a noop unless called externally. */ s.close(); if (listener != null && this.source != null) listener.handleSourceChange(this.source, "resume"); }
/** * Handles a warning. * * The behaviour of this method is defined by the * implementation. It may simply record the error message, or * it may throw an exception. */ public void handleWarning(Source source, int line, int column, String msg) throws LexerException { warnings++; print(source.getName() + ":" + line + ":" + column + ": warning: " + msg); }
/** * Handles a warning. * * If a PreprocessorListener is installed, it receives the * warning. Otherwise, an exception is thrown. */ protected void warning(int line, int column, @Nonnull String msg) throws LexerException { if (warnings.contains(Warning.ERROR)) error(line, column, msg); else if (listener != null) listener.handleWarning(source, line, column, msg); else throw new LexerException("Warning at " + line + ":" + column + ": " + msg); }
protected void error(int line, int column, String msg) throws LexerException { if (listener != null) listener.handleError(this, line, column, msg); else throw new LexerException("Error at " + line + ":" + column + ": " + msg); }
/** * Pushes a Source onto the input stack. * * @param source the new Source to push onto the top of the input stack. * @param autopop if true, the Source is automatically removed from the input stack at EOF. * @see #getSource() * @see #pop_source() */ protected void push_source(@Nonnull Source source, boolean autopop) { source.init(this); source.setParent(this.source, autopop); // source.setListener(listener); if (listener != null) listener.handleSourceChange(this.source, SourceChangeEvent.SUSPEND); this.source = source; if (listener != null) listener.handleSourceChange(this.source, SourceChangeEvent.PUSH); }
/** * Handles an error. * * The behaviour of this method is defined by the * implementation. It may simply record the error message, or * it may throw an exception. */ public void handleError(Source source, int line, int column, String msg) throws LexerException { errors++; print(source.getName() + ":" + line + ":" + column + ": error: " + msg); }
protected void warning(int line, int column, String msg) throws LexerException { if (werror) error(line, column, msg); else if (listener != null) listener.handleWarning(this, line, column, msg); else throw new LexerException("Warning at " + line + ":" + column + ": " + msg); }
/** * Handles an error. * * If a PreprocessorListener is installed, it receives the * error. Otherwise, an exception is thrown. */ protected void error(int line, int column, String msg) throws LexerException { if (listener != null) listener.handleError(source, line, column, msg); else throw new LexerException("Error at " + line + ":" + column + ": " + msg); }