appfun allows the user to apply a function f to
the result of a parser p, assuming that p is successful.
This is the same as the |>>
function from FParsec and is an alias for pipe
.
A parser.
bind is a curried function that takes a parser p and returns a function that takes a parser f which returns the composition of p and f. If any of the parsers fail, the original inputstream is returned in the Failure object (i.e., bind backtracks).
A parser
char takes a character and yields a parser that consume that character. The returned parser succeeds if the next character in the input stream is c, otherwise it fails.
choice specifies an ordered choice between two parsers, p1 and p2. The returned parser will first apply parser p1. If p1 succeeds, p1's Outcome is returned. If p1 fails, p2 is applied and the Outcome of p2 is returned.
An exception is when an outcome is a critical failure, that outcome is immediately returned.
A parser.
Like choice, but chooses from multiple possible parsers The parser will be tried in the order of the input, and the result of the first parser to succeed is returned Example usage: choices(p1, p2, p3)
An array of parsers to try
The debug parser takes a parser p and a debug string, printing the debug string as a side-effect before applying p to the input.
a parser
Produce a diagnostic message for a parser failure.
The Failure object.
The amount of context (in chars) to show to the left and right of the failure position.
digit returns a parser that consumes a single numeric character, from 0-9. Note that the type of the result is a string, not a number.
Returns a parser that succeeds only if the end of the input has been reached.
expect tries to apply the given parser and returns the result of that parser if it succeeds, otherwise it returns a critical Failure If the parser results in a critical Failure, expect simply returns it, otherwise expect creates a critical Failure with the given error message and the start pos of the istream as the error pos.
The parser to try
The error message if the parser fails
fail
fails if the given parser p
succeeds. On failure,
fail
returns the given error message. For either outcome,
success or failure, fail
never consumes input.
A parser
An error message
A floating point parser, with optional fraction.
fresult returns a parser that applies the parser p, and if p succeeds, returns the value x.
a parser
An integer parser.
item successfully consumes the first character if the input string is non-empty, otherwise it fails.
left returns a parser that applies the parser p, then the parser q, and if both are successful, returns the result of p.
a parser
letter returns a parser that consumes a single alphabetic character, from a-z, regardless of case.
lower returns a parser that consumes a single character if that character is lowercase.
many repeatedly applies the parser p until p fails. many always succeeds, even if it matches nothing or if an outcome is critical. many tries to guard against an infinite loop by raising an exception if p succeeds without changing the parser state.
The parser to try
many1 repeatedly applies the parser p until p fails. many1 must succeed at least once. many1 tries to guard against an infinite loop by raising an exception if p succeeds without changing the parser state.
The parser to try
An optimized parser that seeks the input until the given predicate does not return true. On success, it returns the matching CharStream.
A function that returns true if the given character should be accepted.
An optimized parser that seeks the input until the given predicate does not return true. On success, it returns the matching CharStream.
A function that returns true if the given character code should be accepted.
nl matches and returns a newline.
ok
succeeds without consuming any input, returning whatever
is given here.
A result object.
pipe
allows the user to apply a function f to
the result of a parser p, assuming that p is successful.
This is the same as the |>>
function from FParsec and is an alias for appfun
A parser.
pipe2(p1)(p2)(f)
applies the parsers p1
and p2
in sequence.
It returns the result of the function application f(t,u)
, where
t
and u
are the results returned by p1
and p2
.
A function that takes the result of p1
and p2
.
pipe3(p1)(p2)(p3)(f)
applies the parsers p1
, p2
, and p3
in
sequence. It returns the result of the function application f(a,b,c)
,
where a
, b
, and c
are the results returned by p1
, p2
, and
p3
, respectively.
A parser.
A parser.
A parser.
A function that takes the results of p1
, p2
, and p3
.
prefix
is a prefix-optimized choice
combinator. If pre
succeeds, p
is called, and prefix
's and p
's results
are returned by calling the reducer f
. If p
fails,
just p
's result is returned. Use this whereever you would
write choice(p)(pipe2(p)(q)(f)).
A prefix parser that should always succeed.
A suffix parser that may succeed.
A function that is called only if p
succeeds.
rec1ArgParser
is a forward declaration for a recursive parser that
takes one argument. It is effectively a form of deferred evaluation to
prevent Javascript from eagerly expanding recursive grammar productions.
A pair, [decl,impl]
where decl
is a parser declaration and impl
is an implementation for p
recParser
is a forward declaration for a recursive parser.
It is effectively a form of deferred evaluation to prevent
Javascript from eagerly expanding recursive grammar productions.
A pair, [decl,impl]
where decl
is a parser declaration and impl
is an implementation for p
result succeeds without consuming any input, and returns v.
The result of the parse.
right returns a parser that applies the parser p, then the parser q, and if both are successful, returns the result of q.
a parser
sat
takes a predicate and yields a parser that consumes a
single character if the character satisfies the predicate,
otherwise it fails.
satClass
takes an array of satisfactory characters and yields
a parser that consumes a single character if the character
is in the array, otherwise it fails.
seq
takes a parser p
and a parser q
. It applies p
to the input,
passing the remaining input stream to q
; q
is then applied. It
returns the result of p
and q
as a tuple.
A parser
str
yields a parser for the given string.
A string
Match any of given alternatives in the given array of strings. Matches longest-first and, where length is the same, lexicographically first.
An array of acceptable strings.
upper returns a parser that consumes a single character if that character is uppercase.
ws matches zero or more of the following whitespace characters: ' ', '\t', '\n', or '\r\n' ws returns matched whitespace in a single CharStream result. Note: ws NEVER fails
ws1 matches one or more of the following whitespace characters: ' ', '\t', '\n', or '\r\n' ws1 returns matched whitespace in a single CharStream result.
zero fails without consuming any input.
the error message.
Generated using TypeDoc
Union type representing a successful or failed parse.