public void visitVarAssignment(VarAssignmentNode node) { IdentifierNode identifier = (IdentifierNode)node.getChildren()[0]; string variableName = identifier.getVariableName(); if (!variableAlreadyDeclared(variableName)) { throw new SemanticException("Variable '" + variableName + "' has not been declared."); } if (this.forLoopControlVariables.Contains(variableName)) { throw new SemanticException("Control variable '" + variableName + "' cannot be assigned a new value inside for loop."); } }
public void visitVarAssignment(VarAssignmentNode node) { IdentifierNode identifier = (IdentifierNode)node.getChildren()[0]; string variableName = identifier.getVariableName(); INode expression = node.getChildren()[1]; MiniPLTokenType type; if (this.symbolTable.hasInteger(variableName)) { type = MiniPLTokenType.TYPE_IDENTIFIER_INTEGER; typeCheck(expression, type); } else if (this.symbolTable.hasString(variableName)) { type = MiniPLTokenType.TYPE_IDENTIFIER_STRING; typeCheck(expression, type); } else if (this.symbolTable.hasBool(variableName)) { type = MiniPLTokenType.TYPE_IDENTIFIER_BOOL; typeCheck(expression, type); } }
public void visitVarAssignment(VarAssignmentNode node) { updateValue(node); }