1 8 package org.lsmp.djep.xjep; 9 10 import org.nfunk.jep.*; 11 12 20 public class DeepCopyVisitor extends DoNothingVisitor implements ParserVisitor { 21 22 private XJep xjep; 23 24 public Node deepCopy(Node node,XJep xjep) throws ParseException 25 { 26 this.xjep = xjep; 27 Node res = (Node) node.jjtAccept(this,null); 28 return res; 29 } 30 31 public Object visit(ASTConstant node, Object data) throws ParseException 32 { 33 return xjep.getNodeFactory().buildConstantNode(node); 34 } 35 36 public Object visit(ASTVarNode node, Object data) throws ParseException 37 { 38 return xjep.getNodeFactory().buildVariableNode(node); 39 } 40 41 public Object visit(ASTFunNode node, Object data) throws ParseException 42 { 43 Node children[]=acceptChildrenAsArray(node,data); 44 return xjep.getNodeFactory().buildFunctionNode(node,children); 45 } 46 } 47 | Popular Tags |