this(MG.class,
new Class[] {
MG.Grammar.class,
- MG.NonTerminal.class,
MG.AnonUn.class,
MG.Range.class,
MG.El.class,
MG.Seq.class,
+ MG.NonTerminal.class,
MG.NonTerminalReference.class,
MG.StringLiteral.class,
MG.XTree.class,
if (c != null && t.equals("") && c.getSimpleName().equals(s)) return true;
return false;
}
+ /*
private boolean match(nonterminal t, Class c, String s) {
if (t==null) return false;
if (t.value().equals(s)) return true;
if (c != null && t.equals("") && c.getSimpleName().equals(s)) return true;
return false;
}
+ */
private boolean match(Class c, String s, String nonTerminalName) {
if (match((tag)c.getAnnotation(tag.class), c, s)) return true;
- if (match((nonterminal)c.getAnnotation(nonterminal.class), c, nonTerminalName)) return true;
+ //if (match((nonterminal)c.getAnnotation(tag.class), c, nonTerminalName)) return true;
return false;
}
public boolean match(Constructor con, String s, String nonTerminalName) {
Class c = con.getDeclaringClass();
if (match((tag)con.getAnnotation(tag.class), null, s)) return true;
- if (match((nonterminal)con.getAnnotation(nonterminal.class), c, s)) return true;
+ //if (match((nonterminal)con.getAnnotation(tag.class), c, s)) return true;
return false;
}
public Object repeatTag() {
* that is arg-compatible. If value() is undefined, then the
* class/constructor/method name is used.
*/
+ /*
@Retention(RetentionPolicy.RUNTIME) public static @interface nonterminal { String value() default ""; }
+ */
@Retention(RetentionPolicy.RUNTIME) public static @interface raw { }
public String getName() { return _bindable.getSimpleName(); }
public tag getTag() { return (tag)_bindable.getAnnotation(tag.class); }
- public nonterminal getNonTerminal() { return (nonterminal)_bindable.getAnnotation(nonterminal.class); }
+ //public nonterminal getNonTerminal() { return (nonterminal)_bindable.getAnnotation(tag.class); }
public String toString() { return _bindable.getSimpleName(); }
public Object plant(Object[] fields) { return _bindable.impose(fields); }
public boolean isRaw() { return _bindable.isAnnotationPresent(raw.class); }
(t.value().equals("") && getName().equals(p.tag))))
return buildSequence(p)!=null;
- nonterminal n = getNonTerminal();
+ tag n = getTag();
if (n != null &&
(n.value().equals(p.nonTerminal) ||
(n.value().equals("") && getName().equals(p.nonTerminal))))
}
public static class NonTerminal extends Un {
public String name = null;
- public @nonterminal("NonTerminal") NonTerminal(@arg("Word") String name,
- @arg("RHS") Seq[][] sequences) {
+ public @tag("=") NonTerminal(@arg("Word") String name,
+ @arg("RHS") Seq[][] sequences) {
this.name = name;
this.sequences = sequences;
}
//public static @tag("(") El subexpression(Seq[][] rhs) { return new NonTerminal(rhs); }
- public static @nonterminal("Word") String word(String s) { return s; }
- public static @nonterminal("Quoted") String quoted(String s) { return s; }
- public static @nonterminal("escaped") String c(char c) { return c+""; }
+ public static @tag("Word") String word(String s) { return s; }
+ public static @tag("Quoted") String quoted(String s) { return s; }
+ public static @tag("escaped") String c(char c) { return c+""; }
public static @tag("\"\"") String emptystring() { return ""; }
public static @tag("\n") String retur() { return "\n"; }
public static @tag("\r") String lf() { return "\r"; }
public static class TD {
- public @nonterminal static class Doc extends Dump {
+ public @tag static class Doc extends Dump {
public @arg Header head;
public @arg Body body;
}
- public @nonterminal static class Header extends Dump {
+ public @tag static class Header extends Dump {
public @arg KeyVal[] attrs;
// FIXME: it would be nice to be able to
// void KeyVal(String, String) { ... } imperatively
}
- public @nonterminal static class Body extends Dump {
+ public @tag static class Body extends Dump {
public Section[] sections;
}
- public @nonterminal("Section") static class Section extends Dump {
+ public @tag("Section") static class Section extends Dump {
public String header;
public Paragraph[] paragraphs;
}
- public @nonterminal static class KeyVal extends Dump {
+ public @tag static class KeyVal extends Dump {
public @arg String key;
public @arg Object val;
}