2016-09-05 04:42:50 +03:00
|
|
|
GOTO MAIN
|
|
|
|
|
|
|
|
REM $INCLUDE: 'readline.in.bas'
|
|
|
|
REM $INCLUDE: 'types.in.bas'
|
|
|
|
REM $INCLUDE: 'reader.in.bas'
|
|
|
|
REM $INCLUDE: 'printer.in.bas'
|
|
|
|
|
2016-09-22 07:27:12 +03:00
|
|
|
REM $INCLUDE: 'debug.in.bas'
|
|
|
|
|
2016-10-15 06:42:56 +03:00
|
|
|
REM READ(A$) -> R
|
2016-09-05 04:42:50 +03:00
|
|
|
MAL_READ:
|
|
|
|
GOSUB READ_STR
|
|
|
|
RETURN
|
|
|
|
|
2016-10-15 06:42:56 +03:00
|
|
|
REM EVAL(A, E) -> R
|
2016-10-26 09:26:05 +03:00
|
|
|
SUB EVAL
|
2016-10-15 06:42:56 +03:00
|
|
|
R=A
|
2016-10-26 09:26:05 +03:00
|
|
|
END SUB
|
2016-09-05 04:42:50 +03:00
|
|
|
|
2016-10-15 06:42:56 +03:00
|
|
|
REM PRINT(A) -> R$
|
2016-09-05 04:42:50 +03:00
|
|
|
MAL_PRINT:
|
2016-10-15 06:42:56 +03:00
|
|
|
AZ=A:PR=1:GOSUB PR_STR
|
2016-09-05 04:42:50 +03:00
|
|
|
RETURN
|
|
|
|
|
2016-09-11 06:13:27 +03:00
|
|
|
REM REP(A$) -> R$
|
2016-10-26 09:26:05 +03:00
|
|
|
SUB REP
|
2016-09-05 04:42:50 +03:00
|
|
|
GOSUB MAL_READ
|
2016-10-15 06:42:56 +03:00
|
|
|
IF ER<>-2 THEN GOTO REP_DONE
|
2016-09-20 05:23:21 +03:00
|
|
|
|
2016-10-26 09:26:05 +03:00
|
|
|
A=R:CALL EVAL
|
2016-10-15 06:42:56 +03:00
|
|
|
IF ER<>-2 THEN GOTO REP_DONE
|
2016-09-16 09:00:58 +03:00
|
|
|
|
2016-10-15 06:42:56 +03:00
|
|
|
A=R:GOSUB MAL_PRINT
|
2016-09-20 05:23:21 +03:00
|
|
|
RT$=R$
|
2016-09-16 09:00:58 +03:00
|
|
|
|
2016-09-20 05:23:21 +03:00
|
|
|
REP_DONE:
|
|
|
|
REM Release memory from EVAL
|
2016-10-15 06:42:56 +03:00
|
|
|
AY=R:GOSUB RELEASE
|
2016-09-20 05:23:21 +03:00
|
|
|
R$=RT$
|
2016-10-26 09:26:05 +03:00
|
|
|
END SUB
|
2016-09-05 04:42:50 +03:00
|
|
|
|
2016-09-11 06:13:27 +03:00
|
|
|
REM MAIN program
|
2016-09-05 04:42:50 +03:00
|
|
|
MAIN:
|
|
|
|
GOSUB INIT_MEMORY
|
2016-09-11 06:13:27 +03:00
|
|
|
|
2016-10-23 00:11:46 +03:00
|
|
|
ZT=ZI: REM top of memory after base repl_env
|
2016-09-16 09:00:58 +03:00
|
|
|
|
2016-09-20 05:23:21 +03:00
|
|
|
REPL_LOOP:
|
2016-09-24 06:36:17 +03:00
|
|
|
A$="user> ":GOSUB READLINE: REM call input parser
|
2016-09-20 05:23:21 +03:00
|
|
|
IF EOF=1 THEN GOTO QUIT
|
|
|
|
|
2016-10-26 09:26:05 +03:00
|
|
|
A$=R$:CALL REP: REM call REP
|
2016-09-05 04:42:50 +03:00
|
|
|
|
2016-10-15 06:42:56 +03:00
|
|
|
IF ER<>-2 THEN GOSUB PRINT_ERROR:GOTO REPL_LOOP
|
2016-09-20 05:23:21 +03:00
|
|
|
PRINT R$
|
|
|
|
GOTO REPL_LOOP
|
2016-09-05 04:42:50 +03:00
|
|
|
|
2016-09-20 05:23:21 +03:00
|
|
|
QUIT:
|
2016-10-28 07:47:05 +03:00
|
|
|
REM GOSUB PR_MEMORY_SUMMARY
|
2016-09-11 06:13:27 +03:00
|
|
|
END
|
|
|
|
|
2016-09-20 05:23:21 +03:00
|
|
|
PRINT_ERROR:
|
2016-09-21 05:11:46 +03:00
|
|
|
PRINT "Error: "+ER$
|
2016-10-15 06:42:56 +03:00
|
|
|
ER=-2:ER$=""
|
2016-09-20 05:23:21 +03:00
|
|
|
RETURN
|
|
|
|
|