01: //
02: // Generated by JTB 1.2.1
03: //
04:
05: package oscript.syntaxtree;
06:
07: /**
08: * Represents an grammar optional node, e.g. ( A )? or [ A ]
09: */
10: public class NodeOptional implements Node {
11: public NodeOptional() {
12: node = null;
13: }
14:
15: public NodeOptional(Node n) {
16: addNode(n);
17: }
18:
19: public void addNode(Node n) {
20: if (node != null) // Oh oh!
21: throw new Error("Attempt to set optional node twice");
22:
23: node = n;
24: }
25:
26: public void accept(oscript.visitor.Visitor v) {
27: v.visit(this );
28: }
29:
30: public Object accept(oscript.visitor.ObjectVisitor v, Object argu) {
31: return v.visit(this , argu);
32: }
33:
34: public boolean present() {
35: return node != null;
36: }
37:
38: public Node node;
39: }
|