package sema
import "github.com/azin-lang/Azin/internal/sema"
Index
Types
type Analyzer
type Analyzer struct { // contains filtered or unexported fields }
- The Analyzer struct is responsible for performing sema analysis on the AST of a program. - It maintains a stack of scopes, keeps track of the current function being analyzed, - and uses a diagnostics engine to report errors and warnings.
func New
func New(diag *diagnostics.Engine) *Analyzer
New creates a new Analyzer instance with the provided diagnostics engine.
func (*Analyzer) Analyze
func (a *Analyzer) Analyze(program *ast.Program) error
Analyze performs sema analysis on the given AST program.
type Scope
type Scope struct { Parent *Scope Symbols map[string]*Symbol Functions map[string][]*Symbol }
Scope represents a lexical scope in the source code. It contains a reference to its parent scope and a map of symbols defined within that scope.
type Symbol
type Symbol struct { Name string Type *ast.Identifier Kind SymbolKind Mutable bool Function *ast.FuncStmt Struct *ast.StructStmt Enum *ast.EnumStmt Inferring bool }
Symbol represents a symbol in the sema analysis phase.
type SymbolKind
type SymbolKind uint8
SymbolKind represents the kind of a symbol (variable, function, struct).
const ( SymbolVariable SymbolKind = iota // SymbolVariable represents a variable symbol. SymbolFunction // SymbolFunction represents a function symbol. SymbolStruct // SymbolStruct represents a struct symbol. SymbolEnum // SymbolEnum represents an enum symbol. )