Scala 2.6.1-final

API Specification

This document is the API specification for Scala Library Documentation

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

Parsers is a component that provides generic parser combinators.

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 Parser[T] provides both kinds of information, but a UnitParser only signals success/failure. When composing a `UnitParser' with a normal Parser, the UnitParser only contributes to whether the combined parser is successful (i.e., its result is discarded).

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...

  • is equal to some given object,
  • satisfies a certain predicate,
  • is in the domain of a given partial function,....

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).

case class ~ [+a, +b](val _1 : a, val _2 : b) extends Product
Object Summary
object mkTilde extends AnyRef