ocaml: phase 4 top-level 'let f (a, b) = body' tuple-param decl (+3 tests, 559 total)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 46s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 46s
parse-decl-let lives in the outer ocaml-parse-program scope and does not have access to parse-pattern (which is local to ocaml-parse). Source-slicing approach instead: 1. detect '(IDENT, ...)' in collect-params 2. scan tokens to the matching ')' (tracking nested parens) 3. slice the pattern source string from src 4. push (synth_name, pat_src) onto tuple-srcs Then after collecting params, the rhs source string gets wrapped with 'match SN with PAT_SRC -> (RHS_SRC)' for each tuple-param, innermost-first, and the final string is fed through ocaml-parse. End result is the same AST shape as the iteration-102 inner-let case: a function whose body destructures a synthetic name. let f (a, b) = a + b ;; f (3, 7) = 10 let g x (a, b) = x + a + b ;; g 1 (2, 3) = 6 let h (a, b) (c, d) = a * b + c * d ;; h (1, 2) (3, 4) = 14
This commit is contained in:
@@ -407,6 +407,16 @@ _Newest first._
|
||||
binary search tree (`type 'a tree = Leaf | Node of 'a * 'a tree *
|
||||
'a tree`) with insert + in-order traversal. Tests parametric ADT,
|
||||
recursive match, List.append, List.fold_left.
|
||||
- 2026-05-09 Phase 4 — top-level `let f (a, b) = body` tuple-param
|
||||
decl (+3 tests, 559 total). parse-decl-let (which lives outside
|
||||
the ocaml-parse scope and lacks parse-pattern access) uses a
|
||||
source-slicing approach: detect `(IDENT, ...)`, scan tokens to
|
||||
matching `)`, slice the pattern source string, store as
|
||||
(synth_name, pat_src). After collecting params, wrap the rhs
|
||||
source string with `match SN with PAT_SRC -> (RHS_SRC)` for each
|
||||
tuple-param, innermost first, then ocaml-parse the wrapped
|
||||
string. End result is the same shape as the inner-let case: a
|
||||
function whose body destructures a synthetic name.
|
||||
- 2026-05-09 Phase 4 — `let f (a, b) = body in body2` tuple-param on
|
||||
inner-let bindings (+3 tests, 556 total). Mirrors iteration 101's
|
||||
parse-fun change inside parse-let's parse-one!: same `(IDENT, ...)`
|
||||
|
||||
Reference in New Issue
Block a user