scanner: fix nested multiline comments (#10760)
parent
ba9b53cc4d
commit
719bf63f16
|
@ -983,7 +983,7 @@ fn (mut s Scanner) text_scan() token.Token {
|
||||||
s.pos++
|
s.pos++
|
||||||
return s.new_token(.div_assign, '', 2)
|
return s.new_token(.div_assign, '', 2)
|
||||||
}
|
}
|
||||||
if nextc == `/` {
|
if nextc == `/` { // Single line comments
|
||||||
start := s.pos + 1
|
start := s.pos + 1
|
||||||
s.ignore_line()
|
s.ignore_line()
|
||||||
mut comment_line_end := s.pos
|
mut comment_line_end := s.pos
|
||||||
|
@ -1014,12 +1014,11 @@ fn (mut s Scanner) text_scan() token.Token {
|
||||||
// s.fgenln('// ${s.prev_tok.str()} "$s.line_comment"')
|
// s.fgenln('// ${s.prev_tok.str()} "$s.line_comment"')
|
||||||
// Skip the comment (return the next token)
|
// Skip the comment (return the next token)
|
||||||
continue
|
continue
|
||||||
}
|
} else if nextc == `*` { // Multiline comments
|
||||||
// Multiline comments
|
|
||||||
if nextc == `*` {
|
|
||||||
start := s.pos + 2
|
start := s.pos + 2
|
||||||
start_line := s.line_nr
|
start_line := s.line_nr
|
||||||
mut nest_count := 1
|
mut nest_count := 1
|
||||||
|
s.pos++
|
||||||
// Skip comment
|
// Skip comment
|
||||||
for nest_count > 0 && s.pos < s.text.len - 1 {
|
for nest_count > 0 && s.pos < s.text.len - 1 {
|
||||||
s.pos++
|
s.pos++
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
fn test_nested_multiline_comments() {
|
||||||
|
/*//println(os.args)
|
||||||
|
*/
|
||||||
|
assert true
|
||||||
|
}
|
Loading…
Reference in New Issue