This object contains the core "function-style" combinators as well as the implicit classes which provide the "method-style" combinators. All parsers will likely require something from within!
This object contains the core "function-style" combinators as well as the implicit classes which provide the "method-style" combinators. All parsers will likely require something from within!
- Companion
- class
Type members
Classlikes
This class exposes a ternary operator on pairs of parsers.
This class exposes a ternary operator on pairs of parsers.
- Value Params
- con
A conversion (if required) to turn elements of
pq
into parsers- pq
The parsers which serve the branches of the if
- Version
1.0.0
This class exposes the <#>
combinator on functions.
This class exposes the <#>
combinator on functions.
- Value Params
- f
The function that is used for the map
- Version
1.0.0
This class exposes the commonly used combinators in Parsley. For a description of why the library is designed in this way, see: the Parsley wiki
This class exposes the commonly used combinators in Parsley. For a description of why the library is designed in this way, see: the Parsley wiki
- Value Params
- con
A conversion (if required) to turn
p
into a parser- p
The parser which serves as the method receiver
- Version
1.0.0
Value members
Concrete methods
Given a parser p
, attempts to parse p
. If the parser fails, then attempt
ensures that no input was
consumed. This allows for backtracking capabilities, disabling the implicit cut semantics offered by <|>
.
Given a parser p
, attempts to parse p
. If the parser fails, then attempt
ensures that no input was
consumed. This allows for backtracking capabilities, disabling the implicit cut semantics offered by <|>
.
- Value Params
- p
The parser to run
- Returns
The result of
p
, or ifp
failed ensures the parser state was as it was on entry.
This is one of the core operations of a selective functor. It will conditionally execute one of p
and q
depending on the result from b
. This can be used to implement conditional choice within a parser without
relying on expensive monadic operations.
This is one of the core operations of a selective functor. It will conditionally execute one of p
and q
depending on the result from b
. This can be used to implement conditional choice within a parser without
relying on expensive monadic operations.
- Value Params
- b
The first parser to parse
- p
If
b
returnsLeft
then this parser is executed with the result- q
If
b
returnsRight
then this parser is executed with the result
- Returns
Either the result from
p
orq
depending onb
.
This function is an alias for _.flatten
. Provides namesake to Haskell.
This function is an alias for _.flatten
. Provides namesake to Haskell.
Parses p
without consuming any input. If p
fails and consumes input then so does lookAhead(p)
. Combine with
attempt
if this is undesirable.
Parses p
without consuming any input. If p
fails and consumes input then so does lookAhead(p)
. Combine with
attempt
if this is undesirable.
- Value Params
- p
The parser to look ahead at
- Returns
The result of the lookahead
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. For example, when recognising
keywords, we want to make sure that a keyword is not followed by a legal identifier character,
in which case the keyword is actually an identifier. We can program this behaviour as follows:
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. For example, when recognising
keywords, we want to make sure that a keyword is not followed by a legal identifier character,
in which case the keyword is actually an identifier. We can program this behaviour as follows:
attempt(kw *> notFollowedBy(alphaNum))
This is the traditional applicative pure function (or monadic return) for parsers. It consumes no input and does not influence the state of the parser, but does return the value provided. Useful to inject pure values into the parsing process.
This is the traditional applicative pure function (or monadic return) for parsers. It consumes no input and does not influence the state of the parser, but does return the value provided. Useful to inject pure values into the parsing process.
- Value Params
- x
The value to be returned from the parser
- Returns
A parser which consumes nothing and returns
x
This is one of the core operations of a selective functor. It will conditionally execute one of q
depending on
whether or not p
returns a Left
. It can be used to implement branch
and other selective operations, however
it is more efficiently implemented with branch
itself.
This is one of the core operations of a selective functor. It will conditionally execute one of q
depending on
whether or not p
returns a Left
. It can be used to implement branch
and other selective operations, however
it is more efficiently implemented with branch
itself.
- Value Params
- p
The first parser to parse
- q
If
p
returnsLeft
then this parser is executed with the result
- Returns
Either the result from
p
if it returnedLeft
or the result ofq
applied to theRight
fromp
Evaluate each of the parsers in ps
sequentially from left to right, collecting the results.
Evaluate each of the parsers in ps
sequentially from left to right, collecting the results.
- Value Params
- ps
Parsers to be sequenced
- Returns
The list containing results, one from each parser, in order
Evaluate each of the parsers in ps
sequentially from left to right, ignoring the results.
Evaluate each of the parsers in ps
sequentially from left to right, ignoring the results.
- Value Params
- ps
Parsers to be performed
Like sequence
but produces a list of parsers to sequence by applying the function f
to each
element in xs
.
Like sequence
but produces a list of parsers to sequence by applying the function f
to each
element in xs
.
- Value Params
- f
The function to map on each element of
xs
to produce parsers- xs
Values to generate parsers from
- Returns
The list containing results formed by executing each parser generated from
xs
andf
in sequence
Concrete fields
This parser consumes no input and returns the current column number reached in the input stream
This parser consumes no input and returns the current column number reached in the input stream
- Returns
The column number the parser is currently at
The empty
parser consumes no input and fails softly (that is to say, no error message)
The empty
parser consumes no input and fails softly (that is to say, no error message)
This parser consumes no input and returns the current line number reached in the input stream
This parser consumes no input and returns the current line number reached in the input stream
- Returns
The line number the parser is currently at