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.

template named(alias r, string name)
named

See Also

defined.

1 alias or!(literal!("abc"), charRange!('0','9')) rule;
2 alias named!(rule, "myRule") myRule;
3 
4 auto input = "abc3";
5 auto p1 = rule(input);
6 auto p2 = myRule(input);
7 
8 // They are both successful
9 assert(p1.successful && p2.successful);
10 assert(p1.matches == p2.matches);
11 // But the names are different
12 assert(p1.name == `or!(literal!("abc"), charRange!('0','9'))`);
13 assert(p2.name == `myRule`);
14 // Same children:
15 assert(p2.children == p1.children);

Meta