-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.fs
44 lines (42 loc) · 827 Bytes
/
main.fs
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
require ast.fs
require lexer.fs
require lib.fs
require parser.fs
: main ( -- n )
EXIT_SUCCESS begin
dup prepare-prompt
read-cmdline while
\ Save address of readline string, we have to free it later.
2dup >r >r
0 >errno
parse-special-regular ['] lstate-init catch if
drop
errno> strerror type-err cr-err
else
dup >r
['] parse-cmdline ['] lex catch
r> lstate-free
if
2drop 2drop
errno> if
errno> strerror type-err cr-err
else
s" Syntax error" type-err cr-err
endif
else
\ Save ast for deletion
dup >r
over swap ['] ast-exec catch
r> ast-free
if
2drop
errno> strerror type-err cr-err
else
nip
endif
endif
endif
\ Free readline string.
r> r> free-cmdline
repeat 2drop ;
' main init