changeset 177 | 53def1fbf472 |
parent 172 | 47b5c91eff47 |
child 178 | d36363d648e3 |
--- a/progs/comb1.scala Fri Nov 01 15:56:17 2013 +0000 +++ b/progs/comb1.scala Fri Nov 01 23:19:45 2013 +0000 @@ -24,6 +24,11 @@ } // atomic parsers +case class CharParser(c: Char) extends Parser[String, Char] { + def parse(sb: String) = + if (sb.head == c) Set((c, sb.tail)) else Set() +} + case class StringParser(s: String) extends Parser[String, String] { def parse(sb: String) = { val (prefix, suffix) = sb.splitAt(s.length)