vet, parser: use parse_file, remove parse_vet_file (#21444)

This commit is contained in:
Turiiya 2024-05-06 17:31:13 +02:00 committed by GitHub
parent f08b333b52
commit 7e82654414
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 1 additions and 25 deletions

View file

@ -109,7 +109,7 @@ fn (mut vt Vet) vet_file(path string) {
prefs.is_vsh = path.ends_with('.vsh')
mut table := ast.new_table()
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)
source_lines := os.read_lines(vt.file) or { []string{} }
for ln, line in source_lines {

View file

@ -256,30 +256,6 @@ pub fn parse_file(path string, mut table ast.Table, comments_mode scanner.Commen
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 {
util.timing_start('PARSE')
defer {