Package org.antlr.runtime

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


      "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, "xyz");
    String result = tokens.toString(0,6);
    String expecting = "abxyzba";
    assertEquals(expecting, result);
  }
View Full Code Here


      "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, "xyz");
    tokens.replace(3, 5, "foo"); // overlaps, error
    Exception exc = null;
    try {
      tokens.toString();
    }
View Full Code Here

    CharStream input = new ANTLRStringStream("abcccba");
    Interpreter lexEngine = new Interpreter(g, input);
    TokenRewriteStream tokens = new TokenRewriteStream(lexEngine);
    tokens.fill();
    tokens.replace(2, 4, "xyz");
    tokens.replace(3, 5, "foo"); // overlaps, error
    Exception exc = null;
    try {
      tokens.toString();
    }
    catch (IllegalArgumentException iae) {
View Full Code Here

      "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, "xyz");
    tokens.replace(1, 3, "foo"); // overlap, error
    Exception exc = null;
    try {
      tokens.toString();
    }
View Full Code Here

    CharStream input = new ANTLRStringStream("abcccba");
    Interpreter lexEngine = new Interpreter(g, input);
    TokenRewriteStream tokens = new TokenRewriteStream(lexEngine);
    tokens.fill();
    tokens.replace(2, 4, "xyz");
    tokens.replace(1, 3, "foo"); // overlap, error
    Exception exc = null;
    try {
      tokens.toString();
    }
    catch (IllegalArgumentException iae) {
View Full Code Here

      "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

    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

      "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

      "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

    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

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.