Repository navigation
02_parse Level-1d: migrate grammar validity scans, production lookup, and token head-peek onto std/ catamorphisms - #4658
Merged
Merged
Conversation
briansrls
marked this pull request as ready for review
June 11, 2026 02:59
Contributor
Author
|
Re the non-blocking note on |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
02_parse Level-1d: migrate grammar validity scans, production lookup, and token head-peek onto std/ catamorphisms
Continues the stage-adoption lane (#4639 Level-1b GrammarExpr folds, #4651 Level-1c capture spans →
fold_node_tree_span). Per MODELING M9 the std/ DFS came first: every replacement below consumes an operation that already exists inv4.std.algebra/v4.std.collection— no new substrate was added.Hand-match queries dissolved
grammar_dup_check_step+GrammarDupCheckResultaccumulator coproduct (🟡)v4.std.algebra.uniqueover production namesgrammar_has_left_recursion_stepor-foldv4.std.algebra.anygrammar_has_undefined_nonterminals_stepor-foldv4.std.algebra.anygrammar_lookup_production_stepfirst-matchWitnessfoldv4.std.algebra.filter+v4.std.collection.list_at_optionalhead projectionTokenPeekper-use carrier coproduct (🟡) + handfold_list_rightpeekv4.std.collection.list_at_optional(Optional<Token>head projection — the mark's exact dissolve-on-arrival condition)Net: two 🟡 carrier types and four hand step-folds deleted;
grammar_has_duplicate_productions's 🟡 upgraded to 🟢 substrate-consumer (the marked scan morphism arrived asunique). The left-recursion / undefined-nonterminal 🟡 marks stay (their full reachability/scan morphisms have not arrived; only the or-fold plumbing migrated).parse_token_firstsurvives as a one-line typed bridge pinningT = Tokenfor the bootstrap compiler's monomorphic field-access inference (direct inline match failed to infertok.class).Equivalence notes:
filteris order-preserving, so head-of-filtered == old first-match fold; first match == unique match post-validation since duplicate names are rejected pre-parse.unique(pairwise name eq) == old set-membership scan.Claims (src/v4/test/claim/parse/grammar_validation.dag)
claim_distinct_productions_not_duplicate— negative dup-scan case; guards the polarity of theuniquemigration (existing claim only covered the duplicate→true direction).claim_lookup_production_present_holds—Holdspayload is the production with the requested name (second production in the fixture, so a head-only/wrong-filter lookup goes red).claim_lookup_production_absent_violates— fail-closedViolatesfor a missing name.Verification
gunbc run --claim-rungreen on both new lookup witnesses (true, exit 0).parse_productionpath (exercises the Terminal-arm head projection and table lookup): all green..github/ci-floor/v4-m1-rust-emit-probe.sh):compiled: 442 files emitted, 0 diagnostics.🤖 Generated with Claude Code