1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

scanner: fix bin/oct/hex without number parts

This commit is contained in:
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++ 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) number := filter_num_sep(s.text.str, start_pos, s.pos)
s.pos-- s.pos--
return number return number
@ -165,6 +168,9 @@ fn (s mut Scanner) ident_hex_number() string {
} }
s.pos++ 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) number := filter_num_sep(s.text.str, start_pos, s.pos)
s.pos-- s.pos--
return number return number
@ -183,6 +189,9 @@ fn (s mut Scanner) ident_oct_number() string {
} }
s.pos++ 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) number := filter_num_sep(s.text.str, start_pos, s.pos)
s.pos-- s.pos--
return number return number

View File

@ -143,6 +143,9 @@ fn (s mut Scanner) ident_bin_number() string {
} }
s.pos++ 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) number := filter_num_sep(s.text.str, start_pos, s.pos)
s.pos-- s.pos--
return number return number
@ -161,6 +164,9 @@ fn (s mut Scanner) ident_hex_number() string {
} }
s.pos++ 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) number := filter_num_sep(s.text.str, start_pos, s.pos)
s.pos-- s.pos--
return number return number
@ -179,6 +185,9 @@ fn (s mut Scanner) ident_oct_number() string {
} }
s.pos++ 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) number := filter_num_sep(s.text.str, start_pos, s.pos)
s.pos-- s.pos--
return number return number