Package org.antlr.v4.runtime

Examples of org.antlr.v4.runtime.TokenStream.seek()


  }

  @Test(expected = IllegalArgumentException.class)
  public void testNegativeSeek() {
    CharStream input = createStream("");
    input.seek(-1);
  }

  @Test
  public void testSeekPastEOF() {
    CharStream input = createStream("");
View Full Code Here


  @Test
  public void testSeekPastEOF() {
    CharStream input = createStream("");
    assertEquals(0, input.index());
    input.seek(1);
    assertEquals(0, input.index());
  }

  /**
   * The {@link IntStream} interface does not specify the behavior when marks
View Full Code Here

   */
  @Test(expected = IllegalArgumentException.class)
  public void testMarkPassedToSeek() {
    CharStream input = createStream("");
    int m1 = input.mark();
    input.seek(m1);
  }

  @Test(expected = IllegalArgumentException.class)
  public void testSeekBeforeBufferStart() {
    CharStream input = createStream("xyz");
View Full Code Here

    CharStream input = createStream("xyz");
    input.consume();
    int m1 = input.mark();
    assertEquals(1, input.index());
    input.consume();
    input.seek(0);
  }

  @Test(expected = UnsupportedOperationException.class)
  public void testGetTextBeforeBufferStart() {
    CharStream input = createStream("xyz");
View Full Code Here

    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));
View Full Code Here

      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() {
View Full Code Here

    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);
View Full Code Here

    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));
  }

  @Test public void test1Char() throws Exception {
    TestingUnbufferedCharStream input = createStream("x");
View Full Code Here

    int alt = interp.adaptivePredict(input, decision, ParserRuleContext.EMPTY);

    assertEquals(expectedAlt, alt);

    // Check adaptive prediction
    input.seek(0);
    alt = interp.adaptivePredict(input, decision, null);
    assertEquals(expectedAlt, alt);
    // run 2x; first time creates DFA in atn
    input.seek(0);
    alt = interp.adaptivePredict(input, decision, null);
View Full Code Here

    // Check adaptive prediction
    input.seek(0);
    alt = interp.adaptivePredict(input, decision, null);
    assertEquals(expectedAlt, alt);
    // run 2x; first time creates DFA in atn
    input.seek(0);
    alt = interp.adaptivePredict(input, decision, null);
    assertEquals(expectedAlt, alt);
  }

  public void checkDFAConstruction(LexerGrammar lg, Grammar g, int decision,
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.