scanner: implement s.trace/2
parent
0afe36e153
commit
079fbffaf5
|
@ -19,12 +19,13 @@ const (
|
||||||
|
|
||||||
pub struct Scanner {
|
pub struct Scanner {
|
||||||
pub mut:
|
pub mut:
|
||||||
file_path string
|
file_path string // '/path/to/file.v'
|
||||||
text string
|
file_base string // 'file.v'
|
||||||
pos int
|
text string // the whole text of the file
|
||||||
line_nr int
|
pos int // current position in the file, first character is s.text[0]
|
||||||
|
line_nr int // current line number
|
||||||
last_nl_pos int // for calculating column
|
last_nl_pos int // for calculating column
|
||||||
is_inside_string bool
|
is_inside_string bool // set to true in a string, *at the start* of an $var or ${expr}
|
||||||
is_inter_start bool // for hacky string interpolation TODO simplify
|
is_inter_start bool // for hacky string interpolation TODO simplify
|
||||||
is_inter_end bool
|
is_inter_end bool
|
||||||
is_enclosed_inter bool
|
is_enclosed_inter bool
|
||||||
|
@ -109,6 +110,7 @@ pub fn new_vet_scanner_file(file_path string, comments_mode CommentsMode, pref &
|
||||||
}
|
}
|
||||||
mut s := new_vet_scanner(raw_text, comments_mode, pref)
|
mut s := new_vet_scanner(raw_text, comments_mode, pref)
|
||||||
s.file_path = file_path
|
s.file_path = file_path
|
||||||
|
s.file_base = os.base(file_path)
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,6 +129,7 @@ pub fn new_vet_scanner(text string, comments_mode CommentsMode, pref &pref.Prefe
|
||||||
is_fmt: pref.is_fmt
|
is_fmt: pref.is_fmt
|
||||||
comments_mode: comments_mode
|
comments_mode: comments_mode
|
||||||
file_path: 'internal_memory'
|
file_path: 'internal_memory'
|
||||||
|
file_base: 'internal_memory'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1291,3 +1294,9 @@ pub fn (mut s Scanner) codegen(newtext string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn (mut s Scanner) trace(fbase string, message string) {
|
||||||
|
if s.file_base == fbase {
|
||||||
|
println('> s.trace | ${fbase:-10s} | $message')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue