scanner: fix bin/oct/hex without number parts

pull/3831/head
SleepyRoy 2020-02-25 01:02:36 +08:00 committed by GitHub
parent 3c0b73c2d6
commit 794ee6fc9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 0 deletions

View File

@ -147,6 +147,9 @@ fn (s mut Scanner) ident_bin_number() string {
}
s.pos++
}
if start_pos + 2 == s.pos {
s.error('number part of this binary is not provided')
}
number := filter_num_sep(s.text.str, start_pos, s.pos)
s.pos--
return number
@ -165,6 +168,9 @@ fn (s mut Scanner) ident_hex_number() string {
}
s.pos++
}
if start_pos + 2 == s.pos {
s.error('number part of this hexadecimal is not provided')
}
number := filter_num_sep(s.text.str, start_pos, s.pos)
s.pos--
return number
@ -183,6 +189,9 @@ fn (s mut Scanner) ident_oct_number() string {
}
s.pos++
}
if start_pos + 2 == s.pos {
s.error('number part of this octal is not provided')
}
number := filter_num_sep(s.text.str, start_pos, s.pos)
s.pos--
return number

View File

@ -143,6 +143,9 @@ fn (s mut Scanner) ident_bin_number() string {
}
s.pos++
}
if start_pos + 2 == s.pos {
s.error('number part of this binary is not provided')
}
number := filter_num_sep(s.text.str, start_pos, s.pos)
s.pos--
return number
@ -161,6 +164,9 @@ fn (s mut Scanner) ident_hex_number() string {
}
s.pos++
}
if start_pos + 2 == s.pos {
s.error('number part of this hexadecimal is not provided')
}
number := filter_num_sep(s.text.str, start_pos, s.pos)
s.pos--
return number
@ -179,6 +185,9 @@ fn (s mut Scanner) ident_oct_number() string {
}
s.pos++
}
if start_pos + 2 == s.pos {
s.error('number part of this octal is not provided')
}
number := filter_num_sep(s.text.str, start_pos, s.pos)
s.pos--
return number