That documentation page could use some love indeed.
The "labels" that are talked about function as optionally declared "names" for two different kinds of things:
- alternative rules of a non-terminal may have a label, as in
syntax E = add: E "+" E | sub: E "-" E;
- symbol positions inside a syntax rule may have a label, as in
syntax E = E lhs "+" E rhs | E lhs "-" E rhs;
Having a label on a rule enables different functionality from having a label on a symbol position.
For rules we get:
myExp is myLabel
; checks to see if the top parse tree node has a syntax rule labeled with that label
ParseTree::implode
uses the rule labels to map concrete parse tree nodes to abstract data tree nodes
- When writing a post-parse disambiguation filter, an Action filter, you must use the alternative name to bind the filter to the proper parsetree node, as in
Exp add(Exp lhs, Exp rhs) { ... }
will be called when constructing syntax Exp = add: Exp "+" Exp;
For symbol positions we get:
myExp has myLabel
; checks to see whether the current parse tree node has a syntax rule where one of the symbol positions is labeled with myLabel
myExp.myLabel
; projects out the tree at the labeled position from given parse tree
myExp.myLabel = newExp
; replaces the tree at the labeled position in the given parse tree