@@ -48,6 +48,7 @@ pub mut:
48
48
all_tokens []token.Token // *only* used in comments_mode: .toplevel_comments, contains all tokens
49
49
tidx int
50
50
eofs int
51
+ pref & pref.Preferences
51
52
}
52
53
53
54
/*
@@ -94,23 +95,26 @@ pub enum CommentsMode {
94
95
}
95
96
96
97
// new scanner from file.
97
- pub fn new_scanner_file (file_path string , comments_mode CommentsMode, is_fmt bool ) & Scanner {
98
+ pub fn new_scanner_file (file_path string , comments_mode CommentsMode, pref & pref.Preferences) & Scanner {
99
+ // is_fmt := pref.is_fmt
98
100
if ! os.exists (file_path) {
99
101
verror ("$file_path doesn't exist" )
100
102
}
101
103
raw_text := util.read_file (file_path) or {
102
104
verror (err)
103
105
return voidptr (0 )
104
106
}
105
- mut s := new_scanner (raw_text, comments_mode, is_fmt ) // .skip_comments)
107
+ mut s := new_scanner (raw_text, comments_mode, pref ) // .skip_comments)
106
108
// s.init_fmt()
107
109
s.file_path = file_path
108
110
return s
109
111
}
110
112
111
113
// new scanner from string.
112
- pub fn new_scanner (text string , comments_mode CommentsMode, is_fmt bool ) & Scanner {
114
+ pub fn new_scanner (text string , comments_mode CommentsMode, pref & pref.Preferences) & Scanner {
115
+ is_fmt := pref.is_fmt
113
116
s := & Scanner{
117
+ pref: pref
114
118
text: text
115
119
is_print_line_on_error: true
116
120
is_print_colored_error: true
@@ -768,6 +772,10 @@ fn (mut s Scanner) text_scan() token.Token {
768
772
return s.new_token (.chartoken, ident_char, ident_char.len + 2 ) // + two quotes
769
773
}
770
774
`(` {
775
+ // TODO `$if vet {` for performance
776
+ if s.pref.is_vet && s.text[s.pos + 1 ] == ` ` {
777
+ println ('$s.file_path :$s.line_nr : Looks like you are adding a space after `(`' )
778
+ }
771
779
return s.new_token (.lpar, '' , 1 )
772
780
}
773
781
`)` {
0 commit comments