Class UnexpectedTokenException

  • All Implemented Interfaces:
    java.io.Serializable

    public class UnexpectedTokenException
    extends ParseException
    Thrown when a token of unexpected types is encountered during the parsing.
    Since:
    0.7.0
    See Also:
    Serialized Form
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) Lexer.Token.Type[] getExpectedTokenTypes()
      Gets the expected token types.
      (package private) Lexer.Token getUnexpectedToken()
      Gets the unexpected token.
      java.lang.String toString()
      Returns the string representation of this exception containing the information about the unexpected token and, if available, about the expected types.
      • Methods inherited from class java.lang.Throwable

        addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • unexpected

        private final Lexer.Token unexpected
        The unexpected token.
      • expected

        private final Lexer.Token.Type[] expected
        The array of the expected token types.
    • Constructor Detail

      • UnexpectedTokenException

        UnexpectedTokenException​(UnexpectedElementException cause)
        Constructs a UnexpectedTokenException instance with the wrapped UnexpectedElementException exception.
        Parameters:
        cause - the wrapped exception
      • UnexpectedTokenException

        UnexpectedTokenException​(Lexer.Token token,
                                 Lexer.Token.Type... expected)
        Constructs a UnexpectedTokenException instance with the unexpected token and the expected types.
        Parameters:
        token - the unexpected token
        expected - an array of the expected token types
    • Method Detail

      • getUnexpectedToken

        Lexer.Token getUnexpectedToken()
        Gets the unexpected token.
        Returns:
        the unexpected token
      • getExpectedTokenTypes

        Lexer.Token.Type[] getExpectedTokenTypes()
        Gets the expected token types.
        Returns:
        an array of expected token types
      • toString

        public java.lang.String toString()
        Returns the string representation of this exception containing the information about the unexpected token and, if available, about the expected types.
        Overrides:
        toString in class ParseException
        Returns:
        the string representation of this exception