12 unstable releases (3 breaking)
Uses new Rust 2024
| 0.4.0 | Feb 21, 2026 |
|---|---|
| 0.3.1 | Feb 16, 2026 |
| 0.2.1 | Feb 14, 2026 |
| 0.1.6 | Feb 10, 2026 |
#923 in Parser implementations
175KB
3.5K
SLoC
zpl_toolchain_spec_compiler
Part of the zpl-toolchain project.
Purpose
- Validate per-command JSONC files under
spec/commands/againstspec/schema/zpl-spec.schema.jsonc. - Merge into a single registry and emit generated artifacts:
generated/parser_tables.jsongenerated/constraints_bundle.jsongenerated/docs_bundle.jsongenerated/coverage.json
CLI
zpl-spec-compiler build --spec-dir spec --out-dir generated
zpl-spec-compiler check --spec-dir spec
Inputs
spec/commands/*.jsonc: one file per command family (codes[]+arity+signature+args/constraints).- Schema reference:
../../spec/schema/zpl-spec.schema.jsonc.
Outputs
parser_tables.json: canonical table set consumed by parser/validator (includes the opcode trie inline), per-commandstructuralRules, and top-levelstructuralRuleIndex(by kind/trigger/effect).constraints_bundle.json: constraints extracted per command code (not consumed at runtime; available for external tooling such as IDE plugins and documentation generators).docs_bundle.json: per-code docs view with signature, args, docs, enumValues, composites.exposesArgs, missingFields (not consumed at runtime; available for external tooling).coverage.json: present/missing counts; per_code stats (arg_count, union_positions, missing fields, validation_errors).
Notes
- Comments are allowed in source JSONC; the compiler strips them before validation.
- The compiler passes through fields to
spec-tablesstructures and performs cross-field validation (signature/args/composites/overrides; arg hygiene), including structural rule binding validation. - A
constraint_kinds_match_schematest validates thatConstraintKind::ALL(the Rust enum) and the JSONC schema'skindenum stay in sync. - A structural trigger invariant test validates
CommandEntrytrigger flags align withstructuralRuleIndex.byTrigger. - Schema version policy is strict: all loaded spec files must use a single schema version, and it must match the compiler
SCHEMA_VERSIONconstant. Mixed or unexpected versions failcheck/build.
Dependencies
~1.4–4.5MB
~80K SLoC