IdParser

laika.parse.code.common.Identifier.IdParser

Configurable base parser for identifiers in code blocks.

Attributes

Source
Identifier.scala
Graph
Supertypes
class Parser[CodeSpan]
class Object
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

Allows an identifier to be recognized if it immediately follows a digit, for example in CSS length values: 1.2em.

Allows an identifier to be recognized if it immediately follows a digit, for example in CSS length values: 1.2em.

Attributes

Source
Identifier.scala

The collection of parsers provided by this instance.

The collection of parsers provided by this instance. The order of parsers is relevant, since they will be applied in the specified order. If any parser successfully produces a result, the subsequent parsers will not be invoked.

Attributes

Definition Classes
Source
Identifier.scala
override def startChars: Type[Char]

The set of trigger characters that can start this parser.

The set of trigger characters that can start this parser.

Attributes

Definition Classes
Source
Identifier.scala

Associates the result with the specified code category.

Associates the result with the specified code category.

Attributes

Source
Identifier.scala

Applies a function to the parser result to determine the code category.

Applies a function to the parser result to determine the code category.

Attributes

Source
Identifier.scala

Adds the specified characters to the set of characters allowed as part of an identifier, but not allowed as the first character.

Adds the specified characters to the set of characters allowed as part of an identifier, but not allowed as the first character.

Attributes

Source
Identifier.scala

Adds the specified characters to the set of characters allowed to start an identifier.

Adds the specified characters to the set of characters allowed to start an identifier. Will also be added to the set of characters for the parser of the rest of the identifier.

Attributes

Source
Identifier.scala

Adds the specified prefix to this identifier.

Adds the specified prefix to this identifier.

The resulting parser will first parse this prefix and subsequently the base parser for this identifier that will still apply the rules for which characters are allowed to start the identifier.

An example would be an identifier like #foo in CSS, where # is the prefix, and foo follows the rules of this identifier parser.

Attributes

Source
Identifier.scala

Inherited methods

def *: Repeat[CodeSpan]

Returns a parser that repeatedly applies this parser.

Returns a parser that repeatedly applies this parser. It will always succeed, potentially with an empty list as the result.

Attributes

Inherited from:
Parser
Source
Parser.scala
def +: Repeat[CodeSpan]

Returns a parser that repeatedly applies this parser (at least once).

Returns a parser that repeatedly applies this parser (at least once).

Attributes

Inherited from:
Parser
Source
Parser.scala

Merges the parsers of this collection with those of the specified other collection.

Merges the parsers of this collection with those of the specified other collection. The order of parsers is relevant, since they will be applied in the specified order. If any parser successfully produces a result, the subsequent parsers will not be invoked

Attributes

Inherited from:
CodeSpanParser
Source
CodeSpanParser.scala

Attempts to parse the specified literal string from the input left over by this parser, but only keeps the left result.

Attempts to parse the specified literal string from the input left over by this parser, but only keeps the left result.

a <~ b only succeeds if both parsers succeed.

Attributes

Definition Classes
Inherited from:
PrefixedParser
Source
PrefixedParser.scala
override def <~[U](p: Parser[U]): PrefixedParser[CodeSpan]

Applies the specified parser to the input left over by this parser, but only keeps the left result.

Applies the specified parser to the input left over by this parser, but only keeps the left result.

a <~ b only succeeds if both parsers succeed.

Attributes

Definition Classes
Inherited from:
PrefixedParser
Source
PrefixedParser.scala
override def >>[U](fq: CodeSpan => Parser[U]): PrefixedParser[U]

Operator synonym for flatMap.

Operator synonym for flatMap.

Attributes

Definition Classes
Inherited from:
PrefixedParser
Source
PrefixedParser.scala

Returns a parser that optionally parses what this parser parses.

Returns a parser that optionally parses what this parser parses.

Attributes

Inherited from:
Parser
Source
Parser.scala
override def ^^[U](f: CodeSpan => U): PrefixedParser[U]

