Last active
August 29, 2015 13:57
-
-
Save frozenspider/9615134 to your computer and use it in GitHub Desktop.
trait Parsers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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