From f8a1d2ca7bf5dc81e9c729a51a628d691f650b50 Mon Sep 17 00:00:00 2001 From: Mark Harrah Date: Mon, 30 Sep 2013 09:03:39 -0400 Subject: [PATCH] Docs: add section on built-in parsers to Parsing-Input --- src/sphinx/Detailed-Topics/Parsing-Input.rst | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/sphinx/Detailed-Topics/Parsing-Input.rst b/src/sphinx/Detailed-Topics/Parsing-Input.rst index 0938a9bf2..edb25b722 100644 --- a/src/sphinx/Detailed-Topics/Parsing-Input.rst +++ b/src/sphinx/Detailed-Topics/Parsing-Input.rst @@ -15,9 +15,9 @@ Parser combinators build up a parser from smaller parsers. A `String => Option[T]`. It accepts a `String` to parse and produces a value wrapped in `Some` if parsing succeeds or `None` if it fails. Error handling and tab completion make this picture more complicated, -but we'll stick with Option for this discussion. +but we'll stick with `Option` for this discussion. -The following examples assume the imports: +The following examples assume the imports: :: import sbt._ import complete.DefaultParsers._ @@ -54,6 +54,20 @@ from a `Char` or `String`. Other basic parser constructors are the // The argument is the error message. val alwaysFail: Parser[Nothing] = failure("Invalid input.") +Built-in parsers +---------------- + +sbt comes with several built-in parsers defined in `sbt.complete.DefaultParsers <../../api/sbt/complete/DefaultParsers$.html>`_. +Some commonly used built-in parsers are: + + * `Space`, `NotSpace`, `OptSpace`, and `OptNotSpace` for parsing spaces or non-spaces, required or not. + * `StringBasic` for parsing text that may be quoted. + * `IntBasic` for parsing a signed Int value. + * `Digit` and `HexDigit` for parsing a single decimal or hexadecimal digit. + * `Bool` for parsing a `Boolean` value + +See the `DefaultParsers API <../../api/sbt/complete/DefaultParsers$.html>`_ for details. + Combining parsers -----------------