named

Internal helper template, to get a parse tree node with a name. For example, given:

alias or!(literal!("abc"), charRange!('0','9')) myRule;

myRule gives nodes named "or", since its the parent rule. If you want nodes to be named "myRule", use named. named just overwrites the original root node name, the children are left untouched.

  1. ParseTree named(ParseTree p)
    template named(alias r, string name)
  2. ParseTree named(string input)
  3. string named(GetName g)

Members

Functions

named
ParseTree named(ParseTree p)
Undocumented in source. Be warned that the author may not have intended to support it.
named
ParseTree named(string input)
Undocumented in source. Be warned that the author may not have intended to support it.
named
string named(GetName g)
Undocumented in source. Be warned that the author may not have intended to support it.

See Also

defined.

alias or!(literal!("abc"), charRange!('0','9')) rule;
alias named!(rule, "myRule") myRule;

auto input = "abc3";
auto p1 = rule(input);
auto p2 = myRule(input);

// They are both successful
assert(p1.successful && p2.successful);
assert(p1.matches == p2.matches);
// But the names are different
assert(p1.name == `or!(literal!("abc"), charRange!('0','9'))`);
assert(p2.name == `myRule`);
// Same children:
assert(p2.children == p1.children);

Meta