From: adam Date: Tue, 4 Mar 2008 05:09:51 +0000 (-0500) Subject: add LabelNode X-Git-Url: http://git.megacz.com/?p=sbp.git;a=commitdiff_plain;h=f95343b3b6e918434ff68924e79df22b9cb074e8 add LabelNode darcs-hash:20080304050951-5007d-9277771831af51cbfee7ab5db853f1d4256db114.gz --- 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 {