The engine formerly behind the '< ' Pegged rule: all sequence subelements of a rule are interspersed
with a space-consuming rule, given as the first template parameter. It's not used by Pegged anymore
but can be useful for low-level code. It might become deprecated, but it's not there yet.
1 aliasand!(literal!"abc", literal!"def") rule1; // "abc" "def", equivalent to "abcdef"2 aliasspaceAnd!(oneOrMore!blank, literal!"abc", literal!"def") rule2; // "abc" "def", but with spaces in-between.3 4 stringinput1 = "abcdef";
5 stringinput2 = " abc
6 7 def "; // with spaces and end of line markers.8 9 assert(rule1(input1).successful); // OK10 assert(!rule1(input2).successful); // NOK, couldn't find "def" after "abc"11 12 assert(rule2(input1).successful); // OK13 assert(rule2(input2).successful); // Still OK14 assert(rule2(input2).matches == ["abc","def"]);// rule2 finds the literals among the spaces
As you can see on the previous line, spaceAnd discards the matched spaces
and returns matches only for the 'real' subrules.
Note: by using a non-space rule as the first template argument,
you can use spaceAnd as a generic 'find these patterns, possibly separated by this pattern' rule.
The engine formerly behind the '< ' Pegged rule: all sequence subelements of a rule are interspersed with a space-consuming rule, given as the first template parameter. It's not used by Pegged anymore but can be useful for low-level code. It might become deprecated, but it's not there yet.
As you can see on the previous line, spaceAnd discards the matched spaces and returns matches only for the 'real' subrules.
Note: by using a non-space rule as the first template argument, you can use spaceAnd as a generic 'find these patterns, possibly separated by this pattern' rule.
For example, using digits as separators: