public Preprocessor(Source initial) { this(); addInput(initial); }
public Preprocessor(Source initial) { this(); addInput(initial); }
public Preprocessor(@Nonnull Source initial) { this(); addInput(initial); }
/** * Adds input for the Preprocessor. * * @see #addInput(Source) */ public void addInput(File file) throws IOException { addInput(new FileLexerSource(file)); }
/** * Adds input for the Preprocessor. * * @see #addInput(Source) */ public void addInput(File file) throws IOException { addInput(new FileLexerSource(file)); }
/** * Adds input for the Preprocessor. * * @see #addInput(Source) */ public void addInput(@Nonnull File file) throws IOException { addInput(new FileLexerSource(file)); }
public void execute() { FileWriter writer = null; try { if (input == null) throw new BuildException("Input not specified"); if (output == null) throw new BuildException("Output not specified"); cpp.addInput(this.input); writer = new FileWriter(this.output); for (;;) { Token tok = cpp.token(); if (tok != null && tok.getType() == Token.EOF) break; writer.write(tok.getText()); } } catch (Exception e) { throw new BuildException(e); } finally { if (writer != null) { try { writer.close(); } catch (IOException e) { } } } }
public void execute() { FileWriter writer = null; try { if (input == null) throw new BuildException("Input not specified"); if (output == null) throw new BuildException("Output not specified"); cpp.addInput(this.input); writer = new FileWriter(this.output); for (;;) { Token tok = cpp.token(); if (tok != null && tok.getType() == Token.EOF) break; writer.write(tok.getText()); } } catch (Exception e) { throw new BuildException(e); } finally { if (writer != null) { try { writer.close(); } catch (IOException e) { } } } }
public void setUp() throws Exception { final PipedOutputStream po = new PipedOutputStream(); writer = new OutputStreamWriter(po); p = new Preprocessor(); p.addInput( new LexerSource( new InputStreamReader( new PipedInputStream(po) ), true ) ); }
@Before public void setUp() throws Exception { final PipedOutputStream po = new PipedOutputStream(); writer = new OutputStreamWriter(po); p = new Preprocessor(); p.addInput( new LexerSource( new InputStreamReader( new PipedInputStream(po) ), true ) ); }
cpp.addInput(input); writer = new FileWriter(output); for (;;) {
public static String preprocessSources(JNAeratorConfig config, Collection<String> includeStrings, Collection<File> files, List<Define> defines, boolean verbose, TypeConversion typeConverter, MacroUseCallback macrosDependenciesOut, Map<String, Macro> macros) throws IOException, LexerException { Preprocessor preProcessor = PreprocessorUtils.createPreProcessor(config.preprocessorConfig, macrosDependenciesOut); for (String content : includeStrings) { preProcessor.addInput(new StringLexerSource(content, true)); preProcessor.addInput(file);
public static String preprocessSources(JNAeratorConfig config, Collection<String> includeStrings, Collection<File> files, List<Define> defines, boolean verbose, TypeConversion typeConverter, MacroUseCallback macrosDependenciesOut, Map<String, Macro> macros) throws IOException, LexerException { Preprocessor preProcessor = PreprocessorUtils.createPreProcessor(config.preprocessorConfig, macrosDependenciesOut); for (String content : includeStrings) { preProcessor.addInput(new StringLexerSource(content, true)); preProcessor.addInput(file);
@Test public void testAbsoluteInclude() throws Exception { File file = new File("build/resources/test/absolute.h"); assertTrue(file.exists()); String input = "#include <" + file.getAbsolutePath() + ">\n"; LOG.info("Input: " + input); Preprocessor pp = new Preprocessor(); pp.addInput(new StringLexerSource(input, true)); Reader r = new CppReader(pp); String output = CharStreams.toString(r); r.close(); LOG.info("Output: " + output); assertTrue(output.contains("absolute-result")); } }
public List<String> run() throws SoShaderException { try { final SoShaderPreprocessorJCPP p = SoShaderPreprocessorJCPP.this; this.pp.setSystemIncludePath(p.modules); this.pp.setFileSystem(p.filesystem); this.pp.addInput(p.filesystem.getFile(this.file).getSource()); this.pp.setListener(this); this.setupDefines(); final int bsize = 2 << 14; try (final ByteArrayOutputStream bao = new ByteArrayOutputStream(bsize)) { this.processTokens(bao); return this.processLines(bao); } } catch (final IOException e) { throw new SoShaderExceptionIO(e); } }
@Test public void testWhitespacePasting() throws IOException { Preprocessor pp = new Preprocessor(); pp.addInput(new StringLexerSource( "#define ONE(arg) one_##arg\n" + "#define TWO(arg) ONE(two_##arg)\n" + "\n" + "TWO(good)\n" + "TWO( /* evil newline */\n" + " bad)\n" + "\n" + "ONE(good)\n" + "ONE( /* evil newline */\n" + " bad)\n", true)); Reader r = new CppReader(pp); String text = CharStreams.toString(r).trim(); LOG.info("Output is:\n" + text); assertEquals("one_two_good\n" + "one_two_bad\n" + "\n" + "one_good\n" + "one_bad", text); } }
Preprocessor pp = new Preprocessor(); pp.addFeature(Feature.KEEPCOMMENTS); pp.addInput(new StringLexerSource(input, true)); Reader r = new CppReader(pp); String output = CharStreams.toString(r).trim();