summaryrefslogtreecommitdiff
path: root/docs/examples/parsing/lambda
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan.moors@epfl.ch>2008-02-07 12:39:51 +0000
committerAdriaan Moors <adriaan.moors@epfl.ch>2008-02-07 12:39:51 +0000
commit0eae9599357eb76fb38d2a95d1d4d6f089b814b3 (patch)
tree0cb296642e3d3f8b4d9d63bfab76d374750d3c13 /docs/examples/parsing/lambda
parentf3e42a50ab77e51040b3698c710b1ca86bfc0611 (diff)
downloadscala-0eae9599357eb76fb38d2a95d1d4d6f089b814b3.tar.gz
scala-0eae9599357eb76fb38d2a95d1d4d6f089b814b3.tar.bz2
scala-0eae9599357eb76fb38d2a95d1d4d6f089b814b3.zip
updated examples and json parser to use combina...
updated examples and json parser to use combinator1-style parsing, have not yet renamed combinator -> combinatorold, and combinator1 -> combinator --> doing that using SVN rename, so history is preserved (thus, the build for this revision will break, but the next one should be okay. sorry)
Diffstat (limited to 'docs/examples/parsing/lambda')
-rwxr-xr-xdocs/examples/parsing/lambda/Main.scala2
-rwxr-xr-xdocs/examples/parsing/lambda/TestParser.scala22
2 files changed, 12 insertions, 12 deletions
diff --git a/docs/examples/parsing/lambda/Main.scala b/docs/examples/parsing/lambda/Main.scala
index c0453e75a8..81a175de77 100755
--- a/docs/examples/parsing/lambda/Main.scala
+++ b/docs/examples/parsing/lambda/Main.scala
@@ -12,7 +12,7 @@ import java.io.InputStreamReader
*
* Usage: scala examples.parsing.lambda.Main <file>
*
- * (example files: see test/*.kwi)
+ * (example files: see test/ *.kwi)
*
* @author Miles Sabin (adapted slightly by Adriaan Moors)
*/
diff --git a/docs/examples/parsing/lambda/TestParser.scala b/docs/examples/parsing/lambda/TestParser.scala
index 92d370c29b..22257c1731 100755
--- a/docs/examples/parsing/lambda/TestParser.scala
+++ b/docs/examples/parsing/lambda/TestParser.scala
@@ -34,33 +34,33 @@ trait TestParser extends StdTokenParsers with ImplicitConversions with TestSynt
chainl1(expr4, expr3, op3 ^^ {o => (a: Term, b: Term) => App(App(o, a), b)})
def expr4 : Parser[Term] =
- ( "\\" ~ lambdas
- | "let" ~ name ~ "=" ~ expr1 ~ "in" ~ expr1 ^^ flatten3(Let)
- | "if" ~ expr1 ~ "then" ~ expr1 ~ "else" ~ expr1 ^^ flatten3(If)
+ ( "\\" ~> lambdas
+ | ("let" ~> name) ~ ("=" ~> expr1) ~ ("in" ~> expr1) ^^ flatten3(Let)
+ | ("if" ~> expr1) ~ ("then" ~> expr1) ~ ("else" ~> expr1) ^^ flatten3(If)
| chainl1(aexpr, success(App(_: Term, _: Term)))
)
def lambdas : Parser[Term] =
- name ~ ("->" ~ expr1 | lambdas) ^^ flatten2(Lam)
+ name ~ ("->" ~> expr1 | lambdas) ^^ flatten2(Lam)
def aexpr : Parser[Term] =
( numericLit ^^ (_.toInt) ^^ Lit
| name ^^ Ref
- | "unit" ^^ Unit
- | "(" ~ expr1 ~ ")"
+ | "unit" ^^^ Unit()
+ | "(" ~> expr1 <~ ")"
)
def op1 : Parser[Term] =
- "==" ^^ Ref(Name("=="))
+ "==" ^^^ Ref(Name("=="))
def op2 : Parser[Term] =
- ( "+" ^^ Ref(Name("+"))
- | "-" ^^ Ref(Name("-"))
+ ( "+" ^^^ Ref(Name("+"))
+ | "-" ^^^ Ref(Name("-"))
)
def op3 : Parser[Term] =
- ( "*" ^^ Ref(Name("*"))
- | "/" ^^ Ref(Name("/"))
+ ( "*" ^^^ Ref(Name("*"))
+ | "/" ^^^ Ref(Name("/"))
)
def parse(r: Reader[char]) : ParseResult[Term] =