scala/scala — pull request #3768 by som-snytt (2014-05-20 14:26:16+00:00)
Title:  SI-6476 Improve error on escapement

Behavior of escape processing under string interpolation can
be confusing. This PR improves the exception message so
you know at least what sort of escapes are handled.
```
scala> s"\d".r
scala.StringContext$InvalidEscapeException: invalid escape '\d' not one of [\b, \t, \n, \f, \r, \\, \", \'] at index 0 in "\d". Use \\ for literal \.

scala> s"a\"
scala.StringContext$InvalidEscapeException: invalid escape at terminal index 1 in "a\". Use \\ for literal \.

t6476-bad-esc-d.scala:3: error: ';' expected but string literal found. (A trailing '\' escapes nothing. Use \\, $$ or $" for literal \, $ or ".)
def f = s"\"abcdef\""
^
```
Also enable $" under -Xfuture. This is the same as retronym's tweak,
but puts it under `-Xfuture` until the ecosystem catches up.

Also give the parser enough knowledge of `s` and `f`
to emit an error on the puzzling badly escaped
quote. The error is emitted as supplemental
advice when a subsequent syntax error is encountered,
such as an unclosed literal.

The mechanism is non-ideal but serves to mitigate the pain of
many users from us hoi polloi all the way up to paulp. Hoi paulpoi.

These are the remaining commits from #3695.

Review by @retronym