Package org.antlr.v4.runtime

Examples of org.antlr.v4.runtime.CommonTokenStream.fill()


                       "B : 'b';\n" +
                       "C : 'c';\n");
    String input = "abc";
    LexerInterpreter lexEngine = g.createLexerInterpreter(new ANTLRInputStream(input));
    CommonTokenStream stream = new CommonTokenStream(lexEngine);
    stream.fill();
    TokenStreamRewriter tokens = new TokenStreamRewriter(stream);
    tokens.delete(0, 2);
    tokens.insertBefore(0, "z");
    stream.fill();
// combine with left edge of rewrite
View Full Code Here


    CommonTokenStream stream = new CommonTokenStream(lexEngine);
    stream.fill();
    TokenStreamRewriter tokens = new TokenStreamRewriter(stream);
    tokens.delete(0, 2);
    tokens.insertBefore(0, "z");
    stream.fill();
// combine with left edge of rewrite
    String result = tokens.getText();
    String expecting = "z";
    stream.fill();
// make sure combo is not znull
View Full Code Here

    tokens.insertBefore(0, "z");
    stream.fill();
// combine with left edge of rewrite
    String result = tokens.getText();
    String expecting = "z";
    stream.fill();
// make sure combo is not znull
    assertEquals(expecting, result);
  }

  @Test public void testDisjointInserts() throws Exception {
View Full Code Here

                       "B : 'b';\n" +
                       "C : 'c';\n");
    String input = "abc";
    LexerInterpreter lexEngine = g.createLexerInterpreter(new ANTLRInputStream(input));
    CommonTokenStream stream = new CommonTokenStream(lexEngine);
    stream.fill();
    TokenStreamRewriter tokens = new TokenStreamRewriter(stream);
    tokens.insertBefore(1, "x");
    tokens.insertBefore(2, "y");
    tokens.insertBefore(0, "z");
    String result = tokens.getText();
View Full Code Here

                       "B : 'b';\n" +
                       "C : 'c';\n");
    String input = "abcc";
    LexerInterpreter lexEngine = g.createLexerInterpreter(new ANTLRInputStream(input));
    CommonTokenStream stream = new CommonTokenStream(lexEngine);
    stream.fill();
    TokenStreamRewriter tokens = new TokenStreamRewriter(stream);
    tokens.replace(1, 2, "foo");
    tokens.replace(0, 3, "bar");
    stream.fill();
// wipes prior nested replace
View Full Code Here

    CommonTokenStream stream = new CommonTokenStream(lexEngine);
    stream.fill();
    TokenStreamRewriter tokens = new TokenStreamRewriter(stream);
    tokens.replace(1, 2, "foo");
    tokens.replace(0, 3, "bar");
    stream.fill();
// wipes prior nested replace
    String result = tokens.getText();
    String expecting = "bar";
    assertEquals(expecting, result);
  }
View Full Code Here

                       "B : 'b';\n" +
                       "C : 'c';\n");
    String input = "abcc";
    LexerInterpreter lexEngine = g.createLexerInterpreter(new ANTLRInputStream(input));
    CommonTokenStream stream = new CommonTokenStream(lexEngine);
    stream.fill();
    TokenStreamRewriter tokens = new TokenStreamRewriter(stream);
    tokens.replace(0, 3, "bar");
    tokens.replace(1, 2, "foo");
    stream.fill();
// cannot split earlier replace
View Full Code Here

    CommonTokenStream stream = new CommonTokenStream(lexEngine);
    stream.fill();
    TokenStreamRewriter tokens = new TokenStreamRewriter(stream);
    tokens.replace(0, 3, "bar");
    tokens.replace(1, 2, "foo");
    stream.fill();
// cannot split earlier replace
    Exception exc = null;
    try {
      tokens.getText();
    }
View Full Code Here

                       "B : 'b';\n" +
                       "C : 'c';\n");
    String input = "abcc";
    LexerInterpreter lexEngine = g.createLexerInterpreter(new ANTLRInputStream(input));
    CommonTokenStream stream = new CommonTokenStream(lexEngine);
    stream.fill();
    TokenStreamRewriter tokens = new TokenStreamRewriter(stream);
    tokens.replace(1, 2, "foo");
    tokens.replace(0, 2, "bar");
    stream.fill();
// wipes prior nested replace
View Full Code Here

    CommonTokenStream stream = new CommonTokenStream(lexEngine);
    stream.fill();
    TokenStreamRewriter tokens = new TokenStreamRewriter(stream);
    tokens.replace(1, 2, "foo");
    tokens.replace(0, 2, "bar");
    stream.fill();
// wipes prior nested replace
    String result = tokens.getText();
    String expecting = "barc";
    assertEquals(expecting, result);
  }
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.