picolisp

Unnamed repository; edit this file to name it for gitweb.
git clone https://logand.com/git/picolisp.git/
Log | Files | Refs | README | LICENSE

commit 3224b36f09f169955b87c8aaedc3dfacd839e78d
parent e292278762f6ddf319b2894996c3a347606a50c2
Author: Commit-Bot <unknown>
Date:   Thu, 11 Nov 2010 15:08:21 +0000

Automatic commit from picoLisp.tgz, From: Thu, 11 Nov 2010 15:08:21 GMT
Diffstat:
Mersatz/PicoLisp.java | 18+++++++-----------
Mersatz/README | 3++-
Mersatz/picolisp.jar | 0
Mersatz/sys.src | 18+++++++-----------
Mlib/debug.l | 3++-
5 files changed, 18 insertions(+), 24 deletions(-)

diff --git a/ersatz/PicoLisp.java b/ersatz/PicoLisp.java @@ -1,4 +1,4 @@ -// 10nov10abu +// 11nov10abu // (c) Software Lab. Alexander Burger import java.util.*; @@ -13,6 +13,7 @@ import java.lang.reflect.*; /* Ersatz PicoLisp Interpreter (Poor Man's PicoLisp) */ public class PicoLisp { final static Console Term = System.console(); + final static StringBuffer Line = new StringBuffer(); final static HashMap<String,Symbol> Intern = new HashMap<String,Symbol>(); final static HashMap<String,Symbol> Transient = new HashMap<String,Symbol>(); final static byte MonLen[] = new byte[] {31,31,28,31,30,31,30,31,31,30,31,30,31}; @@ -45,7 +46,6 @@ public class PicoLisp { static Catch Catch; static Env Env = new Env(); - static StringBuilder Line; static Process[] Pids = new Process[12]; static PicoLispReader[] InFiles = new PicoLispReader[12]; static PicoLispWriter[] OutFiles = new PicoLispWriter[12]; @@ -400,9 +400,9 @@ public class PicoLisp { for (;;) { String s = Term.readLine(); if (s == null) - Line = null; + Line.append('\0'); else { - Line = new StringBuilder(s); + Line.append(s); Line.append('\n'); } try {p.sink().write(ByteBuffer.allocate(1));} @@ -1590,17 +1590,13 @@ public class PicoLisp { if (this != StdIn || Term == null) Chr = Rd.read(); else { - if (Line == null) { + while (Line.length() == 0) { waitFd(null, 0, -1); ((Pipe.SourceChannel)StdIn.Chan).read(ByteBuffer.allocate(1)); } - if (Line == null) + if ((Chr = Line.charAt(0)) == '\0') Chr = -1; - else { - Chr = Line.charAt(0); - if (Line.deleteCharAt(0).length() == 0) - Line = null; - } + Line.deleteCharAt(0); } if (Chr < 0) { if ((Chr = Eof1) != 0) diff --git a/ersatz/README b/ersatz/README @@ -1,4 +1,4 @@ -03nov10abu +11nov10abu (c) Software Lab. Alexander Burger @@ -23,6 +23,7 @@ There is no support for - child processes ('fork') - interprocess communication ('tell', 'hear', 'ipc' etc.) - databases (external symbols) +- signal handling Invocation diff --git a/ersatz/picolisp.jar b/ersatz/picolisp.jar Binary files differ. diff --git a/ersatz/sys.src b/ersatz/sys.src @@ -1,4 +1,4 @@ -// 10nov10abu +// 11nov10abu // (c) Software Lab. Alexander Burger import java.util.*; @@ -13,6 +13,7 @@ import java.lang.reflect.*; /* Ersatz PicoLisp Interpreter (Poor Man's PicoLisp) */ public class PicoLisp { final static Console Term = System.console(); + final static StringBuffer Line = new StringBuffer(); final static HashMap<String,Symbol> Intern = new HashMap<String,Symbol>(); final static HashMap<String,Symbol> Transient = new HashMap<String,Symbol>(); final static byte MonLen[] = new byte[] {31,31,28,31,30,31,30,31,31,30,31,30,31}; @@ -45,7 +46,6 @@ public class PicoLisp { static Catch Catch; static Env Env = new Env(); - static StringBuilder Line; static Process[] Pids = new Process[12]; static PicoLispReader[] InFiles = new PicoLispReader[12]; static PicoLispWriter[] OutFiles = new PicoLispWriter[12]; @@ -98,9 +98,9 @@ public class PicoLisp { for (;;) { String s = Term.readLine(); if (s == null) - Line = null; + Line.append('\0'); else { - Line = new StringBuilder(s); + Line.append(s); Line.append('\n'); } try {p.sink().write(ByteBuffer.allocate(1));} @@ -1288,17 +1288,13 @@ public class PicoLisp { if (this != StdIn || Term == null) Chr = Rd.read(); else { - if (Line == null) { + while (Line.length() == 0) { waitFd(null, 0, -1); ((Pipe.SourceChannel)StdIn.Chan).read(ByteBuffer.allocate(1)); } - if (Line == null) + if ((Chr = Line.charAt(0)) == '\0') Chr = -1; - else { - Chr = Line.charAt(0); - if (Line.deleteCharAt(0).length() == 0) - Line = null; - } + Line.deleteCharAt(0); } if (Chr < 0) { if ((Chr = Eof1) != 0) diff --git a/lib/debug.l b/lib/debug.l @@ -1,4 +1,4 @@ -# 12mar10abu +# 11nov10abu # (c) Software Lab. Alexander Burger # Browsing @@ -28,6 +28,7 @@ "Fun" (list '(X) (list 'pp 'X (lit "M"))) "M" (mapcar car (filter pair (val "M"))) ) ) (loop + (flush) (T (atom "M") (prinl)) (T (line) T) ("Fun" (pop '"M")) ) ) )