From 4a7a1a69bb2de9a3447ca298b844c37a3342159a Mon Sep 17 00:00:00 2001 From: David Schmenk Date: Thu, 1 Aug 2024 20:51:30 -0700 Subject: [PATCH] Add more string handling and cool macros in defun.lisp --- doc/DRAWL.md | 14 ++-- images/apple/DRAWL.po | Bin 143360 -> 143360 bytes src/lisp/defun.lisp | 20 +++++- src/lisp/drawl.pla | 154 +++++++++++++++++++++++++++--------------- src/lisp/s-expr.pla | 58 ++++++++++++++++ src/lisp/s-math.pla | 5 ++ 6 files changed, 189 insertions(+), 62 deletions(-) diff --git a/doc/DRAWL.md b/doc/DRAWL.md index 1b3d93a..5c7af06 100644 --- a/doc/DRAWL.md +++ b/doc/DRAWL.md @@ -58,6 +58,7 @@ The DRAWL implementation comes with the following built-in functions: - OR(...) - NULL() - NUMBERP() +- STRINGP() ### Misc @@ -139,6 +140,8 @@ The DRAWL implementation comes with the following built-in functions: - PI() = Constant value of pi - MATH_E() = Constant value of e +- NUMBER() = Convert atom to number (symbol and array return NIL) +- INTEGER() = Convert number to integer - LOGB() - SCALEB_I() - TRUNCATE() @@ -163,11 +166,12 @@ The DRAWL implementation comes with the following built-in functions: ### Strings -- SUBS = SUB String offset length -- CATS = conCATenate Strings -- LENS = LENgth String -- CHARS = CHARacter String from integer value -- ASCII = ASCII value of first character in string +- STRING() = Convert atom to string +- SUBS() = SUB String offset length +- CATS(...) = conCATenate Strings +- LENS() = LENgth String +- CHARS() = CHARacter String from integer value +- ASCII() = ASCII value of first character in string ### Lo-Res Graphics diff --git a/images/apple/DRAWL.po b/images/apple/DRAWL.po index 035b2e9d683a9eb3b87951e74770efab0a7dcb3e..1770b9932e6aefdd53fbbf9c79cba066cc18ad87 100644 GIT binary patch delta 7503 zcmZ{p33!y%y@$`Y%p@d%B$JS2l8_A9Boi_ufIvusOcp{g%P^U+34+{$nrfsjSn$et zPyv;y$J{!luC%l+v{FHdR-{k`iv>kRu(ev`QmTO#suedd_x+NYB*b2x=bhhwJ?DI9 z63*e{wxiLv9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L}>3iGP>dWX$}V zQkq-r(1a5*-}T-1Xa4mAoj=Oa4Q?@iQA$l*`1O`CLfo<_Wv(sQM_OFm5zSL$tvLiW z3Bof!Su~Gmh!;fArOSttpqzRDx7ptO%@gwW)h0|cM&#O%z4!wvSAT{-4d;m4i7iX$7)Z7FaF<%PE+d!-RZt6l zXl4_dWewNY;;+Xqu(Hh!R*nf;{mcq$hKTj$$6)7wG5c6P2FO)v&Z*^J8V!Db-?ZncX$Hm!Tm71Zv7 z`{56;n!dGmp?S(4rk}^ZWEYuN@o!Lji+CGjcA@*xPtY&WuhD;@KcTj(SodQ8Nu7Yn z#0)|U(NXAF7mqdg39bU|MJru{%ruv!>+pWpNYmtU^i2F^E-U1DSoRP3zLU>19IQ<) z7P~*#_Wr)ZTMz8^Cp%(y+Xs8Mb_T=6*8OceI{k=FzvshU`+UhGI|D|&JSMqB?AX=z z&f%>)w$>((;S1X=pFSg%`oDAdcKP&K*_&SkSK*(ISFy?!8@3x$lx-Dc@|#yv-FZLu x#q*os^F4lh+{rZicar) @@ -154,9 +143,43 @@ def natv_plot(symptr, expr) return expr end -def natv_bye(symptr, expr) - quit = TRUE - return new_sym("GOODBYE!") +def natv_printer(symptr, expr) + byte slot + + slot = eval_int16(expr) & 7 + if slot + if !scrncsw + scrncsw = *csw + fin + *csw = $C000 | (slot << 8) + else + if scrncsw + *csw = scrncsw + fin + scrncsw = 0 + fin + return new_int(slot, 0) +end + +def natv_read(symptr, expr) + return readfn() +end + +def natv_readstring(symptr, expr) + var len + + if fileref // Reading from file + len = fileio:read(fileref, filebuf, FILEBUF_SIZE-1) + if len + if ^(filebuf + len - 1) == $0D + len-- // Remove trailing carriage return + fin + return new_string(filebuf) + fin + fileio:close(fileref) // End of file, fall through to keyboard + fileref = 0 + fin + return new_string(gets(':'|$80)) end // @@ -196,7 +219,8 @@ def read_fileline ^(filebuf + len) = 0 // NULL terminate else fileio:close(fileref) - readfn = @read_keybd + fileref = 0 + readfn = @read_keybd return FALSE fin until len @@ -221,6 +245,26 @@ def read_file return expr end +def natv_readfile(symptr, expr) + symptr = eval_expr(expr=>car) + if symptr->type <> STRING_TYPE + puts("Not string in READFILE:"); print_expr(expr); putln + return NULL + fin + fileref = fileio:open(symptr + stringstr) + if fileref + fileio:newline(fileref, $7F, $0D) + readfn = @read_file + if !filebuf + filebuf = heapalloc(FILEBUF_SIZE) + fin + else + puts("Unable to open: "); puts(symptr + stringstr); putln + symptr = NULL + fin + return symptr +end + // // Handle command line options // @@ -274,20 +318,22 @@ end // puts("DRAWL (LISP 1.5) v1.0 symbolic processor\n") -sym_fpint = new_sym("FMTFPI") -sym_fpfrac = new_sym("FMTFPF") -sym_fpint=>natv = @natv_fpint -sym_fpfrac=>natv = @natv_fpfrac -sym_fpint=>apval = new_int(fmt_fpint, 0) ^ NULL_HACK -sym_fpfrac=>apval = new_int(fmt_fpfrac, 0) ^ NULL_HACK -new_sym("CLEAR")=>natv = @natv_clear -new_sym("GC")=>natv = @natv_gc -new_sym("READ")=>natv = @natv_read -new_sym("PRINTER")=>natv = @natv_printer -new_sym("GR")=>natv = @natv_gr -new_sym("COLOR")=>natv = @natv_color -new_sym("PLOT")=>natv = @natv_plot -new_sym("QUIT")=>natv = @natv_bye +sym_fpint = new_sym("FMTFPI") +sym_fpfrac = new_sym("FMTFPF") +sym_fpint=>natv = @natv_fpint +sym_fpfrac=>natv = @natv_fpfrac +sym_fpint=>apval = new_int(fmt_fpint, 0) ^ NULL_HACK +sym_fpfrac=>apval = new_int(fmt_fpfrac, 0) ^ NULL_HACK +new_sym("CLEAR")=>natv = @natv_clear +new_sym("QUIT")=>natv = @natv_bye +new_sym("GC")=>natv = @natv_gc +new_sym("GR")=>natv = @natv_gr +new_sym("COLOR")=>natv = @natv_color +new_sym("PLOT")=>natv = @natv_plot +new_sym("PRINTER")=>natv = @natv_printer +new_sym("READ")=>natv = @natv_read +new_sym("READSTRING")=>natv = @natv_readstring +new_sym("READFILE")=>natv = @natv_readfile parse_cmdline hook_eval = @hookfn diff --git a/src/lisp/s-expr.pla b/src/lisp/s-expr.pla index 22ae3a8..7538e91 100644 --- a/src/lisp/s-expr.pla +++ b/src/lisp/s-expr.pla @@ -1077,6 +1077,25 @@ def natv_eq(symptr, expr) return bool_pred(iseq) end +def natv_number(symptr, expr) + var num + + expr = eval_expr(expr=>car) + if not expr; return NULL; fin + when expr->type & TYPE_MASK + is STRING_TYPE // Convert string to number + memcpy(tempstr, expr + stringstr, expr->stringstr + 1) + ^(tempstr + ^tempstr + 1) = 0 + drop, expr = parse_num(tempstr + 1) + break + is SYM_TYPE + is ARRAY_TYPE + expr = NULL + is NUM_TYPE + wend + return expr +end + def natv_numberp(symptr, expr) expr = eval_expr(expr=>car) return bool_pred(expr and (expr->type & TYPE_MASK == NUM_TYPE)) @@ -1458,6 +1477,42 @@ def natv_setq(symptr, expr) return expr ?? expr=>cdr :: NULL end +def natv_string(symptr, expr) + expr = eval_expr(expr=>car) + if not expr; return NULL; fin + ^tempstr = 0 + when expr->type & TYPE_MASK + is NUM_TYPE + when expr->type + is NUM_INT + i32tos(expr + intval, tempstr) + break + is NUM_FLOAT + ext2str(expr + floatval, tempstr, fmt_fpint, fmt_fpfrac, fmt_fp) + if ^(tempstr + 1) == ' ' // Remove leading space + memcpy (tempstr + 1, tempstr + 2, ^tempstr) + ^tempstr-- + fin + break + wend + break + is SYM_TYPE + ^tempstr = expr->type & SYM_LEN + memcpy(tempstr + 1, expr + name, ^tempstr) + break; + is ARRAY_TYPE + ^tempstr = 2 + ^(tempstr + 1) = '[' + ^(tempstr + 2) = ']' + break; + wend + return new_string(tempstr) +end + +def natv_stringp(symptr, expr) + return bool_pred(eval_expr(expr=>car)->type == STRING_TYPE) +end + def natv_subs(symptr, expr) var stringptr byte ofst, len @@ -1565,6 +1620,7 @@ new_sym("LIST")=>natv = @natv_list new_sym("ATOM")=>natv = @natv_atom new_sym("EQ")=>natv = @natv_eq new_sym("NUMBERP")=>natv = @natv_numberp +new_sym("NUMBER")=>natv = @natv_number new_sym("NOT")=>natv = @natv_null new_sym("AND")=>natv = @natv_and new_sym("OR")=>natv = @natv_or @@ -1586,6 +1642,8 @@ new_sym("GO")=>natv = @natv_go new_sym("RETURN")=>natv = @natv_return new_sym("SET")=>natv = @natv_set new_sym("SETQ")=>natv = @natv_setq +new_sym("STRINGP")=>natv = @natv_stringp +new_sym("STRING")=>natv = @natv_string new_sym("SUBS")=>natv = @natv_subs new_sym("CATS")=>natv = @natv_cats new_sym("LENS")=>natv = @natv_lens diff --git a/src/lisp/s-math.pla b/src/lisp/s-math.pla index 945867b..f0b30e9 100644 --- a/src/lisp/s-math.pla +++ b/src/lisp/s-math.pla @@ -135,6 +135,10 @@ export def eval_int16(expr)#1 // Always return an int return result=>intval end +def natv_integer(symptr, expr) + return eval_int(expr) +end + def natv_sum(symptr, expr) var num, extptr word[2] intsum @@ -775,6 +779,7 @@ end sane:initFP() new_sym("PI")=>apval = new_float(@ext_pi) ^ NULL_HACK new_sym("MATH_E")=>apval = new_float(@ext_e) ^ NULL_HACK +new_sym("INTEGER")=>natv = @natv_integer new_sym("SUM")=>natv = @natv_sum new_sym("+")=>natv = @natv_sum new_sym("-")=>natv = @natv_sub