__anonymous.enforceMatch

Match all next characters against the function until it returns false.

  1. TString enforceMatch(Checker check)
    struct __anonymous
    TString
    enforceMatch
    (
    Checker check
    )
  2. ParsingStream!T enforceMatch(Checker check, out TString match)

Parameters

check
Type: Checker

Function to match against.

Return Value

Type: TString

All matched characters.

Throws

MatchException if didn't match anything

Examples

1 auto stream = parsingStream("This is a sentence");
2 ParsingStream.Checker check = a => a.isAlpha;
3 
4 
5 assert(stream.enforceMatch(check) == "This");
6 
7 // Will fail, there is some whitespace before — remember to skip()!
8 assertThrown(stream.enforceMatch(check));
9 
10 assert(stream.skip.enforceMatch(check) == "is");
11 

Meta