+ public static abstract class ElementNode {
+ public String getLabel() { return null; }
+ public String getOwnerTag() { return null; }
+ public boolean drop() { return false; }
+ public Atom toAtom(Context cx) { throw new Error("can't convert a " + this.getClass().getName() + " to an atom"); }
+ public abstract Element build(Context cx, NonTerminalNode cnt);
+ }
+
+ public static abstract class ElementNodeWrapper extends ElementNode {
+ protected ElementNode _e;
+ public ElementNodeWrapper(ElementNode e) { this._e = e; }
+ public String getLabel() { return _e.getLabel(); }
+ public String getOwnerTag() { return _e.getOwnerTag(); }
+ public boolean drop() { return _e.drop(); }
+ public Atom toAtom(Context cx) { return _e.toAtom(cx); }
+ public Element build(Context cx, NonTerminalNode cnt) { return _e.build(cx, cnt); }
+ }
+
+ public static class Constant extends ElementNode {
+ Element constant;
+ public Constant(Element constant) { this.constant = constant; }
+ public Element build(Context cx, NonTerminalNode cnt) { return constant; }
+ public Atom toAtom(Context cx) {
+ if (constant instanceof Atom) return ((Atom)constant);
+ return super.toAtom(cx);
+ }
+ }
+
+ public abstract static class PostProcess extends ElementNodeWrapper {
+ public PostProcess(ElementNode e) { super(e); }
+ public Element build(Context cx, NonTerminalNode cnt) { return postProcess(_e.build(cx, cnt)); }
+ public abstract Element postProcess(Element e);
+ }
+
+ public static class Drop extends ElementNodeWrapper {
+ public Drop(ElementNode e) { super(e); }
+ public boolean drop() { return true; }
+ }
+
+ public static class Label extends ElementNodeWrapper {
+ public String label;
+ public Label(String label, ElementNode e) { super(e); this.label = label; }
+ public String getLabel() { return label; }
+ }
+
+ /*
+ static class Invert extends Atom {
+ private final Atom a;
+ public Invert(Atom a) { this.a = a; }
+ public Topology top() { return a.complement(); }
+ public String toString() { return "~"+a; }
+ }
+ */