A synonym for map, allowing the grammar to be declared in a concise way.

A synonym for map, allowing the grammar to be declared in a concise way.

Attributes

Definition Classes
Inherited from:
PrefixedParser
Source
PrefixedParser.scala
override def as[U](v: => U): PrefixedParser[U]

Returns a parser that ignores the result of this parser (if it succeeds) and returns the specified result instead.

Returns a parser that ignores the result of this parser (if it succeeds) and returns the specified result instead.

Subclasses may override this method to avoid any expensive result processing.

Attributes

Definition Classes
Inherited from:
PrefixedParser
Source
PrefixedParser.scala
override def collect[U, V >: CodeSpan](f: PartialFunction[CodeSpan, U], error: V => String): PrefixedParser[U]

Returns a parser that applies a partial function to the result of this parser.

Returns a parser that applies a partial function to the result of this parser.

p.collect(f) succeeds if p succeeds and f is defined at the result of p, In that case it returns f applied to the result of p.

Value parameters

error

an optional function that takes the same argument as f and produces an error message.

f

a partial function that will be applied to this parser's result.

Attributes

Definition Classes
Inherited from:
PrefixedParser
Source
PrefixedParser.scala
def count: Parser[Int]

Returns a parser that produces the number of characters consumed by this parser while discarding the original result.

Returns a parser that produces the number of characters consumed by this parser while discarding the original result.

Attributes

Inherited from:
Parser
Source
Parser.scala

Provides a cursor over the input consumed by this parser while discarding the actual result.

Provides a cursor over the input consumed by this parser while discarding the actual result. Use withCursor if you also need access to the result.

This is required for parsers that create AST nodes that need to be resolved in a rewrite step and need to report the source location in case of failure. It is also required when passing a result of a first-pass parser to a recursive parser to preserve line positions.

Attributes

Definition Classes
Inherited from:
PrefixedParser
Source
PrefixedParser.scala
override def evalMap[U](f: CodeSpan => Either[String, U]): PrefixedParser[U]

Returns a parser that applies a function to the result of this parser producing an Either where Left is interpreted as failure.

Returns a parser that applies a function to the result of this parser producing an Either where Left is interpreted as failure. It is an alternative to ^? for scenarios where the conditional check cannot be easily performed in a pattern match.

p.evalMap(f) succeeds if p succeeds and f returns a Right when applied to the result of p.

Attributes

Definition Classes
Inherited from:
PrefixedParser
Source
PrefixedParser.scala
override def flatMap[U](f: CodeSpan => Parser[U]): PrefixedParser[U]

Builds a new parser by applying the specified function to the result of this parser and subsequently applying the parser returned by that function to the input left over by this parser.

Builds a new parser by applying the specified function to the result of this parser and subsequently applying the parser returned by that function to the input left over by this parser.

Attributes

Definition Classes
Inherited from:
PrefixedParser
Source
PrefixedParser.scala

Handle any error, potentially recovering from it, by mapping it to a new parser that will be applied at the same starting position as the failing parser.

Handle any error, potentially recovering from it, by mapping it to a new parser that will be applied at the same starting position as the failing parser.

This is similar to the orElse or | method, but allows the alternative parser to inspect the error of the preceding one.

Attributes

See also

recoverWith to recover from only certain errors.

Inherited from:
Parser
Source
Parser.scala
override def map[U](f: CodeSpan => U): PrefixedParser[U]

Builds a new parser by applying the specified function to the result of this parser.

Builds a new parser by applying the specified function to the result of this parser.

Attributes

Definition Classes
Inherited from:
PrefixedParser
Source
PrefixedParser.scala

Applies the specified parser when this parser fails.

Applies the specified parser when this parser fails.

a.orElse(b) succeeds if either of the parsers succeeds.

This is a specialized variant of the orElse method of the base trait that preserves the nature of the PrefixedParser if both original parsers implement this trait.

Attributes

Inherited from:
PrefixedParser
Source
PrefixedParser.scala
def orElse[U >: CodeSpan](p0: => Parser[U]): Parser[U]

