Header menu logo XParsec.ActiveParsers

Patterns Module

Active patterns over a Cursor{T,S,I} for any item type: the parsers of XParsec.Parsers as patterns, and patterns to run other parsers.

A pattern that parses a value binds the value and the cursor after it, Name (value, next); a pattern that only consumes input binds the cursor after it, Name next. Nest a pattern in next to parse what follows:

 | Item '(' (Parsed expr (e, Item ')' next)) -> ValueSome(e, next)
union case ValueOption.ValueSome: 'T -> ValueOption<'T>

Each pattern named after an XParsec parser runs that parser, so it matches exactly what the parser accepts. The ...Return, ...L and skip... variants have no pattern of their own: return the value from the arm, label the parser built with ActiveParser.toParserL, and ignore the value bound by the pattern.

Active patterns

Active pattern Description

(|Active|_|) p cursor

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

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

Matches when the active parser p matches; binds its value and the cursor after it.

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

(|AnyItem|_|) cursor

Full Usage: (|AnyItem|_|) cursor

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

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

Matches any item, as pid; binds it and the cursor after it.

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

(|AnyOf|_|) xs cursor

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

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

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

Matches one of the items xs, as anyOf; binds it and the cursor after it.

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

(|EOF|_|) cursor

Full Usage: (|EOF|_|) cursor

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

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

Matches the end of the input, as eof.

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

(|InRange|_|) xMin xMax cursor

Full Usage: (|InRange|_|) xMin xMax cursor

Parameters:
    xMin : 'T
    xMax : 'T
    cursor : Cursor<'T, 'State, 'Input>

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

Matches an item between xMin and xMax inclusive, as anyInRange; binds it and the cursor after it.

xMin : 'T
xMax : 'T
cursor : Cursor<'T, 'State, 'Input>
Returns: ('T * Cursor<'T, 'State, 'Input>) voption

(|ItemSeq|_|) xs cursor

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

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

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

Matches the items of xs in order, as pseq; binds the cursor after them. An empty xs always matches.

xs : 'T seq
cursor : Cursor<'T, 'State, 'Input>
Returns: Cursor<'T, 'State, 'Input> voption

(|Item|_|) x cursor

Full Usage: (|Item|_|) x cursor

Parameters:
    x : 'T
    cursor : Cursor<'T, 'State, 'Input>

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

Matches the item x, as pitem; binds the cursor after it.

x : 'T
cursor : Cursor<'T, 'State, 'Input>
Returns: Cursor<'T, 'State, 'Input> voption

(|NoneOf|_|) xs cursor

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

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

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

Matches an item that is none of xs, as noneOf; binds it and the cursor after it.

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

(|Parsed|_|) p cursor

Full Usage: (|Parsed|_|) 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 when the XParsec parser p succeeds; binds its value and the cursor after it.

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

(|Satisfy|_|) predicate cursor

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

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

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

Matches an item that satisfies predicate, as satisfy; binds it and the cursor after it.

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

(|SetUserState|_|) state cursor

Full Usage: (|SetUserState|_|) state cursor

Parameters:
    state : 'State
    cursor : Cursor<'T, 'State, 'Input>

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

Binds the cursor with the user state state, as setUserState. Always matches.

state : 'State
cursor : Cursor<'T, 'State, 'Input>
Returns: Cursor<'T, 'State, 'Input> voption

(|Skipped|_|) p cursor

Full Usage: (|Skipped|_|) 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 when the XParsec parser p succeeds; binds the cursor after it.

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

(|UpdateUserState|_|) mapping cursor

Full Usage: (|UpdateUserState|_|) mapping cursor

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

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

Binds the cursor with the user state changed by mapping, as updateUserState. Always matches.

mapping : 'State -> 'State
cursor : Cursor<'T, 'State, 'Input>
Returns: Cursor<'T, 'State, 'Input> voption

(|UserStateSatisfies|_|) predicate cursor

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

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

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

Matches when the user state satisfies predicate, as userStateSatisfies.

predicate : 'State -> bool
cursor : Cursor<'T, 'State, 'Input>
Returns: unit voption

(|UserState|) cursor

Full Usage: (|UserState|) cursor

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

Returns: 'State

Binds the user state at the cursor, as getUserState. Always matches.

cursor : Cursor<'T, 'State, 'Input>
Returns: 'State

Type something to start searching.