From 6326b6d58e49244b5c6daccecb6f4646304366ce Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Thu, 15 Oct 2020 11:09:19 +0300 Subject: [PATCH] parser: add helper method p.trace/2 --- vlib/v/parser/parser.v | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/vlib/v/parser/parser.v b/vlib/v/parser/parser.v index f27b2096e3..c629141a06 100644 --- a/vlib/v/parser/parser.v +++ b/vlib/v/parser/parser.v @@ -15,6 +15,7 @@ import runtime import time pub struct Parser { + file_base string // "hello.v" file_name string // "/home/user/hello.v" file_name_dir string // "/home/user" 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 table: b_table file_name: path + file_base: os.base(path) file_name_dir: os.dir(path) pref: pref scope: &ast.Scope{ @@ -128,6 +130,7 @@ pub fn parse_vet_file(path string, table_ &table.Table, pref &pref.Preferences) comments_mode: .parse_comments table: table_ file_name: path + file_base: os.base(path) file_name_dir: os.dir(path) pref: pref scope: &ast.Scope{ @@ -2050,3 +2053,9 @@ fn (mut p Parser) unsafe_stmt() ast.Stmt { pos: pos } } + +fn (mut p Parser) trace(fbase string, message string) { + if p.file_base == fbase { + println('> p.trace | ${fbase:-10s} | $message') + } +}