@@ -8,6 +8,7 @@ import v.parser
8
8
import v.ast
9
9
import v.pref
10
10
import v.errors
11
+ import v.checker
11
12
import strings
12
13
13
14
struct Context {
17
18
is_print bool
18
19
is_terse bool
19
20
is_skip_defaults bool
21
+ check bool
20
22
hide_names map [string ]bool
21
23
}
22
24
@@ -43,6 +45,7 @@ fn main() {
43
45
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' )
44
46
ctx.is_terse = fp.bool ('terse' , `t` , false , 'terse output, only with tree node names (AST structure), no details' )
45
47
ctx.is_skip_defaults = fp.bool ('skip-defaults' , `s` , false , 'skip properties that have default values like false, 0, "", etc' )
48
+ ctx.check = fp.bool ('check' , `k` , false , 'run v.checker as well (it may modify the AST)' )
46
49
hfields := fp.string_multi ('hide' , 0 , 'hide the specified fields. You can give several, by separating them with `,`' ).join (',' )
47
50
for hf in hfields.split (',' ) {
48
51
ctx.hide_names[hf] = true
@@ -170,7 +173,12 @@ fn json(file string) string {
170
173
pref: pref_
171
174
}
172
175
// parse file with comment
173
- ast_file := parser.parse_file (file, mut t.table, .parse_comments, t.pref)
176
+ mut ast_file := parser.parse_file (file, mut t.table, .parse_comments, t.pref)
177
+
178
+ if context.check {
179
+ mut the_checker := checker.new_checker (t.table, pref_)
180
+ the_checker.check (mut ast_file)
181
+ }
174
182
t.root = t.ast_file (ast_file)
175
183
// generate the ast string
176
184
s := json_print (mut t.root)
0 commit comments