Parser for escaped and verbatim string literals #396

harrah opened this Issue Jan 5, 2013 · 1 comment

1 participant



see Arguments with whitespace. 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:

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:

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 for Java spec.

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.

run quux


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 \.


IMPORTANT This project has moved to This issue still exists to avoid dead links, but GitHub limitations prevent the original issue from being correctly preserved here. Please see sbt/sbt#396 for the full issue and to comment.

@harrah harrah closed this Jan 5, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment