public DefaultPreprocessorListener() { clear(); }
/** * 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. */ @Override public void handleError(Source source, int line, int column, String msg) throws LexerException { errors++; print(source.getName() + ":" + line + ":" + column + ": error: " + msg); }
p.addFeature(Feature.CSYNTAX); p.addInput(sl); pl = new DefaultPreprocessorListener(); p.setListener(pl); assertNotNull("CPP has listener", p.getListener()); assertTrue(testError(p)); assertTrue("Listener has errors", pl.getErrors() > 0);
@Test public void testPragma() throws Exception { File file = new File("build/resources/test/pragma.c"); assertTrue(file.exists()); CharSource source = Files.asCharSource(file, Charsets.UTF_8); CppReader r = new CppReader(source.openBufferedStream()); r.getPreprocessor().setListener(new DefaultPreprocessorListener()); String output = CharStreams.toString(r); r.close(); LOG.info("Output: " + output); // assertTrue(output.contains("absolute-result")); } }
pp.addFeature(Feature.LINEMARKERS); pp.addWarning(Warning.IMPORT); pp.setListener(new DefaultPreprocessorListener()); 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. */ @Override public void handleWarning(Source source, int line, int column, String msg) throws LexerException { warnings++; print(source.getName() + ":" + line + ":" + column + ": warning: " + msg); }