ocaml: phase 1+6 Buffer + parser !x in app args (+3 tests, 425 total)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 48s

Parser fix: at-app-start? and parse-app's loop recognise prefix !
as a deref of the next app arg. So 'List.rev !b' parses as
'(:app List.rev (:deref b))' instead of stalling at !.

Buffer module backed by a ref holding string list:
  create _ = ref []
  add_string b s = b := s :: !b
  contents b = String.concat "" (List.rev !b)
  add_char/length/clear/reset
This commit is contained in:
2026-05-08 16:16:52 +00:00
parent dbe3c6c203
commit 2f271fa6a6
4 changed files with 39 additions and 3 deletions

View File

@@ -167,7 +167,7 @@
((= tt "ctor") true)
((and (= tt "keyword") (or (= tv "true") (= tv "false")))
true)
((and (= tt "op") (or (= tv "(") (= tv "[") (= tv "{"))) true)
((and (= tt "op") (or (= tv "(") (= tv "[") (= tv "{") (= tv "!"))) true)
(else false)))))
(set!
parse-pattern-atom
@@ -532,7 +532,7 @@
((= tt "ctor") true)
((and (= tt "keyword") (or (= tv "true") (= tv "false") (= tv "begin")))
true)
((and (= tt "op") (or (= tv "(") (= tv "[") (= tv "{"))) true)
((and (= tt "op") (or (= tv "(") (= tv "[") (= tv "{") (= tv "!"))) true)
(else false)))))
(define parse-atom-postfix
(fn ()
@@ -568,7 +568,12 @@
(when
(at-app-start?)
(let
((arg (parse-atom-postfix)))
((arg
(cond
((at-op? "!")
(begin (advance-tok!)
(list :deref (parse-atom-postfix))))
(else (parse-atom-postfix)))))
(begin (set! head (list :app head arg)) (loop))))))
(loop)
head))))