Package org.antlr.runtime

Examples of org.antlr.runtime.TokenRewriteStream.fill()


      "B : 'b';\n" +
      "C : 'c';\n");
    CharStream input = new ANTLRStringStream("abc");
    Interpreter lexEngine = new Interpreter(g, input);
    TokenRewriteStream tokens = new TokenRewriteStream(lexEngine);
    tokens.fill();
    tokens.insertBefore(0, "0");
    tokens.replace(0, "x"); // supercedes insert at 0
    String result = tokens.toString();
    String expecting = "0xbc";
    assertEquals(expecting, result);
View Full Code Here


      "B : 'b';\n" +
      "C : 'c';\n");
    CharStream input = new ANTLRStringStream("abc");
    Interpreter lexEngine = new Interpreter(g, input);
    TokenRewriteStream tokens = new TokenRewriteStream(lexEngine);
    tokens.fill();
    tokens.insertBefore(1, "x");
    tokens.insertBefore(1, "y");
    String result = tokens.toString();
    String expecting = "ayxbc";
    assertEquals(expecting, result);
View Full Code Here

      "B : 'b';\n" +
      "C : 'c';\n");
    CharStream input = new ANTLRStringStream("abc");
    Interpreter lexEngine = new Interpreter(g, input);
    TokenRewriteStream tokens = new TokenRewriteStream(lexEngine);
    tokens.fill();
    tokens.insertBefore(0, "x");
    tokens.insertBefore(0, "y");
    tokens.replace(0, "z");
    String result = tokens.toString();
    String expecting = "yxzbc";
View Full Code Here

      "B : 'b';\n" +
      "C : 'c';\n");
    CharStream input = new ANTLRStringStream("abc");
    Interpreter lexEngine = new Interpreter(g, input);
    TokenRewriteStream tokens = new TokenRewriteStream(lexEngine);
    tokens.fill();
    tokens.replace(2, "x");
    tokens.insertBefore(2, "y");
    String result = tokens.toString();
    String expecting = "abyx";
    assertEquals(expecting, result);
View Full Code Here

      "B : 'b';\n" +
      "C : 'c';\n");
    CharStream input = new ANTLRStringStream("abc");
    Interpreter lexEngine = new Interpreter(g, input);
    TokenRewriteStream tokens = new TokenRewriteStream(lexEngine);
    tokens.fill();
    tokens.insertBefore(2, "y");
    tokens.replace(2, "x");
    String result = tokens.toString();
    String expecting = "abyx";
    assertEquals(expecting, result);
View Full Code Here

      "B : 'b';\n" +
      "C : 'c';\n");
    CharStream input = new ANTLRStringStream("abc");
    Interpreter lexEngine = new Interpreter(g, input);
    TokenRewriteStream tokens = new TokenRewriteStream(lexEngine);
    tokens.fill();
    tokens.insertBefore(2, "y");
    tokens.delete(2);
    String result = tokens.toString();
    String expecting = "aby";
    assertEquals(expecting, result);
View Full Code Here

      "B : 'b';\n" +
      "C : 'c';\n");
    CharStream input = new ANTLRStringStream("abc");
    Interpreter lexEngine = new Interpreter(g, input);
    TokenRewriteStream tokens = new TokenRewriteStream(lexEngine);
    tokens.fill();
    tokens.replace(2, "x");
    tokens.insertAfter(2, "y");
    String result = tokens.toString();
    String expecting = "abxy";
    assertEquals(expecting, result);
View Full Code Here

      "B : 'b';\n" +
      "C : 'c';\n");
    CharStream input = new ANTLRStringStream("abcccba");
    Interpreter lexEngine = new Interpreter(g, input);
    TokenRewriteStream tokens = new TokenRewriteStream(lexEngine);
    tokens.fill();
    tokens.replace(2, 4, "x");
    tokens.insertBefore(2, "y");
    String result = tokens.toString();
    String expecting = "abyxba";
    assertEquals(expecting, result);
View Full Code Here

      "B : 'b';\n" +
      "C : 'c';\n");
    CharStream input = new ANTLRStringStream("abcccba");
    Interpreter lexEngine = new Interpreter(g, input);
    TokenRewriteStream tokens = new TokenRewriteStream(lexEngine);
    tokens.fill();
    tokens.replace(2, 4, "x");
    tokens.insertBefore(4, "y"); // no effect; within range of a replace
    Exception exc = null;
    try {
      tokens.toString();
View Full Code Here

      "B : 'b';\n" +
      "C : 'c';\n");
    CharStream input = new ANTLRStringStream("abcccba");
    Interpreter lexEngine = new Interpreter(g, input);
    TokenRewriteStream tokens = new TokenRewriteStream(lexEngine);
    tokens.fill();
    tokens.replace(2, 4, "x");
    tokens.insertAfter(4, "y");
    String result = tokens.toString();
    String expecting = "abxyba";
    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.