Header menu logo XParsec.ActiveParsers

CombinatorPatterns Module

The combinators of XParsec.Combinators as active patterns. Each takes XParsec parsers, as its combinator does, runs the combinator, and binds its value and the cursor after it.

The combinators that a match already expresses have no pattern: nest patterns to sequence parsers (>>., .>>, .>>., tuple2, pipe2, bind), map the value in the arm (|>>, >>%), write alternatives as arms (<|>, <|>%), and match the next item for dispatch. Patterns carry no error, so the labels (<?>, choiceL, followedByL, ...) have none either; ignore the value of a pattern for the skip... combinators.

To run an active parser with a combinator, turn it into a parser with ActiveParser.toParser.

Active patterns

Active pattern Description

(|Between|_|) pOpen pClose p cursor

Full Usage: (|Between|_|) pOpen pClose p cursor

Parameters:
    pOpen : Parser<'A, 'T, 'State, 'Input>
    pClose : Parser<'B, 'T, 'State, 'Input>
    p : Parser<'C, 'T, 'State, 'Input>
    cursor : Cursor<'T, 'State, 'Input>

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

Matches pOpen, p and pClose, as between; binds the value of p.

pOpen : Parser<'A, 'T, 'State, 'Input>
pClose : Parser<'B, 'T, 'State, 'Input>
p : Parser<'C, 'T, 'State, 'Input>
cursor : Cursor<'T, 'State, 'Input>
Returns: ('C * Cursor<'T, 'State, 'Input>) voption

(|Chainl1|_|) p pOp cursor

Full Usage: (|Chainl1|_|) p pOp cursor

