harrah/xsbt — pull request #396 by eed3si9n (2012-03-11 12:14:45+00:00)
Title: Parser for escaped and verbatim string literals

## background

see [Arguments with whitespace][1]. Heiko wrote:

> How can I pass arguments to the run method that contain a whitespace, e.g.
>
> run "Mark Harrah"

## what's here

I've changed the `spaceDelimited` parser as follows:

```scala
def spaceDelimited(display: String): Parser[Seq[String]] = (token(Space) ~> token(StringBasic, display)).* <~ SpaceClass.*
```

Instead of simple `NotSpace`, it uses `StringBasic`, which parses three different kinds of strings:

```scala
lazy val StringBasic = StringVerbatim | StringEscapable | NotQuoted
```

### verbatim string

Verbatim string uses the same style as Scala:

```
run """foo bar C:\""" """x"""
```

Arguments are passed into the app as two arguments.

### escaped string

Escaped string uses the same style as Scala/Java. See [String Literals][2] for Java spec.

```scala
run "baz\u0398\t\""
```

This passes in `bazΘ	"`.

### unquoted string

Finally, for backward compat, we have unquoted string, which begins with non-double-quotation character and ends with a space.

## note

All escape sequence evaluations are done at the parser-level, so the underlying settings system does not see any escaping. Thus most of the existing tasks should be able get the benefits without changing them.
The exceptions are InputTasks and Command that currently uses `"` and `\`.

[1]: https://groups.google.com/forum/#!topic/simple-build-tool/el5c3oaSgsw/discussion
[2]: http://docs.oracle.com/javase/specs/jls/se5.0/html/lexical.html#101083