equal
deleted
inserted
replaced
101 val NumParserInt2 = NumParser.map(_.toInt) |
101 val NumParserInt2 = NumParser.map(_.toInt) |
102 |
102 |
103 |
103 |
104 // A parser for palindromes (just returns them as string) |
104 // A parser for palindromes (just returns them as string) |
105 lazy val Pal : Parser[String, String] = { |
105 lazy val Pal : Parser[String, String] = { |
106 (p"a" ~ Pal ~ p"a").map{ case ((x, y), z) => s"$x$y$z" } || |
106 ((p"a" ~ Pal) ~ p"a").map{ case ((x, y), z) => s"$x$y$z" } || |
107 (p"b" ~ Pal ~ p"b").map{ case ((x, y), z) => s"$x$y$z" } || |
107 (p"b" ~ Pal ~ p"b").map{ case ((x, y), z) => s"$x$y$z" } || |
108 p"a" || p"b" || p"" |
108 p"a" || p"b" || p"" |
109 } |
109 } |
|
110 |
|
111 def foo(x: Int) = |
|
112 println(s"$x + $x = ${x + x}") |
110 |
113 |
111 // examples |
114 // examples |
112 Pal.parse_all("abaaaba") |
115 Pal.parse_all("abaaaba") |
113 Pal.parse("abaaaba") |
116 Pal.parse("abaaaba") |
114 |
117 |