public void Visit(NegNode node) { node.Operand.Accept(this); if (node.Operand.StaticType.Text != "Int") { errors.Add(SemanticError.InvalidUseOfOperator(node, node.Operand.StaticType)); } if (!scope.IsDefinedType("Int", out node.StaticType)) { errors.Add(SemanticError.NotDeclaredType(new TypeNode(node.Line, node.Column, "Int"))); } }
public void Visit(ComparisonOperation node) { node.LeftOperand.Accept(this); node.RightOperand.Accept(this); if (node.LeftOperand.StaticType.Text != "Int" || node.RightOperand.StaticType.Text != "Int") { errors.Add(SemanticError.InvalidUseOfOperator(node, node.LeftOperand.StaticType, node.RightOperand.StaticType)); } if (!scope.IsDefinedType("Bool", out node.StaticType)) { errors.Add(SemanticError.NotDeclaredType(new TypeNode(node.Line, node.Column, "Bool"))); } }
public void Visit(EqualNode node) { node.LeftOperand.Accept(this); node.RightOperand.Accept(this); if (node.LeftOperand.StaticType.Text != node.RightOperand.StaticType.Text || !(new string[3] { "Bool", "Int", "String" }.Contains(node.LeftOperand.StaticType.Text))) { errors.Add(SemanticError.InvalidUseOfOperator(node, node.LeftOperand.StaticType, node.RightOperand.StaticType)); } if (!scope.IsDefinedType("Bool", out node.StaticType)) { errors.Add(SemanticError.NotDeclaredType(new TypeNode(node.Line, node.Column, "Bool"))); } }