summaryrefslogtreecommitdiff
path: root/src/compiler/scala
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan@lightbend.com>2017-02-21 11:57:05 -0800
committerGitHub <noreply@github.com>2017-02-21 11:57:05 -0800
commitd60f6e340766f8876adb21092081bf264c64597f (patch)
treec465fa15a9e1d6207c45107b318818aa84b6ea50 /src/compiler/scala
parenta8c4a54d18c5560417d8c41db8b23a10fe8d616d (diff)
downloadscala-d60f6e340766f8876adb21092081bf264c64597f.tar.gz
scala-d60f6e340766f8876adb21092081bf264c64597f.tar.bz2
scala-d60f6e340766f8876adb21092081bf264c64597f.zip
Revert "SI-10133 Require escaped single quote char lit"
Diffstat (limited to 'src/compiler/scala')
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/Scanners.scala24
1 files changed, 6 insertions, 18 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala
index d72002f0a7..3ed1570c1c 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala
@@ -543,36 +543,24 @@ trait Scanners extends ScannersCommon {
}
fetchDoubleQuote()
case '\'' =>
- def unclosedCharLit() = {
- val msg = "unclosed character literal"
- // previous token was Symbol contiguous with the orphan single quote at offset
- if (token == SYMBOLLIT && offset == lastOffset) {
- syntaxError(s"""$msg (or use " for string literal "$strVal")""")
- } else {
- syntaxError(msg)
- }
- }
def fetchSingleQuote() = {
nextChar()
if (isIdentifierStart(ch))
charLitOr(getIdentRest)
else if (isOperatorPart(ch) && (ch != '\\'))
charLitOr(getOperatorRest)
- else if (ch == '\'') {
- nextChar()
- val advice = if (ch == '\'') { do nextChar() while (ch == '\''); " (use '\\'' for single quote)" } else ""
- syntaxError(s"empty character literal${advice}")
- }
else if (!isAtEnd && (ch != SU && ch != CR && ch != LF || isUnicodeEscape)) {
getLitChar()
- if (ch != '\'') unclosedCharLit()
- else {
+ if (ch == '\'') {
nextChar()
token = CHARLIT
setStrVal()
+ } else {
+ syntaxError("unclosed character literal")
}
}
- else unclosedCharLit()
+ else
+ syntaxError("unclosed character literal")
}
fetchSingleQuote()
case '.' =>
@@ -804,7 +792,7 @@ trait Scanners extends ScannersCommon {
next.token = kwArray(idx)
}
} else {
- syntaxError(s"invalid string interpolation $$$ch, expected: $$$$, $$identifier or $${expression}")
+ syntaxError("invalid string interpolation: `$$', `$'ident or `$'BlockExpr expected")
}
} else {
val isUnclosedLiteral = !isUnicodeEscape && (ch == SU || (!multiLine && (ch == CR || ch == LF)))