Class Summary | |
trait
|
ImplicitConversions
extends AnyRef
This object contains implicit conversions that come in handy when using the `^^' combinator
{@see Parsers} to construct an AST from the concrete syntax.
The reason for this is that the sequential composition combinator (`~') combines its constituents into a ~. When several `~'s are combined, this results in nested `~'s (to the left). The `flatten*' coercions makes it easy to apply an `n'-argument function to a nested ~ of depth (`n-1') The `headOptionTailToFunList' converts a function that takes a List[A] to a function that accepts a ~[A, Option[List[A]]] (this happens when, e.g., parsing something of the following shape: p ~ opt("." ~ repsep(p, ".")) -- where `p' is a parser that yields an A) |
trait
|
Parsers
extends AnyRef
It requires the type of the elements these parsers should parse (each parser is polymorphic in the type of result it produces).
There are two aspects to the result of a parser: (1) success or failure,
and (2) the result. A The term ``parser combinator'' refers to the fact that these parsers are constructed from primitive parsers and composition operators, such as sequencing, alternation, optionality, repetition, lifting, and so on. A ``primitive parser'' is a parser that accepts or rejects a single piece of input, based on a certain criterion, such as whether the input...
Even more primitive parsers always produce the same result, irrespective of the input. @requires Elem the type of elements the provided parsers consume (When consuming invidual characters, a parser is typically called a ``scanner'', which produces ``tokens'' that are consumed by what is normally called a ``parser''. Nonetheless, the same principles apply, regardless of the input type.)@provides Input = Reader[Elem] The type of input the parsers in this component expect. @provides Parser[+T] extends (Input => ParseResult[T]) Essentially, a `Parser[T]' is a function from `Input' to `ParseResult[T]'. @provides ParseResult[+T] is like an `Option[T]', in the sense that it is either `Success[T]', which consists of some result (:T) (and the rest of the input) or `Failure[T]', which provides an error message (and the rest of the input). |