package parse
- Alphabetic
- Public
- Protected
Package Members
Type Members
- case class Failure(msgProvider: Message, next: ParserContext, maxOffset: Int) extends Parsed[Nothing] with Product with Serializable
The failure case of
Parsed
containing an error message and the remaining input.The failure case of
Parsed
containing an error message and the remaining input.Implementation note: The message property is of type
Message
, to allow for lazy message creation. The former SDK parser combinators which this API is partially inspired by contained a lot of unnecessary string concatenations for messages which were then never read. This implementation avoids this extra cost and the result is measurable (about 15% performance gain for a typical Markdown document for example).- msgProvider
A provider that produces an error message for this failure based on its ParserContext
- next
The unconsumed input at the point where the failing parser started
- maxOffset
The offset position the parser could successfully read to before failing
- trait Message extends AnyRef
Represents a lazy failure message.
Represents a lazy failure message. Implementations can use the specified
ParserContext
to construct the actual message, e.g. for adding parts of the input to the message. - sealed abstract class Parsed[+T] extends AnyRef
Represents the result of a
Parser
, a value of typeT
in case of success, a message in case of failure as well as theParserContext
for the remaining input. - abstract class Parser[+T] extends AnyRef
The abstract base for all parser implementations.
The abstract base for all parser implementations.
Contains the main
parse
function as well as various combinator function to create a new parser based on this one. - case class ParserContext(source: Source, offset: Int, nestLevel: Int) extends Product with Serializable
Represents the state and context of a parsing operation, containing the input string as well as positional information/
- case class Position(s: Source, offset: Int) extends Product with Serializable
Represents an offset into a source string.
Represents an offset into a source string. Its main purpose is error reporting, e.g. printing a visual representation of the line containing the error.
- s
the source for this position
- offset
the offset into the source string
- case class Source(value: String) extends Product with Serializable
Represents the input string for a parsing operation.
- case class Success[+T](result: T, next: ParserContext) extends Parsed[T] with Product with Serializable
The success case of
Parsed
containing the result and the remaining input.
Value Members
- object Failure extends Serializable
- object Message
Message companion providing several pre-built messages and factory methods.
- object Parser
Companion factory for creating new parser instances.
- object ParserContext extends Serializable
Companion for creating new
ParserContext
instances. - object builders extends TextParsers with InlineParsers with BlockParsers
Grouping of all parser builders that allows to construct most common parsers with a single import.
Grouping of all parser builders that allows to construct most common parsers with a single import.
These include the base parsers like
opt
andnot
, the text parsers likeliteral
andanyOf(Char*)
, as well as the more specialized parsers for text markup likespans
andblocks
.Alternatively these groups can be brought into scope individually.
- object implicits
Collection of extension methods that helps keeping parser definitions concise.
Collection of extension methods that helps keeping parser definitions concise.
It includes extension methods on string that allows to use string literals in parser definitions like
"{" ~ anyNot('}') ~ "}"
and extensions for parsers for particular target types, e.g.concat
for aParser[Seq[A], Seq[A]]
andmapN
for any parserParser[A ~ B ~ C]
(up to 5 concatenated elements).