Skip to content

v2 grammar follow-up: promote data decls to Decl::Data variant #60

@hyperpolymath

Description

@hyperpolymath

Context

The pest grammar has a data_decl rule (line 62 of ephapax.pest); the core parser's parse_declaration routes Rule::data_decl through parse_type_decl (lib.rs:146) and the core Decl enum has no Data variant — data decls are folded into Decl::Type with the constructors encoded as a binary-sum chain. The surface AST already models data properly (SurfaceDecl::Data(DataDecl)); only the core AST is the kludge.

What to do

  1. Add Decl::Data { name: Var, type_params: Vec<SmolStr>, constructors: Vec<ConstructorDef> } (or similar) to ephapax-syntax.
  2. Update parse_declaration in the core parser to build the new variant instead of routing through parse_type_decl.
  3. Update the desugar pass: SurfaceDecl::Data already lowers to data-registry entries (no core Decl emitted); after this change the desugar can optionally emit a real Decl::Data for downstream consumers that want the structured form.
  4. Patch every exhaustive match on Decl to handle the new arm (same audit pattern used for Decl::Extern in feat(parser,desugar): extern abi blocks (clean — replaces #47/#53) #54).

Acceptance

  • Decl::Data variant exists with constructor list intact
  • Core parser produces the new variant for data decls
  • All existing match sites compile and the workspace tests stay green
  • Cosmetic only — the runtime behaviour should be unchanged

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions