laika.parse
Members list
Type members
Classlikes
A block source represents the source for a block level element where each individual line might have a different x-offset to the root source.
A block source represents the source for a block level element where each individual line might have a different x-offset to the root source.
This type of source is essential to preserve position tracking in recursive block parsing. For block level markup the first passes have to identify the type of block and remove their markup decoration. The remaining inline markup is then passed to inline parsers, but the input to those parsers is no longer a consecutive substring of the root input, making it hard to provide exact positions in error messages.
This type of source cursor solves this issue by providing a view to parsers that looks like a consecutive string of inline markup without the stripped decoration, while maintaining the x- and y-offsets of each line in relation to the root source.
Such a source will be used in multi-pass parsers, where the root parser might strip some markup decoration from each line and then pass the result down to the next recursion. In such a case each line might have a different x-offset from the root input. The use of this instance ensures that the correct position can still be tracked.
Attributes
- Companion:
- object
- Graph
- Supertypes
Companion for creating BlockSource instances.
Companion for creating BlockSource instances.
Attributes
- Companion:
- class
- Graph
- Supertypes
- class Objecttrait Matchableclass Any
- Self type
- BlockSource.type
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).
Attributes
- maxOffset
The offset position the parser could successfully read to before failing
- msgProvider
A provider that produces an error message for this failure based on its SourceCursor
- next
The unconsumed input at the point where the failing parser started
- Companion:
- object
- Graph
- Supertypes
- trait Serializabletrait Producttrait Equalsclass Parsed[Nothing]class Objecttrait Matchableclass Any
Represents a generated source, where an AST node has been created programmatically and cannot be traced back to the corresponding input source.
Represents a generated source, where an AST node has been created programmatically and cannot be traced back to the corresponding input source.
Attributes
- Graph
- Supertypes
- Self type
- GeneratedSource.type
A line source represents all or part of a single line from the root input source.
A line source represents all or part of a single line from the root input source.
Such a source will be used in multi-pass parsers, particularly block-level parsers, where the root parser might strip some markup decoration from each line and then pass the result down to the next recursion. In such a case each line might have a different x-offset from the root input. The use of this instance ensures that the correct position can still be tracked.
A LineSource
is usually used as part of a BlockSource
and less frequently on its own.
Attributes
- Companion:
- object
- Graph
- Supertypes
Companion for creating LineSource instances.
Companion for creating LineSource instances.
Attributes
- Companion:
- class
- Graph
- Supertypes
- class Objecttrait Matchableclass Any
- Self type
- LineSource.type
Represents a lazy failure message.
Implementations can use the specified SourceCursor
to construct
the actual message, e.g. for adding parts of the input to the message.
Represents a lazy failure message.
Implementations can use the specified SourceCursor
to construct
the actual message, e.g. for adding parts of the input to the message.
Attributes
- Companion:
- object
- Graph
- Supertypes
- class Objecttrait Matchableclass Any
Represents the result of a Parser
, a value of type T
in case of success,
a message in case of failure as well as the SourceCursor
for the remaining input.
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.
Attributes
- Companion:
- object
- Graph
- Supertypes
- class Objecttrait Matchableclass Any
- Known subtypes
- class Repeat[T]class Characters[T]class DelimitedTexttrait PrefixedParser[T]trait CodeParserBaseclass CharParserclass NumericParserclass StringParserclass TagParserclass IdParserclass DelimiterParserclass Literalclass PrefixCharacters[T]
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.
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.
Attributes
- offset
the offset into the source string
- s
the source for this position
- Graph
- Supertypes
- class Objecttrait Matchableclass Any
A root source represents the full input string of a parsing operation.
A root source represents the full input string of a parsing operation.
In a single-pass parser like those for HOCON or CSS, only RootCursor
instances will be used for the entire
parsing operation.
In a multi-pass parser like those for text markup, a RootCursor
is only used for the first pass,
whereas the subsequent passes on parts of the input are performed with the other SourceCursor
implementations.
For this reason this type of cursor is only meant to be used for creating a root cursor for the input holding the whole document (e.g. the entire markup document or the full template).
For creating a cursor for a fragment of the input, either BlockSource
or LineSource
must be used
to preserve position tracking in relation to the root input.
Attributes
- Graph
- Supertypes
Represents the state and context of a parsing operation, containing the input string as well as positional information.
Represents the state and context of a parsing operation, containing the input string as well as positional information.
Attributes
- Companion:
- object
- Graph
- Supertypes
- class Objecttrait Matchableclass Any
- Known subtypes
Companion for creating new SourceCursor
instances.
This type of constructor is only meant to be used for creating a root cursor for the input holding
the whole document (e.g. the entire markup document or the full template).
Companion for creating new SourceCursor
instances.
This type of constructor is only meant to be used for creating a root cursor for the input holding
the whole document (e.g. the entire markup document or the full template).
For creating a cursor for a fragment of the input, either BlockSource
or LineSource
must be used
to preserve position tracking in relation to the root input.
Attributes
- Companion:
- trait
- Graph
- Supertypes
- class Objecttrait Matchableclass Any
- Self type
- SourceCursor.type
Represents any source cursor other than the root cursor and it is mandated by some APIs that solely deal with recursive parsing where the root input will never be used as the source for the parser.
Represents any source cursor other than the root cursor and it is mandated by some APIs that solely deal with recursive parsing where the root input will never be used as the source for the parser.
Attributes
- Graph
- Supertypes
- Known subtypes
The success case of Parsed
containing the result and the remaining input.
The success case of Parsed
containing the result and the remaining input.
Attributes
- Graph
- Supertypes
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
and not
, the text parsers like literal
and anyOf(Char*)
,
as well as the more specialized parsers for text markup like spans
and blocks
.
Alternatively these groups can be brought into scope individually.
Attributes
- Graph
- Supertypes
- trait BlockParserstrait InlineParserstrait TextParserstrait Parsersclass Objecttrait Matchableclass Any
- Self type
- builders.type
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 a Parser[Seq[A], Seq[A]]
and mapN
for any parser Parser[A ~ B ~ C]
(up to 5 concatenated elements).
Attributes
- Graph
- Supertypes
- class Objecttrait Matchableclass Any
- Self type
- implicits.type