summaryrefslogtreecommitdiff
path: root/sources/examples
diff options
context:
space:
mode:
authormichelou <michelou@epfl.ch>2004-05-10 11:20:07 +0000
committermichelou <michelou@epfl.ch>2004-05-10 11:20:07 +0000
commit0c2b5967e0fd21a8f82b8e6b69412cf7c85581d4 (patch)
tree15d2e3b500252e76b02bbee485d6f7e233aad100 /sources/examples
parentcb2627b3cc4e57935717b520791c4e27f1eb9cc0 (diff)
downloadscala-0c2b5967e0fd21a8f82b8e6b69412cf7c85581d4.tar.gz
scala-0c2b5967e0fd21a8f82b8e6b69412cf7c85581d4.tar.bz2
scala-0c2b5967e0fd21a8f82b8e6b69412cf7c85581d4.zip
- changed indentation.
Diffstat (limited to 'sources/examples')
-rw-r--r--sources/examples/parsers1.scala58
1 files changed, 29 insertions, 29 deletions
diff --git a/sources/examples/parsers1.scala b/sources/examples/parsers1.scala
index 426ec809fa..09de0343ab 100644
--- a/sources/examples/parsers1.scala
+++ b/sources/examples/parsers1.scala
@@ -2,47 +2,47 @@ package examples;
object parsers1 {
-abstract class Parsers {
+ abstract class Parsers {
- type intype;
+ type intype;
- abstract class Parser {
+ abstract class Parser {
- type Result = Option[intype];
+ type Result = Option[intype];
- def apply(in: intype): Result;
+ def apply(in: intype): 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 {
- case None => None
- case Some(in1) => q(in1)
+ /*** 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 {
+ case None => None
+ case Some(in1) => q(in1)
+ }
}
- }
- /*** 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 {
- case None => q(in)
- case s => s
+ /*** 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 {
+ case None => q(in)
+ case s => s
+ }
}
}
- }
- val empty = new Parser {
- def apply(in: intype): Result = Some(in)
- }
+ val empty = new Parser {
+ def apply(in: intype): Result = Some(in)
+ }
- val fail = new Parser {
- def apply(in: intype): Result = None
- }
+ val fail = new Parser {
+ def apply(in: intype): Result = None
+ }
- def opt(p: Parser): Parser = p ||| empty; // p? = (p | <empty>)
- def rep(p: Parser): Parser = opt(rep1(p)); // p* = [p+]
- def rep1(p: Parser): Parser = p &&& rep(p); // p+ = p p*
-}
+ def opt(p: Parser): Parser = p ||| empty; // p? = (p | <empty>)
+ def rep(p: Parser): Parser = opt(rep1(p)); // p* = [p+]
+ def rep1(p: Parser): Parser = p &&& rep(p); // p+ = p p*
+ }
abstract class ListParsers extends Parsers {
def chr(p: char => boolean): Parser;