The parser to match against.
If yes then allow partial matches, otherwise only allow full matches.
true if there was a full or partial (if allowed) match, otherwise false.
If a partial match is allowed, and a partial match is found before a valid full match is found, then only the partial match is returned.
// Test empty parsers. auto parser = ArgPullParser([]); assert(!Pattern("v").matchSpacefull(parser)); // Test that the parser's position is moved forward correctly. parser = ArgPullParser(["v", "verbose"]); assert(Pattern("v").matchSpacefull(parser)); assert(Pattern("verbose").matchSpacefull(parser)); assert(parser.empty); // Test that a parser that fails to match isn't moved forward at all. parser = ArgPullParser(["v", "verbose"]); assert(!Pattern("lel").matchSpacefull(parser)); assert(parser.front.value == "v"); // Test that a pattern with spaces works. parser = ArgPullParser(["give", "me", "chocolate"]); assert(Pattern("give me").matchSpacefull(parser)); assert(parser.front.value == "chocolate"); // Test that multiple patterns work. parser = ArgPullParser(["v", "verbose"]); assert(Pattern("lel|v|verbose").matchSpacefull(parser)); assert(Pattern("lel|v|verbose").matchSpacefull(parser)); assert(parser.empty);
Advances the given token parser in an attempt to match with any of this pattern's subpatterns.
Description: On successful or partial match (if allowPartial is yes) the given parser will be advanced to the first token that is not part of the match.
e.g. For the pattern ("hey there"), if you matched it with the tokens ["hey", "there", "me"], the resulting parser would only have ["me"] left.
On a failed match, the given parser is left unmodified.