diff --git a/cmd/tools/vast/vast.v b/cmd/tools/vast/vast.v index 31cf5d099f..094f45f587 100644 --- a/cmd/tools/vast/vast.v +++ b/cmd/tools/vast/vast.v @@ -8,6 +8,7 @@ import v.parser import v.ast import v.pref import v.errors +import v.checker import strings struct Context { @@ -17,6 +18,7 @@ mut: is_print bool is_terse bool is_skip_defaults bool + check bool hide_names map[string]bool } @@ -43,6 +45,7 @@ fn main() { ctx.is_compile = fp.bool('compile', `c`, false, 'watch the .v file for changes, rewrite the .json file, *AND* generate a .c file too on any change') ctx.is_terse = fp.bool('terse', `t`, false, 'terse output, only with tree node names (AST structure), no details') ctx.is_skip_defaults = fp.bool('skip-defaults', `s`, false, 'skip properties that have default values like false, 0, "", etc') + ctx.check = fp.bool('check', `k`, false, 'run v.checker as well (it may modify the AST)') hfields := fp.string_multi('hide', 0, 'hide the specified fields. You can give several, by separating them with `,`').join(',') for hf in hfields.split(',') { ctx.hide_names[hf] = true @@ -170,7 +173,12 @@ fn json(file string) string { pref: pref_ } // parse file with comment - ast_file := parser.parse_file(file, mut t.table, .parse_comments, t.pref) + mut ast_file := parser.parse_file(file, mut t.table, .parse_comments, t.pref) + + if context.check { + mut the_checker := checker.new_checker(t.table, pref_) + the_checker.check(mut ast_file) + } t.root = t.ast_file(ast_file) // generate the ast string s := json_print(mut t.root)