mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
scanner: implement s.trace/2
This commit is contained in:
parent
0afe36e153
commit
079fbffaf5
@ -19,13 +19,14 @@ 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]
|
||||||
last_nl_pos int // for calculating column
|
line_nr int // current line number
|
||||||
is_inside_string bool
|
last_nl_pos int // for calculating column
|
||||||
is_inter_start bool // for hacky string interpolation TODO simplify
|
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_end bool
|
is_inter_end bool
|
||||||
is_enclosed_inter bool
|
is_enclosed_inter bool
|
||||||
line_comment string
|
line_comment string
|
||||||
@ -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…
x
Reference in New Issue
Block a user