diff options
author | Paul Phillips <paulp@improving.org> | 2009-10-23 15:37:20 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2009-10-23 15:37:20 +0000 |
commit | 3926c98936f79d25e1fcd2e0c206e3cb35f7ada8 (patch) | |
tree | 8dc794a7d48d470c4c750f9cc04b1efcf1d98c8d /src | |
parent | 42a111ba41ce2f551d56ccde8ca878f1da27a0b4 (diff) | |
download | scala-3926c98936f79d25e1fcd2e0c206e3cb35f7ada8.tar.gz scala-3926c98936f79d25e1fcd2e0c206e3cb35f7ada8.tar.bz2 scala-3926c98936f79d25e1fcd2e0c206e3cb35f7ada8.zip |
Parser fix involving backquoted identifiers (#2...
Parser fix involving backquoted identifiers (#2514) plus test case.
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/ast/parser/Scanners.scala | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala index c966a23fcb..150de8db4d 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala @@ -306,13 +306,7 @@ trait Scanners { base = 10 getNumber() case '`' => - nextChar() - if (getStringLit('`')) { - finishNamed(); - if (name.length == 0) syntaxError("empty quoted identifier") - token = BACKQUOTED_IDENT - } - else syntaxError("unclosed quoted identifier") + getBackquotedIdent() case '\"' => nextChar() if (ch == '\"') { @@ -475,6 +469,16 @@ trait Scanners { // Identifiers --------------------------------------------------------------- + private def getBackquotedIdent(): Unit = { + nextChar() + if (getStringLit('`')) { + finishNamed(); + if (name.length == 0) syntaxError("empty quoted identifier") + token = BACKQUOTED_IDENT + } + else syntaxError("unclosed quoted identifier") + } + private def getIdentRest(): Unit = (ch: @switch) match { case 'A' | 'B' | 'C' | 'D' | 'E' | 'F' | 'G' | 'H' | 'I' | 'J' | @@ -747,6 +751,10 @@ trait Scanners { case '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' => return restOfNumber() + /** Backquoted idents like 22.`foo` */ + case '`' => + return setStrVal() + /** These letters may be part of a literal, or a method invocation on an Int */ case 'd' | 'D' | 'f' | 'F' => lookahead.nextChar() |