This class enables "operator-style" alternative combinators on parsers.
This extension class exposes a collection of "operator-style" combinators on values that are convertible to parsers
that are plain syntactic sugar for other functionality in the library; they are potentially
less readable than the combinators they replace, so should be used sparingly.
Attributes
P
the type of base value that this class is used on (the conversion to Parsley) is summoned automatically.
con
a conversion that allows values convertible to parsers to be used.
p
the value that this class is enabling methods on.
Constructor:
This constructor should not be called manually, it is designed to be used via Scala's implicit resolution.
This combinator, pronounced "and not", first parses its argument q, and if it fails, it will parse this parser, returning its result.
This combinator, pronounced "and not", first parses its argument q, and if it fails, it will parse this parser, returning its result.
First q is parsed, which will never consume input regardless of failure or success. If it failed, then this parser is executed and its result
is returned. If either q succeeds or this parser fails, the combinator fails.
Attributes
q
the parser to quotient this parser by.
Returns:
a parser that only parses this parser if q cannot parse.
Example:
// a less efficient version of a keyword: it's more efficient to not have to read the entire keyword twice
def keyword(kw: String): Parsley[Unit] = {
string(kw).void - identifier
}