Parameters:
    p : Parser<'A, 'T, 'State, 'Input>
    pOp : Parser<('A -> 'A -> 'A), 'T, 'State, 'Input>
    cursor : Cursor<'T, 'State, 'Input>

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

Matches p one or more times separated by pOp, as chainl1; binds the values combined by the operators, left-associative.

p : Parser<'A, 'T, 'State, 'Input>
pOp : Parser<('A -> 'A -> 'A), 'T, 'State, 'Input>
cursor : Cursor<'T, 'State, 'Input>
Returns: ('A * Cursor<'T, 'State, 'Input>) voption

(|Chainl|_|) p pOp orElse cursor

Full Usage: (|Chainl|_|) p pOp orElse cursor

Parameters:
    p : Parser<'A, 'T, 'State, 'Input>
    pOp : Parser<('A -> 'A -> 'A), 'T, 'State, 'Input>
    orElse : 'A
    cursor : Cursor<'T, 'State, 'Input>

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

As Chainl1, or binds orElse when p fails at once, as chainl. Always matches.

p : Parser<'A, 'T, 'State, 'Input>
pOp : Parser<('A -> 'A -> 'A), 'T, 'State, 'Input>
orElse : 'A
cursor : Cursor<'T, 'State, 'Input>
Returns: ('A * Cursor<'T, 'State, 'Input>) voption

(|Chainr1|_|) p pOp cursor

Full Usage: (|Chainr1|_|) p pOp cursor

Parameters:
    p : Parser<'A, 'T, 'State, 'Input>
    pOp : Parser<('A -> 'A -> 'A), 'T, 'State, 'Input>
    cursor : Cursor<'T, 'State, 'Input>

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

Matches p one or more times separated by pOp, as chainr1; binds the values combined by the operators, right-associative.

p : Parser<'A, 'T, 'State, 'Input>
pOp : Parser<('A -> 'A -> 'A), 'T, 'State, 'Input>
cursor : Cursor<'T, 'State, 'Input>
Returns: ('A * Cursor<'T, 'State, 'Input>) voption

(|Chainr|_|) p pOp orElse cursor

Full Usage: (|Chainr|_|) p pOp orElse cursor

Parameters:
    p : Parser<'A, 'T, 'State, 'Input>
    pOp : Parser<('A -> 'A -> 'A), 'T, 'State, 'Input>
    orElse : 'A
    cursor : Cursor<'T, 'State, 'Input>

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

As Chainr1, or binds orElse when p fails at once, as chainr. Always matches.

p : Parser<'A, 'T, 'State, 'Input>
pOp : Parser<('A -> 'A -> 'A), 'T, 'State, 'Input>
orElse : 'A
cursor : Cursor<'T, 'State, 'Input>
Returns: ('A * Cursor<'T, 'State, 'Input>) voption

(|Choice|_|) ps cursor

Full Usage: (|Choice|_|) ps cursor

Parameters:
    ps : Parser<'A, 'T, 'State, 'Input> seq
    cursor : Cursor<'T, 'State, 'Input>

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

Matches the first of the parsers ps that succeeds, as choice.

ps : Parser<'A, 'T, 'State, 'Input> seq
cursor : Cursor<'T, 'State, 'Input>
Returns: ('A * Cursor<'T, 'State, 'Input>) voption

(|CountMany1Satisfies|_|) predicate cursor

Full Usage: (|CountMany1Satisfies|_|) predicate cursor

Parameters:
    predicate : 'T -> bool
    cursor : Cursor<'T, 'State, 'Input>

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

Matches one or more items that satisfy predicate, as countMany1Satisfies; binds their count.

predicate : 'T -> bool
cursor : Cursor<'T, 'State, 'Input>
Returns: (int64 * Cursor<'T, 'State, 'Input>) voption

(|CountManySatisfies|_|) predicate cursor

Full Usage: (|CountManySatisfies|_|) predicate cursor

Parameters:
    predicate : 'T -> bool
    cursor : Cursor<'T, 'State, 'Input>

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

Matches zero or more items that satisfy predicate, as countManySatisfies; binds their count. Always matches.

predicate : 'T -> bool
cursor : Cursor<'T, 'State, 'Input>
Returns: (int64 * Cursor<'T, 'State, 'Input>) voption

(|FollowedBy|_|) p cursor

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

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

Returns: unit voption
Modifiers: inline
Type parameters: 'A, 'T, 'State, 'Input

Matches when p would succeed, as followedBy, without consuming input.

p : Parser<'A, 'T, 'State, 'Input>
cursor : Cursor<'T, 'State, 'Input>
Returns: unit voption

(|LookAhead|_|) p cursor

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

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

Returns: 'A voption
Modifiers: inline
Type parameters: 'A, 'T, 'State, 'Input

Matches when p would succeed, as lookAhead, without consuming input; binds its value only.

p : Parser<'A, 'T, 'State, 'Input>
cursor : Cursor<'T, 'State, 'Input>
Returns: 'A voption

(|Many1Items2|_|) p1 p cursor

Full Usage: (|Many1Items2|_|) p1 p cursor

Parameters:
    p1 : Parser<'A, 'T, 'State, 'Input>
    p : Parser<'A, 'T, 'State, 'Input>
    cursor : Cursor<'T, 'State, 'Input>

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

Matches p1, then p zero or more times, as many1Items2; binds their values.

p1 : Parser<'A, 'T, 'State, 'Input>
p : Parser<'A, 'T, 'State, 'Input>
cursor : Cursor<'T, 'State, 'Input>
Returns: (ImmutableArray<'A> * Cursor<'T, 'State, 'Input>) voption

(|Many1Till|_|) p pEnd cursor

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

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

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

Matches p one or more times until pEnd, as many1Till; binds struct (values, endValue).

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

(|Many1|_|) p cursor

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

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

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

Matches p one or more times, as many1; binds its values.

p : Parser<'A, 'T, 'State, 'Input>
cursor : Cursor<'T, 'State, 'Input>
Returns: (ImmutableArray<'A> * Cursor<'T, 'State, 'Input>) voption

(|ManyTill|_|) p pEnd cursor

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

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

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

Matches p zero or more times until pEnd, as manyTill; binds struct (values, endValue).

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

(|Many|_|) p cursor

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

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

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

Matches p zero or more times, as many; binds its values. Always matches.

p : Parser<'A, 'T, 'State, 'Input>
cursor : Cursor<'T, 'State, 'Input>
Returns: (ImmutableArray<'A> * Cursor<'T, 'State, 'Input>) voption

(|NotEmpty|_|) p cursor

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

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

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

Matches p when it consumes input, as notEmpty.

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

(|NotFollowedBy|_|) p cursor

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

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

Returns: unit voption
Modifiers: inline
Type parameters: 'A, 'T, 'State, 'Input

Matches when p would fail, as notFollowedBy, without consuming input.

p : Parser<'A, 'T, 'State, 'Input>
cursor : Cursor<'T, 'State, 'Input>
Returns: unit voption

(|Optional|_|) p cursor

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

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

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

Matches p if it succeeds, as optional; binds the cursor after it. Always matches.

p : Parser<'A, 'T, 'State, 'Input>
cursor : Cursor<'T, 'State, 'Input>
Returns: Cursor<'T, 'State, 'Input> voption

(|Opt|_|) p cursor

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

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

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

Matches p if it succeeds, as opt; binds ValueSome of its value, or ValueNone and the cursor unchanged. Always matches.

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

(|PArray|_|) n p cursor

Full Usage: (|PArray|_|) n p cursor

Parameters:
    n : int
    p : Parser<'A, 'T, 'State, 'Input>
    cursor : Cursor<'T, 'State, 'Input>

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

Matches p exactly n times, as parray; binds its values.

n : int
p : Parser<'A, 'T, 'State, 'Input>
cursor : Cursor<'T, 'State, 'Input>
Returns: (ImmutableArray<'A> * Cursor<'T, 'State, 'Input>) voption

(|SepBy1|_|) p pSep cursor

Full Usage: (|SepBy1|_|) p pSep cursor

Parameters:
    p : Parser<'A, 'T, 'State, 'Input>
    pSep : Parser<'B, 'T, 'State, 'Input>
    cursor : Cursor<'T, 'State, 'Input>

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

Matches p one or more times separated by pSep, as sepBy1; binds struct (values, separators).

p : Parser<'A, 'T, 'State, 'Input>
pSep : Parser<'B, 'T, 'State, 'Input>
cursor : Cursor<'T, 'State, 'Input>
Returns: ((ImmutableArray<'A> * ImmutableArray<'B>) * Cursor<'T, 'State, 'Input>) voption

(|SepBy|_|) p pSep cursor

Full Usage: (|SepBy|_|) p pSep cursor

Parameters:
    p : Parser<'A, 'T, 'State, 'Input>
    pSep : Parser<'B, 'T, 'State, 'Input>
    cursor : Cursor<'T, 'State, 'Input>

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

Matches p zero or more times separated by pSep, as sepBy; binds struct (values, separators). Always matches.

p : Parser<'A, 'T, 'State, 'Input>
pSep : Parser<'B, 'T, 'State, 'Input>
cursor : Cursor<'T, 'State, 'Input>
Returns: ((ImmutableArray<'A> * ImmutableArray<'B>) * Cursor<'T, 'State, 'Input>) voption

(|SepEndBy1|_|) p pSep cursor

Full Usage: (|SepEndBy1|_|) p pSep cursor

Parameters:
    p : Parser<'A, 'T, 'State, 'Input>
    pSep : Parser<'B, 'T, 'State, 'Input>
    cursor : Cursor<'T, 'State, 'Input>

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

Matches p one or more times separated and optionally ended by pSep, as sepEndBy1; binds struct (values, separators).

p : Parser<'A, 'T, 'State, 'Input>
pSep : Parser<'B, 'T, 'State, 'Input>
cursor : Cursor<'T, 'State, 'Input>
Returns: ((ImmutableArray<'A> * ImmutableArray<'B>) * Cursor<'T, 'State, 'Input>) voption

(|SepEndBy|_|) p pSep cursor

Full Usage: (|SepEndBy|_|) p pSep cursor

Parameters:
    p : Parser<'A, 'T, 'State, 'Input>
    pSep : Parser<'B, 'T, 'State, 'Input>
    cursor : Cursor<'T, 'State, 'Input>

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

Matches p zero or more times separated and optionally ended by pSep, as sepEndBy; binds struct (values, separators). Always matches.

p : Parser<'A, 'T, 'State, 'Input>
pSep : Parser<'B, 'T, 'State, 'Input>
cursor : Cursor<'T, 'State, 'Input>
Returns: ((ImmutableArray<'A> * ImmutableArray<'B>) * Cursor<'T, 'State, 'Input>) voption

Type something to start searching.