Package errors
Class SyntaxError
- java.lang.Object
-
- errors.Error
-
- errors.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
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class errors.Error
Error.ErrorMessage
-
-
Constructor Summary
Constructors Constructor Description SyntaxError(SourceSpan span, java.lang.String problem, java.lang.String solution)
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static SyntaxErroremptyParenthesis(SourceSpan openParenSpan, SourceSpan closeParenSpan)Generate and return a SyntaxError for a set of empty parenthesis.static SyntaxErrorincompleteExpression(SourceSpan span)Generate and return a SyntaxError for an incomplete expression.static SyntaxErrorinvalidStatement(SourceSpan span)Generate and return a SyntaxError for an invalid statement.static SyntaxErrorunexpectedToken(Token token, TokenType expectedType)Generate and return a SyntaxError for an unexpected token.-
Methods inherited from class errors.Error
getErrorMessage
-
-
-
-
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 errorexpectedType- 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 tokencloseParenSpan- The location information for the close parenthesis token- Returns:
- A SyntaxError containing information about an error that occurred
-
-