tools: cleanup the output of V, compiled with `-d trace_parser` and `-d trace_checker`

pull/12743/head
Delyan Angelov 2021-12-06 09:44:52 +02:00
parent 89eb5425cd
commit 3ab82a23c5
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
4 changed files with 14 additions and 15 deletions

View File

@ -4627,8 +4627,8 @@ fn (mut c Checker) check_loop_label(label string, pos token.Position) {
fn (mut c Checker) stmt(node ast.Stmt) {
$if trace_checker ? {
stmt_pos := node.pos
eprintln('checking file: ${c.file.path:-30} | stmt pos: ${stmt_pos.str():-45} | stmt')
ntype := typeof(node).replace('v.ast.', '')
eprintln('checking: ${c.file.path:-30} | pos: ${node.pos.line_str():-39} | node: $ntype | $node')
}
c.expected_type = ast.void_type
match mut node {

View File

@ -14,11 +14,7 @@ pub fn (mut p Parser) expr(precedence int) ast.Expr {
}
pub fn (mut p Parser) check_expr(precedence int) ?ast.Expr {
$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} | expr($precedence)')
}
p.trace_parser('expr($precedence)')
mut node := ast.empty_expr()
is_stmt_ident := p.is_stmt_ident
p.is_stmt_ident = false

View File

@ -509,11 +509,13 @@ fn (mut p Parser) check_name() string {
return name
}
[if trace_parser ?]
fn (p &Parser) trace_parser(label string) {
eprintln('parsing: ${p.file_name:-30}|tok.pos: ${p.tok.position().line_str():-39}|tok.kind: ${p.tok.kind:-10}|tok.lit: ${p.tok.lit:-10}|$label')
}
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')
}
p.trace_parser('top_stmt')
for {
match p.tok.kind {
.key_pub {
@ -686,10 +688,7 @@ pub fn (mut p Parser) eat_comments(cfg EatCommentsConfig) []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.trace_parser('stmt($is_top_level)')
p.is_stmt_ident = p.tok.kind == .name
match p.tok.kind {
.lcbr {

View File

@ -17,6 +17,10 @@ pub mut:
pub fn (mut p Position) free() {
}
pub fn (p Position) line_str() string {
return '{l: ${p.line_nr + 1:5}, c: ${p.col:3}, p: ${p.pos:5}, ll: ${p.last_line + 1:5}}'
}
pub fn (pos Position) extend(end Position) Position {
return Position{
...pos