mirror of
https://github.com/vlang/v.git
synced 2025-09-13 22:42:26 +03:00
vet, parser: use parse_file
, remove parse_vet_file
(#21444)
This commit is contained in:
parent
f08b333b52
commit
7e82654414
2 changed files with 1 additions and 25 deletions
|
@ -109,7 +109,7 @@ fn (mut vt Vet) vet_file(path string) {
|
||||||
prefs.is_vsh = path.ends_with('.vsh')
|
prefs.is_vsh = path.ends_with('.vsh')
|
||||||
mut table := ast.new_table()
|
mut table := ast.new_table()
|
||||||
vt.vprintln("vetting file '${path}'...")
|
vt.vprintln("vetting file '${path}'...")
|
||||||
file := parser.parse_vet_file(path, mut table, prefs)
|
file := parser.parse_file(path, mut table, .parse_comments, prefs)
|
||||||
vt.stmts(file.stmts)
|
vt.stmts(file.stmts)
|
||||||
source_lines := os.read_lines(vt.file) or { []string{} }
|
source_lines := os.read_lines(vt.file) or { []string{} }
|
||||||
for ln, line in source_lines {
|
for ln, line in source_lines {
|
||||||
|
|
|
@ -256,30 +256,6 @@ pub fn parse_file(path string, mut table ast.Table, comments_mode scanner.Commen
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn parse_vet_file(path string, mut table_ ast.Table, pref_ &pref.Preferences) &ast.File {
|
|
||||||
$if trace_parse_vet_file ? {
|
|
||||||
eprintln('> ${@MOD}.${@FN} path: ${path}')
|
|
||||||
}
|
|
||||||
global_scope := &ast.Scope{
|
|
||||||
parent: unsafe { nil }
|
|
||||||
}
|
|
||||||
mut p := Parser{
|
|
||||||
scanner: scanner.new_scanner_file(path, .parse_comments, pref_) or { panic(err) }
|
|
||||||
table: table_
|
|
||||||
pref: pref_
|
|
||||||
scope: &ast.Scope{
|
|
||||||
start_pos: 0
|
|
||||||
parent: global_scope
|
|
||||||
}
|
|
||||||
errors: []errors.Error{}
|
|
||||||
warnings: []errors.Warning{}
|
|
||||||
}
|
|
||||||
p.set_path(path)
|
|
||||||
file := p.parse()
|
|
||||||
unsafe { p.free_scanner() }
|
|
||||||
return file
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn (mut p Parser) parse() &ast.File {
|
pub fn (mut p Parser) parse() &ast.File {
|
||||||
util.timing_start('PARSE')
|
util.timing_start('PARSE')
|
||||||
defer {
|
defer {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue