-
Notifications
You must be signed in to change notification settings - Fork 8
/
repl.c
38 lines (35 loc) · 989 Bytes
/
repl.c
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
#include <stdio.h>
#include "scm.h"
static void repl(void) {
int p;
scm_object object;
while (1) {
p = printf("> ");
if (p < 0) {
scm_fatal("repl: print failed");
}
/* TODO Currently scm_read and scm_eval exit in the
* case of failure. Eventually scm_read and
* scm_eval will return Scheme error objects in the
* case of failure. For example, scm_read may
* return a syntax error for bad user input. Check
* the return value for errors and report them to
* the user.
*/
object = scm_read(stdin);
object = scm_eval(object);
p = scm_write(stdout, object);
if (p < 0) {
scm_fatal("repl: print failed");
}
p = printf("\n");
if (p < 0) {
scm_fatal("repl: print failed");
}
}
}
int main(void) {
printf("Welcome to Royal Scheme. Ctrl-c to exit.\n");
repl();
return 0;
}