Package org.antlr.v4.runtime

Examples of org.antlr.v4.runtime.CharStream


   * {@link UnbufferedCharStream} creates marks in such a way that this
   * invalid usage results in an {@link IllegalArgumentException}.
   */
  @Test(expected = IllegalArgumentException.class)
  public void testMarkPassedToSeek() {
    CharStream input = createStream("");
    int m1 = input.mark();
    input.seek(m1);
  }
View Full Code Here


    input.seek(m1);
  }

  @Test(expected = IllegalArgumentException.class)
  public void testSeekBeforeBufferStart() {
    CharStream input = createStream("xyz");
    input.consume();
    int m1 = input.mark();
    assertEquals(1, input.index());
    input.consume();
    input.seek(0);
  }
View Full Code Here

    input.seek(0);
  }

  @Test(expected = UnsupportedOperationException.class)
  public void testGetTextBeforeBufferStart() {
    CharStream input = createStream("xyz");
    input.consume();
    int m1 = input.mark();
    assertEquals(1, input.index());
    input.getText(new Interval(0, 1));
  }
View Full Code Here

    input.getText(new Interval(0, 1));
  }

  @Test
  public void testGetTextInMarkedRange() {
    CharStream input = createStream("xyz");
    input.consume();
    int m1 = input.mark();
    assertEquals(1, input.index());
    input.consume();
    input.consume();
    assertEquals("yz", input.getText(new Interval(1, 2)));
  }
View Full Code Here

    assertEquals("yz", input.getText(new Interval(1, 2)));
  }

  @Test
  public void testLastChar() {
    CharStream input = createStream("abcdef");

    input.consume();
    assertEquals('a', input.LA(-1));

    int m1 = input.mark();
    input.consume();
    input.consume();
    input.consume();
    assertEquals('d', input.LA(-1));

    input.seek(2);
    assertEquals('b', input.LA(-1));

    input.release(m1);
    input.seek(3);
    assertEquals('c', input.LA(-1));
    // this special case is not required by the IntStream interface, but
    // UnbufferedCharStream allows it so we have to make sure the resulting
    // state is consistent
    input.seek(2);
    assertEquals('b', input.LA(-1));
  }
View Full Code Here

    for (InputDescriptor inputDescriptor : sources) {
      if (inputCount >= MAX_FILES_PER_PARSE_ITERATION) {
        break;
      }

      final CharStream input = inputDescriptor.getInputStream();
            input.seek(0);
            inputSize += input.size();
      inputCount++;
      Future<FileParseResult> futureChecksum = executorService.submit(new Callable<FileParseResult>() {
        @Override
        public FileParseResult call() {
          // this incurred a great deal of overhead and was causing significant variations in performance results.
View Full Code Here

            "PLUS : '+';\n" +
            "MULT : '*';\n" +
            "WS : ' '+;\n");
        // Tokens: 012345678901234567
        // Input:  x = 302;
        CharStream input = new ANTLRInputStream(
      new StringReader("x = 302;")
    );
        LexerInterpreter lexEngine = g.createLexerInterpreter(input);
        TokenStream tokens = new UnbufferedTokenStream<Token>(lexEngine);

View Full Code Here

            "PLUS : '+';\n" +
            "MULT : '*';\n" +
            "WS : ' '+;\n");
        // Tokens: 012345678901234567
        // Input:  x = 302;
        CharStream input = new ANTLRInputStream(
      new StringReader("x = 302;")
    );
        LexerInterpreter lexEngine = g.createLexerInterpreter(input);
    TestingUnbufferedTokenStream<Token> tokens = new TestingUnbufferedTokenStream<Token>(lexEngine);

View Full Code Here

            "PLUS : '+';\n" +
            "MULT : '*';\n" +
            "WS : ' '+;\n");
        // Tokens: 012345678901234567
        // Input:  x = 302;
        CharStream input = new ANTLRInputStream(
      new StringReader("x = 302;")
    );
        LexerInterpreter lexEngine = g.createLexerInterpreter(input);
    TestingUnbufferedTokenStream<Token> tokens = new TestingUnbufferedTokenStream<Token>(lexEngine);

View Full Code Here

            "PLUS : '+';\n" +
            "MULT : '*';\n" +
            "WS : ' '+;\n");
        // Tokens: 012345678901234567
        // Input:  x = 302;
        CharStream input = new ANTLRInputStream(
      new StringReader("x = 302 + 1;")
    );
        LexerInterpreter lexEngine = g.createLexerInterpreter(input);
    TestingUnbufferedTokenStream<Token> tokens = new TestingUnbufferedTokenStream<Token>(lexEngine);

View Full Code Here

TOP

Related Classes of org.antlr.v4.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.