projects
/
sbp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
add LabelNode
[sbp.git]
/
src
/
edu
/
berkeley
/
sbp
/
meta
/
GrammarAST.java
diff --git
a/src/edu/berkeley/sbp/meta/GrammarAST.java
b/src/edu/berkeley/sbp/meta/GrammarAST.java
index
e039b37
..
586d519
100644
(file)
--- 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("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));
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; }
}
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 {
//////////////////////////////////////////////////////////////////////////////
public class Context {