Tabnine Logo
CppReader
Code IndexAdd Tabnine to your IDE (free)

How to use
CppReader
in
org.anarres.cpp

Best Java code snippets using org.anarres.cpp.CppReader (Showing top 15 results out of 315)

origin: nativelibs4java/JNAerator

public int read(char cbuf[], int off, int len)
          throws IOException {
  if (token == null)
    return -1;
  for (int i = 0; i < len; i++) {
    int	ch = read();
    if (ch == -1)
      return i;
    cbuf[off + i] = (char)ch;
  }
  return len;
}
origin: nativelibs4java/JNAerator

public int read()
          throws IOException {
  if (!refill())
    return -1;
  return token.charAt(idx++);
}
origin: shevek/jcpp

  @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"));
  }
}
origin: shevek/jcpp

  @Test
  public void testRegression() throws Exception {
    String inText = Files.toString(inFile, Charsets.UTF_8);
    LOG.info("Read " + name + ":\n" + inText);
    CppReader cppReader = new CppReader(new StringReader(inText));
    String cppText = CharStreams.toString(cppReader);
    LOG.info("Generated " + name + ":\n" + cppText);
    if (outFile.exists()) {
      String outText = Files.toString(outFile, Charsets.UTF_8);
      LOG.info("Expected " + name + ":\n" + outText);
      assertEquals(outText, inText);
    }

  }
}
origin: nativelibs4java/JNAerator

private void testCppReader(String in, String out)
          throws Exception {
  System.out.println("Testing " + in + " => " + out);
  StringReader    r = new StringReader(in);
  CppReader        p = new CppReader(r);
  p.getPreprocessor().setSystemIncludePath(
      Collections.singletonList("src/test/resources/input")
        );
  p.getPreprocessor().getFeatures().add(Feature.LINEMARKERS);
  BufferedReader    b = new BufferedReader(p);
  String    line;
  while ((line = b.readLine()) != null) {
    System.out.println(" >> " + line);
  }
}
origin: shevek/jcpp

  @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"));
  }
}
origin: shevek/jcpp

public static String testCppReader(@Nonnull String in, Feature... f)
    throws Exception {
  System.out.println("Testing " + in);
  StringReader r = new StringReader(in);
  CppReader p = new CppReader(r);
  p.getPreprocessor().setSystemIncludePath(
      Collections.singletonList("src/test/resources")
  );
  p.getPreprocessor().addFeatures(f);
  BufferedReader b = new BufferedReader(p);
  StringBuilder out = new StringBuilder();
  String line;
  while ((line = b.readLine()) != null) {
    System.out.println(" >> " + line);
    out.append(line).append("\n");
  }
  return out.toString();
}
origin: nativelibs4java/JNAerator

String sourceContent = ReadText.readText(new CppReader(preProcessor));
preProcessor.close();
origin: com.nativelibs4java/anarres-jnaerator

public int read(char cbuf[], int off, int len)
          throws IOException {
  if (token == null)
    return -1;
  for (int i = 0; i < len; i++) {
    int	ch = read();
    if (ch == -1)
      return i;
    cbuf[off + i] = (char)ch;
  }
  return len;
}
origin: com.nativelibs4java/anarres-jnaerator

public int read()
          throws IOException {
  if (!refill())
    return -1;
  return token.charAt(idx++);
}
origin: com.nativelibs4java/jnaerator

String sourceContent = ReadText.readText(new CppReader(preProcessor));
preProcessor.close();
origin: shevek/jcpp

@Override
/* XXX Very slow and inefficient. */
public int read(char cbuf[], int off, int len)
    throws IOException {
  if (token == null)
    return -1;
  for (int i = 0; i < len; i++) {
    int ch = read();
    if (ch == -1)
      return i;
    cbuf[off + i] = (char) ch;
  }
  return len;
}
origin: shevek/jcpp

@Override
public int read()
    throws IOException {
  if (!refill())
    return -1;
  return token.charAt(idx++);
}
origin: shevek/jcpp

  @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);
  }
}
origin: shevek/jcpp

pp.addFeature(Feature.KEEPCOMMENTS);
pp.addInput(new StringLexerSource(input, true));
Reader r = new CppReader(pp);
String output = CharStreams.toString(r).trim();
LOG.info("Output is:\n" + output);
org.anarres.cppCppReader

Javadoc

A Reader wrapper around the Preprocessor. This is a utility class to provide a transparent Readerwhich preprocesses the input text.

Most used methods

  • <init>
  • getPreprocessor
    Returns the Preprocessor used by this CppReader.
  • read
  • refill
  • close

Popular in Java

  • Updating database using SQL prepared statement
  • startActivity (Activity)
  • getSystemService (Context)
  • getSupportFragmentManager (FragmentActivity)
  • FileNotFoundException (java.io)
    Thrown when a file specified by a program cannot be found.
  • SortedSet (java.util)
    SortedSet is a Set which iterates over its elements in a sorted order. The order is determined eithe
  • JButton (javax.swing)
  • JOptionPane (javax.swing)
  • DateTimeFormat (org.joda.time.format)
    Factory that creates instances of DateTimeFormatter from patterns and styles. Datetime formatting i
  • Option (scala)
  • Top plugins for Android Studio
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now