Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vet, parser: remove vet_errors and vet_notices from parser #21424

Merged
merged 1 commit into from
May 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions cmd/tools/vvet/vvet.v
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,10 @@ 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, errors, notices := parser.parse_vet_file(path, mut table, prefs)
file, errors := parser.parse_vet_file(path, mut table, prefs)
vt.stmts(file.stmts)
// Transfer errors from scanner and parser
vt.errors << errors
vt.notices << notices
source_lines := os.read_lines(vt.file) or { []string{} }
for ln, line in source_lines {
vt.vet_line(source_lines, line, ln)
Expand Down
36 changes: 3 additions & 33 deletions vlib/v/parser/parser.v
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,6 @@ pub mut:
errors []errors.Error
warnings []errors.Warning
notices []errors.Notice
vet_errors []vet.Error
vet_notices []vet.Error
template_paths []string // record all compiled $tmpl files; needed for `v watch run webserver.v`
}

Expand Down Expand Up @@ -259,7 +257,7 @@ 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, []vet.Error, []vet.Error) {
pub fn parse_vet_file(path string, mut table_ ast.Table, pref_ &pref.Preferences) (&ast.File, []vet.Error) {
$if trace_parse_vet_file ? {
eprintln('> ${@MOD}.${@FN} path: ${path}')
}
Expand All @@ -278,10 +276,10 @@ pub fn parse_vet_file(path string, mut table_ ast.Table, pref_ &pref.Preferences
warnings: []errors.Warning{}
}
p.set_path(path)
p.vet_errors << p.scanner.vet_errors
vet_errors := p.scanner.vet_errors
file := p.parse()
unsafe { p.free_scanner() }
return file, p.vet_errors, p.vet_notices
return file, vet_errors
}

pub fn (mut p Parser) parse() &ast.File {
Expand Down Expand Up @@ -2152,34 +2150,6 @@ fn (mut p Parser) note_with_pos(s string, pos token.Pos) {
}
}

fn (mut p Parser) vet_error(msg string, line int, fix vet.FixKind, typ vet.ErrorType) {
pos := token.Pos{
line_nr: line + 1
}
p.vet_errors << vet.Error{
message: msg
file_path: p.scanner.file_path
pos: pos
kind: .error
fix: fix
typ: typ
}
}

fn (mut p Parser) vet_notice(msg string, line int, fix vet.FixKind, typ vet.ErrorType) {
pos := token.Pos{
line_nr: line + 1
}
p.vet_notices << vet.Error{
message: msg
file_path: p.scanner.file_path
pos: pos
kind: .notice
fix: fix
typ: typ
}
}

fn (mut p Parser) parse_multi_expr(is_top_level bool) ast.Stmt {
// in here might be 1) multi-expr 2) multi-assign
// 1, a, c ... } // multi-expression
Expand Down
Loading