Skip to content

feat: Implement multi-pass semantic analysis framework with AST transformation pipeline#17

Closed
Copilot wants to merge 1 commit into
experiment/huge-interpretation-refactor-v2from
copilot/sub-pr-16
Closed

feat: Implement multi-pass semantic analysis framework with AST transformation pipeline#17
Copilot wants to merge 1 commit into
experiment/huge-interpretation-refactor-v2from
copilot/sub-pr-16

Conversation

Copy link
Copy Markdown

Copilot AI commented Feb 11, 2026

Replaces direct expression building pattern with a composable analysis framework supporting multi-pass semantic enrichment, optimization, and code generation.

Architecture Changes

Analysis Framework

  • Multi-pass pipeline: type resolution → member resolution → variable lifetime → control flow → constant folding
  • AnalysisContext carries metadata across passes using NodeMetadataStore with reference-equality node identity
  • Analyzer + AnalyzerBuilder for composing analysis passes
  • Diagnostic reporting infrastructure for analysis errors and warnings

AST Nodes

  • Immutable record-based node hierarchy replaces mutable Value classes
  • Stable NodeId (GUID v7) for node identification across transformations
  • Nodes are pure data structures—semantic information lives in analysis context, not nodes

Code Generation

  • LinqExpressionGenerator compiles analyzed AST to LINQ expression trees
  • Control flow constructs: If, Switch, While, DoWhile, For, Break, Continue, Return, TryCatchFinally, Using
  • Mermaid AST visualization with metadata annotations

Domain Modeling

  • Renamed DataModelingDomainModeling to reflect broader scope
  • DataModelAstExtensions bridges domain models to AST evaluation
  • DataModelMemberAccessAnalyzer resolves property access through introspection bridge

Example

// Build analyzer with semantic passes
var analyzer = new AnalyzerBuilder()
    .WithTypeResolution()
    .WithMemberResolution()
    .WithConstantFolding()
    .Build();

// Analyze AST
var result = analyzer.Analyze(astNode, context);

// Generate LINQ expression from analyzed AST
var generator = new LinqExpressionGenerator(context);
var expression = generator.Generate(result.Node);

Breaking Changes

  • Value.BuildExpression() removed—use analysis framework + LinqExpressionGenerator
  • InterpretationContext.ToParameterExpression() marked obsolete
  • Test helpers updated to use CompileLambda pattern

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Add variable scope management and semantic analysis middleware feat: Implement multi-pass semantic analysis framework with AST transformation pipeline Feb 11, 2026
Copilot AI requested a review from scoizzle February 11, 2026 14:18
@scoizzle scoizzle marked this pull request as ready for review February 11, 2026 14:20
@scoizzle scoizzle closed this Feb 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants