Package org.antlr.v4.runtime

Examples of org.antlr.v4.runtime.CommonTokenStream.fill()


                       "B : 'b';\n" +
                       "C : 'c';\n");
    String input = "abcccba";
    LexerInterpreter lexEngine = g.createLexerInterpreter(new ANTLRInputStream(input));
    CommonTokenStream stream = new CommonTokenStream(lexEngine);
    stream.fill();
    TokenStreamRewriter tokens = new TokenStreamRewriter(stream);
    tokens.replace(2, 4, "xyz");
    String result = tokens.getText(Interval.of(0, 6));
    String expecting = "abxyzba";
    assertEquals(expecting, result);
View Full Code Here


                       "B : 'b';\n" +
                       "C : 'c';\n");
    String input = "abcccba";
    LexerInterpreter lexEngine = g.createLexerInterpreter(new ANTLRInputStream(input));
    CommonTokenStream stream = new CommonTokenStream(lexEngine);
    stream.fill();
    TokenStreamRewriter tokens = new TokenStreamRewriter(stream);
    tokens.replace(2, 4, "xyz");
    tokens.replace(3, 5, "foo");
    stream.fill();
// overlaps, error
View Full Code Here

    CommonTokenStream stream = new CommonTokenStream(lexEngine);
    stream.fill();
    TokenStreamRewriter tokens = new TokenStreamRewriter(stream);
    tokens.replace(2, 4, "xyz");
    tokens.replace(3, 5, "foo");
    stream.fill();
// overlaps, error
    Exception exc = null;
    try {
      tokens.getText();
    }
View Full Code Here

                       "B : 'b';\n" +
                       "C : 'c';\n");
    String input = "abcccba";
    LexerInterpreter lexEngine = g.createLexerInterpreter(new ANTLRInputStream(input));
    CommonTokenStream stream = new CommonTokenStream(lexEngine);
    stream.fill();
    TokenStreamRewriter tokens = new TokenStreamRewriter(stream);
    tokens.replace(2, 4, "xyz");
    tokens.replace(1, 3, "foo");
    stream.fill();
// overlap, error
View Full Code Here

    CommonTokenStream stream = new CommonTokenStream(lexEngine);
    stream.fill();
    TokenStreamRewriter tokens = new TokenStreamRewriter(stream);
    tokens.replace(2, 4, "xyz");
    tokens.replace(1, 3, "foo");
    stream.fill();
// overlap, error
    Exception exc = null;
    try {
      tokens.getText();
    }
View Full Code Here

                       "B : 'b';\n" +
                       "C : 'c';\n");
    String input = "abcba";
    LexerInterpreter lexEngine = g.createLexerInterpreter(new ANTLRInputStream(input));
    CommonTokenStream stream = new CommonTokenStream(lexEngine);
    stream.fill();
    TokenStreamRewriter tokens = new TokenStreamRewriter(stream);
    tokens.replace(2, 2, "xyz");
    tokens.replace(0, 3, "foo");
    String result = tokens.getText();
    String expecting = "fooa";
View Full Code Here

                       "B : 'b';\n" +
                       "C : 'c';\n");
    String input = "abc";
    LexerInterpreter lexEngine = g.createLexerInterpreter(new ANTLRInputStream(input));
    CommonTokenStream stream = new CommonTokenStream(lexEngine);
    stream.fill();
    TokenStreamRewriter tokens = new TokenStreamRewriter(stream);
    tokens.insertBefore(0, "x");
    tokens.insertBefore(0, "y");
    String result = tokens.getText();
    String expecting = "yxabc";
View Full Code Here

                       "B : 'b';\n" +
                       "C : 'c';\n");
    String input = "abc";
    LexerInterpreter lexEngine = g.createLexerInterpreter(new ANTLRInputStream(input));
    CommonTokenStream stream = new CommonTokenStream(lexEngine);
    stream.fill();
    TokenStreamRewriter tokens = new TokenStreamRewriter(stream);
    tokens.insertBefore(1, "x");
    tokens.insertBefore(0, "y");
    tokens.insertBefore(1, "z");
    String result = tokens.getText();
View Full Code Here

                       "B : 'b';\n" +
                       "C : 'c';\n");
    String input = "abc";
    LexerInterpreter lexEngine = g.createLexerInterpreter(new ANTLRInputStream(input));
    CommonTokenStream stream = new CommonTokenStream(lexEngine);
    stream.fill();
    TokenStreamRewriter tokens = new TokenStreamRewriter(stream);
    tokens.replace(0, 2, "foo");
    tokens.insertBefore(0, "z");
    stream.fill();
// combine with left edge of rewrite
View Full Code Here

    CommonTokenStream stream = new CommonTokenStream(lexEngine);
    stream.fill();
    TokenStreamRewriter tokens = new TokenStreamRewriter(stream);
    tokens.replace(0, 2, "foo");
    tokens.insertBefore(0, "z");
    stream.fill();
// combine with left edge of rewrite
    String result = tokens.getText();
    String expecting = "zfoo";
    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.