__anonymous.enforceMatch

A chainable version of the method. Matches all next characters against the function until it returns false.

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

Parameters

check
Type: Checker

Function to match against.

match
Type: TString

Matched string (output).

Return Value

Type: ParsingStream!T

Self, for chaining.

Throws

MatchException if didn't match anything

Examples

1 auto stream = parsingStream("This is a sentence");
2 ParsingStream.Checker check = a => a.isAlpha;
3 string a, b, c;
4 
5 assertNotThrown(stream
6     .skip.enforceMatch(check, a)
7     .skip.enforceMatch(check, b)
8 );
9 
10 assert(a == "This" && b == "is");
11 
12 // No .skip!
13 assertThrown(stream.enforceMatch(check, c));
14 

Meta