session manipulation commands

save, clear, list, and remove session settings
This commit is contained in:
Mark Harrah 2011-02-02 22:56:11 -05:00
parent 536e95cca5
commit 8183b717dd
1 changed files with 4 additions and 0 deletions

View File

@ -39,9 +39,13 @@ trait Parsers
lazy val Port = token(IntBasic, "<port>")
lazy val IntBasic = mapOrFail( '-'.? ~ Digit.+ )( Function.tupled(toInt) )
lazy val NatBasic = mapOrFail( Digit.+ )( _.mkString.toInt )
private[this] def toInt(neg: Option[Char], digits: Seq[Char]): Int =
(neg.toSeq ++ digits).mkString.toInt
def rep1sep[T](rep: Parser[T], sep: Parser[_]): Parser[Seq[T]] =
(rep ~ (sep ~> rep).*).map { case (x ~ xs) => x +: xs }
def mapOrFail[S,T](p: Parser[S])(f: S => T): Parser[T] =
p flatMap { s => try { success(f(s)) } catch { case e: Exception => failure(e.toString) } }