Class TokenBuffer.Cursor

java.lang.Object
io.github.protasm.jvmud.compiler.token.TokenBuffer.Cursor
Enclosing class:
TokenBuffer

public final class TokenBuffer.Cursor extends Object
Parser-facing reader over this buffer.
  • Method Details

    • position

      public int position()
    • isAtEnd

      public boolean isAtEnd()
    • mark

      public int mark()
    • rewind

      public void rewind(int mark)
    • peek

      public Token<?> peek(int k)
      Lookahead where peek(0)==current(). Never throws; returns EOF past end.
    • current

      public Token<?> current()
    • previous

      public Token<?> previous()
    • advance

      public Token<?> advance()
      Advance by one; stays on EOF once past end. Returns the consumed token.
    • check

      public boolean check(TokenType... types)
      True if current token matches any of the given types (no consume).
    • match

      public boolean match(TokenType... types)
      If current matches any type, consume and return true; else false.
    • consume

      public Token<?> consume(String messageIfMismatch, TokenType... expected)
      Consume exactly one of the expected types or throw. Returns the consumed token.
    • advanceThrough

      public Token<?> advanceThrough(TokenType type)
      Consume repeated occurrences of a single type. Returns the last consumed or EOF if none.