DelimiterParser
A parser that simplifies the expression of typical conditions for start and end delimiters of inline spans.
It allows to specify conditions for the immediately preceding and following character of the parsed delimiter.
As an example, the following parser is only composed of base combinators
lookBehind(1, not(' ')) ~ "**" ~ lookAhead(not(' '))
It looks for the string "**" as a delimiter and does not allow any space character before or after the delimiter
With this API it can be rewritten as:
delimiter("**").prevNot(' ').nextNot(' ')
The only characters that this parser will consume and return as a result are those of the delimiter itself, not the surrounding characters that it validated.
Value members
Concrete methods
Ensures that the character immediately following the delimiter is not one of the specified characters.
Ensures that the character immediately following the delimiter is not one of the specified characters.
Ensures that the character immediately following the delimiter is not in the specified set.
Ensures that the character immediately following the delimiter is not in the specified set.
Ensures that the character immediately following the delimiter does not satisfy the given predicate.
Ensures that the character immediately following the delimiter does not satisfy the given predicate.
Ensures that the characters immediately preceding and following the delimiter do not satisfy the given predicate.
Ensures that the characters immediately preceding and following the delimiter do not satisfy the given predicate.
This option exists for the rare occasion where certain kinds of pairs of characters surrounding a delimiter cannot be allowed. This logic would be particularly cumbersome to express with the basic combinators.
Ensures that the character immediately preceding the delimiter is not one of the specified characters.
Ensures that the character immediately preceding the delimiter is not one of the specified characters.
Ensures that the character immediately preceding the delimiter is not in the specified set.
Ensures that the character immediately preceding the delimiter is not in the specified set.
Inherited methods
Returns a parser that repeatedly applies this parser. It will always succeed, potentially with an empty list as the result.
Returns a parser that repeatedly applies this parser. It will always succeed, potentially with an empty list as the result.
- Inherited from:
- Parser
Returns a parser that repeatedly applies this parser (at least once).
Returns a parser that repeatedly applies this parser (at least once).
- Inherited from:
- Parser
Returns a parser that optionally parses what this parser parses.
Returns a parser that optionally parses what this parser parses.
- Inherited from:
- Parser
- Definition Classes
- Inherited from:
- PrefixedParser
Returns a parser that produces the number of characters consumed by this parser while discarding the original result.
Returns a parser that produces the number of characters consumed by this parser while discarding the original result.
- Inherited from:
- Parser
Handle any error, potentially recovering from it, by mapping it to a new parser that will be applied at the same starting position than the failing parser.
Handle any error, potentially recovering from it, by mapping it to a new parser that will be applied at the same starting position than the failing parser.
This is similar to the orElse
or |
method, but allows the alternative
parser to inspect the error of the preceding one.
- See also:
recoverWith to recover from only certain errors.
- Inherited from:
- Parser
Applies the specified parser when this parser fails.
Applies the specified parser when this parser fails.
a.orElse(b)
succeeds if either of the parsers succeeds.
This is a specialized variant of the orElse
method of the
base trait that preserves the nature of the PrefixedParser
if both original parsers implement this trait.
- Inherited from:
- PrefixedParser
Applies the specified parser when this parser fails.
Applies the specified parser when this parser fails.
a orElse b
succeeds if either of the parsers succeeds.
In case both parsers fail, the Failure
instance will
be from the parser with the most successfully read characters.
In the case of multiple failures having the same number of characters,
the one with the highest precedence (this parser) will be chosen.
Implementation note: The parameter is by-name to allow the definition of recursive parsers. In contrast to the former SDK parser combinators this is the only place where a parser with a by-name parameter is used whereas in all other places the additional cost is avoided.
- Inherited from:
- Parser
Parses the specified string and returns the result.
Parses the specified string and returns the result.
- Inherited from:
- Parser
Handle certain errors, potentially recovering from it, by mapping them to a new parser that will be applied at the same starting position than the failing parser.
Handle certain errors, potentially recovering from it, by mapping them to a new parser that will be applied at the same starting position than the failing parser.
- See also:
handleErrorWith to handle any/all errors.
- Inherited from:
- Parser
Returns a parser that repeatedly applies this parser with the specified separator string between those invocations.
Returns a parser that repeatedly applies this parser with the specified separator string between those invocations.
p.rep(sep).min(1)
is equivalent to (p ~ (sep ~> p).rep).concat
.
The returned parser offers an API to specify further constraints
like min
or max
.
- Inherited from:
- Parser
Returns a parser that repeatedly applies this parser with the specified separator parser between those invocations.
Returns a parser that repeatedly applies this parser with the specified separator parser between those invocations.
p.rep(sep).min(1)
is equivalent to (p ~ (sep ~> p).rep).concat
.
The returned parser offers an API to specify further constraints
like min
or max
.
- Inherited from:
- Parser
Returns a parser that repeatedly applies this parser.
The returned parser offers an API to specify further constraints
like min
or max
.
Returns a parser that repeatedly applies this parser.
The returned parser offers an API to specify further constraints
like min
or max
.
- Inherited from:
- Parser
Returns a parser that repeatedly applies this parser until either this parser fails or the specified end condition is met. The end condition will be applied after each successful invocation of this parser.
Returns a parser that repeatedly applies this parser until either this parser fails or the specified end condition is met. The end condition will be applied after each successful invocation of this parser.
The result of the returned parser is a tuple consisting of the list containing the
result of the invocations of this parser plus the result of the end condition.
The latter is returned as an Option
as it might be empty when the parsing finished because of this parser failing.
Note that it is more convenient to include the end condition in the repeating parser itself and use
the simpler rep
method.
This combinator is an alternative if you need to know the result of the end condition.
- Inherited from:
- Parser
Returns a parser that invokes the specified function repeatedly, passing the result of this parser if it succeeds, to produce new parsers that get applied until one of them fails.
Returns a parser that invokes the specified function repeatedly, passing the result of this parser if it succeeds, to produce new parsers that get applied until one of them fails.
The result of the returned parser is a list containing the result of this parser (if it succeeds) plus the results of successful invocations of the parsers returned by the specified function.
- Inherited from:
- Parser
Discards the result of a successful parser.
Discards the result of a successful parser.
- Inherited from:
- Parser
Changes the failure message produced by a parser.
Changes the failure message produced by a parser.
- Inherited from:
- Parser
Applies the specified parser when this parser fails.
Applies the specified parser when this parser fails.
a | b
succeeds if either of the parsers succeeds.
This is a specialized variant of the |
method of the
base trait that preserves the nature of the PrefixedParser
if both original parsers implement this trait.
- Inherited from:
- PrefixedParser
Applies the specified parser when this parser fails.
Applies the specified parser when this parser fails.
a | b
succeeds if either of the parsers succeeds.
Implementation note: The parameter is by-name to allow the definition of recursive parsers. In contrast to the former SDK parser combinators this is the only place where a parser with a by-name parameter is used whereas in all other places the additional cost is avoided.
- Inherited from:
- Parser