ocaml: phase 5.1 baseline OCaml programs (5/5 pass) + lookahead boundary
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 33s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 33s
lib/ocaml/baseline/{factorial,list_ops,option_match,module_use,sum_squares}.ml
exercised through ocaml-run-program (file-read F). lib/ocaml/baseline/
run.sh runs them and compares against expected.json — all 5 pass.
To make module_use.ml (with nested let-in) parse, parser's
skip-let-rhs-boundary! now uses has-matching-in? lookahead: a let at
depth 0 in a let-decl rhs opens a nested block IFF a matching in
exists before any decl-keyword. Without that in, the let is a new
top-level decl (preserves test 274 'let x = 1 let y = 2').
This is the first piece of Phase 5.1 'vendor a slice of OCaml
testsuite' — handcrafted fixtures for now, real testsuite TBD.
This commit is contained in:
8
lib/ocaml/baseline/option_match.ml
Normal file
8
lib/ocaml/baseline/option_match.ml
Normal file
@@ -0,0 +1,8 @@
|
||||
(* Baseline: option type + pattern matching *)
|
||||
let safe_div a b =
|
||||
if b = 0 then None else Some (a / b) ;;
|
||||
let result =
|
||||
match safe_div 20 4 with
|
||||
| None -> 0
|
||||
| Some x -> x ;;
|
||||
result
|
||||
Reference in New Issue
Block a user