diff options
author | SiegeLord <slabode@aim.com> | 2014-01-11 16:27:48 -0500 |
---|---|---|
committer | SiegeLord <slabode@aim.com> | 2014-01-11 16:27:48 -0500 |
commit | 165153e95ca932a5cb32e2de8e612f57ee014b00 (patch) | |
tree | 63ad7f8751a72d6542fb4ac1fff29a79ab454349 | |
parent | 6e2450ce641c6f1b3ade6d8d9eb21367bcb4223c (diff) | |
download | scintilla-mirror-165153e95ca932a5cb32e2de8e612f57ee014b00.tar.gz |
Rust: Make lexing of float literals more correct.
-rw-r--r-- | lexers/LexRust.cxx | 44 |
1 files changed, 23 insertions, 21 deletions
diff --git a/lexers/LexRust.cxx b/lexers/LexRust.cxx index 8917b9182..bf59933af 100644 --- a/lexers/LexRust.cxx +++ b/lexers/LexRust.cxx @@ -240,22 +240,6 @@ static void ScanDigits(Accessor& styler, int& pos, int base) { } } -static bool ScanExponent(Accessor& styler, int& pos) { - int c = styler.SafeGetCharAt(pos, '\0'); - if (c == 'e' || c == 'E') { - pos++; - c = styler.SafeGetCharAt(pos, '\0'); - if (c == '-' || c == '+') - pos++; - int old_pos = pos; - ScanDigits(styler, pos, 10); - if (old_pos == pos) { - return false; - } - } - return true; -} - static void ScanNumber(Accessor& styler, int& pos) { int base = 10; int c = styler.SafeGetCharAt(pos, '\0'); @@ -287,13 +271,31 @@ static void ScanNumber(Accessor& styler, int& pos) { } else if (c == '6' && n == '4') { pos += 2; } - } else if (c == '.') { - error = base != 10; - pos++; - ScanDigits(styler, pos, 10); - error |= !ScanExponent(styler, pos); + } else { + n = styler.SafeGetCharAt(pos + 1, '\0'); + if (c == '.' && !(IsIdentifierStart(n) || n == '.')) { + error |= base != 10; + pos++; + ScanDigits(styler, pos, 10); + } + + c = styler.SafeGetCharAt(pos, '\0'); + if (c == 'e' || c == 'E') { + error |= base != 10; + pos++; + c = styler.SafeGetCharAt(pos, '\0'); + if (c == '-' || c == '+') + pos++; + int old_pos = pos; + ScanDigits(styler, pos, 10); + if (old_pos == pos) { + error = true; + } + } + c = styler.SafeGetCharAt(pos, '\0'); if (c == 'f') { + error |= base != 10; pos++; c = styler.SafeGetCharAt(pos, '\0'); n = styler.SafeGetCharAt(pos + 1, '\0'); |