v.scanner
fn new_scanner #
fn new_scanner(prefs &pref.Preferences, mode Mode) Scanner
new_scanner supports new scanner handling for scanner.
fn Mode.from #
fn Mode.from[W](input W) !Mode
from returns the Mode value of an integer or of a field name, or an error if there is none.
fn Mode.zero #
fn Mode.zero() Mode
zero returns a Mode value with no flags set.
enum Mode #
enum Mode {
normal
scan_comments
skip_interpolation
}
Mode lists mode values used by scanner.
fn (Mode) is_empty #
fn (e &Mode) is_empty() bool
is_empty returns true if no flags are set.
fn (Mode) has #
fn (e &Mode) has(flag Mode) bool
has returns true if any of the flags in flag are set.
fn (Mode) all #
fn (e &Mode) all(flag Mode) bool
all returns true if all the flags in flag are set.
fn (Mode) set #
fn (mut e Mode) set(flag Mode)
set sets the flags in flag.
fn (Mode) set_all #
fn (mut e Mode) set_all()
set_all sets all the flags.
fn (Mode) clear #
fn (mut e Mode) clear(flag Mode)
clear clears the flags in flag.
fn (Mode) clear_all #
fn (mut e Mode) clear_all()
clear_all clears all the flags.
fn (Mode) toggle #
fn (mut e Mode) toggle(flag Mode)
toggle flips the flags in flag.
struct Diagnostic #
struct Diagnostic {
pub:
offset int
end int
severity string
message string
details []string
detail_offset int = -1
detail_message string
}
Diagnostic describes a lexical error at a byte offset in the current source.
struct Scanner #
struct Scanner {
pref &pref.Preferences
mode Mode
skip_interpolation bool
mut:
file &token.File = unsafe { nil }
insert_semi bool
after_dot bool
pub mut:
src string
offset int
pos int
lit string
in_str_incomplete bool
in_str_inter bool
in_str_inter_format bool
str_inter_cbr_depth int
str_quote u8
str_parent_quotes []u8
str_parent_depths []int
diagnostics []Diagnostic
// line_directives makes the scanner record valid `#line` directives in its file.
// Only the scanner that reads a whole source file for the parser turns it on.
line_directives bool
// line_directive_offsets lists the offsets of the `#line` directives scanned, valid
// or not, so the parser can report the ones that are not between statements.
line_directive_offsets []int
}
Scanner represents scanner data used by scanner.
fn (Scanner) skip_block_to #
fn (mut s Scanner) skip_block_to(offset int)
skip_block_to resumes scanning at offset, right after the } that closes a top-level block whose contents the caller does not need to lex (the FastC declaration passes record function bodies once and skip them in the later passes); the scanner state is what scanning that } leaves.
fn (Scanner) init #
fn (mut s Scanner) init(file &token.File, src string)
init resets the scanner for src, ignoring a leading UTF-8 byte order mark.
fn (Scanner) current_file #
fn (s &Scanner) current_file() &token.File
current_file returns current file data for Scanner.
fn (Scanner) scan #
fn (mut s Scanner) scan() token.Token
scan supports scan handling for Scanner.
fn (Scanner) compile_value #
fn (s &Scanner) compile_value(name string) ?string
compile_value is the value given with -d name=value, if any.