diff options
author | Paul Phillips <paulp@improving.org> | 2009-09-15 22:13:15 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2009-09-15 22:13:15 +0000 |
commit | a5f4411f8a6dfc670efb8074e0845a1f54d65a2a (patch) | |
tree | 6c98ea04a02a13680893c6e77004afbc881474b1 /src | |
parent | 4ccb0bf2b78919934cf67b901096331de638ee09 (diff) | |
download | scala-a5f4411f8a6dfc670efb8074e0845a1f54d65a2a.tar.gz scala-a5f4411f8a6dfc670efb8074e0845a1f54d65a2a.tar.bz2 scala-a5f4411f8a6dfc670efb8074e0845a1f54d65a2a.zip |
Fix and test case for #2081.
Diffstat (limited to 'src')
-rwxr-xr-x | src/compiler/scala/tools/nsc/ast/parser/Scanners.scala | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala index 237394a7f1..63ec09e8cf 100755 --- a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala @@ -711,18 +711,32 @@ trait Scanners { if (base <= 10 && ch == '.') { val lookahead = lookaheadReader lookahead.nextChar() + def restOfNumber() = { + putChar(ch) + nextChar() + getFraction() + } + lookahead.ch match { - case '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | - '8' | '9' | 'd' | 'D' | 'e' | 'E' | 'f' | 'F' => - putChar(ch) - nextChar() - return getFraction() + case '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' => + return restOfNumber() + + /** These letters may be part of a literal, or a method invocation on an Int */ + case 'd' | 'D' | 'f' | 'F' => + lookahead.nextChar() + if (!isIdentifierPart(lookahead.ch)) + return restOfNumber() + + /** A little more special handling for e.g. 5e7 */ + case 'e' | 'E' => + lookahead.nextChar() + val ch = lookahead.ch + if (!isIdentifierPart(ch) || (ch >= '0' && ch <= '9') || ch == '+' || ch == '-') + return restOfNumber() + case _ => - if (!isIdentifierStart(lookahead.ch)) { - putChar(ch) - nextChar() - return getFraction() - } + if (!isIdentifierStart(lookahead.ch)) + return restOfNumber() } } if (base <= 10 && |