public override void CheckSemantics(TigerScope scope, Report report) { ContainingScope = scope; //Check children IdNode.CheckSemantics(scope, report); TypeNode.CheckSemantics(scope, report); ExpressionNode.CheckSemantics(scope, report); if (!IdNode.IsOK || !TypeNode.IsOK || !ExpressionNode.IsOK) { return; } //Check use of variable name if (!scope.VariableNameAvailable(IdNode.Name)) { report.AddError(SemanticErrors.VariableNameAlreadyInUse(IdNode, IdNode.Name)); return; } //Check children types if (!TypeNode.TigerType.Assignable(ExpressionNode.TigerType)) { report.AddError(SemanticErrors.InvalidAssignType(ExpressionNode, TypeNode.TigerType, ExpressionNode.TigerType)); } //Add variable to scope VariableInfo = scope.DefineVariable(IdNode.Name, TypeNode.TigerType, ContainingScope); IsOK = true; }
public override void CheckSemantics(TigerScope scope, Report report) { ContainingScope = scope; //Check children IdNode.CheckSemantics(scope, report); TypeNode.CheckSemantics(scope, report); if (!IdNode.IsOK || !TypeNode.IsOK) { return; } //Check use of variable name if (!scope.VariableNameAvailable(IdNode.Name)) { report.AddError(SemanticErrors.RepeatedParameterName(IdNode, IdNode.Name)); return; } //Add variable to scope VariableInfo = scope.DefineVariable(IdNode.Name, TypeNode.TigerType, scope); TigerType = TypeNode.TigerType; }