mirror of
https://github.com/sbt/sbt.git
synced 2026-09-07 11:01:08 +02:00
fix 'not' parser combinator, add EOF
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user