* parsing with this Union should be provided to <tt>buildFromAST</tt>
*/
public static Union getMetaGrammar() {
* parsing with this Union should be provided to <tt>buildFromAST</tt>
*/
public static Union getMetaGrammar() {
if (head.equals("!")) return new DropNode(walkElement(t.child(0)));
if (head.equals("^")) return new LiteralNode(walkString(t.child(0)), true);
if (head.equals("!")) return new DropNode(walkElement(t.child(0)));
if (head.equals("^")) return new LiteralNode(walkString(t.child(0)), true);
if (head.equals("Quoted")) return stringifyChildren(t);
if (head.equals("Literal")) return new LiteralNode(walkString(t.child(0)));
if (head.equals("->")) return walkSeq(t.child(0)).follow(walkElement(t.child(1)));
if (head.equals("Quoted")) return stringifyChildren(t);
if (head.equals("Literal")) return new LiteralNode(walkString(t.child(0)));
if (head.equals("->")) return walkSeq(t.child(0)).follow(walkElement(t.child(1)));
try {
String newPrefix = t.size()<2 ? "" : (walkString(t.child(1))+".");
FileInputStream fis = new FileInputStream(file);
try {
String newPrefix = t.size()<2 ? "" : (walkString(t.child(1))+".");
FileInputStream fis = new FileInputStream(file);
return (GrammarNode)new GrammarAST(includes, newPrefix).walk(tr);
} catch (Exception e) {
throw new RuntimeException("while parsing " + file, e);
return (GrammarNode)new GrammarAST(includes, newPrefix).walk(tr);
} catch (Exception e) {
throw new RuntimeException("while parsing " + file, e);
public boolean drop(Context cx) { return false; }
public Atom toAtom(Context cx) { throw new Error("can't convert a " + this.getClass().getName() + " to an atom: " + this); }
public abstract Element build(Context cx, NonTerminalNode cnt, boolean dropall);
public boolean drop(Context cx) { return false; }
public Atom toAtom(Context cx) { throw new Error("can't convert a " + this.getClass().getName() + " to an atom: " + this); }
public abstract Element build(Context cx, NonTerminalNode cnt, boolean dropall);
throw new RuntimeException("multiple non-dropped elements in sequence: " + Sequence.create("", els));
boolean[] lifts = new boolean[elements.length];
for(int i=0; i<elements.length; i++)
throw new RuntimeException("multiple non-dropped elements in sequence: " + Sequence.create("", els));
boolean[] lifts = new boolean[elements.length];
for(int i=0; i<elements.length; i++)
public Element build(Context cx, NonTerminalNode cnt, boolean dropall) { return _e.build(cx, cnt, dropall); }
}
public Element build(Context cx, NonTerminalNode cnt, boolean dropall) { return _e.build(cx, cnt, dropall); }
}
private class TildeNode extends ElementNodeWrapper {
public TildeNode(ElementNode e) { super(e); }
public Atom toAtom(Context cx) { return (Atom)((Topology<Character>)_e.toAtom(cx).complement()); }
private class TildeNode extends ElementNodeWrapper {
public TildeNode(ElementNode e) { super(e); }
public Atom toAtom(Context cx) { return (Atom)((Topology<Character>)_e.toAtom(cx).complement()); }