Status: All Phases Delivered (Phases 1-6)
Audience: Historical reference for parser evolution. For active development, see test contracts in docs/internals/architecture.md.
Parser evolved from coverage-driven (per-file whack-a-mole) to grammar-driven design with comprehensive test harness. All six phases delivered:
- Created
internal/workspace/libs/stdlib_conformance_test.go - Stdlib gate: 94/94 files clean (no allowlist)
- Hard failing signal for parser regressions
- Golden AST fixtures:
tests/parser/testdata/parse/*.{sysml,golden} - Negative tests:
internal/syntax/parser/negative_test.go - Round-trip tests:
internal/syntax/parser/integration_test.go - Catches silently-wrong ASTs (not just diagnostics)
- Replaced per-body keyword whitelists with general member parser
- Added checkpoint/restore backtracking infrastructure
- Removed terminal errors from body parsers (graceful fallback)
- Stdlib: 94/94 clean maintained
- Semantic decisions inventoried (
docs/phase4_semantic_inventory.md) - Datatype def-vs-usage inference fixed
- Parser focuses on syntactic structure, semantics downstream
- Vendored OMG SysML-v2 grammar (KerML.xtext, SysML.xtext)
- Created
docs/grammar/PRODUCTION_MAP.md(50+ mappings) - ADR 0001: Rationale for hand-written recursive descent parser
- Status claims updated to measured reality (no superlatives)
- Four-layer test contract documented in
ARCHITECTURE.md - Contributing guidelines reference test contract
Parser Test Layers:
- Conformance Gate: 94/94 stdlib files clean (zero allowlist)
- Golden ASTs: 17 fixtures (10 structural + 7 behavioral)
- Negative Tests: 15 cases (malformed syntax)
- Round-trip: Integration tests verify parse → dump → parse stability
Key Achievements:
- Zero terminal errors in body parsers (graceful fallback)
- No keyword whitelists (general member grammar unified)
- All syntax decisions in parser, semantic decisions downstream
- Grammar traceability to OMG pilot reference implementation
See docs/internals/architecture.md for current test requirements:
- Parser Test Contract: 4 layers (conformance, golden, negative, round-trip)
- Behavioral Test Contract: 4 layers (golden ASTs, conformance, traces, robustness)
# Stdlib conformance gate
go test ./internal/workspace/libs/ -run TestStdlibConformance -v
# Golden AST fixtures
go test ./tests/parser -run TestGolden -v
# Negative tests
go test ./tests/parser ./internal/syntax/parser -run TestNegative -v
# Round-trip tests
go test ./internal/syntax/parser/ -run TestIntegration -v
# All parser tests
go test ./internal/syntax/parser/ -vFor detailed implementation notes, see git history:
- Phase 1: Commits establishing conformance gate
- Phase 2: Commits adding golden/negative test infrastructure
- Phase 3: Commit 2c9e6ac (unified member parsing)
- Phase 4: Commits 3eee3d4, cd5c162 (datatype fix)
- Phase 5: Commit 8bfaf0c (grammar traceability)
- Phase 6: Commit f18af39 (doc reconciliation)
Parser evolution complete. Focus shifted to behavioral robustness (see docs/BEHAVIOR_ROBUSTNESS_PLAN.md).