- public MetaClause makeMetaClause(Tree<String> t, Conjunct c) {
- //System.err.println("MetaClause.makeMetaClause("+t+")");
- if (t==null) return new Epsilon();
- if (t.head()==null) return new Epsilon();
- if (t.head().equals("{")) return new MetaTree(makeConjunct(t.child(0)));
- if (t.head().equals("*")) return new MetaRepeat(makeMetaClause(t.child(0), c), false, null, true, true);
- if (t.head().equals("+")) return new MetaRepeat(makeMetaClause(t.child(0), c), false, null, false, true);
- if (t.head().equals("?")) return new MetaRepeat(makeMetaClause(t.child(0), c), false, null, true, false);
- if (t.head().equals("**")) return new MetaRepeat(makeMetaClause(t.child(0), c), true, null, true, true);
- if (t.head().equals("++")) return new MetaRepeat(makeMetaClause(t.child(0), c), true, null, false, true);
- if (t.head().equals("*/")) return new MetaRepeat(makeMetaClause(t.child(0), c), false, makeMetaClause(t.child(1), c), true, true);
- if (t.head().equals("+/")) return new MetaRepeat(makeMetaClause(t.child(0), c), false, makeMetaClause(t.child(1), c), false, true);
- if (t.head().equals("**/")) return new MetaRepeat(makeMetaClause(t.child(0), c), true, makeMetaClause(t.child(1), c), true, true);
- if (t.head().equals("++/")) return new MetaRepeat(makeMetaClause(t.child(0), c), true, makeMetaClause(t.child(1), c), false, true);
- if (t.head().equals("()")) return new Epsilon();
- if (t.head().equals("[")) return new MetaRange(t.child(0));
- if (t.head().equals("literal")) return new StringLiteral(t.child(0));
- if (t.head().equals("nonTerminal")) return new NonTerminalReference(t.child(0));
- if (t.head().equals(")")) return new SelfReference();
- if (t.head().equals("(")) return new Parens(t.child(0));
- if (t.head().equals("~")) return new MetaInvert(t.child(0), c);
- if (t.head().equals("!")) { MetaClause mc = makeMetaClause(t.child(0), c); mc.drop = true; return mc; }
- if (t.head().equals("^")) { c.tag = string(t.child(0)); return new StringLiteral(t.child(0)); }
- if (t.head().equals("^^")) throw new Error("carets: " + t);
- if (t.head().equals(":")) {
- String name = string(t.child(0));
- MetaClause clause = makeMetaClause(t.child(1), c);
- c.addNamedClause(name, clause);
- return clause;
- }
- throw new Error("unknown: " + t);
- }