Interface Scanner

  • All Superinterfaces:
    java.util.Iterator<Token>
    All Known Implementing Classes:
    ScannerImpl

    public interface Scanner
    extends java.util.Iterator<Token>
    This interface represents an input stream of Tokens.

    The scanner and the parser form together the 'Parse' step in the loading process.

    See Also:
    3.1. Processes
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      boolean checkToken​(Token.ID... choices)
      Check if the next token is one of the given types.
      Token next()
      Returns the next token.
      Token peekToken()
      Return the next token, but do not delete it from the stream.
      void resetDocumentIndex()
      Set the document index to 0 after a document end
      • Methods inherited from interface java.util.Iterator

        forEachRemaining, hasNext, remove
    • Method Detail

      • checkToken

        boolean checkToken​(Token.ID... choices)
        Check if the next token is one of the given types.
        Parameters:
        choices - token IDs to match with
        Returns:
        true if the next token is one of the given types. Returns false if no more tokens are available.
        Throws:
        ScannerException - Thrown in case of malformed input.
      • peekToken

        Token peekToken()
        Return the next token, but do not delete it from the stream.
        Returns:
        The token that will be returned on the next call to next()
        Throws:
        ScannerException - Thrown in case of malformed input.
        java.lang.IndexOutOfBoundsException - if no more token left
      • resetDocumentIndex

        void resetDocumentIndex()
        Set the document index to 0 after a document end