-
Notifications
You must be signed in to change notification settings - Fork 4
/
repl.rkt
48 lines (42 loc) · 1.5 KB
/
repl.rkt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#lang racket
(compile-allow-set!-undefined #t)
(compile-enforce-module-constants #f)
(require racket/runtime-path)
(require (only-in racket/exn
exn->string)
shen/lang/interposition-points
shen/lang/load
shen/lang/macros
shen/lang/namespaces
shen/lang/namespace-requires
shen/lang/printer
shen/lang/prolog-debug-gui
(only-in shen/lang/reader
detect-prolog-syntax
shen-readtable)
(only-in shen/lang/syntax-utils
syntax->shen-prolog-term)
(only-in shen/lang/system-functions
[eval shen:eval])
shen/lang/type-syntax-expanders
syntax/parse
syntax/stx)
(define (shen-repl)
(define prompt-num 0)
(open-prolog-debug-gui)
(parameterize ([current-readtable shen-readtable])
(let loop ()
(with-handlers ([shen-type-check-exn? (lambda (_) (printf "type error"))]
[exn:break? (lambda (e)
(write-char #\newline)
(exit))]
[exn? (lambda (e)
(printf "error: ~a~n" (exn->string e)))])
(printf "(~a~a) " prompt-num (if (type-check?) '+ '-))
(set! prompt-num (add1 prompt-num))
(load-shen-form (detect-prolog-syntax
(expand-shen-form
(read-syntax)))))
(printf "~n~n")
(loop))))
(shen-repl)