scanner: minor cleanup in scanner.v (#14565)

master
yuyi 2022-05-31 16:52:47 +08:00 committed by GitHub
parent db34adaec8
commit 80cc88427b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 19 additions and 21 deletions

View File

@ -39,7 +39,6 @@ pub mut:
is_enclosed_inter bool
line_comment string
last_lt int = -1 // position of latest <
// prev_tok TokenKind
is_started bool
is_print_line_on_error bool
is_print_colored_error bool
@ -240,15 +239,15 @@ fn (s Scanner) num_lit(start int, end int) string {
unsafe {
txt := s.text.str
mut b := malloc_noscan(end - start + 1) // add a byte for the endstring 0
mut i1 := 0
for i := start; i < end; i++ {
mut i_no_sep := 0
for i in start .. end {
if txt[i] != scanner.num_sep {
b[i1] = txt[i]
i1++
b[i_no_sep] = txt[i]
i_no_sep++
}
}
b[i1] = 0 // C string compatibility
return b.vstring_with_len(i1)
b[i_no_sep] = 0 // C string compatibility
return b.vstring_with_len(i_no_sep)
}
}
@ -1053,7 +1052,6 @@ fn (mut s Scanner) text_scan() token.Token {
}
return s.new_token(.comment, comment, comment.len + 2)
}
// s.fgenln('// ${s.prev_tok.str()} "$s.line_comment"')
// Skip the comment (return the next token)
continue
} else if nextc == `*` { // Multiline comments