summaryrefslogtreecommitdiff
path: root/src/compiler/scala
diff options
context:
space:
mode:
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)))