Interface TokenStream<Token,​Position>

  • Type Parameters:
    Token - - the type of items in the stream
    Position - - the type which implements the positions in the stream
    All Known Implementing Classes:
    SqlTokenStream

    public interface TokenStream<Token,​Position>
    A read-only sequence of TokenStreams that are read one-by-one. Reads are not destructive and the stream can be reset and reread. At any time a position may be obtained, and subsequently used to reset the stream to that position.
    • Method Detail

      • moreTokens

        boolean moreTokens()
        Returns:
        true if there are more tokens after the current position in the stream
      • readToken

        Token readToken()
        Reads token at the current position and the position is not changed.
        Returns:
        the current TokenStream in the stream if any, otherwise null
      • getNext

        Token getNext()
        Increment position in the stream; no-op if already at the end.
        Returns:
        the next TokenStream in the stream if any, otherwise null
      • stepBack

        void stepBack()
        Decrement position in the stream; no-op if already at the beginning.
      • position

        Position position()
        Returns:
        the current position in the stream
      • reset

        void reset​(Position position)
        Reset the stream to the position provided, if it is a valid position. Otherwise undefined.
        Parameters:
        position - - previously returned place in the stream
      • reset

        void reset()
        Reset the stream to the start. Equivalent to tokenStream.reset(START) where Position START = tokenStream.getPosition(); was executed first after instantiation of the TokenStream.