From d60f6e340766f8876adb21092081bf264c64597f Mon Sep 17 00:00:00 2001 From: Adriaan Moors Date: Tue, 21 Feb 2017 11:57:05 -0800 Subject: Revert "SI-10133 Require escaped single quote char lit" --- .../scala/tools/nsc/ast/parser/Scanners.scala | 24 ++++++---------------- 1 file changed, 6 insertions(+), 18 deletions(-) (limited to 'src/compiler/scala') 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))) -- cgit v1.2.3