tools: cleanup the output of V, compiled with `-d trace_parser` and `-d trace_checker`
parent
89eb5425cd
commit
3ab82a23c5
|
@ -4627,8 +4627,8 @@ fn (mut c Checker) check_loop_label(label string, pos token.Position) {
|
||||||
|
|
||||||
fn (mut c Checker) stmt(node ast.Stmt) {
|
fn (mut c Checker) stmt(node ast.Stmt) {
|
||||||
$if trace_checker ? {
|
$if trace_checker ? {
|
||||||
stmt_pos := node.pos
|
ntype := typeof(node).replace('v.ast.', '')
|
||||||
eprintln('checking file: ${c.file.path:-30} | stmt pos: ${stmt_pos.str():-45} | stmt')
|
eprintln('checking: ${c.file.path:-30} | pos: ${node.pos.line_str():-39} | node: $ntype | $node')
|
||||||
}
|
}
|
||||||
c.expected_type = ast.void_type
|
c.expected_type = ast.void_type
|
||||||
match mut node {
|
match mut node {
|
||||||
|
|
|
@ -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 {
|
pub fn (mut p Parser) check_expr(precedence int) ?ast.Expr {
|
||||||
$if trace_parser ? {
|
p.trace_parser('expr($precedence)')
|
||||||
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)')
|
|
||||||
}
|
|
||||||
|
|
||||||
mut node := ast.empty_expr()
|
mut node := ast.empty_expr()
|
||||||
is_stmt_ident := p.is_stmt_ident
|
is_stmt_ident := p.is_stmt_ident
|
||||||
p.is_stmt_ident = false
|
p.is_stmt_ident = false
|
||||||
|
|
|
@ -509,11 +509,13 @@ fn (mut p Parser) check_name() string {
|
||||||
return name
|
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 {
|
pub fn (mut p Parser) top_stmt() ast.Stmt {
|
||||||
$if trace_parser ? {
|
p.trace_parser('top_stmt')
|
||||||
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')
|
|
||||||
}
|
|
||||||
for {
|
for {
|
||||||
match p.tok.kind {
|
match p.tok.kind {
|
||||||
.key_pub {
|
.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 {
|
pub fn (mut p Parser) stmt(is_top_level bool) ast.Stmt {
|
||||||
$if trace_parser ? {
|
p.trace_parser('stmt($is_top_level)')
|
||||||
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 {
|
||||||
|
|
|
@ -17,6 +17,10 @@ pub mut:
|
||||||
pub fn (mut p Position) free() {
|
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 {
|
pub fn (pos Position) extend(end Position) Position {
|
||||||
return Position{
|
return Position{
|
||||||
...pos
|
...pos
|
||||||
|
|
Loading…
Reference in New Issue