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

parser: minor cleanup of parse_block_no_scope() (#7644)

This commit is contained in:
yuyi 2020-12-28 17:58:44 +08:00 committed by GitHub
parent 64c0645bcb
commit dea3d0431d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -364,15 +364,15 @@ pub fn (mut p Parser) parse_block_no_scope(is_top_level bool) []ast.Stmt {
p.check(.lcbr) p.check(.lcbr)
mut stmts := []ast.Stmt{} mut stmts := []ast.Stmt{}
if p.tok.kind != .rcbr { if p.tok.kind != .rcbr {
mut c := 0 mut count := 0
for p.tok.kind !in [.eof, .rcbr] { for p.tok.kind !in [.eof, .rcbr] {
stmts << p.stmt(is_top_level) stmts << p.stmt(is_top_level)
c++ count++
if c % 100000 == 0 { if count % 100000 == 0 {
eprintln('parsed $c statements so far from fn $p.cur_fn_name ...') eprintln('parsed $count statements so far from fn $p.cur_fn_name ...')
} }
if c > 1000000 { if count > 1000000 {
p.error_with_pos('parsed over $c statements from fn $p.cur_fn_name, the parser is probably stuck', p.error_with_pos('parsed over $count statements from fn $p.cur_fn_name, the parser is probably stuck',
p.tok.position()) p.tok.position())
return [] return []
} }