Examples of TokenRewriteStream


Examples of org.antlr.runtime.TokenRewriteStream

      "A : 'a';\n" +
      "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

Examples of org.antlr.runtime.TokenRewriteStream

      "A : 'a';\n" +
      "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();
    }
    catch (IllegalArgumentException iae) {
      exc = iae;
    }
    String expecting = "insert op <InsertBeforeOp@[@4,4:4='c',<6>,1:4]:\"y\"> within boundaries of previous <ReplaceOp@[@2,2:2='c',<6>,1:2]..[@4,4:4='c',<6>,1:4]:\"x\">";
View Full Code Here

Examples of org.antlr.runtime.TokenRewriteStream

      "A : 'a';\n" +
      "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

Examples of org.antlr.runtime.TokenRewriteStream

      "A : 'a';\n" +
      "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(0, 6, "x");
    String result = tokens.toString();
    String expecting = "x";
    assertEquals(expecting, result);
  }
View Full Code Here

Examples of org.antlr.runtime.TokenRewriteStream

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

Examples of org.antlr.runtime.TokenRewriteStream

      "A : 'a';\n" +
      "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, "xyz");
    tokens.replace(3, 5, "foo"); // overlaps, error
    Exception exc = null;
    try {
      tokens.toString();
    }
    catch (IllegalArgumentException iae) {
      exc = iae;
    }
    String expecting = "replace op boundaries of <ReplaceOp@[@3,3:3='c',<6>,1:3]..[@5,5:5='b',<5>,1:5]:\"foo\"> overlap with previous <ReplaceOp@[@2,2:2='c',<6>,1:2]..[@4,4:4='c',<6>,1:4]:\"xyz\">";
View Full Code Here

Examples of org.antlr.runtime.TokenRewriteStream

      "A : 'a';\n" +
      "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, "xyz");
    tokens.replace(1, 3, "foo"); // overlap, error
    Exception exc = null;
    try {
      tokens.toString();
    }
    catch (IllegalArgumentException iae) {
      exc = iae;
    }
    String expecting = "replace op boundaries of <ReplaceOp@[@1,1:1='b',<5>,1:1]..[@3,3:3='c',<6>,1:3]:\"foo\"> overlap with previous <ReplaceOp@[@2,2:2='c',<6>,1:2]..[@4,4:4='c',<6>,1:4]:\"xyz\">";
View Full Code Here

Examples of org.antlr.runtime.TokenRewriteStream

      "A : 'a';\n" +
      "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

Examples of org.antlr.runtime.TokenRewriteStream

      "A : 'a';\n" +
      "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

Examples of org.antlr.runtime.TokenRewriteStream

      "A : 'a';\n" +
      "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";
    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.