Exception thrown when parsing a text markup document or fragment fails.
Provides additional combinator methods to parsers via implicit conversion.
Abstracts the internal process of building up the result of an inline parser.
ResultBuilder that produces a list of spans.
ResultBuilder that produces a String.
API for specifying further constraints on the parsers provided by this base trait.
Consumes any kind of input, always succeeds.
Consumes any kind of input, always succeeds.
This parser would consume the entire input unless a max
constraint
is specified.
Consumes any number of consecutive characters that are not one of the specified characters.
Consumes any number of consecutive characters that are not one of the specified characters. Always succeeds unless a minimum number of required matches is specified.
Consumes any number of consecutive characters that are in one of the specified character ranges.
Consumes any number of consecutive characters that are in one of the specified character ranges. Always succeeds unless a minimum number of required matches is specified.
Consumes any number of consecutive occurrences of the specified characters.
Consumes any number of consecutive occurrences of the specified characters. Always succeeds unless a minimum number of required matches is specified.
Consumes any number of characters for which the specified parser fails on the corresponding offset.
Consumes any number of characters for which the specified parser fails on the corresponding offset.
This parser fails if the end of input is reached without the specified parser ever succeeding or
if the parser causes an Error result instead of a plain Failure or Success.
Further constraints like minimum or maximum number of required matching characters can be specified
through the API of the returned TextParser
instance.
Consumes any number of consecutive characters that are not one of the specified characters.
Consumes any number of consecutive characters that are not one of the specified characters.
This parser is identical to the anyBut
parser except for two differences: this parser fails
if it reaches the end of the input without seeing any of the specified
characters and it also consumes this final character, without adding it
to the result. This parser is usually used when a construct like a span
enclosed between two characters needs to be parsed.
Consumes any number of consecutive characters which satisfy the specified predicate.
Consumes any number of consecutive characters which satisfy the specified predicate. Always succeeds unless a minimum number of required matches is specified.
Succeeds at the start of the input.
Succeeds at the start of the input.
Implicit conversion that allows to pass a single
character to the range-based anyIn
parser.
Implicit conversion that allows to pass a single
character to the range-based anyIn
parser.
Succeeds at the end of the input.
Succeeds at the end of the input.
Succeeds at the end of a line, including the end of the input.
Succeeds at the end of a line, including the end of the input. Produces an empty string as a result and consumes any new line characters.
Generic base parser that parses inline elements based on the specified helper parsers.
Generic base parser that parses inline elements based on the specified helper parsers. Usually not used directly by parser implementations, this is the base parser the other inline parsers of this trait delegate to.
the element type produced by a single parser for a nested span
the type of the result this parser produces
a mapping from the start character of a span to the corresponding parser for nested span elements
responsible for building the final result of this parser based on the results of the helper parsers
the resulting parser
Applies the specified parser at the specified offset behind the current position.
Applies the specified parser at the specified offset behind the current position. Never consumes any input.
Returns an optimized, Array-based lookup function for the specified characters.
Returns an optimized, Array-based lookup function for the specified characters.
Returns an optimized, Array-based lookup function for the specified ranges of characters.
Returns an optimized, Array-based lookup function for the specified ranges of characters.
Fully parses the input string and produces a list of spans, using the
default span parsers returned by the spanParsers
method.
Fully parses the input string and produces a list of spans, using the
default span parsers returned by the spanParsers
method.
This function is expected to always succeed, errors would be considered a bug of this library, as the parsers treat all unknown or malformed markup as regular text. Some parsers might additionally insert system message elements in case of markup errors.
the input to parse
the result of the parser in form of a list of spans
Fully parses the input string and produces a list of spans.
Fully parses the input string and produces a list of spans.
This function is expected to always succeed, errors would be considered a bug of this library, as the parsers treat all unknown or malformed markup as regular text. Some parsers might additionally insert system message elements in case of markup errors.
the input to parse
a mapping from the start character of a span to the corresponding parser
the result of the parser in form of a list of spans
Fully parses the input from the specified reader and returns the result.
Fully parses the input from the specified reader and returns the result. This function is expected to always succeed, errors would be considered a bug in this library, as the parsers treat all unknown or malformed markup as regular text.
Fully parses the specified input string and returns the result.
Fully parses the specified input string and returns the result. This function is expected to always succeed, errors would be considered a bug in this library, as the parsers treat all unknown or malformed markup as regular text.
A parser generator for repetitions where all subsequent parsers after the first depend on the result of the previous.
A parser generator for repetitions where all subsequent parsers after the first depend on the result of the previous.
the parser to use for the first piece of input
a function that determines the next parser based on the result of the previous
(Changed in version 2.9.0) The p0
call-by-name arguments is evaluated at most once per constructed Parser object, instead of on every need that arises during parsing.
Uses the parser for at most the specified number of repetitions, always succeeds.
Uses the parser for at most the specified number of repetitions, always succeeds. The result is the list of results from applying the parser repeatedly.
Uses the parser for at least the specified number of repetitions or otherwise fails.
Uses the parser for at least the specified number of repetitions or otherwise fails. Continues to apply the parser after the minimum has been reached until if fails. The result is the list of results from applying the parser repeatedly.
The mapping of markup start characters to their corresponding span parsers.
The mapping of markup start characters to their corresponding span parsers.
A parser mapped to a start character is not required to successfully parse the subsequent input. If it fails the character that triggered the parser invocation will be treated as normal text. The mapping is merely used as a performance optimization. The parser will be invoked with the input offset pointing to the character after the one specified as the key for the mapping.
Parses a list of spans based on the specified helper parsers.
Parses a list of spans based on the specified helper parsers.
the parser for the text of the current span element
the resulting parser
Parses text based on the specified helper parsers.
Parses text based on the specified helper parsers.
the parser for the text of the current element
a mapping from the start character of a span to the corresponding parser for nested span elements
the resulting parser
Parses horizontal whitespace (space and tab).
Parses horizontal whitespace (space and tab). Always succeeds, consuming all whitespace found.
(Since version 2.10.0) lastNoSuccess was not thread-safe and will be removed in 2.11.0
(Since version 2.10.0) lastNoSuccess was not thread-safe and will be removed in 2.11.0
A generic base trait for inline parsers. Provides base parsers that abstract aspects of inline parsing common to most lightweight markup languages.
It contains helper parsers that abstract the typical logic required for parsing nested spans. In many cases a parser has to recognize the end of the span as well as potentially the start of a nested spans. These two concerns are usually unrelated.
This trait offers helpers that simplify creating these types of parsers and also optimize performance of inline parsing. Due to the nature of lightweight text markup inline parsing would usually require trying a long list of choicing on each input character, which is slow. These base parsers work based on mappings from the first character of an inline span to the corresponding full parser.