v.scanner #

fn new_scanner #

fn new_scanner(text string, comments_mode CommentsMode, pref &pref.Preferences) &Scanner

new scanner from string.

fn new_scanner_file #

fn new_scanner_file(file_path string, comments_mode CommentsMode, pref &pref.Preferences) &Scanner

new scanner from file.

fn new_vet_scanner #

fn new_vet_scanner(text string, comments_mode CommentsMode, pref &pref.Preferences) &Scanner

fn new_vet_scanner_file #

fn new_vet_scanner_file(file_path string, comments_mode CommentsMode, pref &pref.Preferences) &Scanner

fn verror #

fn verror(s string)

enum CommentsMode #

enum CommentsMode {
	skip_comments
	parse_comments
	toplevel_comments
}

The different kinds of scanner modes: .skip_comments - simplest/fastest, just ignores all comments early. This mode is used by the compiler itself. .parse_comments is used by vfmt. Ideally it should handle inline /* */ comments too, i.e. it returns every kind of comment as a new token. .toplevel_comments is used by vdoc, parses only top level ones that are outside structs/enums/fns.

struct Scanner #

struct Scanner {
pub mut:
	file_path         string
	text              string
	pos               int
	line_nr           int
	last_nl_pos       int
	is_inside_string  bool
	is_inter_start    bool
	is_inter_end      bool
	is_enclosed_inter bool
	line_comment      string
	is_started                  bool
	is_print_line_on_error      bool
	is_print_colored_error      bool
	is_print_rel_paths_on_error bool
	quote                       byte
	inter_quote                 byte
	line_ends                   []int
	nr_lines                    int
	is_vh                       bool
	is_fmt                      bool
	comments_mode               CommentsMode
	is_inside_toplvl_statement  bool
	all_tokens                  []token.Token
	tidx                        int
	eofs                        int
	pref                        &pref.Preferences
	errors                      []errors.Error
	warnings                    []errors.Warning
	vet_errors                  []vet.Error
}

fn (Scanner) set_is_inside_toplevel_statement #

fn (mut s Scanner) set_is_inside_toplevel_statement(newstate bool)

NB: this is called by v's parser

fn (Scanner) set_current_tidx #

fn (mut s Scanner) set_current_tidx(cidx int)

fn (Scanner) scan_all_tokens_in_buffer #

fn (mut s Scanner) scan_all_tokens_in_buffer()

fn (Scanner) scan #

fn (mut s Scanner) scan() token.Token

fn (Scanner) buffer_scan #

fn (mut s Scanner) buffer_scan() token.Token

fn (Scanner) warn #

fn (mut s Scanner) warn(msg string)

fn (Scanner) error #

fn (mut s Scanner) error(msg string)

fn (Scanner) codegen #

fn (mut s Scanner) codegen(newtext string)