Package org.antlr.runtime

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


    CharStream input = new ANTLRStringStream("abc");
    Interpreter lexEngine = new Interpreter(g, input);
    TokenRewriteStream tokens = new TokenRewriteStream(lexEngine);
    tokens.LT(1); // fill buffer
    tokens.insertBefore(1, "x");
    tokens.insertBefore(2, "y");
    tokens.insertBefore(0, "z");
    String result = tokens.toString();
    String expecting = "zaxbyc";
    assertEquals(expecting, result);
  }
View Full Code Here


    Interpreter lexEngine = new Interpreter(g, input);
    TokenRewriteStream tokens = new TokenRewriteStream(lexEngine);
    tokens.LT(1); // fill buffer
    tokens.insertBefore(1, "x");
    tokens.insertBefore(2, "y");
    tokens.insertBefore(0, "z");
    String result = tokens.toString();
    String expecting = "zaxbyc";
    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.LT(1); // fill buffer
    tokens.insertBefore(1, "foo");
    tokens.replace(1, 2, "foo"); // kill prev insert
    String result = tokens.toString();
    String expecting = "afooc";
    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.LT(1); // fill buffer
    tokens.insertBefore(1, "x");
    tokens.replace(2, 3, "foo");
    String result = tokens.toString();
    String expecting = "axbfoo";
    assertEquals(expecting, result);
  }
View Full Code Here

    CharStream input = new ANTLRStringStream("abcc");
    Interpreter lexEngine = new Interpreter(g, input);
    TokenRewriteStream tokens = new TokenRewriteStream(lexEngine);
    tokens.LT(1); // fill buffer
    tokens.replace(2, 3, "foo");
    tokens.insertBefore(1, "x");
    String result = tokens.toString();
    String expecting = "axbfoo";
    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.LT(1); // fill buffer
    tokens.insertBefore(0, "0");
    String result = tokens.toString();
    String expecting = "0abc";
    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.LT(1); // fill buffer
    tokens.insertBefore(1, "x");
    tokens.insertAfter(1, "x");
    String result = tokens.toString();
    String expecting = "axbxc";
    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.LT(1); // fill buffer
        tokens.insertBefore(0, "_");
        tokens.replace(1, "x");
    tokens.replace(1, "y");
    String result = tokens.toString();
    String expecting = "_ayc";
    assertEquals(expecting, result);
View Full Code Here

    CharStream input = new ANTLRStringStream("abc");
    Interpreter lexEngine = new Interpreter(g, input);
    TokenRewriteStream tokens = new TokenRewriteStream(lexEngine);
    tokens.LT(1); // fill buffer
    tokens.replace(0, 2, "x");
    tokens.insertBefore(1, "0");
    Exception exc = null;
    try {
      tokens.toString();
    }
    catch (IllegalArgumentException iae) {
View Full Code Here

      "C : 'c';\n");
    CharStream input = new ANTLRStringStream("abc");
    Interpreter lexEngine = new Interpreter(g, input);
    TokenRewriteStream tokens = new TokenRewriteStream(lexEngine);
    tokens.LT(1); // fill buffer
    tokens.insertBefore(0, "0");
    tokens.replace(0, "x"); // supercedes insert at 0
    String result = tokens.toString();
    String expecting = "xbc";
    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.