Skip to content

Commit

Permalink
REPL improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
pavpanchekha committed Jun 3, 2024
1 parent 1a8016b commit afa4f41
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions eval/repl.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,19 @@
(when (< n 4)
(raise-user-error 'set "Precision must be an integer greater than 3"))
(set! precision n)]
[`(FPCore ,(? symbol? name) (,(? symbol? args) ...)
,(and (or (? list?) (? symbol?) (? number?))
body))
[`(define (,(? symbol? name) ,(? symbol? args) ...)
,body)
(hash-set! fns name
(rival-compile (list (fix-up-fpcore body)) args
(list (bf-discretization precision))))]
[`(eval ,body)
(define machine (rival-compile (list (fix-up-fpcore body)) '()
(list (bf-discretization precision))))
(define out
(parameterize ([bf-precision precision])
(vector-ref (rival-apply machine (vector)) 0)))
(display (bigfloat->string out))
(newline)]
[`(eval ,(? symbol? name) ,(? real? vals) ...)
(define machine (hash-ref fns name))
(unless (= (vector-length (rival-machine-arguments machine)) (length vals))
Expand All @@ -47,4 +54,4 @@
(newline)])
(display "> "))
(display "exit")
(newline))
(newline)))

0 comments on commit afa4f41

Please sign in to comment.