Skip to content

Instantly share code, notes, and snippets.

@frozenspider
Last active August 29, 2015 13:57
Show Gist options
  • Save frozenspider/9615134 to your computer and use it in GitHub Desktop.
Save frozenspider/9615134 to your computer and use it in GitHub Desktop.
trait Parsers
trait Parsers {
type Elem
type Input = Reader[Elem]
sealed abstract class ParseResult[+T] {
...
}
case class Success[+T](result: T, override val next: Input) extends ParseResult[T] {
...
}
sealed abstract class NoSuccess(val msg: String, override val next: Input) extends ParseResult[Nothing] {
...
}
case class Failure(override val msg: String, override val next: Input) extends NoSuccess(msg, next) {
...
}
case class Error(override val msg: String, override val next: Input) extends NoSuccess(msg, next) {
...
}
def Parser[T](f: Input => ParseResult[T]): Parser[T] = ...
abstract class Parser[+T] extends (Input => ParseResult[T]) {
...
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment