public override void ValidateNodeSemantic() { var validateSemantic = IdNode.ValidateSemantic(); if (!(validateSemantic is IntegerType)) { throw new SemanticException("Not an Integer type."); } var counterValueType = validateSemantic.IsAssignable(CounterValue.ValidateSemantic()); if (!counterValueType) { throw new SemanticException($"{CounterValue} can't be assign."); } if (Condition.ValidateSemantic() is IntegerType) { SymbolTable.AddSymbolTable(ForSymbolTable); foreach (var sentenceNode in Statements) { sentenceNode.ValidateNodeSemantic(); } SymbolTable.RemoveSymbolTable(); } else { throw new SemanticException("Not an integer type."); } }
public override void ValidateNodeSemantic() { //var validateSemantic = IdNode.ValidateSemantic(); //if (!(validateSemantic is IntegerType)) throw new SemanticException("Not an Integer type."); if (IdNodeCollection.ValidateSemantic() is ArrayType) { SymbolTable.AddSymbolTable(ForInSymbolTable); SymbolTable.Instance.DeclareVariable(IdNode.Value, ((ArrayType)IdNodeCollection.ValidateSemantic()).Type); foreach (var sentenceNode in Statements) { sentenceNode.ValidateNodeSemantic(); } SymbolTable.RemoveSymbolTable(); } else { throw new SemanticException("Not an iterable variable."); } }
public override void ValidateNodeSemantic() { var idType = ValueIdNode.ValidateSemantic(); var expressionType = Value.ValidateSemantic(); if (!idType.IsAssignable(expressionType)) { throw new SemanticException($"Type Mismatch Exception between {idType} and {expressionType}"); } if (SymbolTable.Instance.GetConstant(ValueIdNode.Value)) { throw new SemanticException($"Constant variable: {ValueIdNode.Value} can't be assign."); } }
public override void ValidateSemantic() { var typeNode = CaseName.ValidateSemantic(); if (typeNode is IntType) { foreach (var caseStatement in CaseStatements) { foreach (var statement in caseStatement.Statements) { statement.ValidateSemantic(); } } } }