Header menu logo XParsec.ActiveParsers

CharPatterns Module

Active patterns over a Cursor{T,S,I} of characters: the parsers of XParsec.CharParsers as patterns, and Until and Delimited.

Use them as the arms of a match, nesting a pattern in the cursor another binds:

 match cursor with
 | PString "//" (Until "\n" (comment, next)) -> ...
 | PChar '"' (Until "\"" (text, next)) -> ...
val comment: obj
val next: obj

A pattern's arguments are evaluated each time the pattern is tried. The AnyString... patterns build a lookup from their strings each time; in a hot loop, build the parser once with CharParsers.anyString and match it with Parsed.

Active patterns

Active pattern Description

(|AnyChar|_|) cursor

Full Usage: (|AnyChar|_|) cursor

Parameters:
    cursor : Cursor<char, 'State, 'Input>

Returns: (char * Cursor<char, 'State, 'Input>) voption
Modifiers: inline
Type parameters: 'State, 'Input

Matches any character, as anyChar; binds it and the cursor after it.

cursor : Cursor<char, 'State, 'Input>
Returns: (char * Cursor<char, 'State, 'Input>) voption

(|AnyStringByReturn|_|) comparison xs cursor

Full Usage: (|AnyStringByReturn|_|) comparison xs cursor

Parameters:
Returns: ('A * Cursor<char, 'State, 'Input>) voption
Modifiers: inline
Type parameters: 'A, 'State, 'Input

Matches the longest of the strings of xs compared with comparison, as anyStringByReturn; binds the value paired with it and the cursor after it.

comparison : StringComparison
xs : (string * 'A) seq
cursor : Cursor<char, 'State, 'Input>
Returns: ('A * Cursor<char, 'State, 'Input>) voption

(|AnyStringBy|_|) comparison xs cursor

Full Usage: (|AnyStringBy|_|) comparison xs cursor

Parameters:
Returns: (string * Cursor<char, 'State, 'Input>) voption
Modifiers: inline
Type parameters: 'State, 'Input

Matches the longest of the strings xs compared with comparison, as anyStringBy; binds the string of xs and the cursor after it.

comparison : StringComparison
xs : string seq
cursor : Cursor<char, 'State, 'Input>
Returns: (string * Cursor<char, 'State, 'Input>) voption

(|AnyStringCIReturn|_|) xs cursor

Full Usage: (|AnyStringCIReturn|_|) xs cursor

Parameters:
    xs : (string * 'A) seq
    cursor : Cursor<char, 'State, 'Input>

Returns: ('A * Cursor<char, 'State, 'Input>) voption
Modifiers: inline
Type parameters: 'A, 'State, 'Input

Matches the longest of the strings of xs ignoring case, as anyStringCIReturn; binds the value paired with it and the cursor after it.

xs : (string * 'A) seq
cursor : Cursor<char, 'State, 'Input>
Returns: ('A * Cursor<char, 'State, 'Input>) voption

(|AnyStringCI|_|) xs cursor

Full Usage: (|AnyStringCI|_|) xs cursor

Parameters:
    xs : string seq
    cursor : Cursor<char, 'State, 'Input>

Returns: (string * Cursor<char, 'State, 'Input>) voption
Modifiers: inline
Type parameters: 'State, 'Input

Matches the longest of the strings xs ignoring case, as anyStringCI; binds the string of xs and the cursor after it.

xs : string seq
cursor : Cursor<char, 'State, 'Input>
Returns: (string * Cursor<char, 'State, 'Input>) voption

(|AnyStringReturn|_|) xs cursor

Full Usage: (|AnyStringReturn|_|) xs cursor

Parameters:
    xs : (string * 'A) seq
    cursor : Cursor<char, 'State, 'Input>

Returns: ('A * Cursor<char, 'State, 'Input>) voption
Modifiers: inline
Type parameters: 'A, 'State, 'Input

Matches the longest of the strings of xs, as anyStringReturn; binds the value paired with it and the cursor after it.

xs : (string * 'A) seq
cursor : Cursor<char, 'State, 'Input>
Returns: ('A * Cursor<char, 'State, 'Input>) voption

(|AnyString|_|) xs cursor

Full Usage: (|AnyString|_|) xs cursor

Parameters:
    xs : string seq
    cursor : Cursor<char, 'State, 'Input>

Returns: (string * Cursor<char, 'State, 'Input>) voption
Modifiers: inline
Type parameters: 'State, 'Input

Matches the longest of the strings xs, as anyString; binds it and the cursor after it.

xs : string seq
cursor : Cursor<char, 'State, 'Input>
Returns: (string * Cursor<char, 'State, 'Input>) voption

(|AsciiLetter|_|) cursor

Full Usage: (|AsciiLetter|_|) cursor

Parameters:
    cursor : Cursor<char, 'State, 'Input>

Returns: (char * Cursor<char, 'State, 'Input>) voption
Modifiers: inline
Type parameters: 'State, 'Input

Matches an ASCII letter, as asciiLetter; binds it and the cursor after it.

cursor : Cursor<char, 'State, 'Input>
Returns: (char * Cursor<char, 'State, 'Input>) voption

(|Delimited|_|) delimiter cursor

Full Usage: (|Delimited|_|) delimiter cursor

Parameters:
    delimiter : string
    cursor : Cursor<char, 'State, 'Input>

Returns: (string * Cursor<char, 'State, 'Input>) voption

Matches delimiter, the text up to the next delimiter, and that delimiter; binds the text between them and the cursor after the closing delimiter.

delimiter : string
cursor : Cursor<char, 'State, 'Input>
Returns: (string * Cursor<char, 'State, 'Input>) voption

(|Digit|_|) cursor

Full Usage: (|Digit|_|) cursor

Parameters:
    cursor : Cursor<char, 'State, 'Input>

Returns: (char * Cursor<char, 'State, 'Input>) voption
Modifiers: inline
Type parameters: 'State, 'Input

Matches an ASCII digit, as digit; binds it and the cursor after it.

cursor : Cursor<char, 'State, 'Input>
Returns: (char * Cursor<char, 'State, 'Input>) voption

(|Many1Chars2|_|) first p cursor

Full Usage: (|Many1Chars2|_|) first p cursor

Parameters:
    first : Parser<char, char, 'State, 'Input>
    p : Parser<char, char, 'State, 'Input>
    cursor : Cursor<char, 'State, 'Input>

Returns: (string * Cursor<char, 'State, 'Input>) voption
Modifiers: inline
Type parameters: 'State, 'Input

Matches the parser first, then p zero or more times, as many1Chars2; binds the characters as a string and the cursor after them.

first : Parser<char, char, 'State, 'Input>
p : Parser<char, char, 'State, 'Input>
cursor : Cursor<char, 'State, 'Input>
Returns: (string * Cursor<char, 'State, 'Input>) voption

(|Many1Chars|_|) p cursor

Full Usage: (|Many1Chars|_|) p cursor

Parameters:
    p : Parser<char, char, 'State, 'Input>
    cursor : Cursor<char, 'State, 'Input>

Returns: (string * Cursor<char, 'State, 'Input>) voption
Modifiers: inline
Type parameters: 'State, 'Input

Matches the parser p one or more times, as many1Chars; binds the characters as a string and the cursor after them.

p : Parser<char, char, 'State, 'Input>
cursor : Cursor<char, 'State, 'Input>
Returns: (string * Cursor<char, 'State, 'Input>) voption

(|ManyCharsTill|_|) p pEnd cursor

Full Usage: (|ManyCharsTill|_|) p pEnd cursor

Parameters:
    p : Parser<'A, char, 'State, 'Input>
    pEnd : Parser<'B, char, 'State, 'Input>
    cursor : Cursor<char, 'State, 'Input>

Returns: ((string * 'B) * Cursor<char, 'State, 'Input>) voption
Modifiers: inline
Type parameters: 'A, 'State, 'Input, 'B

Matches the parser p until the parser pEnd matches, as manyCharsTill; binds the characters as a string with the value of pEnd, and the cursor after pEnd.

p : Parser<'A, char, 'State, 'Input>
pEnd : Parser<'B, char, 'State, 'Input>
cursor : Cursor<char, 'State, 'Input>
Returns: ((string * 'B) * Cursor<char, 'State, 'Input>) voption

(|ManyChars|_|) p cursor

Full Usage: (|ManyChars|_|) p cursor

Parameters:
    p : Parser<char, char, 'State, 'Input>
    cursor : Cursor<char, 'State, 'Input>

Returns: (string * Cursor<char, 'State, 'Input>) voption
Modifiers: inline
Type parameters: 'State, 'Input

Matches the parser p zero or more times, as manyChars; binds the characters as a string and the cursor after them.

p : Parser<char, char, 'State, 'Input>
cursor : Cursor<char, 'State, 'Input>
Returns: (string * Cursor<char, 'State, 'Input>) voption

(|Newline|_|) cursor

Full Usage: (|Newline|_|) cursor

Parameters:
    cursor : Cursor<char, 'State, 'Input>

Returns: Cursor<char, 'State, 'Input> voption
Modifiers: inline
Type parameters: 'State, 'Input

Matches \n, \r or \r\n, as newline; binds the cursor after it.

cursor : Cursor<char, 'State, 'Input>
Returns: Cursor<char, 'State, 'Input> voption

(|PBigInt|_|) cursor

Full Usage: (|PBigInt|_|) cursor

Parameters:
    cursor : Cursor<char, 'State, 'Input>

Returns: (BigInteger * Cursor<char, 'State, 'Input>) voption
Modifiers: inline
Type parameters: 'State, 'Input

Matches an integer of any size, as pbigint; binds it and the cursor after it.

cursor : Cursor<char, 'State, 'Input>
Returns: (BigInteger * Cursor<char, 'State, 'Input>) voption

(|PChar|_|) c cursor

Full Usage: (|PChar|_|) c cursor

Parameters:
    c : char
    cursor : Cursor<char, 'State, 'Input>

Returns: Cursor<char, 'State, 'Input> voption
Modifiers: inline
Type parameters: 'State, 'Input

Matches the character c, as pchar; binds the cursor after it.

c : char
cursor : Cursor<char, 'State, 'Input>
Returns: Cursor<char, 'State, 'Input> voption

(|PFloat|_|) cursor

Full Usage: (|PFloat|_|) cursor

Parameters:
    cursor : Cursor<char, 'State, 'Input>

Returns: (float * Cursor<char, 'State, 'Input>) voption
Modifiers: inline
Type parameters: 'State, 'Input

Matches a floating-point number, as pfloat; binds it and the cursor after it.

cursor : Cursor<char, 'State, 'Input>
Returns: (float * Cursor<char, 'State, 'Input>) voption

(|PInt16|_|) cursor

Full Usage: (|PInt16|_|) cursor

Parameters:
    cursor : Cursor<char, 'State, 'Input>

Returns: (int16 * Cursor<char, 'State, 'Input>) voption
Modifiers: inline
Type parameters: 'State, 'Input

Matches a signed 16-bit integer, as pint16; binds it and the cursor after it.

cursor : Cursor<char, 'State, 'Input>
Returns: (int16 * Cursor<char, 'State, 'Input>) voption

(|PInt32|_|) cursor

Full Usage: (|PInt32|_|) cursor

Parameters:
    cursor : Cursor<char, 'State, 'Input>

Returns: (int * Cursor<char, 'State, 'Input>) voption
Modifiers: inline
Type parameters: 'State, 'Input

Matches a signed 32-bit integer, as pint32; binds it and the cursor after it.

cursor : Cursor<char, 'State, 'Input>
Returns: (int * Cursor<char, 'State, 'Input>) voption

(|PInt64|_|) cursor

Full Usage: (|PInt64|_|) cursor

Parameters:
    cursor : Cursor<char, 'State, 'Input>

Returns: (int64 * Cursor<char, 'State, 'Input>) voption
Modifiers: inline
Type parameters: 'State, 'Input

Matches a signed 64-bit integer, as pint64; binds it and the cursor after it.

cursor : Cursor<char, 'State, 'Input>
Returns: (int64 * Cursor<char, 'State, 'Input>) voption

(|PInt8|_|) cursor

Full Usage: (|PInt8|_|) cursor

Parameters:
    cursor : Cursor<char, 'State, 'Input>

Returns: (int8 * Cursor<char, 'State, 'Input>) voption
Modifiers: inline
Type parameters: 'State, 'Input

Matches a signed 8-bit integer, as pint8; binds it and the cursor after it.

cursor : Cursor<char, 'State, 'Input>
Returns: (int8 * Cursor<char, 'State, 'Input>) voption

(|PStringCI|_|) s cursor

Full Usage: (|PStringCI|_|) s cursor

Parameters:
    s : string
    cursor : Cursor<char, 'State, 'Input>

Returns: Cursor<char, 'State, 'Input> voption
Modifiers: inline
Type parameters: 'State, 'Input

Matches the string s ignoring case, as stringCIReturn; binds the cursor after it.

s : string
cursor : Cursor<char, 'State, 'Input>
Returns: Cursor<char, 'State, 'Input> voption

(|PString|_|) s cursor

Full Usage: (|PString|_|) s cursor

Parameters:
    s : string
    cursor : Cursor<char, 'State, 'Input>

Returns: Cursor<char, 'State, 'Input> voption
Modifiers: inline
Type parameters: 'State, 'Input

Matches the string s, as pstring; binds the cursor after it. An empty s always matches.

s : string
cursor : Cursor<char, 'State, 'Input>
Returns: Cursor<char, 'State, 'Input> voption

(|PUInt16|_|) cursor

Full Usage: (|PUInt16|_|) cursor

Parameters:
    cursor : Cursor<char, 'State, 'Input>

Returns: (uint16 * Cursor<char, 'State, 'Input>) voption
Modifiers: inline
Type parameters: 'State, 'Input

Matches an unsigned 16-bit integer, as puint16; binds it and the cursor after it.

cursor : Cursor<char, 'State, 'Input>
Returns: (uint16 * Cursor<char, 'State, 'Input>) voption

(|PUInt32|_|) cursor

Full Usage: (|PUInt32|_|) cursor

Parameters:
    cursor : Cursor<char, 'State, 'Input>

Returns: (uint32 * Cursor<char, 'State, 'Input>) voption
Modifiers: inline
Type parameters: 'State, 'Input

Matches an unsigned 32-bit integer, as puint32; binds it and the cursor after it.

cursor : Cursor<char, 'State, 'Input>
Returns: (uint32 * Cursor<char, 'State, 'Input>) voption

(|PUInt64|_|) cursor

Full Usage: (|PUInt64|_|) cursor

Parameters:
    cursor : Cursor<char, 'State, 'Input>

Returns: (uint64 * Cursor<char, 'State, 'Input>) voption
Modifiers: inline
Type parameters: 'State, 'Input

Matches an unsigned 64-bit integer, as puint64; binds it and the cursor after it.

cursor : Cursor<char, 'State, 'Input>
Returns: (uint64 * Cursor<char, 'State, 'Input>) voption

(|PUInt8|_|) cursor

Full Usage: (|PUInt8|_|) cursor

Parameters:
    cursor : Cursor<char, 'State, 'Input>

Returns: (uint8 * Cursor<char, 'State, 'Input>) voption
Modifiers: inline
Type parameters: 'State, 'Input

Matches an unsigned 8-bit integer, as puint8; binds it and the cursor after it.

cursor : Cursor<char, 'State, 'Input>
Returns: (uint8 * Cursor<char, 'State, 'Input>) voption

(|Spaces1|_|) cursor

Full Usage: (|Spaces1|_|) cursor

Parameters:
    cursor : Cursor<char, 'State, 'Input>

Returns: Cursor<char, 'State, 'Input> voption
Modifiers: inline
Type parameters: 'State, 'Input

Matches one or more whitespace characters, as spaces1; binds the cursor after them.

cursor : Cursor<char, 'State, 'Input>
Returns: Cursor<char, 'State, 'Input> voption

(|Spaces|_|) cursor

Full Usage: (|Spaces|_|) cursor

Parameters:
    cursor : Cursor<char, 'State, 'Input>

Returns: Cursor<char, 'State, 'Input> voption
Modifiers: inline
Type parameters: 'State, 'Input

Matches zero or more whitespace characters, as spaces; binds the cursor after them.

cursor : Cursor<char, 'State, 'Input>
Returns: Cursor<char, 'State, 'Input> voption

(|Until|_|) delimiter cursor

Full Usage: (|Until|_|) delimiter cursor

Parameters:
    delimiter : string
    cursor : Cursor<char, 'State, 'Input>

Returns: (string * Cursor<char, 'State, 'Input>) voption

Matches the text up to the first delimiter and the delimiter; binds the text without the delimiter and the cursor after the delimiter. Does not match when the delimiter is missing.

delimiter : string
cursor : Cursor<char, 'State, 'Input>
Returns: (string * Cursor<char, 'State, 'Input>) voption

Type something to start searching.