Applies the specified parser when this parser fails.

Applies the specified parser when this parser fails.

a orElse b succeeds if either of the parsers succeeds.

In case both parsers fail, the Failure instance will be from the parser with the most successfully read characters. In the case of multiple failures having the same number of characters, the one with the highest precedence (this parser) will be chosen.

Implementation note: The parameter is by-name to allow the definition of recursive parsers. In contrast to the former SDK parser combinators this is the only place where a parser with a by-name parameter is used whereas in all other places the additional cost is avoided.

Attributes

Inherited from:
Parser
Source
Parser.scala

Parses the string content in the specified context and returns the result.

Parses the string content in the specified context and returns the result.

This is the only abstract method in Parser that concrete implementations need to implement.

Attributes

Inherited from:
PrefixedParser
Source
PrefixedParser.scala

Parses the specified string and returns the result.

Parses the specified string and returns the result.

Attributes

Inherited from:
Parser
Source
Parser.scala

Handle certain errors, potentially recovering from it, by mapping them to a new parser that will be applied at the same starting position than the failing parser.

Handle certain errors, potentially recovering from it, by mapping them to a new parser that will be applied at the same starting position than the failing parser.

Attributes

See also

handleErrorWith to handle any/all errors.

Inherited from:
Parser
Source
Parser.scala

Returns a parser that repeatedly applies this parser with the specified separator string between those invocations.

Returns a parser that repeatedly applies this parser with the specified separator string between those invocations.

p.rep(sep).min(1) is equivalent to (p ~ (sep ~> p).rep).concat.

The returned parser offers an API to specify further constraints like min or max.

Attributes

Inherited from:
Parser
Source
Parser.scala

Returns a parser that repeatedly applies this parser with the specified separator parser between those invocations.

Returns a parser that repeatedly applies this parser with the specified separator parser between those invocations.

p.rep(sep).min(1) is equivalent to (p ~ (sep ~> p).rep).concat.

The returned parser offers an API to specify further constraints like min or max.

Attributes

Inherited from:
Parser
Source
Parser.scala

Returns a parser that repeatedly applies this parser.

Returns a parser that repeatedly applies this parser. The returned parser offers an API to specify further constraints like min or max.

Attributes

Inherited from:
Parser
Source
Parser.scala

Returns a parser that repeatedly applies this parser until either this parser fails or the specified end condition is met.

Returns a parser that repeatedly applies this parser until either this parser fails or the specified end condition is met. The end condition will be applied after each successful invocation of this parser.

The result of the returned parser is a tuple consisting of the list containing the result of the invocations of this parser plus the result of the end condition. The latter is returned as an Option as it might be empty when the parsing finished because of this parser failing.

Note that it is more convenient to include the end condition in the repeating parser itself and use the simpler rep method. This combinator is an alternative if you need to know the result of the end condition.

Attributes

Inherited from:
Parser
Source
Parser.scala
def repWith[U >: CodeSpan](next: U => Parser[U]): Parser[List[U]]

Returns a parser that invokes the specified function repeatedly, passing the result of this parser if it succeeds, to produce new parsers that get applied until one of them fails.

Returns a parser that invokes the specified function repeatedly, passing the result of this parser if it succeeds, to produce new parsers that get applied until one of them fails.

The result of the returned parser is a list containing the result of this parser (if it succeeds) plus the results of successful invocations of the parsers returned by the specified function.

Attributes

Inherited from:
Parser
Source
Parser.scala
override def source: PrefixedParser[String]

Retrieves the part of the input consumed by this parser while discarding the result.

Retrieves the part of the input consumed by this parser while discarding the result.

This is useful in scenarios where many string-based parsers are combined and produce a deeply nested result like String ~ Option[String] ~ List[String] where it would require some boilerplate to concatenate the results. Using the source method, the entire text consumed by this combination of parsers will be returned.

If you also need the position within the input or need to pass the result to a recursive parser manually, use the cursor method instead.

Attributes

