diff options
author | Iulian Dragos <jaguarul@gmail.com> | 2007-04-26 13:37:47 +0000 |
---|---|---|
committer | Iulian Dragos <jaguarul@gmail.com> | 2007-04-26 13:37:47 +0000 |
commit | 8d2349581f5694704fb1bebc713339d46823ec67 (patch) | |
tree | 44be4d4b13a50c44a22e3310e9a2b24baa9cbf44 /docs/examples/typeinf.scala | |
parent | 99630e293745f07ac3e88582872230c015a4f963 (diff) | |
download | scala-8d2349581f5694704fb1bebc713339d46823ec67.tar.gz scala-8d2349581f5694704fb1bebc713339d46823ec67.tar.bz2 scala-8d2349581f5694704fb1bebc713339d46823ec67.zip |
Updated examples wrt.
Diffstat (limited to 'docs/examples/typeinf.scala')
-rw-r--r-- | docs/examples/typeinf.scala | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/docs/examples/typeinf.scala b/docs/examples/typeinf.scala index f2dd252ff7..da9ba9384c 100644 --- a/docs/examples/typeinf.scala +++ b/docs/examples/typeinf.scala @@ -163,55 +163,55 @@ object typeInfer { /** identifiers or keywords */ def id: Parser[String] = for ( - val c: char <- rep(chr(' ')) &&& chr(isLetter); - val cs: List[char] <- rep(chr(isLetterOrDigit)) + c: char <- rep(chr(' ')) &&& chr(isLetter); + cs: List[char] <- rep(chr(isLetterOrDigit)) ) yield (c :: cs).mkString("", "", "") /** Non-keyword identifiers */ def ident: Parser[String] = - for (val s <- id; s != "let" && s != "in") yield s + for (s <- id; if s != "let" && s != "in") yield s /** term = '\' ident '.' term | term1 {term1} | let ident "=" term in term */ def term: Parser[Term] = ( ( for ( - val _ <- wschr('\\'); - val x <- ident; - val _ <- wschr('.'); - val t <- term) + _ <- wschr('\\'); + x <- ident; + _ <- wschr('.'); + t <- term) yield Lam(x, t): Term ) ||| ( for ( - val letid <- id; letid == "let"; - val x <- ident; - val _ <- wschr('='); - val t <- term; - val inid <- id; inid == "in"; - val c <- term) + letid <- id; if letid == "let"; + x <- ident; + _ <- wschr('='); + t <- term; + inid <- id; if inid == "in"; + c <- term) yield Let(x, t, c) ) ||| ( for ( - val t <- term1; - val ts <- rep(term1)) + t <- term1; + ts <- rep(term1)) yield (t /: ts)((f, arg) => App(f, arg)) ) ) /** term1 = ident | '(' term ')' */ def term1: Parser[Term] = ( - ( for (val s <- ident) + ( for (s <- ident) yield Var(s): Term ) ||| ( for ( - val _ <- wschr('('); - val t <- term; - val _ <- wschr(')')) + _ <- wschr('('); + t <- term; + _ <- wschr(')')) yield t ) ) /** all = term ';' */ def all: Parser[Term] = for ( - val t <- term; - val _ <- wschr(';')) + t <- term; + _ <- wschr(';')) yield t } |