if (head.equals("Elements")) return seq2((ElementNode[])Reflection.rebuild(walkChildren(t), ElementNode[].class));
if (head.equals("NonTerminalReference")) return new ReferenceNode(stringifyChildren(t.child(0)));
//if (head.equals(")")) return new ReferenceNode(stringifyChildren(t.child(0)));
+ if (head.equals("{")) return new XTree((Seq)walk(t.child(0)));
if (head.equals("::")) return tag((String)walk(t.child(0)), (Seq)walk(t.child(1)));
if (head.equals("++")) return plusmax((ElementNode)walk(t.child(0)));
if (head.equals("+")) return plus((ElementNode)walk(t.child(0)));
if (head.equals("Quoted")) return stringifyChildren(t);
if (head.equals("Literal")) return new LiteralNode((String)walk(t.child(0)));
if (head.equals("->")) return arrow((Seq)walk(t.child(0)), (ElementNode)walk(t.child(1)));
- if (head.equals("DropNT")) return new NonTerminalNode((String)walk(t.child(0)), (Seq[][])walk(t.child(1)), true, null, true);
+ if (head.equals("DropNT")) return new NonTerminalNode((String)walk(t.child(0)), (Seq[][])walkChildren(t.child(1)), false, null, true);
if (head.equals("=") && t.size()==2) return new NonTerminalNode((String)walk(t.child(0)), (Seq[][])walk(t.child(1)), true, null, false);
if (head.equals("=")) return new NonTerminalNode((String)walk(t.child(0)), (Seq[][])walk(t.child(2)), true, (String)walk(t.child(1)), false);
if (head.equals("&")) return and2((Seq)walk(t.child(0)), (Seq)walk(t.child(1)));
if (!drops[i])
if (idx==-1) idx = i;
else multiNonDrop = true;
- if (tag==null && multiNonDrop)
- throw new Error("multiple non-dropped elements in sequence: " + Sequence.create(els, ""));
for(int i=0; i<elements.length; i++) {
if (!multiNonDrop && i==idx && tag!=null && elements[i] instanceof RepeatNode) {
els[i] = ((RepeatNode)elements[i]).build(cx, cnt, dropall, tag);
} else
els[i] = elements[i].build(cx, cnt, dropall);
}
+ if (tag==null && multiNonDrop)
+ throw new RuntimeException("multiple non-dropped elements in sequence: " + Sequence.create(els, ""));
if (!multiNonDrop) {
if (idx == -1)
ret = tag==null
}
- /*
- public class XTree extends ElementNode {
- public Seq body;
+ public class XTree extends ElementNode {
+ public Seq body;
+ public XTree(Seq seq) { this.body = seq; }
public Element build(Context cx, NonTerminalNode cnt, boolean dropall) {
Union u = new Union(null, false);
Sequence s = body.build(cx, u, null, dropall);
return u2;
}
}
- */
}