diff options
Diffstat (limited to 'syntaxtree/NodeOptional.java')
-rw-r--r-- | syntaxtree/NodeOptional.java | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/syntaxtree/NodeOptional.java b/syntaxtree/NodeOptional.java new file mode 100644 index 0000000..d9a8c43 --- /dev/null +++ b/syntaxtree/NodeOptional.java @@ -0,0 +1,41 @@ +// +// Generated by JTB 1.3.2 +// + +package syntaxtree; + +/** + * Represents an grammar optional node, e.g. ( A )? or [ A ] + */ +public class NodeOptional implements Node { + public NodeOptional() { + node = null; + } + + public NodeOptional(Node n) { + addNode(n); + } + + public void addNode(Node n) { + if ( node != null) // Oh oh! + throw new Error("Attempt to set optional node twice"); + + node = n; + } + public void accept(visitor.Visitor v) { + v.visit(this); + } + public <R,A> R accept(visitor.GJVisitor<R,A> v, A argu) { + return v.visit(this,argu); + } + public <R> R accept(visitor.GJNoArguVisitor<R> v) { + return v.visit(this); + } + public <A> void accept(visitor.GJVoidVisitor<A> v, A argu) { + v.visit(this,argu); + } + public boolean present() { return node != null; } + + public Node node; +} + |