defined

Internal helper template, to get a parse tree node with a name, while keeping the original node (see also named). 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 defined. Contrary to named (see before), the original node is pushed as the child.

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

Members

Functions

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

See Also

named.

alias or!(literal!("abc"), charRange!('0','9')) rule;
alias defined!(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`);
// Here the original tree is not discarded:
assert(p2.children[0] == p1);

Meta