public override void ValidateSemantic() { var valorType = eValor.EvaluateType(); if ((!(valorType is IntType) && !(valorType is BoolType))) { throw new SemanticException("Invalid types."); } }
public override Types EvaluateType() { var leftType = leftOperand.EvaluateType(); var rightType = rightOperand.EvaluateType(); var rule = leftType.GetType().Name + "," + rightType.GetType().Name; if (rules.ContainsKey(rule)) { return(rules[rule]); } throw new SemanticException("Rule not supported"); }
public override Types EvaluateType(Types type) { if (!(type is ArrayType)) { throw new SemanticException("Type must be an array!"); } var arrType = (ArrayType)type; var exprType = value.EvaluateType(); if (!(exprType is IntType)) { throw new SemanticException("Type must be an int!"); } return(arrType.type); }
public override void ValidateSemantic() { var valorType = eValor.EvaluateType(); if (!SymbolsTable.vars.ContainsKey(id.ToString())) { SymbolsTable.vars[id.ToString()] = valorType; return; } var nodeType = id.EvaluateType(); if (valorType.GetType() != nodeType.GetType()) { throw new SemanticException("Incorrect assignation types."); } }