OperatorSugar
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
- Since
-
4.0.0
- Source
- extension.scala
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
Members list
Value members
Concrete methods
This combinator, pronounced "star", will parse this parser zero or more times returning a list of the parsed results.
This combinator, pronounced "star", will parse this parser zero or more times returning a list of the parsed results.
Equivalent to many
, but as a postfix operator: many(p)
is the same as p.*
.
Attributes
- See also
-
many
for more details. - Note
-
an alias for
many
. - Source
- extension.scala
This combinator, pronounced "plus", will parse this parser one or more times returning a list of the parsed results.
This combinator, pronounced "plus", will parse this parser one or more times returning a list of the parsed results.
Equivalent to some
, but as a postfix operator: some(p)
is the same as p.+
.
Attributes
- See also
-
some
for more details. - Note
-
an alias for
some
. - Source
- extension.scala
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.
Value parameters
- q
-
the parser to quotient this parser by.
Attributes
- 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 }
- Source
- extension.scala
This combinator, pronounced "option", will try parsing this parser wrapping its result in Some
, and return None
if it fails.
This combinator, pronounced "option", will try parsing this parser wrapping its result in Some
, and return None
if it fails.
Equivalent to option
, but as a postfix operator: option(p)
is the same as p.?
.
Attributes
- See also
-
option
for more details. - Note
-
an alias for
option
. - Source
- extension.scala
This combinator, pronounced "not", will succeed when this parser fails, and vice-versa, never consuming input.
This combinator, pronounced "not", will succeed when this parser fails, and vice-versa, never consuming input.
Equivalent to notFollowedBy
, but as a prefix operator: notFollowedBy(p)
is the same as !p
.
Attributes
- See also
-
notFollowedBy
for more details. - Note
-
an alias for
notFollowedBy
. - Source
- extension.scala