cats.parse
package cats.parse
Type members
Classlikes
Creates an appender given the first item to be added
This is used to build the result in Parser.repAs
This is used to build the result in Parser.repAs
- Companion
- object
This is a class to convert linear offset in
a string into lines, or the column and line numbers.
a string into lines, or the column and line numbers.
This is useful for display to humans who in text
editors think in terms of line and column numbers
editors think in terms of line and column numbers
- Companion
- object
Parser[A]
is a Parser0[A]
that will always consume one-or-more
characters on a successful parse.
characters on a successful parse.
Since Parser is guaranteed to consume input it provides additional
methods which would be unsafe when used on parsers that succeed
without consuming input, such as
methods which would be unsafe when used on parsers that succeed
without consuming input, such as
rep0
.When a Parser is composed with a Parser0 the result is usually a
Parser. Parser overrides many of Parser0's methods to refine the
return type. In other cases, callers may need to use the
helper method to refine the type of their expressions.
Parser. Parser overrides many of Parser0's methods to refine the
return type. In other cases, callers may need to use the
with1
helper method to refine the type of their expressions.
Parser doesn't provide any additional guarantees over Parser0 on
what kind of parsing failures it can return.
what kind of parsing failures it can return.
- Companion
- object
Parser0[A]
attempts to extract an
potentially moving its offset forward in the process.
A
value from the given input,potentially moving its offset forward in the process.
When calling
parse
, one of three outcomes occurs:-
Success: The parser consumes zero-or-more characters of input
and successfully extracts a value. The input offset will be
moved forward by the number of characters consumed. -
Epsilon failure: The parser fails to extract a value without
consuming any characters of input. The input offset will not be
changed. -
Arresting failure: The parser fails to extract a value but does
consume one-or-more characters of input. The input offset will
be moved forward by the number of characters consumed and all
parsing will stop (unless a higher-level parser backtracks).
Operations such as
an arresting failure. Arresting failures can be "rewound" using
methods such as
from
rewind successful parses by
failures for
x.orElse(y)
will only consider parser y
ifx
returns an epsilon failure; these methods cannot recover froman arresting failure. Arresting failures can be "rewound" using
methods such as
x.backtrack
(which converts arresting failuresfrom
x
into epsilon failures), or softProduct(x, y)
(which canrewind successful parses by
x
that are followed by epsilonfailures for
y
).Rewinding tends to make error reporting more difficult and can lead
to exponential parser behavior it is not the default behavior.
to exponential parser behavior it is not the default behavior.
- Companion
- object
object Rfc5234
Parsers for the common rules of RFC5234. These rules are
referenced by several RFCs.
referenced by several RFCs.
- See also