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

pull/5814/head
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) {
$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()

View File

@ -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 {