Semantic Analysis
class SemanticAnalysis
Content copied to clipboard
Semantic analysis
Class which contains all functions used to aid semantic analysis. Any errors are thrown and held in the error handler.
Constructors
SemanticAnalysis
Link copied to clipboard
fun SemanticAnalysis()
Content copied to clipboard
Create empty Semantic analysis
Functions
allExpressionsAreSameTypeCheck
Link copied to clipboard
fun allExpressionsAreSameTypeCheck(expected: Type, expressions: List<ExpressionNode>, currentSymbolTable: SymbolTableVisitor, ctx: ParserRuleContext)
Content copied to clipboard
array2DDimensionsMatchCheck
Link copied to clipboard
fun array2DDimensionsMatchCheck(initialiser: InitialiserNode, dataStructureType: DataStructureType, ctx: ParserRuleContext)
Content copied to clipboard
breakOrContinueOutsideLoopCheck
Link copied to clipboard
fun breakOrContinueOutsideLoopCheck(action: String, inLoop: Boolean, ctx: ParserRuleContext)
Content copied to clipboard
checkAnnotationArguments
Link copied to clipboard
fun checkAnnotationArguments(ctx: ParserRuleContext, symbolTable: SymbolTableVisitor, arguments: List<ExpressionNode>): List<Type>
Content copied to clipboard
checkArrayConstructorItemLengthsMatch
Link copied to clipboard
fun checkArrayConstructorItemLengthsMatch(openConstructorSize: Int, closeConstructorSize: Int, ctx: ParserRuleContext)
Content copied to clipboard
checkArrayDimensionsMatchConstructorArguments
Link copied to clipboard
fun checkArrayDimensionsMatchConstructorArguments(dataStructureType: DataStructureType, argumentsSize: Int, ctx: ParserRuleContext)
Content copied to clipboard
checkArrayDimensionsNotGreaterThanTwo
Link copied to clipboard
fun checkArrayDimensionsNotGreaterThanTwo(arrayDimension: Int, ctx: ParserRuleContext)
Content copied to clipboard
checkArrayElemHasCorrectNumberOfIndices
Link copied to clipboard
fun checkArrayElemHasCorrectNumberOfIndices(indices: List<ExpressionNode>, is2DArray: Boolean, ctx: ParserRuleContext)
Content copied to clipboard
checkArrayElemIndexTypes
Link copied to clipboard
fun checkArrayElemIndexTypes(indices: List<ExpressionNode>, currentSymbolTable: SymbolTableVisitor, ctx: ParserRuleContext)
Content copied to clipboard
checkExpressionTypeWithExpectedType
Link copied to clipboard
fun checkExpressionTypeWithExpectedType(expression: ExpressionNode, expected: Type, currentSymbolTable: SymbolTableVisitor, ctx: ParserRuleContext)
Content copied to clipboard
checkExpressionTypeWithExpectedTypes
Link copied to clipboard
fun checkExpressionTypeWithExpectedTypes(expression: ExpressionNode, expected: Set<Type>, currentSymbolTable: SymbolTableVisitor, ctx: ParserRuleContext)
Content copied to clipboard
datastructureConstructorCheck
Link copied to clipboard
fun datastructureConstructorCheck(dataStructureType: DataStructureType, initialValue: List<ExpressionNode>, argumentTypes: List<Type>, ctx: VAlgoLangParser.DataStructureConstructorContext)
Content copied to clipboard
forLoopIdentifierNotBeingReassignedCheck
Link copied to clipboard
fun forLoopIdentifierNotBeingReassignedCheck(identifier: String, forLoopIdentifiers: Set<String>, ctx: ParserRuleContext)
Content copied to clipboard
forLoopRangeTypeCheck
Link copied to clipboard
fun forLoopRangeTypeCheck(symbolTable: SymbolTableVisitor, startExpr: ExpressionNode, endExpr: ExpressionNode, ctx: VAlgoLangParser.RangeHeaderContext)
Content copied to clipboard
forLoopRangeUpdateNumberTypeCheck
Link copied to clipboard
fun forLoopRangeUpdateNumberTypeCheck(symbolTable: SymbolTableVisitor, change: ExpressionNode, ctx: ParserRuleContext)
Content copied to clipboard
globalReturnCheck
Link copied to clipboard
fun globalReturnCheck(inFunction: Boolean, ctx: VAlgoLangParser.ReturnStatementContext)
Content copied to clipboard
incompatibleArgumentTypesCheck
Link copied to clipboard
fun incompatibleArgumentTypesCheck(dataStructureType: DataStructureType, argumentTypes: List<Type>, dataStructureMethod: DataStructureMethod, ctx: ParserRuleContext)
Content copied to clipboard
incompatibleArgumentTypesForFunctionsCheck
Link copied to clipboard
fun incompatibleArgumentTypesForFunctionsCheck(identifier: String, currentSymbolTable: SymbolTableVisitor, argTypes: List<Type>, ctx: VAlgoLangParser.FunctionCallContext)
Content copied to clipboard
incompatibleInitialiserCheck
Link copied to clipboard
fun incompatibleInitialiserCheck(dataStructureType: DataStructureType, initialiser: ASTNode, ctx: ParserRuleContext)
Content copied to clipboard
incompatibleMultipleFunctionCall
Link copied to clipboard
fun incompatibleMultipleFunctionCall(identifier: String, functionData: FunctionData, lhsType: Type, ctx: ParserRuleContext)
Content copied to clipboard
incompatibleOperatorTypeCheck
Link copied to clipboard
fun incompatibleOperatorTypeCheck(operator: String, opExpr: ExpressionNode, currentSymbolTable: SymbolTableVisitor, ctx: VAlgoLangParser.ExprContext)
Content copied to clipboard
incompatibleReturnTypesCheck
Link copied to clipboard
fun incompatibleReturnTypesCheck(currentSymbolTable: SymbolTableVisitor, functionReturnType: Type, expression: ExpressionNode, ctx: VAlgoLangParser.ReturnStatementContext)
Content copied to clipboard
incompatibleTypesCheck
Link copied to clipboard
fun incompatibleTypesCheck(lhsType: Type, rhsType: Type, text: String, ctx: ParserRuleContext)
Content copied to clipboard
inferType
Link copied to clipboard
fun inferType(currentSymbolTable: SymbolTableVisitor, expression: ExpressionNode): Type
Content copied to clipboard
invalidArrayElemAssignment
Link copied to clipboard
fun invalidArrayElemAssignment(identifier: String, type: Type, ctx: VAlgoLangParser.Assignment_lhsContext)
Content copied to clipboard
invalidNumberOfArgumentsForFunctionsCheck
Link copied to clipboard
fun invalidNumberOfArgumentsForFunctionsCheck(identifier: String, currentSymbolTable: SymbolTableVisitor, numArgs: Int, ctx: VAlgoLangParser.FunctionCallContext)
Content copied to clipboard
missingReturnCheck
Link copied to clipboard
fun missingReturnCheck(identifier: String, statements: List<StatementNode>, type: Type, ctx: VAlgoLangParser.FunctionContext)
Content copied to clipboard
notDataStructureCheck
Link copied to clipboard
fun notDataStructureCheck(currentSymbolTable: SymbolTableVisitor, identifier: String, ctx: ParserRuleContext)
Content copied to clipboard
notValidMethodNameForDataStructureCheck
Link copied to clipboard
fun notValidMethodNameForDataStructureCheck(currentSymbolTable: SymbolTableVisitor, identifier: String, method: String, ctx: ParserRuleContext, overrideType: Type = ErrorType): Boolean
Content copied to clipboard
primitiveArgTypesCheck
Link copied to clipboard
fun primitiveArgTypesCheck(argTypes: List<Type>, methodName: String, dataStructureType: DataStructureType, ctx: VAlgoLangParser.MethodCallContext)
Content copied to clipboard
primitiveInternalTypeForDataStructureCheck
Link copied to clipboard
fun primitiveInternalTypeForDataStructureCheck(internalType: Type, ctx: ParserRuleContext)
Content copied to clipboard
redeclaredFunctionCheck
Link copied to clipboard
fun redeclaredFunctionCheck(currentSymbolTable: SymbolTableVisitor, identifier: String, returnType: Type, parameters: List<ParameterNode>, ctx: ParserRuleContext)
Content copied to clipboard
redeclaredVariableCheck
Link copied to clipboard
fun redeclaredVariableCheck(currentSymbolTable: SymbolTableVisitor, identifier: String, ctx: ParserRuleContext)
Content copied to clipboard
tooManyInferredFunctionsCheck
Link copied to clipboard
fun tooManyInferredFunctionsCheck(currentSymbolTable: SymbolTableVisitor, ctx: ParserRuleContext)
Content copied to clipboard
unableToInferTypeCheck
Link copied to clipboard
undeclaredFunctionCheck
Link copied to clipboard
fun undeclaredFunctionCheck(currentSymbolTable: SymbolTableVisitor, identifier: String, inFunction: Boolean, argTypes: List<Type>, ctx: ParserRuleContext)
Content copied to clipboard
undeclaredIdentifierCheck
Link copied to clipboard
fun undeclaredIdentifierCheck(currentSymbolTable: SymbolTableVisitor, identifier: String, ctx: ParserRuleContext)
Content copied to clipboard
voidTypeDeclarationCheck
Link copied to clipboard
fun voidTypeDeclarationCheck(rhsType: Type, identifier: String, ctx: ParserRuleContext)
Content copied to clipboard