Header menu logo XParsec

CharParsers Module

Defines parsers for characters and strings. These parsers are more optimized for working with strings than the general parsers in `XParsec.Parsers`.

Nested modules

Modules Description

ParseError

Functions and values

Function or value Description

anyChar reader

Full Usage: anyChar reader

Parameters:
    reader : Reader<char, 'State, 'Input, 'InputSlice>

Returns: ParseResult<char, char, 'State>

Succeeds if the Reader position is not at the end of the input, and consumes one char.

reader : Reader<char, 'State, 'Input, 'InputSlice>
Returns: ParseResult<char, char, 'State>

anyOf chars

Full Usage: anyOf chars

Parameters:
    chars : char seq

Returns: Reader<char, 'a, 'b, 'c> -> ParseResult<char, char, 'a>

Matches any of the characters in the given sequence, and returns the character.

chars : char seq
Returns: Reader<char, 'a, 'b, 'c> -> ParseResult<char, char, 'a>

anyString xs

Full Usage: anyString xs

Parameters:
    xs : string seq

Returns: Reader<char, 'a, 'b, 'c> -> ParseResult<string, char, 'a>

Succeeds if the next characters in the reader match any of the given strings (with ordinal comparison), and consumes the characters. Returns the matched string. If no match is found, fails with a detailed error message.

xs : string seq
Returns: Reader<char, 'a, 'b, 'c> -> ParseResult<string, char, 'a>

anyStringBy comp xs

Full Usage: anyStringBy comp xs

Parameters:
Returns: Reader<char, 'a, 'b, 'c> -> ParseResult<string, char, 'a>

Succeeds if the next characters in the reader match any of the given strings (with the given comparison), and consumes the characters. Returns the matched string. If no match is found, fails with a detailed error message.

comp : StringComparison
xs : string seq
Returns: Reader<char, 'a, 'b, 'c> -> ParseResult<string, char, 'a>

anyStringByL comp xs message

Full Usage: anyStringByL comp xs message

Parameters:
Returns: Reader<char, 'a, 'b, 'c> -> ParseResult<string, char, 'a>

Succeeds if the next characters in the reader match any of the given strings (with the given comparison), and consumes the characters. Returns the matched string. If no match is found, fails with the provided message.

comp : StringComparison
xs : string seq
message : string
Returns: Reader<char, 'a, 'b, 'c> -> ParseResult<string, char, 'a>

anyStringByReturn comp xs

Full Usage: anyStringByReturn comp xs

Parameters:
Returns: Reader<char, 'a, 'b, 'c> -> ParseResult<'T, char, 'a>

Succeeds if the next characters in the reader match any of the given strings (with the given comparison), and consumes the characters. Returns the associated result. If no match is found, fails with a detailed error message.

