summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLex Spoon <lex@lexspoon.org>2007-03-16 12:03:48 +0000
committerLex Spoon <lex@lexspoon.org>2007-03-16 12:03:48 +0000
commit73d2dd4ed4db77751b3696d7705255a14872bc23 (patch)
tree83303ac7faef540b63c6fd4cbef3648627be632e
parent53dedee225a009598a771a244ac2aa8b8e9260be (diff)
downloadscala-73d2dd4ed4db77751b3696d7705255a14872bc23.tar.gz
scala-73d2dd4ed4db77751b3696d7705255a14872bc23.tar.bz2
scala-73d2dd4ed4db77751b3696d7705255a14872bc23.zip
- 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
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/Scanners.scala13
1 files 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)
}
}