mirror of
https://github.com/dschmenk/PLASMA.git
synced 2025-04-09 16:40:38 +00:00
Comment and add MEM function to REPL
This commit is contained in:
parent
50d72dd386
commit
06a3bd55e1
@ -40,9 +40,11 @@ import sexpr
|
||||
predef parse_expr(evalptr, level, refill)#2
|
||||
predef eval_expr(expr)#1
|
||||
predef eval_num(expr)#2
|
||||
predef bool_pred(bool)
|
||||
predef bool_pred(bool)#1
|
||||
predef new_cons#1
|
||||
predef new_int(intlo, inthi)#1
|
||||
predef new_sym(symstr)#1
|
||||
predef new_assoc(symptr, valptr)#0
|
||||
predef install_natv(symstr, funcptr)#0
|
||||
end
|
||||
|
||||
//
|
||||
@ -58,7 +60,7 @@ var fileref, filebuf // file read vars
|
||||
byte quit = FALSE // quit interpreter flag
|
||||
|
||||
//
|
||||
// Native function to exit REPL
|
||||
// Native functions
|
||||
//
|
||||
|
||||
def natv_bye(expr)
|
||||
@ -66,6 +68,14 @@ def natv_bye(expr)
|
||||
return NULL // Quick exit from REPL
|
||||
end
|
||||
|
||||
def natv_memavail(expr)
|
||||
return new_int(heapavail, 0)
|
||||
end
|
||||
|
||||
//
|
||||
// Keyboard and file input routines
|
||||
//
|
||||
|
||||
def refill_keybd
|
||||
var readline
|
||||
|
||||
@ -127,6 +137,10 @@ def read_file
|
||||
return expr
|
||||
end
|
||||
|
||||
//
|
||||
// Handle command line options
|
||||
//
|
||||
|
||||
def parse_cmdline#0
|
||||
var filename
|
||||
|
||||
@ -143,10 +157,16 @@ def parse_cmdline#0
|
||||
fin
|
||||
end
|
||||
|
||||
//
|
||||
// REPL
|
||||
//
|
||||
|
||||
parse_cmdline
|
||||
install_natv("BYE", @natv_bye)
|
||||
new_sym("BYE")=>natv = @natv_bye)
|
||||
new_sym("MEM")=>natv = @natv_memavail)
|
||||
while not quit
|
||||
putln; print_expr(eval_expr(readfn()))
|
||||
gc_trigger--; if gc_trigger == 0; gc; gc_trigger = GC_RESET; fin
|
||||
loop
|
||||
puts("\nGoodbye!\n")
|
||||
done
|
||||
|
@ -128,7 +128,7 @@ end
|
||||
// Build ATOMS
|
||||
//
|
||||
|
||||
def new_cons
|
||||
export def new_cons#1
|
||||
var consptr
|
||||
|
||||
if cons_free
|
||||
@ -162,7 +162,7 @@ def match_int(intlo, inthi)
|
||||
return NULL
|
||||
end
|
||||
|
||||
def new_int(intlo, inthi)
|
||||
export def new_int(intlo, inthi)#1
|
||||
var intptr
|
||||
|
||||
intptr = match_int(intlo, inthi)
|
||||
@ -208,7 +208,7 @@ def match_sym(symstr)
|
||||
return NULL
|
||||
end
|
||||
|
||||
def new_sym(symstr)
|
||||
export def new_sym(symstr)#1
|
||||
var symptr
|
||||
|
||||
symptr = match_sym(symstr)
|
||||
@ -750,10 +750,6 @@ end
|
||||
// Install default functions
|
||||
//
|
||||
|
||||
export def install_natv(symstr, funcptr)#0
|
||||
new_sym(symstr)=>natv = funcptr)
|
||||
end
|
||||
|
||||
new_assoc(new_sym("NIL"), NULL)
|
||||
new_assoc(new_sym("T"), @pred_true)
|
||||
new_assoc(new_sym("F"), @pred_false)
|
||||
|
Loading…
x
Reference in New Issue
Block a user