public void visitPrint(PrintNode node) { foreach (INode child in node.getChildren()) { child.accept(this); } }
public void visitPrint(PrintNode printNode) { this.typeStack.Clear(); printNode.getChildren()[0].accept(this); MiniPLTokenType type = this.typeStack.Pop(); this.typeStack.Clear(); if (type != MiniPLTokenType.TYPE_IDENTIFIER_INTEGER && type != MiniPLTokenType.TYPE_IDENTIFIER_STRING) { throw new SemanticException("Print statement can print only integers and strings."); } }
public void visitPrint(PrintNode printNode) { INode expression = printNode.getChildren()[0]; expression.accept(this); if (this.intType) { this.inputOutput.output(popInt()); this.intType = false; } else if (this.strType) { this.inputOutput.output(popString()); this.strType = false; } }