Interface LexicalAnalyzer

  • All Superinterfaces:
    java.lang.Iterable<Token>

    @NotThreadSafe
    public interface LexicalAnalyzer
    extends java.lang.Iterable<Token>
    Lexical analyzer.

    It is not meant to be thread-safe. Before using, make sure the lexer is reset.

    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      boolean hasNext()
      Determines if a next token is available on the input at the current lexer position.
      default java.util.Iterator<Token> iterator()  
      Token next()
      Parse next token.
      void reset​(java.io.InputStream input)
      Reset this lexical analyzer with new input.
      void reset​(java.lang.String input)
      Reset this lexical analyzer with new input.
      • Methods inherited from interface java.lang.Iterable

        forEach, spliterator
    • Method Detail

      • next

        Token next()
        Parse next token.
        Returns:
        next token, or Token.EOF if no token is available on the input
      • hasNext

        boolean hasNext()
        Determines if a next token is available on the input at the current lexer position.
        Returns:
        true if the lexer has a next token to be parsed
      • reset

        void reset​(java.io.InputStream input)
            throws java.io.IOException
        Reset this lexical analyzer with new input.
        Parameters:
        input - new program source code
        Throws:
        java.io.IOException - when input cannot be read
      • reset

        void reset​(java.lang.String input)
        Reset this lexical analyzer with new input.
        Parameters:
        input - new program source code
      • iterator

        default java.util.Iterator<Token> iterator()
        Specified by:
        iterator in interface java.lang.Iterable<Token>