public void visitRead(ReadNode node) { foreach (INode child in node.getChildren()) { child.accept(this); } }
public void visitRead(ReadNode readNode) { IdentifierNode identifier = (IdentifierNode)readNode.getChildren()[0]; string variableName = identifier.getVariableName(); if (!this.symbolTable.hasInteger(variableName) && !this.symbolTable.hasString(variableName)) { throw new SemanticException("Wrong type in read statement. Trying to read input to variable " + variableName + ". Read statement can read only integers and strings."); } }
public void visitRead(ReadNode node) { IdentifierNode identifier = (IdentifierNode)node.getChildren()[0]; string variableName = identifier.getVariableName(); if (this.symbolTable.hasInteger(variableName)) { this.symbolTable.updateVariable(variableName, readInteger()); } else if (this.symbolTable.hasString(variableName)) { this.symbolTable.updateVariable(variableName, readString()); } }