Frontend Contracts¶
This document specifies how language frontends relate to the shared core.
Translation Function¶
For each supported language lang, define:
T_lang: CS_lang -> CoreAST
Where:
CS_langis concrete syntax in that language frontend.CoreASTis the shared parser AST (ast_nodes.py).
Contract Goals¶
Each frontend should satisfy:
- Compositional mapping: syntax constructs map predictably into core nodes.
- Conservative extension: frontend-specific surface variants normalize into existing core constructs, not new semantics by default.
- Semantics-preserving embedding: equivalent constructs in different frontends should execute identically after lowering/codegen.
Non-Goals¶
- No requirement to reconstruct original surface form from
CoreAST. - No claim of full natural-language understanding.
Current Mechanisms¶
- Concept-keyword registry in
resources/usm/keywords.json - Optional surface normalization in
resources/usm/surface_patterns.json - Core wrapping via
lower_to_core_ir
Validation Strategy¶
The project validates frontend contracts through tests:
- parser-level equivalence tests (same
ASTPrinteroutput) - executor-level equivalence tests (same runtime output)
- per-language onboarding checks for keyword completeness and ambiguity