Examples of CxxPreprocessor


Examples of org.sonar.cxx.preprocessor.CxxPreprocessor

public class CxxLexerWithPreprocessingTest {

  private static Lexer lexer;

  public CxxLexerWithPreprocessingTest() {
    CxxPreprocessor cxxpp = new CxxPreprocessor(mock(SquidAstVisitorContext.class));
    lexer = CxxLexer.create(cxxpp, new JoinStringsPreprocessor());
  }
View Full Code Here

Examples of org.sonar.cxx.preprocessor.CxxPreprocessor

  @Test
  public void external_define() {
    CxxConfiguration conf = new CxxConfiguration();
    conf.setDefines(Arrays.asList("M body"));
    CxxPreprocessor cxxpp = new CxxPreprocessor(mock(SquidAstVisitorContext.class), conf);
    lexer = CxxLexer.create(conf, cxxpp, new JoinStringsPreprocessor());

    List<Token> tokens = lexer.lex("M");
    assertThat(tokens).hasSize(2);
    assertThat(tokens, hasToken("body", GenericTokenType.IDENTIFIER));
View Full Code Here

Examples of org.sonar.cxx.preprocessor.CxxPreprocessor

  @Test
  public void external_defines_with_params() {
    CxxConfiguration conf = new CxxConfiguration();
    conf.setDefines(Arrays.asList("minus(a, b) a - b"));
    CxxPreprocessor cxxpp = new CxxPreprocessor(mock(SquidAstVisitorContext.class), conf);
    lexer = CxxLexer.create(conf, cxxpp, new JoinStringsPreprocessor());

    List<Token> tokens = lexer.lex("minus(1, 2)");
    assertThat(tokens).hasSize(4);
    assertThat(tokens, hasToken("1", CxxTokenType.NUMBER));
View Full Code Here

Examples of org.sonar.cxx.preprocessor.CxxPreprocessor

    when(scp.getSourceCode(any(File.class))).thenReturn("#define A B\n");

    SquidAstVisitorContext<Grammar> ctx = mock(SquidAstVisitorContext.class);
    when(ctx.getFile()).thenReturn(new File("/home/joe/file.cc"));

    CxxPreprocessor pp = new CxxPreprocessor(ctx, new CxxConfiguration(), scp);
    lexer = CxxLexer.create(pp, new JoinStringsPreprocessor());

    List<Token> tokens = lexer.lex("#include <file>\n"
      + "A");
    assertThat(tokens).hasSize(2); // B + EOF
View Full Code Here

Examples of org.sonar.cxx.preprocessor.CxxPreprocessor

  @Test
  public void externalMacrosCannotBeOverriden() {
    CxxConfiguration conf = mock(CxxConfiguration.class);
    when(conf.getDefines()).thenReturn(Arrays.asList("name goodvalue"));
    CxxPreprocessor cxxpp = new CxxPreprocessor(mock(SquidAstVisitorContext.class), conf);
    lexer = CxxLexer.create(conf, cxxpp);

    List<Token> tokens = lexer.lex("#define name badvalue\n"
      + "name");
View Full Code Here

Examples of org.sonar.cxx.preprocessor.CxxPreprocessor

  private static Lexer lexer;

  @BeforeClass
  public static void init() {
    CxxPreprocessor cxxpp = new CxxPreprocessor(mock(SquidAstVisitorContext.class));
    lexer = CxxLexer.create(cxxpp, new JoinStringsPreprocessor());
  }
View Full Code Here

Examples of org.sonar.cxx.preprocessor.CxxPreprocessor

    return create(context, new CxxConfiguration());
  }

  public static Parser<Grammar> create(SquidAstVisitorContext<Grammar> context,
                                       CxxConfiguration conf) {
    cxxpp = new CxxPreprocessor(context, conf);
    return Parser.builder(CxxGrammarImpl.create(conf))
      .withLexer(CxxLexer.create(conf, cxxpp, new JoinStringsPreprocessor()))
      .build();
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.