scanner: fix special case - `e` or `E` at the end

pull/3840/head
SleepyRoy 2020-02-25 18:10:05 +08:00 committed by GitHub
parent b17ade1257
commit f859c7f93e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 4 deletions

View File

@ -223,9 +223,10 @@ fn (s mut Scanner) ident_dec_number() string {
// scan exponential part
mut has_exponential_part := false
if s.expect('e', s.pos) || s.expect('E', s.pos) {
exp_start_pos := (s.pos++)
s.pos++
exp_start_pos := s.pos
if s.text[s.pos] in [`-`, `+`] {
if s.pos < s.text.len && s.text[s.pos] in [`-`, `+`] {
s.pos++
}

View File

@ -219,8 +219,9 @@ fn (s mut Scanner) ident_dec_number() string {
// scan exponential part
mut has_exponential_part := false
if s.expect('e', s.pos) || s.expect('E', s.pos) {
exp_start_pos := (s.pos++)
if s.text[s.pos] in [`-`, `+`] {
s.pos++
exp_start_pos := s.pos
if s.pos < s.text.len && s.text[s.pos] in [`-`, `+`] {
s.pos++
}
for s.pos < s.text.len && s.text[s.pos].is_digit() {