1
1
mirror of https://github.com/kanaka/mal.git synced 2024-11-11 00:52:44 +03:00
mal/racket/step1_read_print.rkt
Joel Martin f522319598 Racket: add steps0-A. Self-hosting.
- Some additioanl tests.
- Split step9 tests into optional but self-hosting requirements
  (metadata on functions) and other optional (conj, metadata on
  collections).
2015-01-09 16:16:55 -06:00

31 lines
577 B
Racket
Executable File

#!/usr/bin/env racket
#lang racket
(require "readline.rkt" "types.rkt" "reader.rkt" "printer.rkt")
;; read
(define (READ str)
(read_str str))
;; eval
(define (EVAL ast env)
ast)
;; print
(define (PRINT exp)
(pr_str exp true))
;; repl
(define (rep str)
(PRINT (EVAL (READ str) "")))
(define (repl-loop)
(let ([line (readline "user> ")])
(when (not (eq? nil line))
(with-handlers
([string? (lambda (exc) (printf "Error: ~a~n" exc))]
[blank-exn? (lambda (exc) null)])
(printf "~a~n" (rep line)))
(repl-loop))))
(repl-loop)