Package org.antlr.v4.runtime

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


  }

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

  /**
 
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
   * are not released in the reversed order they were created, but
View Full Code Here

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

  @Test(expected = UnsupportedOperationException.class)
View Full Code Here

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

  @Test
  public void testGetTextInMarkedRange() {
View Full Code Here

  @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

    CommonTokenStream tokens = new CommonTokenStream(lexer);
    tokens.fill();

    assertEquals(Token.EOF, tokens.LA(1));
    assertEquals(0, tokens.index());
    assertEquals(1, tokens.size());
  }

  @Test(expected = IllegalStateException.class)
  public void testCannotConsumeEOF() throws Exception {
View Full Code Here

    CommonTokenStream tokens = new CommonTokenStream(lexer);
    tokens.fill();

    assertEquals(Token.EOF, tokens.LA(1));
    assertEquals(0, tokens.index());
    assertEquals(1, tokens.size());
    tokens.consume();
  }
}
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.