Skip to content

Commit

Permalink
fix 'not' parser combinator, add EOF
Browse files Browse the repository at this point in the history
  • Loading branch information
harrah committed Dec 13, 2011
1 parent 51f8885 commit bca9ace
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 4 additions & 1 deletion util/complete/Parser.scala
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions util/complete/Parsers.scala
Expand Up @@ -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")
Expand Down

0 comments on commit bca9ace

Please sign in to comment.