@@ -24,7 +24,6 @@ pub struct Scanner {
2424pub mut :
2525 file_path string // '/path/to/file.v'
2626 file_base string // 'file.v'
27- file_idx int = - 1 // file idx in the global table `filelist`
2827 text string // the whole text of the file
2928 pos int = - 1 // current position in the file, first character is s.text[0]
3029 line_nr int // current line number
@@ -108,7 +107,7 @@ pub enum CommentsMode {
108107}
109108
110109// new scanner from file.
111- pub fn new_scanner_file (file_path string , file_idx int , comments_mode CommentsMode, pref_ & pref.Preferences) ! & Scanner {
110+ pub fn new_scanner_file (file_path string , comments_mode CommentsMode, pref_ & pref.Preferences) ! & Scanner {
112111 if ! os.is_file (file_path) {
113112 return error ('${file_path } is not a .v file' )
114113 }
@@ -124,7 +123,6 @@ pub fn new_scanner_file(file_path string, file_idx int, comments_mode CommentsMo
124123 comments_mode: comments_mode
125124 file_path: file_path
126125 file_base: os.base (file_path)
127- file_idx: file_idx
128126 }
129127 s.scan_all_tokens_in_buffer ()
130128 return s
@@ -188,28 +186,26 @@ fn (mut s Scanner) new_token(tok_kind token.Kind, lit string, len int) token.Tok
188186 max_column = 1
189187 }
190188 return token.Token{
191- kind: tok_kind
192- lit: lit
193- line_nr: s.line_nr + line_offset
194- col: max_column
195- pos: s.pos - len + 1
196- len: len
197- tidx: cidx
198- file_idx: s.file_idx
189+ kind: tok_kind
190+ lit: lit
191+ line_nr: s.line_nr + line_offset
192+ col: max_column
193+ pos: s.pos - len + 1
194+ len: len
195+ tidx: cidx
199196 }
200197}
201198
202199@[inline]
203200fn (s &Scanner) new_eof_token () token.Token {
204201 return token.Token{
205- kind: .eof
206- lit: ''
207- line_nr: s.line_nr + 1
208- col: s.current_column ()
209- pos: s.pos
210- len: 1
211- tidx: s.tidx
212- file_idx: s.file_idx
202+ kind: .eof
203+ lit: ''
204+ line_nr: s.line_nr + 1
205+ col: s.current_column ()
206+ pos: s.pos
207+ len: 1
208+ tidx: s.tidx
213209 }
214210}
215211
@@ -222,14 +218,13 @@ fn (mut s Scanner) new_multiline_token(tok_kind token.Kind, lit string, len int,
222218 max_column = 1
223219 }
224220 return token.Token{
225- kind: tok_kind
226- lit: lit
227- line_nr: start_line + 1
228- col: max_column
229- pos: s.pos - len + 1
230- len: len
231- tidx: cidx
232- file_idx: s.file_idx
221+ kind: tok_kind
222+ lit: lit
223+ line_nr: start_line + 1
224+ col: max_column
225+ pos: s.pos - len + 1
226+ len: len
227+ tidx: cidx
233228 }
234229}
235230
@@ -950,11 +945,10 @@ pub fn (mut s Scanner) text_scan() token.Token {
950945 comment := s.text[start - 1 ..s.pos].trim_space ()
951946 if s.line_nr != 1 {
952947 comment_pos := token.Pos{
953- line_nr: s.line_nr - 1
954- len: comment.len
955- pos: start
956- col: s.current_column () - comment.len
957- file_idx: s.file_idx
948+ line_nr: s.line_nr - 1
949+ len: comment.len
950+ pos: start
951+ col: s.current_column () - comment.len
958952 }
959953 s.error_with_pos ('a shebang is only valid at the top of the file' ,
960954 comment_pos)
@@ -1128,11 +1122,10 @@ pub fn (mut s Scanner) text_scan() token.Token {
11281122 mut comment := s.text[start..(s.pos - 1 )]
11291123 if ! comment.contains ('\n ' ) {
11301124 comment_pos := token.Pos{
1131- line_nr: start_line
1132- len: comment.len + 4
1133- pos: start
1134- col: s.current_column () - comment.len - 4
1135- file_idx: s.file_idx
1125+ line_nr: start_line
1126+ len: comment.len + 4
1127+ pos: start
1128+ col: s.current_column () - comment.len - 4
11361129 }
11371130 s.error_with_pos ('inline comment is deprecated, please use line comment' ,
11381131 comment_pos)
@@ -1200,10 +1193,9 @@ pub fn (mut s Scanner) ident_string() string {
12001193 s.is_nested_string = false
12011194 }
12021195 lspos := token.Pos{
1203- line_nr: s.line_nr
1204- pos: s.pos
1205- col: s.pos - s.last_nl_pos - 1
1206- file_idx: s.file_idx
1196+ line_nr: s.line_nr
1197+ pos: s.pos
1198+ col: s.pos - s.last_nl_pos - 1
12071199 }
12081200 q := s.text[s.pos]
12091201 is_quote := q in [single_quote, double_quote]
@@ -1519,10 +1511,9 @@ fn trim_slash_line_break(s string) string {
15191511// / escaped utf8 runes in octal like `\342\230\205` => (★)
15201512pub fn (mut s Scanner) ident_char () string {
15211513 lspos := token.Pos{
1522- line_nr: s.line_nr
1523- pos: s.pos
1524- col: s.pos - s.last_nl_pos - 1
1525- file_idx: s.file_idx
1514+ line_nr: s.line_nr
1515+ pos: s.pos
1516+ col: s.pos - s.last_nl_pos - 1
15261517 }
15271518
15281519 start := s.pos // the string position of the first backtick char
@@ -1678,10 +1669,9 @@ fn (mut s Scanner) inc_line_number() {
16781669
16791670pub fn (mut s Scanner) current_pos () token.Pos {
16801671 return token.Pos{
1681- line_nr: s.line_nr
1682- pos: s.pos
1683- col: s.current_column () - 1
1684- file_idx: s.file_idx
1672+ line_nr: s.line_nr
1673+ pos: s.pos
1674+ col: s.current_column () - 1
16851675 }
16861676}
16871677
@@ -1691,9 +1681,8 @@ pub fn (mut s Scanner) note(msg string) {
16911681 return
16921682 }
16931683 pos := token.Pos{
1694- line_nr: s.line_nr
1695- pos: s.pos
1696- file_idx: s.file_idx
1684+ line_nr: s.line_nr
1685+ pos: s.pos
16971686 }
16981687 if s.pref.output_mode == .stdout && ! s.pref.check_only {
16991688 util.show_compiler_message ('notice:' , pos: pos, file_path: s.file_path, message: msg)
0 commit comments