From 43bdb6104356aae28761a35ad0b28908d0f1a55f Mon Sep 17 00:00:00 2001 From: David Schmenk Date: Tue, 9 Jul 2024 12:21:17 -0700 Subject: [PATCH] Add DRAWL page --- README.md | 4 +++- doc/DRAWL.md | 32 ++++++++++++++++++++++++++++++++ src/lisp/s-expr.pla | 10 +++------- src/mklisp | 1 + src/mkrel | 1 + 5 files changed, 40 insertions(+), 8 deletions(-) create mode 100644 doc/DRAWL.md diff --git a/README.md b/README.md index 1a7d8bf..e9ba950 100755 --- a/README.md +++ b/README.md @@ -4,7 +4,9 @@ [Change List](https://github.com/dschmenk/PLASMA/blob/master/doc/Version%202.1.md#changes-in-plasma-for-211-release) -[Get single boot floppy of FORTH for PLASMA 2.11](https://github.com/dschmenk/PLASMA/blob/master/images/apple/PLFORTH.PO) +[FORTH implemented in PLASMA](https://github.com/dschmenk/PLASMA/blob/master/doc/PLFORTH.md) + +[LISP 1.5 implemented in PLASMA](https://github.com/dschmenk/PLASMA/blob/master/doc/DRAWL.md) # The PLASMA Programming Language diff --git a/doc/DRAWL.md b/doc/DRAWL.md new file mode 100644 index 0000000..8dc508a --- /dev/null +++ b/doc/DRAWL.md @@ -0,0 +1,32 @@ +# LISP 1.5 implemented in PLASMA. LISP interpreted in a bytecode VM runnin on a 1 MHz 6502 is going to be sssllllooooowwwww. So I called this implementation DRAWL in keeping with the speech impediment theme. + +DRAWL represents an exploration REPL language for the PLASMA environment. + +It isn't meant to be a full-blown programming language, more of an interactive sandbox for playing with S-expressions. + +## Missing features of LISP 1.5 in DRAWL + +- The PROG feature isn't present. Programming is limited to interpreting lambda S-expressions +- Number values are limited to 32 bit integera, no floating point +- Deep recursion. The 6502 architecture limits recursion, so don't expect too much here + +However, the code is partitioned to allow for easy extension so some of these missing features could be implemented. + +## Features of DRAWL + +- 32 bit integers. Hey, better than you probably expected +- Recursion handles about nine levels deep. Better than nothing +- Fully garbage collected behind the scenes +- Optionally read LISP source file at startup + +LISP is one of the earliest computer languages. As such, it holds a special place in the anals of computer science. I've always wanted to learn why LISP is held in such high regard by so many, so I went about learning LISP by actually implementing a LISP interpreter in PLASMA. PLASMA is well suited to implement other languages due to its rich syntax, performance and libraries. + +## Links + +Here are some links to get you started. + +LISP 1.5 Manual: https://archive.org/details/bitsavers_mitrlelisprammersManual2ed1985_9279667 + +Video showing DRAWL in action: + +Preconfigured PLASMA ProDOS boot floppy for DRAWL: https://github.com/dschmenk/PLASMA/blob/master/images/apple/DRAWL.po diff --git a/src/lisp/s-expr.pla b/src/lisp/s-expr.pla index 27b43df..bd98c1e 100644 --- a/src/lisp/s-expr.pla +++ b/src/lisp/s-expr.pla @@ -338,12 +338,8 @@ end def is_int(c); return c >= '0' and c <= '9'; end -def is_alpha(c) - return c >= 'A' and c <= 'z' -end - def is_alphasym(c) - return c >= '0' and c <= 'z' + return (c >= '*' and c <= 'z') and (c <> '.') and (c <> ',') end def parse_int(evalptr)#2 // return evalptr, intptr @@ -439,9 +435,9 @@ export def parse_expr(evalptr, level, refill)#2 // return evalptr, exprptr elemptr = NULL break otherwise - if (^evalptr == '-' and is_int(^(evalptr+1))) or is_int(^evalptr) + if is_int(^evalptr) or (^evalptr == '-' and is_int(^(evalptr+1))) evalptr, elemptr = parse_int(evalptr) - elsif is_alpha(^evalptr) + elsif is_alphasym(^evalptr) evalptr, elemptr = parse_sym(evalptr) else putc('\\') diff --git a/src/mklisp b/src/mklisp index 2bcb3c8..30a573e 100755 --- a/src/mklisp +++ b/src/mklisp @@ -22,3 +22,4 @@ cat lisp/set.lisp | ./ac.jar -ptx DRAWL.po lisp/SET.LISP TXT cat lisp/list.lisp | ./ac.jar -ptx DRAWL.po lisp/LIST.LISP TXT cat lisp/maplist.lisp | ./ac.jar -ptx DRAWL.po lisp/MAPLIST.LISP TXT cat lisp/gcd.lisp | ./ac.jar -ptx DRAWL.po lisp/GCD.LISP TXT +cat lisp/fact.lisp | ./ac.jar -ptx DRAWL.po lisp/FACT.LISP TXT diff --git a/src/mkrel b/src/mkrel index 31c3d3b..b04a9a0 100755 --- a/src/mkrel +++ b/src/mkrel @@ -182,6 +182,7 @@ cp lisp/set.lisp prodos/bld/lisp/SET.LISP.TXT cp lisp/list.lisp prodos/bld/lisp/LIST.LISP.TXT cp lisp/maplist.lisp prodos/bld/lisp/MAPLIST.LISP.TXT cp lisp/gcd.lisp prodos/bld/lisp/GCD.LISP.TXT +cp lisp/fact.lisp prodos/bld/lisp/FACT.LISP.TXT #mkdir prodos/bld/examples #cp samplesrc/examples/ex.1.pla prodos/bld/examples/EX.1.PLA.TXT