comp : StringComparison
xs : (string * 'T) seq
Returns: Reader<char, 'a, 'b, 'c> -> ParseResult<'T, char, 'a>

anyStringByReturnL comp xs message

Full Usage: anyStringByReturnL comp xs message

Parameters:
Returns: Reader<char, 'a, 'b, 'c> -> ParseResult<'T, char, 'a>

Succeeds if the next characters in the reader match any of the given strings (with the given comparison), and consumes the characters. Returns the associated result. If no match is found, fails with the provided message.

comp : StringComparison
xs : (string * 'T) seq
message : string
Returns: Reader<char, 'a, 'b, 'c> -> ParseResult<'T, char, 'a>

anyStringCI xs

Full Usage: anyStringCI xs

Parameters:
    xs : string seq

Returns: Reader<char, 'a, 'b, 'c> -> ParseResult<string, char, 'a>

Succeeds if the next characters in the reader match any of the given strings (case-insensitive ordinal comparison), and consumes the characters. Returns the matched string. If no match is found, fails with a detailed error message.

xs : string seq
Returns: Reader<char, 'a, 'b, 'c> -> ParseResult<string, char, 'a>

anyStringCIL xs message

Full Usage: anyStringCIL xs message

Parameters:
    xs : string seq
    message : string

Returns: Reader<char, 'a, 'b, 'c> -> ParseResult<string, char, 'a>

Succeeds if the next characters in the reader match any of the given strings (case-insensitive ordinal comparison), and consumes the characters. Returns the matched string. If no match is found, fails with the provided message.

xs : string seq
message : string
Returns: Reader<char, 'a, 'b, 'c> -> ParseResult<string, char, 'a>

anyStringCIReturn xs

Full Usage: anyStringCIReturn xs

Parameters:
    xs : (string * 'T) seq

Returns: Reader<char, 'a, 'b, 'c> -> ParseResult<'T, char, 'a>

Succeeds if the next characters in the reader match any of the given strings (case-insensitive ordinal comparison), and consumes the characters. Returns the associated result. If no match is found, fails with a detailed error message.

xs : (string * 'T) seq
Returns: Reader<char, 'a, 'b, 'c> -> ParseResult<'T, char, 'a>

anyStringCIReturnL xs message

Full Usage: anyStringCIReturnL xs message

Parameters:
    xs : (string * 'T) seq
    message : string

Returns: Reader<char, 'a, 'b, 'c> -> ParseResult<'T, char, 'a>

Succeeds if the next characters in the reader match any of the given strings (case-insensitive ordinal comparison), and consumes the characters. Returns the associated result. If no match is found, fails with the provided message.

xs : (string * 'T) seq
message : string
Returns: Reader<char, 'a, 'b, 'c> -> ParseResult<'T, char, 'a>

anyStringL xs message

Full Usage: anyStringL xs message

Parameters:
    xs : string seq
    message : string

Returns: Reader<char, 'a, 'b, 'c> -> ParseResult<string, char, 'a>

Succeeds if the next characters in the reader match any of the given strings (with ordinal comparison), and consumes the characters. Returns the matched string. If no match is found, fails with the provided message.

xs : string seq
message : string
Returns: Reader<char, 'a, 'b, 'c> -> ParseResult<string, char, 'a>

anyStringReturn xs

Full Usage: anyStringReturn xs

Parameters:
    xs : (string * 'T) seq

Returns: Reader<char, 'a, 'b, 'c> -> ParseResult<'T, char, 'a>

Succeeds if the next characters in the reader match any of the given strings (with ordinal comparison), and consumes the characters. Returns the associated result. If no match is found, fails with a detailed error message.

xs : (string * 'T) seq
Returns: Reader<char, 'a, 'b, 'c> -> ParseResult<'T, char, 'a>

anyStringReturnL xs message

Full Usage: anyStringReturnL xs message

Parameters:
    xs : (string * 'T) seq
    message : string

Returns: Reader<char, 'a, 'b, 'c> -> ParseResult<'T, char, 'a>

Succeeds if the next characters in the reader match any of the given strings (with ordinal comparison), and consumes the characters. Returns the associated result. If no match is found, fails with the provided message.

xs : (string * 'T) seq
message : string
Returns: Reader<char, 'a, 'b, 'c> -> ParseResult<'T, char, 'a>

asciiLetter reader

Full Usage: asciiLetter reader

Parameters:
    reader : Reader<char, 'State, 'Input, 'InputSlice>

Returns: ParseResult<char, char, 'State>

Succeeds if the next character in the reader is an ASCII letter, and consumes one char. Returns the char.

reader : Reader<char, 'State, 'Input, 'InputSlice>
Returns: ParseResult<char, char, 'State>

charReturn c result reader

Full Usage: charReturn c result reader

Parameters:
    c : char
    result : 'a
    reader : Reader<char, 'State, 'Input, 'InputSlice>

Returns: ParseResult<'a, char, 'State>

Succeeds if the next char in the input is equal to the given char, and consumes one char. Returns the `result`, otherwise fails with the Expected char.

c : char
result : 'a
reader : Reader<char, 'State, 'Input, 'InputSlice>
Returns: ParseResult<'a, char, 'State>

digit reader

Full Usage: digit reader

Parameters:
    reader : Reader<char, 'State, 'Input, 'InputSlice>

Returns: ParseResult<char, char, 'State>

Succeeds if the next character in the reader is an ASCII digit, and consumes one char. Returns the char.

reader : Reader<char, 'State, 'Input, 'InputSlice>
Returns: ParseResult<char, char, 'State>

isAsciiLetter c

Full Usage: isAsciiLetter c

Parameters:
    c : char

Returns: bool
c : char
Returns: bool

isDigit c

Full Usage: isDigit c

Parameters:
    c : char

Returns: bool
c : char
Returns: bool

isLetter c

Full Usage: isLetter c

Parameters:
    c : char

Returns: bool
c : char
Returns: bool

many1Chars p1 reader

Full Usage: many1Chars p1 reader

Parameters:
    p1 : Parser<char, char, 'State, 'Input, 'InputSlice>
    reader : Reader<char, 'State, 'Input, 'InputSlice>

Returns: ParseResult<string, char, 'State>

Matches one or more characters that satisfy the given parser `p1`, and returns the string of matched characters. This parser fails if no characters are matched.

p1 : Parser<char, char, 'State, 'Input, 'InputSlice>
reader : Reader<char, 'State, 'Input, 'InputSlice>
Returns: ParseResult<string, char, 'State>

many1Chars2 p1 p reader

Full Usage: many1Chars2 p1 p reader

Parameters:
    p1 : Parser<char, char, 'State, 'Input, 'InputSlice>
    p : Parser<char, char, 'State, 'Input, 'InputSlice>
    reader : Reader<char, 'State, 'Input, 'InputSlice>

Returns: ParseResult<string, char, 'State>

Matches one character that satisfies the parser `p1`, and then zero or more characters that satisfy the parser `p`. Returns the string of matched characters. This parser fails if no characters are matched by `p1`.

p1 : Parser<char, char, 'State, 'Input, 'InputSlice>
p : Parser<char, char, 'State, 'Input, 'InputSlice>
reader : Reader<char, 'State, 'Input, 'InputSlice>
Returns: ParseResult<string, char, 'State>

manyChars p1 reader

Full Usage: manyChars p1 reader

Parameters:
    p1 : Parser<char, char, 'State, 'Input, 'InputSlice>
    reader : Reader<char, 'State, 'Input, 'InputSlice>

Returns: ParseResult<string, char, 'State>

Matches zero or more characters that satisfy the given parser `p1`, and returns the string of matched characters. This parser always succeeds, even if no characters are matched, returning an empty string.

p1 : Parser<char, char, 'State, 'Input, 'InputSlice>
reader : Reader<char, 'State, 'Input, 'InputSlice>
Returns: ParseResult<string, char, 'State>

manyCharsTill p pEnd reader

Full Usage: manyCharsTill p pEnd reader

Parameters:
    p : Parser<'A, char, 'State, 'Input, 'InputSlice>
    pEnd : Parser<'B, char, 'State, 'Input, 'InputSlice>
    reader : Reader<char, 'State, 'Input, 'InputSlice>

Returns: ParseResult<(string * 'B), char, 'State>

Matches zero or more characters that satisfy the parser `p`, until the parser `pEnd` succeeds. Returns the string of matched characters and the parsed value of `pEnd`.

p : Parser<'A, char, 'State, 'Input, 'InputSlice>
pEnd : Parser<'B, char, 'State, 'Input, 'InputSlice>
reader : Reader<char, 'State, 'Input, 'InputSlice>
Returns: ParseResult<(string * 'B), char, 'State>

newline reader

Full Usage: newline reader

Parameters:
    reader : Reader<char, 'State, 'Input, 'InputSlice>

Returns: ParseResult<char, char, 'State>

Matches any of "\n", "\r", or "\r\n" (newline) and returns the value '\n'.

reader : Reader<char, 'State, 'Input, 'InputSlice>
Returns: ParseResult<char, char, 'State>

newlineReturn result reader

Full Usage: newlineReturn result reader

Parameters:
    result : 'a
    reader : Reader<char, 'State, 'Input, 'InputSlice>

Returns: ParseResult<'a, char, 'State>

Matches any of "\n", "\r", or "\r\n" (newline) and returns the provided `result`.

result : 'a
reader : Reader<char, 'State, 'Input, 'InputSlice>
Returns: ParseResult<'a, char, 'State>

pbigint reader

Full Usage: pbigint reader

Parameters:
    reader : Reader<char, 'State, 'Input, 'InputSlice>

Returns: ParseResult<BigInteger, char, 'State>

Parses a signed or unsigned integer in decimal, hexadecimal, octal or binary format.

The parser fails - in place, if not at least one digit (including the 0 in the format specifiers 0x etc.) can be parsed, - if no digit comes after the format specifier, - if the value represented by the input string is greater than System.Int64.MaxValue or less than System.Int64.MinValue.

reader : Reader<char, 'State, 'Input, 'InputSlice>
Returns: ParseResult<BigInteger, char, 'State>

pchar c reader

Full Usage: pchar c reader

Parameters:
    c : char
    reader : Reader<char, 'State, 'Input, 'InputSlice>

Returns: ParseResult<char, char, 'State>

Succeeds if the next char in the input is equal to the given char, and consumes one char. Returns the char, otherwise fails with the Expected char.

c : char
reader : Reader<char, 'State, 'Input, 'InputSlice>
Returns: ParseResult<char, char, 'State>

pfloat reader

Full Usage: pfloat reader

Parameters:
    reader : Reader<char, 'State, 'Input, 'InputSlice>

Returns: ParseResult<float, char, 'State>
reader : Reader<char, 'State, 'Input, 'InputSlice>
Returns: ParseResult<float, char, 'State>

pint16 reader

Full Usage: pint16 reader

Parameters:
    reader : Reader<char, 'a, 'b, 'c>

Returns: ParseResult<int16, char, 'a>

Parses a 16‐bit signed integer, accepting decimal, hexadecimal (0[xX]), octal (0[oO]) and binary (0[bB]) formats.

The parser fails - in place, if not at least one digit (including the 0 in the format specifiers 0x etc.) can be parsed, - if no digit comes after the format specifier, - if the value represented by the input string is greater than Int16.MaxValue or less than Int16.MinValue.

reader : Reader<char, 'a, 'b, 'c>
Returns: ParseResult<int16, char, 'a>

pint32 reader

Full Usage: pint32 reader

Parameters:
    reader : Reader<char, 'a, 'b, 'c>

Returns: ParseResult<int, char, 'a>

Parses a 32‐bit signed integer, accepting decimal, hexadecimal (0[xX]), octal (0[oO]) and binary (0[bB]) formats.

The parser fails - in place, if not at least one digit (including the 0 in the format specifiers 0x etc.) can be parsed, - if no digit comes after the format specifier, - if the value represented by the input string is greater than Int32.MaxValue or less than Int32.MinValue.

reader : Reader<char, 'a, 'b, 'c>
Returns: ParseResult<int, char, 'a>

pint64 reader

Full Usage: pint64 reader

Parameters:
    reader : Reader<char, 'a, 'b, 'c>

Returns: ParseResult<int64, char, 'a>

Parses a 64‐bit signed integer, accepting decimal, hexadecimal (0[xX]), octal (0[oO]) and binary (0[bB]) formats.

The parser fails - in place, if not at least one digit (including the 0 in the format specifiers 0x etc.) can be parsed, - if no digit comes after the format specifier, - if the value represented by the input string is greater than Int64.MaxValue or less than Int64.MinValue.

reader : Reader<char, 'a, 'b, 'c>
Returns: ParseResult<int64, char, 'a>

pint8 reader

Full Usage: pint8 reader

Parameters:
    reader : Reader<char, 'a, 'b, 'c>

Returns: ParseResult<int8, char, 'a>

Parses an 8‐bit signed integer, accepting decimal, hexadecimal (0[xX]), octal (0[oO]) and binary (0[bB]) formats.

The parser fails - in place, if not at least one digit (including the 0 in the format specifiers 0x etc.) can be parsed, - if no digit comes after the format specifier, - if the value represented by the input string is greater than SByte.MaxValue or less than SByte.MinValue.

reader : Reader<char, 'a, 'b, 'c>
Returns: ParseResult<int8, char, 'a>

pstring s reader

Full Usage: pstring s reader

Parameters:
    s : string
    reader : Reader<char, 'State, 'Input, 'InputSlice>

Returns: ParseResult<string, char, 'State>

Succeeds if the next characters in the reader match the given string, and consumes the characters. Returns the string, otherwise fails with the Expected string.

s : string
reader : Reader<char, 'State, 'Input, 'InputSlice>
Returns: ParseResult<string, char, 'State>

puint16 reader

Full Usage: puint16 reader

Parameters:
    reader : Reader<char, 'a, 'b, 'c>

Returns: ParseResult<uint16, char, 'a>

Parses a 16‐bit unsigned integer, accepting decimal, hexadecimal (0[xX]), octal (0[oO]) and binary (0[bB]) formats.

The parser fails - in place, if not at least one digit (including the 0 in the format specifiers 0x etc.) can be parsed, - if no digit comes after the format specifier, - if the value represented by the input string is greater than System.Int64.MaxValue or less than System.Int64.MinValue.

reader : Reader<char, 'a, 'b, 'c>
Returns: ParseResult<uint16, char, 'a>

puint32 reader

Full Usage: puint32 reader

Parameters:
    reader : Reader<char, 'a, 'b, 'c>

Returns: ParseResult<uint32, char, 'a>

Parses a 32‐bit unsigned integer, accepting decimal, hexadecimal (0[xX]), octal (0[oO]) and binary (0[bB]) formats.

The parser fails - in place, if not at least one digit (including the 0 in the format specifiers 0x etc.) can be parsed, - if no digit comes after the format specifier, - if the value represented by the input string is greater than System.Int64.MaxValue or less than System.Int64.MinValue.

reader : Reader<char, 'a, 'b, 'c>
Returns: ParseResult<uint32, char, 'a>

puint64 reader

Full Usage: puint64 reader

Parameters:
    reader : Reader<char, 'a, 'b, 'c>

Returns: ParseResult<uint64, char, 'a>

Parses a 64‐bit unsigned integer, accepting decimal, hexadecimal (0[xX]), octal (0[oO]) and binary (0[bB]) formats.

The parser fails - in place, if not at least one digit (including the 0 in the format specifiers 0x etc.) can be parsed, - if no digit comes after the format specifier, - if the value represented by the input string is greater than System.Int64.MaxValue or less than System.Int64.MinValue.

reader : Reader<char, 'a, 'b, 'c>
Returns: ParseResult<uint64, char, 'a>

puint8 reader

Full Usage: puint8 reader

Parameters:
    reader : Reader<char, 'a, 'b, 'c>

Returns: ParseResult<uint8, char, 'a>

Parses an 8‐bit unsigned integer, accepting decimal, hexadecimal (0[xX]), octal (0[oO]) and binary (0[bB]) formats.

The parser fails - in place, if not at least one digit (including the 0 in the format specifiers 0x etc.) can be parsed, - if no digit comes after the format specifier, - if the value represented by the input string is greater than System.Int64.MaxValue or less than System.Int64.MinValue.

reader : Reader<char, 'a, 'b, 'c>
Returns: ParseResult<uint8, char, 'a>

skipAnyChar reader

Full Usage: skipAnyChar reader

Parameters:
    reader : Reader<char, 'State, 'Input, 'InputSlice>

Returns: ParseResult<unit, char, 'State>

Succeeds if the Reader position is not at the end of the input, and consumes one char. Returns unit.

reader : Reader<char, 'State, 'Input, 'InputSlice>
Returns: ParseResult<unit, char, 'State>

skipChar c reader

Full Usage: skipChar c reader

Parameters:
    c : char
    reader : Reader<char, 'State, 'Input, 'InputSlice>

Returns: ParseResult<unit, char, 'State>

Succeeds if the next char in the input is equal to the given char, and consumes one char. Returns unit, otherwise fails with the Expected char.

c : char
reader : Reader<char, 'State, 'Input, 'InputSlice>
Returns: ParseResult<unit, char, 'State>

skipNewline reader

Full Usage: skipNewline reader

Parameters:
    reader : Reader<char, 'State, 'Input, 'InputSlice>

Returns: ParseResult<unit, char, 'State>

Matches any of "\n", "\r", or "\r\n" (newline) and returns unit.

reader : Reader<char, 'State, 'Input, 'InputSlice>
Returns: ParseResult<unit, char, 'State>

spaces reader

Full Usage: spaces reader

Parameters:
    reader : Reader<char, 'State, 'Input, 'InputSlice>

Returns: ParseResult<unit, char, 'State>

Matches zero or more whitespace characters (space, tab, carriage return, newline) and returns unit.

reader : Reader<char, 'State, 'Input, 'InputSlice>
Returns: ParseResult<unit, char, 'State>

spaces1 reader

Full Usage: spaces1 reader

Parameters:
    reader : Reader<char, 'State, 'Input, 'InputSlice>

Returns: ParseResult<unit, char, 'State>

Matches one or more whitespace characters (space, tab, carriage return, newline) and returns unit.

reader : Reader<char, 'State, 'Input, 'InputSlice>
Returns: ParseResult<unit, char, 'State>

stringCIReturn s result reader

Full Usage: stringCIReturn s result reader

Parameters:
    s : string
    result : 'a
    reader : Reader<char, 'State, 'Input, 'InputSlice>

Returns: ParseResult<'a, char, 'State>

Succeeds if the next characters in the reader match the given string (case insensitive), and consumes the characters. Returns `result`.

s : string
result : 'a
reader : Reader<char, 'State, 'Input, 'InputSlice>
Returns: ParseResult<'a, char, 'State>

stringReturn s result reader

Full Usage: stringReturn s result reader

Parameters:
    s : string
    result : 'a
    reader : Reader<char, 'State, 'Input, 'InputSlice>

Returns: ParseResult<'a, char, 'State>

Succeeds if the next characters in the reader match the given string (case insensitive), and consumes the characters. Returns `result`.

s : string
result : 'a
reader : Reader<char, 'State, 'Input, 'InputSlice>
Returns: ParseResult<'a, char, 'State>

Type something to start searching.