1 8 package org.lsmp.djep.xjep; 9 10 import org.nfunk.jep.*; 11 12 20 public abstract class DoNothingVisitor implements ParserVisitor { 21 22 40 41 44 45 protected Node[] acceptChildrenAsArray(Node node,Object data) throws ParseException 46 { 47 int n = node.jjtGetNumChildren(); 48 Node children[] = new Node[n]; 49 for(int i=0;i<n;++i) 50 children[i]= (Node) node.jjtGetChild(i).jjtAccept(this,data); 51 return children; 52 } 53 54 55 56 public Object visit(SimpleNode node, Object data) throws ParseException 57 { 58 throw new ParseException(this.toString()+": encountered a simple node, problem with visitor."); 59 } 60 61 public Object visit(ASTStart node, Object data) throws ParseException 62 { 63 throw new ParseException(this.toString()+": encountered a start node, problem with visitor."); 64 } 65 66 67 public Object visit(ASTConstant node, Object data) throws ParseException 68 { 69 return node; 70 } 71 72 public Object visit(ASTVarNode node, Object data) throws ParseException 73 { 74 return node; 75 } 76 77 public Object visit(ASTFunNode node, Object data) throws ParseException 78 { 79 Node children[] = acceptChildrenAsArray(node,data); 80 TreeUtils.copyChildrenIfNeeded(node,children); 81 return node; 82 } 83 } 84 | Popular Tags |