From 73d2dd4ed4db77751b3696d7705255a14872bc23 Mon Sep 17 00:00:00 2001 From: Lex Spoon Date: Fri, 16 Mar 2007 12:03:48 +0000 Subject: - if a `foo` quoted identifier is truncated, th... - if a `foo` quoted identifier is truncated, then be careful to leave - the token type as ERROR print a nicer error message if a `foo` quoted - identifier is truncated --- src/compiler/scala/tools/nsc/ast/parser/Scanners.scala | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala index 837ba27e71..080c83f49c 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala @@ -273,8 +273,7 @@ trait Scanners requires SyntaxAnalyzer { return case '`' => in.next - getStringLit('`') - token = IDENTIFIER /*BACKQUOTED_IDENT*/ + getStringLit('`', IDENTIFIER) return case '\"' => in.next @@ -291,7 +290,7 @@ trait Scanners requires SyntaxAnalyzer { name = nme.EMPTY } } else { - getStringLit('\"') + getStringLit('\"', STRINGLIT) } return case '\'' => @@ -569,16 +568,18 @@ trait Scanners requires SyntaxAnalyzer { } } - private def getStringLit(delimiter: char): unit = { + private def getStringLit(delimiter: char, litType: int): unit = { + assert((litType==STRINGLIT) || (litType==IDENTIFIER)) while (in.ch != delimiter && (in.isUnicode || in.ch != CR && in.ch != LF && in.ch != SU)) { getlitch() } if (in.ch == delimiter) { - token = STRINGLIT + token = litType setName in.next } else { - syntaxError("unclosed string literal") + val typeDesc = if(litType == STRINGLIT) "string literal" else "quoted identifier" + syntaxError("unclosed " + typeDesc) } } -- cgit v1.2.3