|
|
@ -157,6 +157,7 @@ fn filter_num_sep(txt byteptr, start int, end int) string {
|
|
|
|
|
|
|
|
|
|
|
|
fn (mut s Scanner) ident_bin_number() string {
|
|
|
|
fn (mut s Scanner) ident_bin_number() string {
|
|
|
|
mut has_wrong_digit := false
|
|
|
|
mut has_wrong_digit := false
|
|
|
|
|
|
|
|
mut first_wrong_digit_pos := 0
|
|
|
|
mut first_wrong_digit := `\0`
|
|
|
|
mut first_wrong_digit := `\0`
|
|
|
|
start_pos := s.pos
|
|
|
|
start_pos := s.pos
|
|
|
|
s.pos += 2 // skip '0b'
|
|
|
|
s.pos += 2 // skip '0b'
|
|
|
@ -168,6 +169,7 @@ fn (mut s Scanner) ident_bin_number() string {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if !has_wrong_digit {
|
|
|
|
else if !has_wrong_digit {
|
|
|
|
has_wrong_digit = true
|
|
|
|
has_wrong_digit = true
|
|
|
|
|
|
|
|
first_wrong_digit_pos = s.pos
|
|
|
|
first_wrong_digit = c
|
|
|
|
first_wrong_digit = c
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -178,7 +180,7 @@ fn (mut s Scanner) ident_bin_number() string {
|
|
|
|
s.error('number part of this binary is not provided')
|
|
|
|
s.error('number part of this binary is not provided')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if has_wrong_digit {
|
|
|
|
else if has_wrong_digit {
|
|
|
|
s.pos-- // adjust error position
|
|
|
|
s.pos = first_wrong_digit_pos // adjust error position
|
|
|
|
s.error('this binary number has unsuitable digit `${first_wrong_digit.str()}`')
|
|
|
|
s.error('this binary number has unsuitable digit `${first_wrong_digit.str()}`')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
number := filter_num_sep(s.text.str, start_pos, s.pos)
|
|
|
|
number := filter_num_sep(s.text.str, start_pos, s.pos)
|
|
|
@ -188,6 +190,7 @@ fn (mut s Scanner) ident_bin_number() string {
|
|
|
|
|
|
|
|
|
|
|
|
fn (mut s Scanner) ident_hex_number() string {
|
|
|
|
fn (mut s Scanner) ident_hex_number() string {
|
|
|
|
mut has_wrong_digit := false
|
|
|
|
mut has_wrong_digit := false
|
|
|
|
|
|
|
|
mut first_wrong_digit_pos := 0
|
|
|
|
mut first_wrong_digit := `\0`
|
|
|
|
mut first_wrong_digit := `\0`
|
|
|
|
start_pos := s.pos
|
|
|
|
start_pos := s.pos
|
|
|
|
s.pos += 2 // skip '0x'
|
|
|
|
s.pos += 2 // skip '0x'
|
|
|
@ -199,6 +202,7 @@ fn (mut s Scanner) ident_hex_number() string {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if !has_wrong_digit {
|
|
|
|
else if !has_wrong_digit {
|
|
|
|
has_wrong_digit = true
|
|
|
|
has_wrong_digit = true
|
|
|
|
|
|
|
|
first_wrong_digit_pos = s.pos
|
|
|
|
first_wrong_digit = c
|
|
|
|
first_wrong_digit = c
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -209,7 +213,7 @@ fn (mut s Scanner) ident_hex_number() string {
|
|
|
|
s.error('number part of this hexadecimal is not provided')
|
|
|
|
s.error('number part of this hexadecimal is not provided')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if has_wrong_digit {
|
|
|
|
else if has_wrong_digit {
|
|
|
|
s.pos-- // adjust error position
|
|
|
|
s.pos = first_wrong_digit_pos // adjust error position
|
|
|
|
s.error('this hexadecimal number has unsuitable digit `${first_wrong_digit.str()}`')
|
|
|
|
s.error('this hexadecimal number has unsuitable digit `${first_wrong_digit.str()}`')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
number := filter_num_sep(s.text.str, start_pos, s.pos)
|
|
|
|
number := filter_num_sep(s.text.str, start_pos, s.pos)
|
|
|
@ -219,6 +223,7 @@ fn (mut s Scanner) ident_hex_number() string {
|
|
|
|
|
|
|
|
|
|
|
|
fn (mut s Scanner) ident_oct_number() string {
|
|
|
|
fn (mut s Scanner) ident_oct_number() string {
|
|
|
|
mut has_wrong_digit := false
|
|
|
|
mut has_wrong_digit := false
|
|
|
|
|
|
|
|
mut first_wrong_digit_pos := 0
|
|
|
|
mut first_wrong_digit := `\0`
|
|
|
|
mut first_wrong_digit := `\0`
|
|
|
|
start_pos := s.pos
|
|
|
|
start_pos := s.pos
|
|
|
|
s.pos += 2 // skip '0o'
|
|
|
|
s.pos += 2 // skip '0o'
|
|
|
@ -230,6 +235,7 @@ fn (mut s Scanner) ident_oct_number() string {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if !has_wrong_digit {
|
|
|
|
else if !has_wrong_digit {
|
|
|
|
has_wrong_digit = true
|
|
|
|
has_wrong_digit = true
|
|
|
|
|
|
|
|
first_wrong_digit_pos = s.pos
|
|
|
|
first_wrong_digit = c
|
|
|
|
first_wrong_digit = c
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -240,7 +246,7 @@ fn (mut s Scanner) ident_oct_number() string {
|
|
|
|
s.error('number part of this octal is not provided')
|
|
|
|
s.error('number part of this octal is not provided')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if has_wrong_digit {
|
|
|
|
else if has_wrong_digit {
|
|
|
|
s.pos-- // adjust error position
|
|
|
|
s.pos = first_wrong_digit_pos // adjust error position
|
|
|
|
s.error('this octal number has unsuitable digit `${first_wrong_digit.str()}`')
|
|
|
|
s.error('this octal number has unsuitable digit `${first_wrong_digit.str()}`')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
number := filter_num_sep(s.text.str, start_pos, s.pos)
|
|
|
|
number := filter_num_sep(s.text.str, start_pos, s.pos)
|
|
|
@ -250,6 +256,7 @@ fn (mut s Scanner) ident_oct_number() string {
|
|
|
|
|
|
|
|
|
|
|
|
fn (mut s Scanner) ident_dec_number() string {
|
|
|
|
fn (mut s Scanner) ident_dec_number() string {
|
|
|
|
mut has_wrong_digit := false
|
|
|
|
mut has_wrong_digit := false
|
|
|
|
|
|
|
|
mut first_wrong_digit_pos := 0
|
|
|
|
mut first_wrong_digit := `\0`
|
|
|
|
mut first_wrong_digit := `\0`
|
|
|
|
start_pos := s.pos
|
|
|
|
start_pos := s.pos
|
|
|
|
// scan integer part
|
|
|
|
// scan integer part
|
|
|
@ -261,6 +268,7 @@ fn (mut s Scanner) ident_dec_number() string {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if !has_wrong_digit {
|
|
|
|
else if !has_wrong_digit {
|
|
|
|
has_wrong_digit = true
|
|
|
|
has_wrong_digit = true
|
|
|
|
|
|
|
|
first_wrong_digit_pos = s.pos
|
|
|
|
first_wrong_digit = c
|
|
|
|
first_wrong_digit = c
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -287,6 +295,7 @@ fn (mut s Scanner) ident_dec_number() string {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if !has_wrong_digit {
|
|
|
|
else if !has_wrong_digit {
|
|
|
|
has_wrong_digit = true
|
|
|
|
has_wrong_digit = true
|
|
|
|
|
|
|
|
first_wrong_digit_pos = s.pos
|
|
|
|
first_wrong_digit = c
|
|
|
|
first_wrong_digit = c
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -333,6 +342,7 @@ fn (mut s Scanner) ident_dec_number() string {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if !has_wrong_digit {
|
|
|
|
else if !has_wrong_digit {
|
|
|
|
has_wrong_digit = true
|
|
|
|
has_wrong_digit = true
|
|
|
|
|
|
|
|
first_wrong_digit_pos = s.pos
|
|
|
|
first_wrong_digit = c
|
|
|
|
first_wrong_digit = c
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -341,7 +351,7 @@ fn (mut s Scanner) ident_dec_number() string {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if has_wrong_digit {
|
|
|
|
if has_wrong_digit {
|
|
|
|
// error check: wrong digit
|
|
|
|
// error check: wrong digit
|
|
|
|
s.pos-- // adjust error position
|
|
|
|
s.pos = first_wrong_digit_pos // adjust error position
|
|
|
|
s.error('this number has unsuitable digit `${first_wrong_digit.str()}`')
|
|
|
|
s.error('this number has unsuitable digit `${first_wrong_digit.str()}`')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if s.text[s.pos - 1] in [`e`, `E`] {
|
|
|
|
else if s.text[s.pos - 1] in [`e`, `E`] {
|
|
|
|