LanguageExt.Parsec by Paul Louth

<PackageReference Include="LanguageExt.Parsec" Version="3.3.43" />

 Prim

public static class Prim
The primitive parser combinators
public static readonly Parser<Unit> eof

This parser only succeeds at the end of the input. This is not a primitive parser but it is defined using 'notFollowedBy'.

public static readonly Parser<int> getIndex

Get the current index into the source

public static readonly Parser<Pos> getPos

Get the current position of the parser in the source as a line and column index (starting at 1 for both)

public static readonly Parser<Unit> unitp

This parser is useful to put at the top of LINQ expressions, it makes it easier to put breakpoints on the actual first parser in an expression. It returns unit

public static Parser<Option<double>> asDouble(Parser<Seq<char>> p)

Parse a char list and convert into an double precision floating point value

public static Parser<Option<float>> asFloat(Parser<Seq<char>> p)

Parse a char list and convert into an double precision floating point value

public static Parser<Option<int>> asInteger(Parser<Seq<char>> p)

Parse a char list and convert into an integer

public static Parser<Option<int>> asInteger(Parser<Seq<char>> p, int fromBase)

Parse a char list and convert into an integer

public static Parser<string> asString(Parser<Seq<char>> p)

Parse a char list and convert into a string

public static Parser<T> attempt<T>(Parser<T> p)

The parser attempt(p) behaves like parser p, except that it pretends that it hasn't consumed any input when an error occurs. This combinator is used whenever arbitrary look ahead is needed. Since it pretends that it hasn't consumed any input when p fails, the either combinator will try its second alternative even when the first parser failed while consuming input. See remarks.

public static Parser<T> between<L, R, T>(Parser<L> open, Parser<R> close, Parser<T> inner)

between(open,close,p) parses open, followed by p and close.

public static Parser<Seq<T>> chain<T>(Parser<T>[] ps)

Runs a sequence of parsers, if any fail then the failure state is returned immediately and subsequence parsers are not run.

public static Parser<Seq<T>> chain<T>(Seq<Parser<T>> ps)

Runs a sequence of parsers, if any fail then the failure state is returned immediately and subsequence parsers are not run.

public static Parser<T> chainl<T>(Parser<T> p, Parser<Func<T, T, T>> op, T x)

chainl(p,op,x) parses zero or more occurrences of p, separated by op

public static Parser<T> chainl1<T>(Parser<T> p, Parser<Func<T, T, T>> op)

chainl1(p,op) parses one or more occurrences of p, separated by op.

public static Parser<T> chainr<T>(Parser<T> p, Parser<Func<T, T, T>> op, T x)

chainr(p,op,x) parses zero or more occurrences of p, separated by op

public static Parser<T> chainr1<T>(Parser<T> p, Parser<Func<T, T, T>> op)

chainr1(p,op) parses one or more occurrences of p, separated by op.

public static Parser<T> choice<T>(Parser<T>[] ps)

choice(ps) tries to apply the parsers in the list ps in order, until one of them succeeds.

public static Parser<T> choice<T>(Seq<Parser<T>> ps)

choice(ps) tries to apply the parsers in the list ps in order, until one of them succeeds.

public static Parser<Seq<T>> count<T>(int n, Parser<T> p)

count(n,p) parses n occurrences of p. If n is smaller or equal to zero, the parser equals to result([]).

public static Parser<T> either<T>(Parser<T> p, Parser<T> q)

This combinator implements choice. The parser either(p,q) first applies p. If it succeeds, the value of p is returned. If p fails /without consuming any input/, parser q is tried.

public static Parser<Seq<T>> endBy<S, T>(Parser<T> p, Parser<S> sep)

endBy(p,sep) parses zerp or more occurrences of p, separated and ended by sep.

public static Parser<Seq<T>> endBy1<S, T>(Parser<T> p, Parser<S> sep)

endBy1(p,sep) parses one or more occurrences of p, separated and ended by sep.

public static Parser<T> failure<T>(string msg)

The parser failure(msg) always fails with a Message error without consuming any input. The parsers 'failure', 'label' and 'unexpected' are the three parsers used to generate error messages. Of these, only 'label' is commonly used. For an example of the use of unexpected, see the definition of 'Text.Parsec.Combinator.notFollowedBy'.

