Class UnexpectedTokenException

All Implemented Interfaces:
Serializable

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

    • unexpected

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

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

    • 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 Details

    • 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 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