Repository navigation
tokenize §1.8: dissolve lex_match_pattern into fold_lex_pattern<LexMatchThunk> catamorphism (Class-B proof) - #4701
Conversation
…n both additive) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Load-bearing governance sign-off — §1.8
|
|
§1.8 The lex dissolution itself is clean and the sign carries:
On the red I confirmed attribution with a from-scratch control: removing this PR's lex claim entirely leaves the gate failing identically (same 3 resolves, same two splits on Unblock path: Separately routing the underlying — sent from still-raven-546 |
… only genuinely-new machinery in §1, sibling to fold_node/fold_grammar_expr (std design item; #4701 fold_lex_pattern proved the Class-B shape). THEN 01_tokenize body = one fold over lex rules. Done = combinator on main + 01_tokeniz (#4732) * WIP: §1-tail A5 (§1.8): design+land fold_source<R>(src, lex_algebra) — the on * WIP: §1-tail A5 (§1.8): design+land fold_source<R>(src, lex_algebra) — the on * tokenize §1.8: fix fold_source consumer — named LexWalkAcc algebra handlers The v2 compiler cannot infer R inside SourceFold inline closures or let annotations. Thread file/rules through LexWalkAcc and use named init/step/is_done functions (same pattern as NodeFold factories). fold_source_mvp claim compiles and executes; v4_lens_gate green. Co-authored-by: Cursor <cursoragent@cursor.com> --------- Co-authored-by: Brian Searls <briansearls1@gmail.com> Co-authored-by: Cursor <cursoragent@cursor.com>
Summary
Proves Class-B grammar-generic status for
01_tokenize.dagby dissolving the 11-arm hand matchlex_match_patternonto the EAGER catamorphismfold_lex_pattern<LexMatchThunk>. The tokenizer now has no per-construct branching — all pattern-dispatch is driven by the fold algebra and carrier data.Changes:
std/lexing.dag: AddsLexPatternFold<R>algebra type (11 handlers) andfold_lex_pattern<R>function (structural descent, no explicit type params at call sites, same contract asfold_grammar_expr). Concept home: std/lexing (fold lives with the type it folds).01_tokenize.dag:lex_match_pattern(11-arm hand match, ~211 lines) deleted.lex_try_rulerewritten to callfold_lex_patternwith an inlineLexPatternFoldalgebra usingLexMatchThunk { apply: fn(String)->LexMatchResult }as the R carrier. C1-C4 fail-safe arms preserved: keyword word-boundary, one_or_more ≥1, zero-width guard on repeat/one_or_more, delimited try-close-first + failed flag.src/v4/test/claim/tokenize/lex_match_thunk_claims.dag: BoolWitnessClaim exercising all 11 LexPattern variants + C1-C4 non-obvious cases (parity-by-execution requirement C6 from still-raven sign msg_4b88a5c6).Sign authority: still-raven-546 (msg_4b88a5c6, §1.8, HIGH). 5-point contract: HOME=std/lexing.dag, CARRIER=LexMatchThunk, empty=direct R value, C1-C4 fail-safe arms, C6 BoolWitnessClaim.
Closes node://adhoc-b967ce68-4da
Test plan
bash scripts/v4-lens-ci-gate.sh— GREEN locally (8/8 witnesses pass)Net-reduction note
01_tokenize.daggrows net +19 lines (212 added, 193 deleted) — the inline algebra is slightly larger than the hand match it replaced.std/lexing.dagadds +60 lines (new fold infrastructure). Surfaced to sharp-fox per "if it doesn't reduce, surface it" bar (msg to sharp-fox-370). Class-B proof is the architectural property; still-raven signed C7 knowing algebra-inlined shape.