/** * Visit a variable node. The value of the variable is obtained from the symbol table (symTab) and * pushed onto the stack. */ public Object visit(ASTVarNode node, Object data) throws ParseException { // try to get the variable object Variable var = symTab.getVar(node.getVarName()); if (var == null) { String message = "Could not evaluate " + node.getVarName() + ": "; throw new ParseException(message + "the variable was not found in the symbol table"); } // get the variable value // Object temp = var.getValue(); Object temp = var.getValue(); if (trapNullValues && temp == null) { String message = "Could not evaluate " + node.getVarName() + ": "; throw new ParseException(message + "variable not set"); } // all is fine // push the value on the stack stack.push(temp); return data; }