001//
002// Generated by JTB 1.3.2
003//
004
005package jtb.syntaxtree;
006
007// Represents an grammar optional node, e.g. ( A )? or [ A ]
008public class NodeOptional implements Node {
009   // This was added after running jtb to remove serializable warning.
010   static final long serialVersionUID = 20150406L;
011
012   public NodeOptional() {
013      node = null;
014   }
015
016   public NodeOptional(Node n) {
017      addNode(n);
018   }
019
020   public void addNode(Node n)  {
021      if ( node != null)                // Oh oh!
022         throw new Error("Attempt to set optional node twice");
023
024      node = n;
025      n.setParent(this);
026   }
027   public void accept(jtb.visitor.Visitor v) {
028      v.visit(this);
029   }
030   public <R,A> R accept(jtb.visitor.GJVisitor<R,A> v, A argu) {
031      return v.visit(this,argu);
032   }
033   public <R> R accept(jtb.visitor.GJNoArguVisitor<R> v) {
034      return v.visit(this);
035   }
036   public <A> void accept(jtb.visitor.GJVoidVisitor<A> v, A argu) {
037      v.visit(this,argu);
038   }
039   public boolean present()   { return node != null; }
040
041   public void setParent(Node n) { parent = n; }
042   public Node getParent()       { return parent; }
043
044   private Node parent;
045   public Node node;
046}
047