scanner: implement s.trace/2
							parent
							
								
									0afe36e153
								
							
						
					
					
						commit
						079fbffaf5
					
				|  | @ -19,13 +19,14 @@ const ( | |||
| 
 | ||||
| pub struct Scanner { | ||||
| pub mut: | ||||
| 	file_path         string | ||||
| 	text              string | ||||
| 	pos               int | ||||
| 	line_nr           int | ||||
| 	last_nl_pos       int // for calculating column
 | ||||
| 	is_inside_string  bool | ||||
| 	is_inter_start    bool // for hacky string interpolation TODO simplify
 | ||||
| 	file_path         string // '/path/to/file.v'
 | ||||
| 	file_base         string // 'file.v'
 | ||||
| 	text              string // the whole text of the file
 | ||||
| 	pos               int    // current position in the file, first character is s.text[0]
 | ||||
| 	line_nr           int    // current line number
 | ||||
| 	last_nl_pos       int    // for calculating column
 | ||||
| 	is_inside_string  bool   // set to true in a string, *at the start* of an $var or ${expr}
 | ||||
| 	is_inter_start    bool   // for hacky string interpolation TODO simplify
 | ||||
| 	is_inter_end      bool | ||||
| 	is_enclosed_inter bool | ||||
| 	line_comment      string | ||||
|  | @ -109,6 +110,7 @@ pub fn new_vet_scanner_file(file_path string, comments_mode CommentsMode, pref & | |||
| 	} | ||||
| 	mut s := new_vet_scanner(raw_text, comments_mode, pref) | ||||
| 	s.file_path = file_path | ||||
| 	s.file_base = os.base(file_path) | ||||
| 	return s | ||||
| } | ||||
| 
 | ||||
|  | @ -127,6 +129,7 @@ pub fn new_vet_scanner(text string, comments_mode CommentsMode, pref &pref.Prefe | |||
| 		is_fmt: pref.is_fmt | ||||
| 		comments_mode: comments_mode | ||||
| 		file_path: 'internal_memory' | ||||
| 		file_base: 'internal_memory' | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
|  | @ -1291,3 +1294,9 @@ pub fn (mut s Scanner) codegen(newtext string) { | |||
| 		} | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| fn (mut s Scanner) trace(fbase string, message string) { | ||||
| 	if s.file_base == fbase { | ||||
| 		println('> s.trace | ${fbase:-10s} | $message') | ||||
| 	} | ||||
| } | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue