X-Git-Url: http://git.megacz.com/?p=sbp.git;a=blobdiff_plain;f=src%2Fedu%2Fberkeley%2Fsbp%2Fmeta%2FGrammarAST.java;fp=src%2Fedu%2Fberkeley%2Fsbp%2Fmeta%2FGrammarAST.java;h=586d519d607defd2cefc7de8d1eefe6c7727c814;hp=e039b372c507da375ee3d425c8b20b9087429da7;hb=f95343b3b6e918434ff68924e79df22b9cb074e8;hpb=8fb8d27ebcaad8074b9d52b31d32406d522e5a57 diff --git a/src/edu/berkeley/sbp/meta/GrammarAST.java b/src/edu/berkeley/sbp/meta/GrammarAST.java index e039b37..586d519 100644 --- a/src/edu/berkeley/sbp/meta/GrammarAST.java +++ b/src/edu/berkeley/sbp/meta/GrammarAST.java @@ -96,6 +96,7 @@ public class GrammarAST { if (head.equals("Elements")) return new Seq((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)), true); + if (head.equals(":")) return new LabelNode(stringifyChildren(t.child(0)), walkElement(t.child(1))); if (head.equals("::")) return walkSeq(t.child(1)).tag(walkString(t.child(0))); if (head.equals("...")) return new DropNode(new RepeatNode(new TildeNode(new AtomNode()), null, true, true, false)); @@ -546,6 +547,12 @@ public class GrammarAST { public boolean isDropped(Context cx) { return true; } } + /** provides a label on the fields of a Seq */ + private class LabelNode extends ElementNodeWrapper { + public final String label; + public LabelNode(String label, ElementNode e) { super(e); this.label = label; } + } + ////////////////////////////////////////////////////////////////////////////// public class Context {