/** * Scope Analysis for MEL * Tracks variable scopes and resolves identifiers * Based on MEL SPEC v0.3.1 Section 4.10 */ import type { ProgramNode } from "../parser/ast.js"; import type { Diagnostic } from "../diagnostics/types.js"; import type { SourceLocation } from "../lexer/source-location.js"; /** * Symbol kinds */ export type SymbolKind = "state" | "computed" | "param" | "action" | "iteration"; /** * Symbol information */ export interface Symbol { name: string; kind: SymbolKind; location: SourceLocation; type?: string; } /** * Scope represents a lexical scope */ export declare class Scope { readonly parent: Scope | null; readonly symbols: Map; readonly kind: "domain" | "action" | "guard"; constructor(kind: "domain" | "action" | "guard", parent?: Scope | null); /** * Define a new symbol in this scope */ define(symbol: Symbol): void; /** * Look up a symbol, searching parent scopes if not found */ lookup(name: string): Symbol | undefined; /** * Check if a symbol is defined in this scope (not parent scopes) */ isDefined(name: string): boolean; } /** * Result of scope analysis */ export interface ScopeAnalysisResult { scopes: Map; diagnostics: Diagnostic[]; } /** * Scope Analyzer - builds scope tree and checks for errors */ export declare class ScopeAnalyzer { private diagnostics; private scopes; private currentScope; private domainScope; /** * Analyze a MEL program */ analyze(program: ProgramNode): ScopeAnalysisResult; private analyzeDomain; private analyzeComputedExpr; private analyzeAction; private analyzeStmt; private analyzeExpr; private checkIdentifier; private checkSystemIdent; private validatePath; private defineSymbol; private error; } /** * Analyze a MEL program for scope issues */ export declare function analyzeScope(program: ProgramNode): ScopeAnalysisResult;