From 0a66d8dc106312d9d5997b9ae983a8e71460cba2 Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Mon, 12 Jul 2021 13:24:24 +0300 Subject: [PATCH] v ast: allow analyzing .vsh files too --- cmd/tools/vast/vast.v | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/cmd/tools/vast/vast.v b/cmd/tools/vast/vast.v index 9511858b95..3f099ab67a 100644 --- a/cmd/tools/vast/vast.v +++ b/cmd/tools/vast/vast.v @@ -93,20 +93,20 @@ fn json_file(file string) string { return json_file } -// for enable_globals -fn new_preferences() &pref.Preferences { - mut p := &pref.Preferences{} - p.fill_with_defaults() - p.enable_globals = true - return p -} - // generate json string fn json(file string) string { + // use as permissive preferences as possible, so that `v ast` + // can print the AST of arbitrary V files, even .vsh or ones + // that require globals: + mut pref := &pref.Preferences{} + pref.fill_with_defaults() + pref.enable_globals = true + pref.is_fmt = true + // mut t := Tree{ root: new_object() table: ast.new_table() - pref: new_preferences() + pref: pref global_scope: &ast.Scope{ start_pos: 0 parent: 0