Documentation
¶
Overview ¶
Package loader reads a program's modules, parses and resolves them, and orders them for initialization (section 10).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct {
// FS supplies sources by slash-separated path; nil means the operating system.
FS fs.FS
// Sources overrides the text of modules by path.
Sources map[string]string
// Mode is the parser mode for the root module, unless its path names a declaration file
// (parser.ModeOf); imports always parse as programs.
Mode parser.Mode
// Extra names the prelude binds in this program, beyond the standard ones.
Extra []string
// Session, when set, makes the root an input of a session: its fields accumulate in this
// scope and may be declared again.
Session *ast.ModuleScope
// Imports, for a session, are the imports of earlier inputs still in force: the root takes
// them before its own, without their text, so its positions stay those of its source.
Imports []*ast.Import
// Recover makes Load go on past errors, for an editor: a module with syntax errors is
// parsed as far as it goes (parser.ParseRecover), a module that cannot be read or is in a
// cycle leaves its import's Module at -1, and the program comes back with the diagnostics
// instead of nil. Such a program is for analysis only and must not be run. Mode is Program.
Recover bool
}
Config says where sources come from.
type Diagnostic ¶
Diagnostic is a load error with its position.
func (Diagnostic) String ¶
func (d Diagnostic) String() string
type Module ¶
type Module struct {
Path string // canonical, the module's identity
File *ast.File
Index int
// Src, Layout, and Resolve are the module's source, layout, and the resolver's findings,
// kept when loading with Recover.
Src string
Layout *parser.Layout
Resolve *resolve.Info
}
Module is one loaded module.