fix 'not' parser combinator, add EOF

This commit is contained in:
Mark Harrah 2011-12-13 17:29:08 -05:00
parent 0ff6b65376
commit a9ccd74eb8
2 changed files with 6 additions and 1 deletions

View File

@ -345,7 +345,10 @@ trait ParserMain
else
b
def not(p: Parser[_]): Parser[Unit] = new Not(p)
def not(p: Parser[_]): Parser[Unit] = p.result match {
case None => new Not(p)
case Some(_) => failure("Excluded.")
}
def oneOf[T](p: Seq[Parser[T]]): Parser[T] = p.reduceLeft(_ | _)
def seq[T](p: Seq[Parser[T]]): Parser[Seq[T]] = seq0(p, Nil)

View File

@ -11,6 +11,8 @@ package sbt.complete
// Some predefined parsers
trait Parsers
{
lazy val EOF = not(any)
lazy val any: Parser[Char] = charClass(_ => true, "any character")
lazy val DigitSet = Set("0","1","2","3","4","5","6","7","8","9")