Package errors

Class SyntaxError


  • public final class SyntaxError
    extends Error
    The SyntaxError class is used to represent an error that occurred during the syntax analysis stage of compilation.

    Static methods for generating SyntaxErrors are stored here, each of which uses a set of pre-defined input Strings.

    Since:
    1.0
    • Constructor Detail

      • SyntaxError

        public SyntaxError​(SourceSpan span,
                           java.lang.String problem,
                           java.lang.String solution)
    • Method Detail

      • incompleteExpression

        public static SyntaxError incompleteExpression​(SourceSpan span)
        Generate and return a SyntaxError for an incomplete expression.
        Parameters:
        span - The location information for where an error occurred
        Returns:
        A SyntaxError containing information about an error that occurred
      • unexpectedToken

        public static SyntaxError unexpectedToken​(Token token,
                                                  TokenType expectedType)
        Generate and return a SyntaxError for an unexpected token.
        Parameters:
        token - The Token which caused the error
        expectedType - The TokenType that was expected
        Returns:
        A SyntaxError containing information about an error that occurred
      • invalidStatement

        public static SyntaxError invalidStatement​(SourceSpan span)
        Generate and return a SyntaxError for an invalid statement.
        Parameters:
        span - The location information for where an error occurred
        Returns:
        A SyntaxError containing information about an error that occurred
      • emptyParenthesis

        public static SyntaxError emptyParenthesis​(SourceSpan openParenSpan,
                                                   SourceSpan closeParenSpan)
        Generate and return a SyntaxError for a set of empty parenthesis.
        Parameters:
        openParenSpan - The location information for the open parenthesis token
        closeParenSpan - The location information for the close parenthesis token
        Returns:
        A SyntaxError containing information about an error that occurred