ocaml: phase 5.1 caesar.ml baseline (ROT13 + s.[i] + Char ops)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 23s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 23s
Side-quests required to land caesar.ml:
1. Top-level 'let r = expr in body' is now an expression decl, not a
broken decl-let. ocaml-parse-program's dispatch now checks
has-matching-in? at every top-level let; if matched, slices via
skip-let-rhs-boundary (which already opens depth on a leading let
with matching in) and ocaml-parse on the slice, wrapping as :expr.
2. runtime.sx: added String.make / String.init / String.map. Used by
caesar.ml's encode = String.init n (fun i -> shift_char s.[i] k).
3. baseline run.sh per-program timeout 240->480s (system load on the
shared host frequently exceeds 240s for large baselines).
caesar.ml exercises:
* the new top-level let-in expression dispatch
* s.[i] string indexing
* Char.code / Char.chr round-trip math
* String.init with a closure that captures k
Test value: Char.code r.[0] + Char.code r.[4] after ROT13(ROT13('hello')) = 104 + 111 = 215.
This commit is contained in:
@@ -1603,7 +1603,22 @@
|
||||
(cond
|
||||
((= (ocaml-tok-type (peek-tok)) "eof") nil)
|
||||
((at-kw? "let")
|
||||
(begin (append! decls (parse-decl-let)) (loop)))
|
||||
(cond
|
||||
;; `let r = expr in body` at the top level is an
|
||||
;; expression-let, not a decl. Detect by scanning
|
||||
;; for a matching `in` at this depth — has-matching-in?
|
||||
;; walks the same boundaries as the decl scanner.
|
||||
((has-matching-in?)
|
||||
(let ((expr-start (cur-pos)))
|
||||
(begin
|
||||
(skip-let-rhs-boundary!)
|
||||
(let ((expr-src (slice src expr-start (cur-pos))))
|
||||
(let ((expr (ocaml-parse expr-src)))
|
||||
(begin
|
||||
(append! decls (list :expr expr))
|
||||
(loop)))))))
|
||||
(else
|
||||
(begin (append! decls (parse-decl-let)) (loop)))))
|
||||
((at-kw? "module")
|
||||
(begin (append! decls (parse-decl-module)) (loop)))
|
||||
((at-kw? "open")
|
||||
|
||||
Reference in New Issue
Block a user