--- a/parser3.scala Fri Nov 23 21:21:27 2012 +0000
+++ b/parser3.scala Sat Nov 24 07:08:51 2012 +0000
@@ -7,6 +7,11 @@
def parse_all(ts: I) : Set[T] =
for ((head, tail) <- parse(ts); if (tail.isEmpty)) yield head
+ def parse_single(ts: I) : T = parse_all(ts).toList match {
+ case t::Nil => t
+ case _ => { println ("Parse Error") ; sys.exit(-1) }
+ }
+
def || (right : => Parser[I, T]) : Parser[I, T] = new AltParser(this, right)
def ==>[S] (f: => T => S) : Parser [I, S] = new FunParser(this, f)
def ~[S] (right : => Parser[I, S]) : Parser[I, (T, S)] = new SeqParser(this, right)