Package org.antlr.runtime

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


      "B : 'b';\n" +
      "C : 'c';\n");
    CharStream input = new ANTLRStringStream("abcba");
    Interpreter lexEngine = new Interpreter(g, input);
    TokenRewriteStream tokens = new TokenRewriteStream(lexEngine);
    tokens.fill();
    tokens.replace(2, 2, "xyz");
    tokens.replace(0, 3, "foo");
    String result = tokens.toString();
    String expecting = "fooa";
    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");
    String result = tokens.toString();
    String expecting = "yxabc";
    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(0, "y");
    tokens.insertBefore(1, "z");
    String result = tokens.toString();
    String expecting = "yazxbc";
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(0, 2, "foo");
    tokens.insertBefore(0, "z"); // combine with left edge of rewrite
    String result = tokens.toString();
    String expecting = "zfoo";
    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.delete(0, 2);
    tokens.insertBefore(0, "z"); // combine with left edge of rewrite
    String result = tokens.toString();
    String expecting = "z"; // make sure combo is not znull
    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(2, "y");
    tokens.insertBefore(0, "z");
    String result = tokens.toString();
    String expecting = "zaxbyc";
View Full Code Here

      "B : 'b';\n" +
      "C : 'c';\n");
    CharStream input = new ANTLRStringStream("abcc");
    Interpreter lexEngine = new Interpreter(g, input);
    TokenRewriteStream tokens = new TokenRewriteStream(lexEngine);
    tokens.fill();
    tokens.replace(1, 2, "foo");
    tokens.replace(0, 3, "bar"); // wipes prior nested replace
    String result = tokens.toString();
    String expecting = "bar";
    assertEquals(expecting, result);
View Full Code Here

      "B : 'b';\n" +
      "C : 'c';\n");
    CharStream input = new ANTLRStringStream("abcc");
    Interpreter lexEngine = new Interpreter(g, input);
    TokenRewriteStream tokens = new TokenRewriteStream(lexEngine);
    tokens.fill();
    tokens.replace(0, 3, "bar");
    tokens.replace(1, 2, "foo"); // cannot split earlier replace
    Exception exc = null;
    try {
      tokens.toString();
View Full Code Here

      "B : 'b';\n" +
      "C : 'c';\n");
    CharStream input = new ANTLRStringStream("abcc");
    Interpreter lexEngine = new Interpreter(g, input);
    TokenRewriteStream tokens = new TokenRewriteStream(lexEngine);
    tokens.fill();
    tokens.replace(1, 2, "foo");
    tokens.replace(0, 2, "bar"); // wipes prior nested replace
    String result = tokens.toString();
    String expecting = "barc";
    assertEquals(expecting, result);
View Full Code Here

      "B : 'b';\n" +
      "C : 'c';\n");
    CharStream input = new ANTLRStringStream("abcc");
    Interpreter lexEngine = new Interpreter(g, input);
    TokenRewriteStream tokens = new TokenRewriteStream(lexEngine);
    tokens.fill();
    tokens.replace(1, 2, "foo");
    tokens.replace(1, 3, "bar"); // wipes prior nested replace
    String result = tokens.toString();
    String expecting = "abar";
    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.