Syntax defines a parser and a printer together and provides combinators to simultaneously build them up from smaller syntax fragments.
Type parameters
- Err
-
Custom error type
- In
-
Element type of the input stream of parsing
- Out
-
Element type of the output stream of printing
- Value
-
The type of the value to be parsed or printed
Attributes
- Companion
- object
- Source
- Syntax.scala
- Graph
-
- Supertypes
- Self type
-
Members list
Value members
Concrete methods
Symbolic alias for repeat0
Symbolic alias for repeat
Symbolic alias for orElseEither
Symbolic alias for orElse
Symbolic alias for zipLeft
Symbolic alias for optional
Symbolic alias for named
Ignores the result of the syntax and result in 'value' instead
Sets the result to 'result' and the value to be printed to 'value'
This syntax repeated at least 'min' times.
This syntax repeated at least 'min' times.
The result is all the parsed elements until the first failure. The failure that stops the repetition gets swallowed and in case auto-backtracking is on, the parser backtracks to the end of the last successful item.
When printing, the input is a chunk of values and each element gets printed.
Attributes
- Source
- Syntax.scala
Enables auto-backtracking for this syntax
Syntax that resets the parsing position in case it fails.
Syntax that resets the parsing position in case it fails.
By default backtracking points are automatically inserted. This behavior can be changed with the autoBacktracking, manualBacktracking and setAutoBacktracking combinators.
Does not affect printing.
Attributes
- Source
- Syntax.scala
Concatenates the syntaxes 'left', then this, then 'right'.
Concatenates the syntaxes 'left', then this, then 'right'.
All three must succeed. The result is this syntax's result.
Note that the 'left' and 'right' syntaxes must have a 'Value' type of Unit. Otherwise the printer could not produce an arbitrary input value for them as their result is discarded.
Attributes
- Source
- Syntax.scala
Prints a debug message when this syntax parses a value
Specifies a filter condition 'condition' that gets checked in both parser and printer mode and in case it evaluates to false, fails with 'failure'.
Specifies a filter condition 'condition' that gets checked in both parser and printer mode and in case it evaluates to false, fails with 'failure'.
Attributes
- Source
- Syntax.scala
Flattens a result of parsed strings to a single string
Disables auto-backtracking for this syntax
Maps the error with the given function 'f'
Associates a name with this syntax. The chain of named parsers are reported in case of failure to help debugging parser issues.
Associates a name with this syntax. The chain of named parsers are reported in case of failure to help debugging parser issues.
Attributes
- Source
- Syntax.scala
Syntax that succeeds only if this syntax fails
Transforms the syntax of a tuple to a syntax of a given case class
Make this syntax optional.
Make this syntax optional.
Failure of the parser will be ignored. In case auto-backtracking is enabled, backtracking is performed on it.
Attributes
- Source
- Syntax.scala
Assigns 'that' syntax as a fallback of this. First this parser or printer gets evaluated. In case it succeeds, the result is this syntax's result. In case it fails, the result is 'that' syntax's result.
Assigns 'that' syntax as a fallback of this. First this parser or printer gets evaluated. In case it succeeds, the result is this syntax's result. In case it fails, the result is 'that' syntax's result.
If auto-backtracking is on, this parser will backtrack before trying 'that' parser.
Attributes
- Source
- Syntax.scala
Assigns 'that' syntax as a fallback of this. First this parser or printer gets evaluated. In case it succeeds, the result is this syntax's result wrapped in 'Left'. In case it fails, the result is 'that' syntax's result, wrapped in 'Right'.
Assigns 'that' syntax as a fallback of this. First this parser or printer gets evaluated. In case it succeeds, the result is this syntax's result wrapped in 'Left'. In case it fails, the result is 'that' syntax's result, wrapped in 'Right'.
If auto-backtracking is on, this parser will backtrack before trying 'that' parser.
Attributes
- Source
- Syntax.scala
Run this parser on the given 'input' chunk of characters
Run this parser on the given 'input' chunk of characters using a specific parser implementation
Run this parser on the given 'input' chunk of characters using a specific parser implementation
Attributes
- Source
- Syntax.scala
Run this parser on the given 'input' chunk
Run this parser on the given 'input' string
Run this parser on the given 'input' string using a specific parser implementation
Run this parser on the given 'input' string using a specific parser implementation
Attributes
- Source
- Syntax.scala
Prints a value 'value' to the target implementation 'target'
Prints a value 'value' and get back the chunk of output elements'
Prints a value 'value' to a string
This syntax repeated at least once.
This syntax repeated at least once.
The result is all the parsed elements until the first failure. The failure that stops the repetition gets swallowed and in case auto-backtracking is on, the parser backtracks to the end of the last successful item.
When printing, the input is a chunk of values and each element gets printed.
Attributes
- Source
- Syntax.scala
This syntax repeated zero or more times.
This syntax repeated zero or more times.
The result is all the parsed elements until the first failure. The failure that stops the repetition gets swallowed and in case auto-backtracking is on, the parser backtracks to the end of the last successful item.
When printing, the input is a chunk of values and each element gets printed.
Attributes
- Source
- Syntax.scala
Repeats this syntax until 'stopCondition', performed after each element, results in success.
Repeats this syntax until 'stopCondition', performed after each element, results in success.
Attributes
- Source
- Syntax.scala
Repeats this syntax at least once and with 'sep' injected between each element
Repeats this syntax at least once and with 'sep' injected between each element
Attributes
- Source
- Syntax.scala
Repeats this syntax zero or more times and with 'sep' injected between each element
Repeats this syntax zero or more times and with 'sep' injected between each element
Attributes
- Source
- Syntax.scala
Enables or disables auto-backtracking for this syntax
Ignores this syntax's result and instead captures the parsed string fragment / directly print the input string
Ignores this syntax's result and instead captures the parsed string fragment / directly print the input string
Attributes
- Source
- Syntax.scala
Strips all the name information from this syntax to improve performance but reduces the failure message's verbosity.
Strips all the name information from this syntax to improve performance but reduces the failure message's verbosity.
Attributes
- Source
- Syntax.scala
Surrounds this parser with the 'other' parser. The result is this parser's result.
Surrounds this parser with the 'other' parser. The result is this parser's result.
Attributes
- Source
- Syntax.scala
Converts a Chunk syntax to a List syntax
Maps the parser's successful result with the given function 'to', and maps the value to be printed with the given function 'from'
Maps the parser's successful result with the given function 'to', and maps the value to be printed with the given function 'from'
Attributes
- Source
- Syntax.scala
Maps the parser's successful result with the given function 'to', and maps the value to be printed with the given function 'from'. Both of the mapping functions can fail the parser/printer.
Maps the parser's successful result with the given function 'to', and maps the value to be printed with the given function 'from'. Both of the mapping functions can fail the parser/printer.
Attributes
- Source
- Syntax.scala
Maps the parser's successful result with the given function 'to', and maps the value to be printed with the given function 'from'. Both of the mapping functions can fail the parser/printer. The failure is indicated in the error channel by the value None.
Maps the parser's successful result with the given function 'to', and maps the value to be printed with the given function 'from'. Both of the mapping functions can fail the parser/printer. The failure is indicated in the error channel by the value None.
Attributes
- Source
- Syntax.scala
Maps the parsed value with the function 'to', and the value to be printed with the partial function 'from'. It the partial function is not defined on the value, the printer fails with 'failure'.
Maps the parsed value with the function 'to', and the value to be printed with the partial function 'from'. It the partial function is not defined on the value, the printer fails with 'failure'.
This can be used to define separate syntaxes for subtypes, that can be later combined.
Attributes
- Source
- Syntax.scala
Syntax that does not consume any input but prints 'printed' and results in unit
Syntax that does not consume any input but prints 'printed' and results in unit
Attributes
- Source
- Syntax.scala
Widens the parser to a supertype of its result
Widens the parser to a supertype of its result
This is useful in combination with the orElse (<>) operator. For example a JSON parser can be expressed by a combination of parsers for the individual json type widened to Json:
nul.widen[Json] <>
bool.widen[Json] <>
str.widen[Json] <>
num.widen[Json] <>
list.widen[Json] <>
obj.widen[Json]
Attributes
- Source
- package.scala
Attributes
- Source
- package.scala
Widen this syntax's printed value type by specifying a partial function to narrow it back to the set of supported subtypes.
Widen this syntax's printed value type by specifying a partial function to narrow it back to the set of supported subtypes.
Attributes
- Source
- Syntax.scala
Concatenates this syntax with 'that' syntax. In case both parser succeeds, the result is a pair of the results. The printer destructures a pair and prints the left value with this, the right value with 'that'.
Concatenates this syntax with 'that' syntax. In case both parser succeeds, the result is a pair of the results. The printer destructures a pair and prints the left value with this, the right value with 'that'.
Attributes
- Source
- package.scala
Concatenates this parser with 'that' parser. In case both parser succeeds, the result is the result of this parser. Otherwise the parser fails. The printer passes the value to be printed to this printer, and also executes 'that' printer with unit as the input value.
Concatenates this parser with 'that' parser. In case both parser succeeds, the result is the result of this parser. Otherwise the parser fails. The printer passes the value to be printed to this printer, and also executes 'that' printer with unit as the input value.
Note that the right syntax must have 'Value' defined as Unit, because there is no way for the printer to reconstruct an arbitrary input for the right printer.
Attributes
- Source
- Syntax.scala
Concatenates this parser with that parser, and if both succeeds, discard the first result and use the second.
Concatenates this parser with that parser, and if both succeeds, discard the first result and use the second.
Attributes
- Source
- package.scala
Symbolic alias for orElse
Symbolic alias for zip
Symbolic alias for zipRight
Inherited methods
Assigns 'that' syntax as a fallback of this. First this parser or printer gets evaluated. In case it succeeds, the result is this syntax's result. In case it fails, the result is 'that' syntax's result.
Assigns 'that' syntax as a fallback of this. First this parser or printer gets evaluated. In case it succeeds, the result is this syntax's result. In case it fails, the result is 'that' syntax's result.
If auto-backtracking is on, this parser will backtrack before trying 'that' parser.
Attributes
- Inherited from:
- VersionSpecificSyntax
- Source
- VersionSpecificSyntax.scala