Skip to content
beskid The Beskid Book

Beskid

Jump to a Beskid service

Beskid

Jump to a Beskid service

15.2 Mod SDK

compiler-sdk package, Beskid.Syntax mirror, Collector contract hierarchy, query pipeline.

Mod SDK

The compiler-sdk package is the Beskid-side API for mods: contracts and Beskid.Syntax operations, not string templates.

Full normative article: Compiler Mod SDK.

ContractRole
CollectorDeclarative target collection and scope narrowing
GeneratorTyped AST contributions (incremental by default)
AnalyzerDiagnostics + rewrite fixes on merged program
Rewriter<TSource, TTarget>Result<TTarget, FixError> Rewrite(...)
AttributeGeneratorExported attributes (e.g. serialization mods)
classDiagram
  accTitle: Mod SDK contracts
  accDescr: The compiler-sdk package declares the Collector, Generator, Analyzer, Rewriter and AttributeGenerator contracts, each with one entry method.
  class Collector {
    <<contract>>
    Collect(CollectRequest) CollectTargetSet
  }
  class Generator {
    <<contract>>
    Generate(GenerationRequest) GeneratedSyntaxContribution
  }
  class Analyzer {
    <<contract>>
    Analyze(AnalysisRequest) AnalysisResult
  }
  class Rewriter~TSourceNode, TTargetNode~ {
    <<contract>>
    Rewrite(TSourceNode) Result
  }
  class AttributeGenerator {
    <<contract>>
    Attributes(AttributeGenerationRequest) AttributeDeclarationSet
  }

Text equivalent: Each SDK contract has one entry method. Collector returns a target set, Generator a typed syntax contribution, Analyzer diagnostics with fixes, Rewriter a Result of the target node, and AttributeGenerator a set of attribute declarations.

  • Node is a contract; traversal uses NodeRef { syntaxGenerationId, nodeId }
  • Beskid.Compiler.Query + fluent DSL (Select, WhereKind, Replace, …)
  • No source text emission: hosts merge typed trees, then re-parse under bounds

Generated mirrors come from beskid_ast_reflect_gen. Rust AST is canonical; SDK sources are not hand-duplicated parallel syntax.

Implementation specs under Compiler mods:

Generator, Analyzer, Rewriter