progs/parser-combinators/comb1.sc
changeset 801 7aab258bf72a
parent 799 85267be9a5ed
child 803 d4fb8c7fc3bf
--- a/progs/parser-combinators/comb1.sc	Sat Nov 07 00:07:28 2020 +0000
+++ b/progs/parser-combinators/comb1.sc	Thu Nov 12 12:18:51 2020 +0000
@@ -79,9 +79,13 @@
 // p"<_some_string_>" 
 
 implicit def parser_interpolation(sc: StringContext) = new {
-  def p(args: Any*) = StrParser(sc.s(args:_*))
+  def p(args: Any*) = TokParser(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 {
@@ -102,7 +106,7 @@
 
 
 // A parser for palindromes (just returns them as string)
-lazy val Pal : Parser[String, String] = {
+lazy val Pal : Parser[List[Token], 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""