diff options
author | Martin Odersky <odersky@gmail.com> | 2005-01-27 14:11:26 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2005-01-27 14:11:26 +0000 |
commit | d0cf4e00d7f234bf98af37518c26eecf169ff99c (patch) | |
tree | 512a2c3cd5676c58e465dd4b6080eedb997b0a28 /sources/examples/parsers1.scala | |
parent | edf4302bff80e8d5ade347ea0d8256100fb49483 (diff) | |
download | scala-d0cf4e00d7f234bf98af37518c26eecf169ff99c.tar.gz scala-d0cf4e00d7f234bf98af37518c26eecf169ff99c.tar.bz2 scala-d0cf4e00d7f234bf98af37518c26eecf169ff99c.zip |
*** empty log message ***
Diffstat (limited to 'sources/examples/parsers1.scala')
-rw-r--r-- | sources/examples/parsers1.scala | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/sources/examples/parsers1.scala b/sources/examples/parsers1.scala index 09de0343ab..2ed0f4be4b 100644 --- a/sources/examples/parsers1.scala +++ b/sources/examples/parsers1.scala @@ -4,18 +4,18 @@ object parsers1 { abstract class Parsers { - type intype; + type inputType; abstract class Parser { - type Result = Option[intype]; + type Result = Option[inputType]; - def apply(in: intype): Result; + def apply(in: inputType): Result; /*** p &&& q applies first p, and if that succeeds, then q */ def &&& (def q: Parser) = new Parser { - def apply(in: intype): Result = Parser.this.apply(in) match { + def apply(in: inputType): Result = Parser.this.apply(in) match { case None => None case Some(in1) => q(in1) } @@ -24,7 +24,7 @@ object parsers1 { /*** p ||| q applies first p, and, if that fails, then q. */ def ||| (def q: Parser) = new Parser { - def apply(in: intype): Result = Parser.this.apply(in) match { + def apply(in: inputType): Result = Parser.this.apply(in) match { case None => q(in) case s => s } @@ -32,11 +32,11 @@ object parsers1 { } val empty = new Parser { - def apply(in: intype): Result = Some(in) + def apply(in: inputType): Result = Some(in) } val fail = new Parser { - def apply(in: intype): Result = None + def apply(in: inputType): Result = None } def opt(p: Parser): Parser = p ||| empty; // p? = (p | <empty>) @@ -69,7 +69,7 @@ object parsers1 { } class ParseString(s: String) extends Parsers { - type intype = int; + type inputType = int; val input = 0; def chr(p: char => boolean) = new Parser { def apply(in: int): Parser#Result = |