v3.parser
fn Parser.new #
fn Parser.new(prefs &pref.Preferences) &Parser
new creates a Parser value for parser.
struct Parser #
struct Parser {
prefs &pref.Preferences
mut:
s scanner.Scanner
tok token.Token
lit string
tok_pos int
peek_tok token.Token = .eof
peek_lit string
peek_pos int
has_peek bool
cur_file string
cur_module string
cur_fn string
cur_struct string // receiver type name of the current method, for `@STRUCT`
comptime_for_vars []string // active `$for` loop variables; a `$if` that reads one is deferred to unroll time
pending_flag bool
pending_params bool
pending_export string
pending_noreturn bool
skip_next_decl bool
disable_fn_body bool
in_for_container bool
local_type_names map[string]string
local_type_scopes []string
export_records []ExportRecord
pub mut:
a &flat.FlatAst = unsafe { nil }
parsed_v_files int
}
Parser represents parser data used by parser.
fn (Parser) parse_file #
fn (mut p Parser) parse_file(path string) &flat.FlatAst
parse_file reads parse file input for parser.
fn (Parser) parse_files #
fn (mut p Parser) parse_files(paths []string) &flat.FlatAst
parse_files reads parse files input for parser.
fn (Parser) parse_files_dispatch #
fn (mut p Parser) parse_files_dispatch(paths []string, allow_parallel bool) ([]int, bool)
parse_files_dispatch parses paths in order, appending to p.a exactly like a serial parse_into loop, across worker threads when there is enough work. Returns each file's first node id in p.a and whether threads were used.
fn (Parser) parse_files_with_starts #
fn (mut p Parser) parse_files_with_starts(paths []string) []int
parse_files_with_starts parses paths in order like parse_files, recording the first node id of each file's region. Import resolution uses the starts to bound per-file post-processing (module-name canonicalization) when files are parsed in batches instead of one at a time.
fn (Parser) parse_into #
fn (mut p Parser) parse_into(path string)
parse_into reads parse into input for parser.