Package org.antlr.runtime

Examples of org.antlr.runtime.CharStream


    Grammar g = new Grammar(
      "lexer grammar t;\n"+
      "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(2, "y");
    tokens.delete(2);
View Full Code Here


    Grammar g = new Grammar(
      "lexer grammar t;\n"+
      "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.insertBefore(0, "0");
    String result = tokens.toString();
    String expecting = "0abc";
View Full Code Here

    Grammar g = new Grammar(
      "lexer grammar t;\n"+
      "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.insertAfter(2, "x");
    String result = tokens.toString();
    String expecting = "abcx";
View Full Code Here

    Grammar g = new Grammar(
      "lexer grammar t;\n"+
      "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.insertAfter(1, "x");
View Full Code Here

    Grammar g = new Grammar(
      "lexer grammar t;\n"+
      "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.replace(0, "x");
    String result = tokens.toString();
View Full Code Here

    Grammar g = new Grammar(
      "lexer grammar t;\n"+
      "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.replace(2, "x");
    String result = tokens.toString();
View Full Code Here

    Grammar g = new Grammar(
      "lexer grammar t;\n"+
      "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.replace(1, "x");
    String result = tokens.toString();
View Full Code Here

            "MUL : '*';\n" +
            "ASSIGN : '=';\n" +
            "WS : ' '+;\n");
        // Tokens: 0123456789
        // Input:  x = 3 * 0;
        CharStream input = new ANTLRStringStream("x = 3 * 0;");
        Interpreter lexEngine = new Interpreter(g, input);
        TokenRewriteStream tokens = new TokenRewriteStream(lexEngine);
        tokens.fill();
        tokens.replace(4, 8, "0"); // replace 3 * 0 with 0

View Full Code Here

            "PLUS : '+';\n" +
            "MULT : '*';\n" +
            "WS : ' '+;\n");
        // Tokens: 012345678901234567
        // Input:  x = 3 * 0 + 2 * 0;
        CharStream input = new ANTLRStringStream("x = 3 * 0 + 2 * 0;");
        Interpreter lexEngine = new Interpreter(g, input);
        TokenRewriteStream tokens = new TokenRewriteStream(lexEngine);
        tokens.fill();

        String result = tokens.toOriginalString();
View Full Code Here

    Grammar g = new Grammar(
      "lexer grammar t;\n"+
      "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.replace(1, "x");
    tokens.replace(1, "y");
View Full Code Here

TOP

Related Classes of org.antlr.runtime.CharStream

Copyright © 2018 www.massapicom. 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.