make, swift3: fix parsing empty literal sequences.
[jackhill/mal.git] / basic / step1_read_print.in.bas
1 GOTO MAIN
2
3 REM $INCLUDE: 'mem.in.bas'
4 REM $INCLUDE: 'types.in.bas'
5 REM $INCLUDE: 'readline.in.bas'
6 REM $INCLUDE: 'reader.in.bas'
7 REM $INCLUDE: 'printer.in.bas'
8
9 REM $INCLUDE: 'debug.in.bas'
10
11 REM READ(A$) -> R
12 MAL_READ:
13 GOSUB READ_STR
14 RETURN
15
16 REM EVAL(A, E) -> R
17 SUB EVAL
18 R=A
19 END SUB
20
21 REM PRINT(A) -> R$
22 MAL_PRINT:
23 AZ=A:B=1:GOSUB PR_STR
24 RETURN
25
26 REM REP(A$) -> R$
27 SUB REP
28 GOSUB MAL_READ
29 IF ER<>-2 THEN GOTO REP_DONE
30
31 A=R:CALL EVAL
32 IF ER<>-2 THEN GOTO REP_DONE
33
34 A=R:GOSUB MAL_PRINT
35
36 REP_DONE:
37 REM Release memory from EVAL
38 AY=R:GOSUB RELEASE
39 END SUB
40
41 REM MAIN program
42 MAIN:
43 GOSUB INIT_MEMORY
44
45 ZT=ZI: REM top of memory after base repl_env
46
47 REPL_LOOP:
48 A$="user> ":GOSUB READLINE: REM call input parser
49 IF EZ=1 THEN GOTO QUIT
50 IF R$="" THEN GOTO REPL_LOOP
51
52 A$=R$:CALL REP: REM call REP
53
54 IF ER<>-2 THEN GOSUB PRINT_ERROR:GOTO REPL_LOOP
55 PRINT R$
56 GOTO REPL_LOOP
57
58 QUIT:
59 REM GOSUB PR_MEMORY_SUMMARY_SMALL
60 #cbm END
61 #qbasic SYSTEM
62
63 PRINT_ERROR:
64 PRINT "Error: "+E$
65 ER=-2:E$=""
66 RETURN
67