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

parser,checker: add -d trace_parser, -d trace_checker

This commit is contained in:
Delyan Angelov 2020-07-12 12:56:01 +03:00
parent 23c8e1f06d
commit 9c43d36513
2 changed files with 12 additions and 4 deletions

View File

@ -1813,6 +1813,10 @@ fn is_const_integer(cfield ast.ConstField) ?ast.IntegerLiteral {
} }
fn (mut c Checker) stmt(node ast.Stmt) { 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 // c.expected_type = table.void_type
match mut node { match mut node {
ast.AssertStmt { ast.AssertStmt {
@ -2044,10 +2048,6 @@ fn (mut c Checker) stmts(stmts []ast.Stmt) {
} }
c.expected_type = table.void_type c.expected_type = table.void_type
for stmt in stmts { 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 c.scope_returns {
if unreachable.line_nr == -1 { if unreachable.line_nr == -1 {
unreachable = stmt.position() unreachable = stmt.position()

View File

@ -372,6 +372,10 @@ fn (mut p Parser) check_name() string {
} }
pub fn (mut p Parser) top_stmt() ast.Stmt { 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 { match p.tok.kind {
.key_pub { .key_pub {
match p.peek_tok.kind { 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 { 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 p.is_stmt_ident = p.tok.kind == .name
match p.tok.kind { match p.tok.kind {
.lcbr { .lcbr {