public static Parser<T> getState<T>()

Special parser for getting user-state that was previously set with setState

public static Parser<T> lazyp<T>(Func<Parser<T>> fn)

Lazy parser - useful in recursive scenarios.

public static Parser<T> lookAhead<T>(Parser<T> p)

lookAhead(p) parses p without consuming any input. If p fails and consumes some input, so does lookAhead(p). Combine with 'attempt' if this is undesirable.

public static Parser<Seq<T>> many<T>(Parser<T> p)

many(p) applies the parser p zero or more times.

public static Parser<Seq<T>> many1<T>(Parser<T> p)

many1(p) applies the parser p one or more times.

public static Parser<Seq<T>> manyn<T>(Parser<T> p, int n)

manyn(p, n) applies the parser p n times.

public static Parser<Seq<T>> manyn0<T>(Parser<T> p, int n)

manyn0(p) applies the parser p zero or up to a maximum of n times.

public static Parser<Seq<T>> manyn1<T>(Parser<T> p, int n)

manyn1(p) applies the parser p one or up to a maximum of n times.

public static Parser<Seq<T>> manyUntil<T, U>(Parser<T> p, Parser<U> end)

public static Parser<Unit> notFollowedBy<T>(Parser<T> p)

notFollowedBy(p) only succeeds when parser p fails. This parser does not consume any input.This parser can be used to implement the 'longest match' rule.

public static Parser<Option<T>> optional<T>(Parser<T> p)

optional(p) tries to apply parser p. If p fails without consuming input, it return 'None', otherwise it returns 'Some' the value returned by p.

public static Parser<T[]> optionalArray<T>(Parser<T> p)

optionalArray(p) tries to apply parser p. If p fails without consuming input, it return [], otherwise it returns a one item array with the result of p.

public static Parser<Lst<T>> optionalList<T>(Parser<T> p)

optionalList(p) tries to apply parser p. If p fails without consuming input, it return [], otherwise it returns a one item Lst with the result of p.

public static Parser<Seq<T>> optionalSeq<T>(Parser<T> p)

optionalSeq(p) tries to apply parser p. If p fails without consuming input, it return an empty IEnumerable, otherwise it returns a one item IEnumerable with the result of p.

public static Parser<T> optionOrElse<T>(T x, Parser<T> p)

optionOrElse(x, p) tries to apply parser p. If p fails without consuming input, it returns the value x, otherwise the value returned by p.

public static ParserResult<T> parse<T>(Parser<T> p, PString input)

Run the parser p with the input provided

public static ParserResult<T> parse<T>(Parser<T> p, string input)

Run the parser p with the input provided

public static Parser<T> result<T>(T value)

Always success parser. Returns the value provided. This is monad return for the Parser monad

public static Parser<Seq<T>> sepBy<S, T>(Parser<T> p, Parser<S> sep)

sepBy(p,sep) parses zero or more occurrences of p, separated by sep.

public static Parser<Seq<T>> sepBy1<S, T>(Parser<T> p, Parser<S> sep)

sepBy1(p,sep) parses one or more occurrences of p, separated by sep.

public static Parser<Seq<T>> sepEndBy<S, T>(Parser<T> p, Parser<S> sep)

sepEndBy(p,sep) parses zero or more occurrences of p, separated and optionally ended by sep.

public static Parser<Seq<T>> sepEndBy1<S, T>(Parser<T> p, Parser<S> sep)

sepEndBy1(p,sep) parses one or more occurrences of p, separated and optionally ended by sep.

public static Parser<Unit> setState<T>(T state)

Special parser for setting user-state that propagates through the computation.

public static Parser<Unit> skipMany<T>(Parser<T> p)

skipMany(p) applies the parser p zero or more times, skipping its result.

public static Parser<Unit> skipMany1<T>(Parser<T> p)

skipMany(p) applies the parser p one or more times, skipping its result.

public static Parser<T> unexpected<T>(string msg)

The parser unexpected(msg) always fails with an Unexpect error message msg without consuming any input.

public static Parser<T> zero<T>()

Always fails (with an Unknown error) without consuming any input