Package org.antlr.runtime

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


      "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


    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();
    }
    catch (IllegalArgumentException iae) {
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, 2, "bar"); // wipes prior nested replace
    String result = tokens.toString();
    String expecting = "barc";
    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, 2, "bar"); // wipes prior nested replace
    String result = tokens.toString();
    String expecting = "barc";
    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(1, 3, "bar"); // wipes prior nested replace
    String result = tokens.toString();
    String expecting = "abar";
    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(1, 3, "bar"); // wipes prior nested replace
    String result = tokens.toString();
    String expecting = "abar";
    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(1, 2, "foo"); // drop previous, identical
    String result = tokens.toString();
    String expecting = "afooc";
    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(1, 2, "foo"); // drop previous, identical
    String result = tokens.toString();
    String expecting = "afooc";
    assertEquals(expecting, result);
  }
View Full Code Here

    CharStream input = new ANTLRStringStream("abc");
    Interpreter lexEngine = new Interpreter(g, input);
    TokenRewriteStream tokens = new TokenRewriteStream(lexEngine);
    tokens.fill();
    tokens.insertBefore(1, "foo");
    tokens.replace(1, 2, "foo"); // kill prev insert
    String result = tokens.toString();
    String expecting = "afoofoo";
    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.insertBefore(1, "x");
    tokens.replace(2, 3, "foo");
    String result = tokens.toString();
    String expecting = "axbfoo";
    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.