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 2ca21837b754f315062982ec606069f88ab84026
parent 765717256bd12c7add80fbd2c854491a460a5bea
Author: Commit-Bot <unknown>
Date:   Sun, 10 Oct 2010 17:13:01 +0000

Automatic commit from picoLisp.tgz, From: Sun, 10 Oct 2010 17:13:01 GMT
Diffstat:
Mdoc/refP.html | 8++++----
Mersatz/README | 4+++-
Mersatz/fun.src | 3+++
Mersatz/picolisp.jar | 0
Mersatz/sys.src | 25++++++++++++++++++++++++-
5 files changed, 34 insertions(+), 6 deletions(-)

diff --git a/doc/refP.html b/doc/refP.html @@ -174,10 +174,10 @@ We said: Hello world! <dd>Substitutes any leading "<code>@</code>" character in the <code>any</code> argument with the <u>PicoLisp Home Directory</u>, as it was remembered during interpreter startup. Optionally, the name may be preceded by a "<code>+</code>" -character (as used by <code><a href="refO.html#out">out</a></code>). This -mechanism is used internally by all I/O functions. See also <code><a -href="ref.html#invoc">Invocation</a></code>, <code><a -href="refB.html#basename">basename</a></code>. and <code><a +character (as used by <code><a href="refI.html#in">in</a></code> and <code><a +href="refO.html#out">out</a></code>). This mechanism is used internally by all +I/O functions. See also <code><a href="ref.html#invoc">Invocation</a></code>, +<code><a href="refB.html#basename">basename</a></code>. and <code><a href="refD.html#dirname">dirname</a></code>. <pre><code> diff --git a/ersatz/README b/ersatz/README @@ -44,4 +44,6 @@ The actual source files are The PicoLisp script "mkJar" will read them, generate the Java source file "PicoLisp.java", compile that with 'javac', and pack the result into a JAR (Java -Archive) file. +Archive) file. "mkJar" expects to be run in the "ersatz/" directory, e.g.: + + $ (cd ersatz; ./mkJar) diff --git a/ersatz/fun.src b/ersatz/fun.src @@ -406,6 +406,9 @@ abs return new Number(((Number)ex.cdr().car().eval()).abs().toByteArray()); ############ io ############ +# (path 'any) -> sym +path + # (load 'any ..) -> any load x = ex.cdr(); diff --git a/ersatz/picolisp.jar b/ersatz/picolisp.jar Binary files differ. diff --git a/ersatz/sys.src b/ersatz/sys.src @@ -38,15 +38,37 @@ public class PicoLisp { static PicoLispWriter OutFile = StdOut; static Any TheCls, TheKey; static String[] Argv; + static String Home; public static void main(String[] argv) { Argv = argv; + init(); <SYM> 1 loadAll(null); load(null, ':', Nil); System.exit(0); } + final static void init() { + String s; + for (int i = 0; i < Argv.length; ++i) + if ((s = Argv[i]).charAt(0) != '-') { + if ((i = s.lastIndexOf('/')) >= 0 && !(i == 1 && s.charAt(0) == '.')) + Home = s.substring(0, i+1); + break; + } + } + + final static String path(String s) { + if (s.charAt(0) == '+') { + if (s.charAt(1) == '@') + return "+" + Home + s.substring(1); + } + else if (s.charAt(0) == '@') + return Home + s.substring(1); + return s; + } + final static void unwind(Catch p) { /* ... */ } @@ -985,10 +1007,11 @@ public class PicoLisp { final public PicoLispReader open(Any ex) { try { + String nm = path(Name); if (firstChar() == '+') { /* ... */ } - return new PicoLispReader(new FileReader(Name), Name); + return new PicoLispReader(new FileReader(nm), nm); } catch (IOException e) { err(ex, this, "Can't open");