More work on barf.

This commit is contained in:
2026-01-07 12:54:27 -05:00
parent 841de92748
commit 5be8bba895
+8
View File
@@ -264,6 +264,14 @@ CFG for the BARF language:
[(Lambda par body) (eval-lambda arg par body)]
[_ (error 'eval-call "Expected lambda expression to call, instead got: ~s." f)])]))
(: findfun : Symbol PROGRAM -> FUN)
; Finds the Fun.
(define (findfun fname prog)
(define foundfun (cases prog [(Prog flist)
(ormap (lambda (f) (cases f [(Fun name param body)
(if (string=? name fname) (f) (#f))])))]))
(if (not foundfun) (error 'findfun "Function not found.") foundfun))
(: eval : BARF -> Primitive)
;; evaluates BARF expressions by reducing them to numbers
(define (eval expr)