Definition Classes
Inherited from:
PrefixedParser
Source
PrefixedParser.scala
def void: Parser[Unit]

Discards the result of a successful parser.

Discards the result of a successful parser.

Attributes

Inherited from:
Parser
Source
Parser.scala

Provides the result of this parser together with a cursor over the input, capturing the consumed source string and its position within the root input.

Provides the result of this parser together with a cursor over the input, capturing the consumed source string and its position within the root input. Use cursor if you do not need access to the actual result.

This is required for parsers that create AST nodes that need to be resolved in a rewrite step and need to report the source location in case of failure. It is also required when passing a result of a first-pass parser to a recursive parser to preserve line positions.

Attributes

Definition Classes
Inherited from:
PrefixedParser
Source
PrefixedParser.scala

Changes the failure message produced by a parser.

Changes the failure message produced by a parser.

Attributes

Inherited from:
Parser
Source
Parser.scala
override def |(value: String)(implicit ev: CodeSpan <:< String): PrefixedParser[String]

Attempts to parse the specified literal string when this parser fails.

Attempts to parse the specified literal string when this parser fails.

a | b succeeds if either of the parsers succeeds.

Attributes

Definition Classes
Inherited from:
PrefixedParser
Source
PrefixedParser.scala

Applies the specified parser when this parser fails.

Applies the specified parser when this parser fails.

a | b succeeds if either of the parsers succeeds.

This is a specialized variant of the | method of the base trait that preserves the nature of the PrefixedParser if both original parsers implement this trait.

Attributes

Inherited from:
PrefixedParser
Source
PrefixedParser.scala
def |[U >: CodeSpan](p: => Parser[U]): Parser[U]

Applies the specified parser when this parser fails.

Applies the specified parser when this parser fails.

a | b succeeds if either of the parsers succeeds.

Implementation note: The parameter is by-name to allow the definition of recursive parsers. In contrast to the former SDK parser combinators this is the only place where a parser with a by-name parameter is used whereas in all other places the additional cost is avoided.

Attributes

Inherited from:
Parser
Source
Parser.scala

Attempts to parse the specified literal string from the input left over by this parser and combines the two results.

Attempts to parse the specified literal string from the input left over by this parser and combines the two results.

a ~ b only succeeds if both parsers succeed, with the results in a wrapper class named ~ for convenient pattern matching:

a ~ b ~ c ^^ {
  case a ~ b ~ c => processResult(a, b, c)
}

Attributes

Definition Classes
Inherited from:
PrefixedParser
Source
PrefixedParser.scala
override def ~[U](p: Parser[U]): PrefixedParser[CodeSpan ~ U]

Applies the specified parser to the input left over by this parser and combines the two results.

Applies the specified parser to the input left over by this parser and combines the two results.

a ~ b only succeeds if both parsers succeed, with the results in a wrapper class named ~ for convenient pattern matching:

a ~ b ~ c ^^ {
  case a ~ b ~ c => processResult(a, b, c)
}

Attributes

Definition Classes
Inherited from:
PrefixedParser
Source
PrefixedParser.scala
override def ~>(value: String): PrefixedParser[String]

Attempts to parse the specified literal string from the input left over by this parser, but only keeps the right result.

Attempts to parse the specified literal string from the input left over by this parser, but only keeps the right result.

a ~> b only succeeds if both parsers succeed.

Attributes

Definition Classes
Inherited from:
PrefixedParser
Source
PrefixedParser.scala
override def ~>[U](p: Parser[U]): PrefixedParser[U]

Applies the specified parser to the input left over by this parser, but only keeps the right result.

Applies the specified parser to the input left over by this parser, but only keeps the right result.

a ~> b only succeeds if both parsers succeed.

Attributes

Definition Classes
Inherited from:
PrefixedParser
Source
PrefixedParser.scala

Concrete fields

The underlying parser that may be optimized based on the specified start characters.

The underlying parser that may be optimized based on the specified start characters.

Attributes

Source
Identifier.scala