Interface Parser.Input<D,T>

Type Parameters:
D - the type of source document identifiers
T - the type of token types; typically an enum type
Enclosing class:
Parser<D,T>

public static interface Parser.Input<D,T>
Abstract interface of immutable parser input states. Each state is a pointer into an immutable infinite sequence of tokens.

For actual, finite input the token sequence should be extended by a potentially infinite repetition of distinguished end tokens (typically of a reserved type EOF) carrying no further information.

See Also:
  • Method Details

    • lookahead

      Token<D,T> lookahead(int k)
      Returns the token that lies a given number of steps ahead.
      Parameters:
      k - the number of steps to look ahead
      Returns:
      the token that lies k steps ahead from this state.
      Throws:
      IllegalArgumentException - if k < 0.
    • hasLookahead

      boolean hasLookahead()
      Checks whether one or more lookahead tokens have been generated ahead.

      Modifications to the token source do only take effect immediately if this method returns false.

    • isStart

      boolean isStart()
      FIXME: document this method, and cross-reference lookbehind.
    • lookbehind

      Token<D,T> lookbehind()
      Returns the token that lies one step behind.
      Returns:
      the token immediately behind this state
      Throws:
      IllegalStateException - if this state points to the start of the token sequence.
    • consume

      Parser.Input<D,T> consume()
      Advances by one step.
      Returns:
      the input state pointing one step ahead in the token sequence.
    • transitionBy

      default Parser.Output<D,T> transitionBy(Update<SimpleMessage<D>> effect)