parser: add helper method p.trace/2

pull/6621/head
Delyan Angelov 2020-10-15 11:09:19 +03:00
parent a4cc1ab7e3
commit 6326b6d58e
1 changed files with 9 additions and 0 deletions

View File

@ -15,6 +15,7 @@ import runtime
import time import time
pub struct Parser { pub struct Parser {
file_base string // "hello.v"
file_name string // "/home/user/hello.v" file_name string // "/home/user/hello.v"
file_name_dir string // "/home/user" file_name_dir string // "/home/user"
pref &pref.Preferences pref &pref.Preferences
@ -106,6 +107,7 @@ pub fn parse_file(path string, b_table &table.Table, comments_mode scanner.Comme
comments_mode: comments_mode comments_mode: comments_mode
table: b_table table: b_table
file_name: path file_name: path
file_base: os.base(path)
file_name_dir: os.dir(path) file_name_dir: os.dir(path)
pref: pref pref: pref
scope: &ast.Scope{ scope: &ast.Scope{
@ -128,6 +130,7 @@ pub fn parse_vet_file(path string, table_ &table.Table, pref &pref.Preferences)
comments_mode: .parse_comments comments_mode: .parse_comments
table: table_ table: table_
file_name: path file_name: path
file_base: os.base(path)
file_name_dir: os.dir(path) file_name_dir: os.dir(path)
pref: pref pref: pref
scope: &ast.Scope{ scope: &ast.Scope{
@ -2050,3 +2053,9 @@ fn (mut p Parser) unsafe_stmt() ast.Stmt {
pos: pos pos: pos
} }
} }
fn (mut p Parser) trace(fbase string, message string) {
if p.file_base == fbase {
println('> p.trace | ${fbase:-10s} | $message')
}
}