--- a/progs/parser-combinators/comb1.sc Thu Nov 12 12:22:26 2020 +0000
+++ b/progs/parser-combinators/comb1.sc Fri Nov 13 15:03:48 2020 +0000
@@ -79,13 +79,9 @@
// p"<_some_string_>"
implicit def parser_interpolation(sc: StringContext) = new {
- def p(args: Any*) = TokParser(sc.s(args:_*))
+ def p(args: Any*) = StrParser(sc.s(args:_*))
}
-
-p"while" ==> StrParser[String,....]
- TokParser[List[Token],....]
-
-for x := 3 to 10
+
// more convenient syntax for parser combinators
implicit def ParserOps[I : IsSeq, T](p: Parser[I, T]) = new {
@@ -106,7 +102,7 @@
// A parser for palindromes (just returns them as string)
-lazy val Pal : Parser[List[Token], String] = {
+lazy val Pal : Parser[String, String] = {
(p"a" ~ Pal ~ p"a").map{ case ((x, y), z) => s"$x$y$z" } ||
(p"b" ~ Pal ~ p"b").map{ case ((x, y), z) => s"$x$y$z" } ||
p"a" || p"b" || p""