diff --git a/cmd/tools/measure/parser_speed.v b/cmd/tools/measure/parser_speed.v index 42d68535df..7e1c120ecd 100644 --- a/cmd/tools/measure/parser_speed.v +++ b/cmd/tools/measure/parser_speed.v @@ -21,7 +21,7 @@ fn main() { } fn hline() { - println('------------------------------------------------------------------------------------------------------------------------------------') + println('---------------------------------------------------------------------------------------------------------------------------------------------------') } fn theader() { @@ -40,6 +40,7 @@ fn process_files(files []string) ! { mut total_tokens := i64(0) mut total_lines := i64(0) mut total_errors := i64(0) + mut total_files := i64(0) for f in files { mut table := ast.new_table() if f == '' { @@ -48,6 +49,7 @@ fn process_files(files []string) ! { if skip_tests && f.ends_with('_test.v') { continue } + total_files++ // do not measure the scanning, but only the parsing: mut p := new_parser(f, .skip_comments, table, pref_) /// @@ -67,7 +69,7 @@ fn process_files(files []string) ! { hline() speed_mb_s := term.colorize(term.bright_yellow, '${(f64(total_bytes) / total_us):6.3f} MB/s') speed_lines_s := term.colorize(term.bright_yellow, '${(1_000_000 * f64(total_lines) / total_us):10.1f} lines/s') - println('${total_us:10}us ${total_tokens:10} ${total_bytes:10} ${total_lines:10} ${(f64(total_bytes) / total_tokens):13.3} ${total_errors:10} Parser speed: ${speed_mb_s}, ${speed_lines_s}, ${nthreads} thread(s)') + println('${total_us:10}us ${total_tokens:10} ${total_bytes:10} ${total_lines:10} ${(f64(total_bytes) / total_tokens):13.3} ${total_errors:10} Parser speed: ${speed_mb_s}, ${speed_lines_s}, ${nthreads:3} thread(s), ${total_files:5} files.') } fn new_parser(path string, comments_mode scanner.CommentsMode, table &ast.Table, pref_ &pref.Preferences) &parser.Parser { diff --git a/cmd/tools/measure/scanner_speed.v b/cmd/tools/measure/scanner_speed.v index c3c6a89c2b..6b9c1e32f6 100644 --- a/cmd/tools/measure/scanner_speed.v +++ b/cmd/tools/measure/scanner_speed.v @@ -18,7 +18,7 @@ fn main() { } fn hline() { - println('-------------------------------------------------------------------------------------------------------------------------------------') + println('----------------------------------------------------------------------------------------------------------------------------------------------------') } fn theader() { @@ -37,6 +37,7 @@ fn process_files(files []string) ! { mut total_tokens := i64(0) mut total_lines := i64(0) mut total_errors := i64(0) + mut total_files := i64(0) for f in files { if f == '' { continue @@ -44,6 +45,7 @@ fn process_files(files []string) ! { if skip_tests && f.ends_with('_test.v') { continue } + total_files++ sw.restart() s := scanner.new_scanner_file(f, .skip_comments, pref_)! f_us := sw.elapsed().microseconds() @@ -59,5 +61,5 @@ fn process_files(files []string) ! { hline() speed_mb_s := term.colorize(term.bright_yellow, '${(f64(total_bytes) / total_us):6.3f} MB/s') speed_lines_s := term.colorize(term.bright_yellow, '${(1_000_000 * f64(total_lines) / total_us):10.1f} lines/s') - println('${total_us:10}us ${total_tokens:10} ${total_bytes:10} ${total_lines:10} ${(f64(total_bytes) / total_tokens):13.3} ${total_errors:10} Scanner speed: ${speed_mb_s}, ${speed_lines_s}, ${nthreads} thread(s)') + println('${total_us:10}us ${total_tokens:10} ${total_bytes:10} ${total_lines:10} ${(f64(total_bytes) / total_tokens):13.3} ${total_errors:10} Scanner speed: ${speed_mb_s}, ${speed_lines_s}, ${nthreads:3} thread(s), ${total_files:5} files.') } diff --git a/vlib/v/parser/fn.v b/vlib/v/parser/fn.v index a16034b4d8..dfc3a7d7e8 100644 --- a/vlib/v/parser/fn.v +++ b/vlib/v/parser/fn.v @@ -11,7 +11,8 @@ import os fn (mut p Parser) call_expr(language ast.Language, mod string) ast.CallExpr { first_pos := p.tok.pos() mut name := if language == .js { p.check_js_name() } else { p.check_name() } - mut is_static_type_method := language == .v && name[0].is_capital() && p.tok.kind == .dot + mut is_static_type_method := language == .v && name.len > 0 && name[0].is_capital() + && p.tok.kind == .dot if is_static_type_method { p.check(.dot) name = name + '__static__' + p.check_name() @@ -1133,10 +1134,10 @@ fn (mut p Parser) closure_vars() []ast.Param { if p.table.global_scope.known_global(var_name) { p.error_with_pos('no need to capture global variable `${var_name}` in closure', p.prev_tok.pos()) - continue + return [] } p.error_with_pos('undefined ident: `${var_name}`', p.prev_tok.pos()) - continue + return [] } var.is_used = true if is_mut {