Package errors
Class SemanticError
- java.lang.Object
-
- errors.Error
-
- errors.SemanticError
-
public final class SemanticError extends Error
The SemanticError class is used to represent an error that occurred during the semantic analysis stage of compilation.Static methods for generating SemanticErrors 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 SemanticError(SourceSpan span, java.lang.String problem, java.lang.String solution)
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static SemanticErrorinvalidExpressionTypes(SourceSpan span, ObjectType actualType, ObjectType[] targetTypes)Generate and return a SemanticError for invalid expression type(s).static SemanticErrorundefinedAssignmentOperator(SourceSpan span, java.lang.String syntax, ObjectType symbolType, ObjectType assignmentType)Generate and return a SemanticError for an incompatible assignment operator.static SemanticErrorundefinedBinaryOperator(SourceSpan span, java.lang.String syntax, ObjectType leftType, ObjectType rightType)Generate and return a SemanticError for an incompatible binary operator.static SemanticErrorundefinedIdentifier(SourceSpan span, java.lang.String syntax)Generate and return a SemanticError for an undeclared symbol.static SemanticErrorundefinedUnaryOperator(SourceSpan span, java.lang.String syntax, ObjectType type)Generate and return a SemanticError for an incompatible unary operator.-
Methods inherited from class errors.Error
getErrorMessage
-
-
-
-
Constructor Detail
-
SemanticError
public SemanticError(SourceSpan span, java.lang.String problem, java.lang.String solution)
-
-
Method Detail
-
undefinedUnaryOperator
public static SemanticError undefinedUnaryOperator(SourceSpan span, java.lang.String syntax, ObjectType type)
Generate and return a SemanticError for an incompatible unary operator.- Parameters:
span- The location information for where an error occurredsyntax- The syntax of the operatortype- The ObjectType of the operand- Returns:
- A SemanticError containing information about an error that occurred
-
undefinedBinaryOperator
public static SemanticError undefinedBinaryOperator(SourceSpan span, java.lang.String syntax, ObjectType leftType, ObjectType rightType)
Generate and return a SemanticError for an incompatible binary operator.- Parameters:
span- The location information for where an error occurredsyntax- The syntax of the operatorleftType- The ObjectType of the left operandrightType- The ObjectType of the right operand- Returns:
- A SemanticError containing information about an error that occurred
-
undefinedAssignmentOperator
public static SemanticError undefinedAssignmentOperator(SourceSpan span, java.lang.String syntax, ObjectType symbolType, ObjectType assignmentType)
Generate and return a SemanticError for an incompatible assignment operator.- Parameters:
span- The location information for where an error occurredsyntax- The syntax of the operatorsymbolType- The ObjectType of the symbolassignmentType- The ObjectType of the assignment- Returns:
- A SemanticError containing information about an error that occurred
-
undefinedIdentifier
public static SemanticError undefinedIdentifier(SourceSpan span, java.lang.String syntax)
Generate and return a SemanticError for an undeclared symbol.- Parameters:
span- The location information for where an error occurredsyntax- The syntax of the identifier- Returns:
- A SemanticError containing information about an error that occurred
-
invalidExpressionTypes
public static SemanticError invalidExpressionTypes(SourceSpan span, ObjectType actualType, ObjectType[] targetTypes)
Generate and return a SemanticError for invalid expression type(s).- Parameters:
span- The location information for where an error occurredactualType- The actual ObjectType of the expressiontargetTypes- The expected ObjectType of the expression- Returns:
- A SemanticError containing information about an error that occurred
-
-