commit 8ae37396a8133b15daf8e66189059fef0d46e744
parent 64a62739935b3c289a7325450ac867b12f9e1d96
Author: Alexander Burger <abu@software-lab.de>
Date: Sat, 29 Dec 2012 18:21:20 +0100
JavaScript 'rd' in "lib/plio.js"
Diffstat:
5 files changed, 72 insertions(+), 3 deletions(-)
diff --git a/CHANGES b/CHANGES
@@ -1,4 +1,5 @@
* DDmmm13 picoLisp-3.1.2
+ JavaScript 'rd' in "lib/plio.js"
'bytes' function
Join multiple namespaces with 'symbols'
diff --git a/ersatz/picolisp.jar b/ersatz/picolisp.jar
Binary files differ.
diff --git a/lib/plio.js b/lib/plio.js
@@ -0,0 +1,68 @@
+/* 29dec12abu
+ * (c) Software Lab. Alexander Burger
+ */
+
+function plio(lst) {
+ var NIX = 0;
+ var BEG = 1;
+ var DOT = 2;
+ var END = 3;
+
+ var NUMBER = 0;
+ var INTERN = 1;
+ var TRANSIENT = 2;
+
+ var PlioPos = 1;
+ var PlioLst = lst;
+ var PlioCnt, PlioMore;
+
+ function byte() {
+ if (PlioCnt == 0) {
+ if (!PlioMore)
+ return -1;
+ PlioMore = (PlioCnt = PlioLst[PlioPos++]) == 255;
+ }
+ --PlioCnt;
+ return PlioLst[PlioPos++];
+ }
+
+ function expr(c) {
+ if ((c & ~3) !== 0) { // Atom
+ PlioMore = (PlioCnt = c >> 2) === 63;
+ if ((c & 3) === NUMBER) {
+ c = byte();
+ var n = c >> 1;
+ if ((c & 1) !== 0)
+ n = -n;
+ var m = 128;
+ while ((c = byte()) >= 0) {
+ n += c * m;
+ m *= 256;
+ }
+ return n;
+ }
+ var str = ""; // TRANSIENT
+ while ((c = byte()) >= 0) {
+ if ((c & 0x80) != 0) {
+ if ((c & 0x20) == 0)
+ c &= 0x1F;
+ else
+ c = (c & 0xF) << 6 | byte() & 0x3F;
+ c = c << 6 | byte() & 0x3F;
+ }
+ str += String.fromCharCode(c);
+ }
+ return str;
+ }
+ if (c !== BEG) // NIX, DOT or END
+ return null;
+ var i = 0;
+ var lst = new Array();
+ lst[0] = expr(PlioLst[PlioPos++]);
+ while ((c = PlioLst[PlioPos++]) !== END && c !== DOT)
+ lst[++i] = expr(c);
+ return lst;
+ }
+
+ return expr(PlioLst[0]);
+}
diff --git a/src/vers.h b/src/vers.h
@@ -1 +1 @@
-static byte Version[4] = {3,1,1,3};
+static byte Version[4] = {3,1,1,4};
diff --git a/src64/version.l b/src64/version.l
@@ -1,6 +1,6 @@
-# 28dec12abu
+# 29dec12abu
# (c) Software Lab. Alexander Burger
-(de *Version 3 1 1 3)
+(de *Version 3 1 1 4)
# vi:et:ts=3:sw=3