From 9c43d36513ff1ed6b20902e557c11d55d0a9de7c Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Sun, 12 Jul 2020 12:56:01 +0300 Subject: [PATCH] parser,checker: add `-d trace_parser`, `-d trace_checker` --- vlib/v/checker/checker.v | 8 ++++---- vlib/v/parser/parser.v | 8 ++++++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/vlib/v/checker/checker.v b/vlib/v/checker/checker.v index b4135680ff..689e0142f8 100644 --- a/vlib/v/checker/checker.v +++ b/vlib/v/checker/checker.v @@ -1813,6 +1813,10 @@ fn is_const_integer(cfield ast.ConstField) ?ast.IntegerLiteral { } fn (mut c Checker) stmt(node ast.Stmt) { + $if trace_checker? { + stmt_pos := node.position() + eprintln('checking file: ${c.file.path:-30} | stmt pos: ${stmt_pos.str():-45} | stmt') + } // c.expected_type = table.void_type match mut node { ast.AssertStmt { @@ -2044,10 +2048,6 @@ fn (mut c Checker) stmts(stmts []ast.Stmt) { } c.expected_type = table.void_type for stmt in stmts { - $if debug_stmts? { - stmt_pos := stmt.position() - eprintln('file: ${c.file.path:-30} | stmt pos: $stmt_pos') - } if c.scope_returns { if unreachable.line_nr == -1 { unreachable = stmt.position() diff --git a/vlib/v/parser/parser.v b/vlib/v/parser/parser.v index 6508822a4b..77bf7656a5 100644 --- a/vlib/v/parser/parser.v +++ b/vlib/v/parser/parser.v @@ -372,6 +372,10 @@ fn (mut p Parser) check_name() string { } pub fn (mut p Parser) top_stmt() ast.Stmt { + $if trace_parser? { + tok_pos := p.tok.position() + eprintln('parsing file: ${p.file_name:-30} | tok.kind: ${p.tok.kind:-10} | tok.lit: ${p.tok.lit:-10} | tok_pos: ${tok_pos.str():-45} | top_stmt') + } match p.tok.kind { .key_pub { match p.peek_tok.kind { @@ -496,6 +500,10 @@ pub fn (mut p Parser) eat_comments() []ast.Comment { } pub fn (mut p Parser) stmt(is_top_level bool) ast.Stmt { + $if trace_parser? { + tok_pos := p.tok.position() + eprintln('parsing file: ${p.file_name:-30} | tok.kind: ${p.tok.kind:-10} | tok.lit: ${p.tok.lit:-10} | tok_pos: ${tok_pos.str():-45} | stmt($is_top_level)') + } p.is_stmt_ident = p.tok.kind == .name match p.tok.kind { .lcbr {