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 ef6a5a732a84d639f0566b6001037008b4147af2
parent a664f5f84a8a0220bc5c8c3e6b9c8e28dfc8dea9
Author: Commit-Bot <unknown>
Date:   Fri, 11 Jun 2010 07:31:47 +0000

Automatic commit from picoLisp.tgz, From: Fri, 11 Jun 2010 07:31:47 GMT
Diffstat:
MCHANGES | 1+
Mdoc/ref.html | 57+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mdoc/refC.html | 36++++++++++++++++++++++++++++++++++++
Mdoc/refH.html | 3++-
Mdoc/refS.html | 20++++++++++++++++++++
Mdoc/refY.html | 25+++++++++++++++++++++++++
Msrc64/big.l | 6+++---
Msrc64/err.l | 16++++++++--------
Msrc64/flow.l | 64++++++++++++++++++++++++++++++++--------------------------------
Msrc64/glob.l | 15++++++++-------
Msrc64/ht.l | 24++++++++++++------------
Msrc64/io.l | 244++++++++++++++++++++++++++++++++++++++++----------------------------------------
Msrc64/main.l | 14+++++++-------
Msrc64/version.l | 4++--
14 files changed, 335 insertions(+), 194 deletions(-)

diff --git a/CHANGES b/CHANGES @@ -1,4 +1,5 @@ * XXjun10 picoLisp-3.0.3 + 'co', 'yield' and 'stack' coroutine functions 'sigio' function 'sqrt' optionally rounds 'format' also accepts 'lst' argument diff --git a/doc/ref.html b/doc/ref.html @@ -68,6 +68,7 @@ href="faq.html">Frequently Asked Questions (FAQ)</a>. </ul> <li><a href="#ev">Evaluation</a> <li><a href="#int">Interrupt</a> + <li><a href="#coroutines">Coroutines</a> <li><a href="#errors">Error Handling</a> <li><a href="#atres">@ Result</a> <li><a href="#cmp">Comparing</a> @@ -1097,6 +1098,53 @@ function, these extra arguments will be ignored. Missing arguments default to <p><hr> +<h3><a name="coroutines">Coroutines</a></h3> + +<p>Coroutines are independent execution contexts. They may have multiple entry +and exit points, and preserve their environment between invocations. + +<p>They are available only in the 64-bit version. + +<p>A coroutine is identified by a tag. This tag can be passed to other +functions, and (re)invoked as needed. In this regard coroutines are similar to +"continuations" in other languages. + +<p>When the goes out of scope, the coroutine will be garabage collected. In +cases where this is desired, using a <a href="#transient">transient</a> symbol +for the tag is recommended. + +<p>A coroutine is created by calling <code><a href="refC.html#co">co</a></code>. +Its <code>prg</code> body will be executed, and unless <code><a +href="refY.html#yield">yield</a></code> is called at some point, the coroutine +will "fall off" at the end and disappear. + +<p>When <code><a href="refY.html#yield">yield</a></code> is called, control is +either transferred back to the caller, or to some other - explicitly specified, +and already running - coroutine. + +<p>A coroutine is stopped and disposed when + +<p><ul> +<li>it simply falls off the end, + +<li>some other (co)routine calls <code><a href="refC.html#co">co</a></code> with +that tag but without a <code>prg</code> body, + +<li>the tag goes out of scope, so that the garbage collector stops it, + +<li>a <code><a href="refT.html#throw">throw</a></code> into another (co)routine +environment is executed, or + +<li>an error occurred, and <a href="#errors">error handling</a> was entered. + +</ul> + +<p>In the current implementation, not more than 64 coroutines can exist at the +same time. Reentrant coroutines are not supported, a coroutine cannot resume +itself directly or indirectly. + + +<p><hr> <h3><a name="int">Interrupt</a></h3> <p>During the evaluation of an expression, the PicoLisp interpreter can be @@ -1110,6 +1158,12 @@ href="refD.html#debug">debug</a></code>, <code><a href="refE.html#e">e</a></code>, <code><a href="ref_.html#^">^</a></code> and <code><a href="refD.html#*Dbg">*Dbg</a></code> +<p>Other interrups may be handled by <code><a +href="refA.html#alarm">alarm</a></code>, <code><a +href="refS.html#sigio">sigio</a></code>, <code><a +href="refH.html#*Hup">*Hup</a></code> and <code><a +href="refS.html#*Sig1">*Sig[12]</a></code>. + <p><hr> <h3><a name="errors">Error Handling</a></h3> @@ -2037,6 +2091,8 @@ abbreviations: <a href="refC.html#catch">catch</a> <a href="refT.html#throw">throw</a> <a href="refF.html#finally">finally</a> + <a href="refC.html#co">co</a> + <a href="refY.html#yield">yield</a> <a href="ref_.html#!">!</a> <a href="refE.html#e">e</a> <a href="ref_.html#$">$</a> @@ -2367,6 +2423,7 @@ abbreviations: <a href="refA.html#alarm">alarm</a> <a href="refP.html#protect">protect</a> <a href="refH.html#heap">heap</a> + <a href="refS.html#stack">stack</a> <a href="refA.html#adr">adr</a> <a href="refE.html#env">env</a> <a href="refU.html#up">up</a> diff --git a/doc/refC.html b/doc/refC.html @@ -543,6 +543,42 @@ copied, while atoms are returned unchanged. -> T </code></pre> +<dt><a name="co"><code>(co 'sym [. prg]) -> any</code></a> +<dd>(64-bit version only) Starts, resumes or stops a <a +href="ref.html#coroutines">coroutine</a> with the tag given by <code>sym</code>. +If <code>prg</code> is not given, a coroutine with that tag will be stopped. +Otherwise, if a coroutine running with that tag is found (pointer equality is +used for comparison), its execution is resumed. Else a new coroutine with that +tag is initialized and started. <code>prg</code> will be executed until it +either terminates normally, or until <code><a +href="refY.html#yield">yield</a></code> is called. In the latter case +<code>co</code> returns, or transfers control to some other, already running, +coroutine. Trying to start more than 64 coroutines will result in a stack +overflow error. Also, a coroutine cannot resume itself directly or indirectly. +See also <code><a href="refS.html#stack">stack</a></code>, <code><a +href="refC.html#catch">catch</a></code> and <code><a +href="refT.html#throw">throw</a></code>. + +<pre><code> +: (de pythag (N) # A generator function + (if (=T N) + (co 'rt) # Stop + (co 'rt + (for X N + (for Y (range X N) + (for Z (range Y N) + (when (= (+ (* X X) (* Y Y)) (* Z Z)) + (yield (list X Y Z)) ) ) ) ) ) ) ) + +: (pythag 20) +-> (3 4 5) +: (pythag 20) +-> (5 12 13) +: (pythag 20) +-> (6 8 10) + +</code></pre> + <dt><a name="count"><code>(count 'tree) -> num</code></a> <dd>Returns the number of nodes in a database tree. See also <code><a href="refT.html#tree">tree</a></code> and <code><a diff --git a/doc/refH.html b/doc/refH.html @@ -125,7 +125,8 @@ href="refT.html#tolr/3">tolr/3</a></code>. <dt><a name="heap"><code>(heap 'flg) -> cnt</code></a> <dd>Returns the total size of the cell heap space in megabytes. If <code>flg</code> is non-<code>NIL</code>, the size of the currently free space -is returned. See also <code><a href="refG.html#gc">gc</a></code>. +is returned. See also <code><a href="refS.html#stack">stack</a></code> and +<code><a href="refG.html#gc">gc</a></code>. <pre><code> : (gc 4) diff --git a/doc/refS.html b/doc/refS.html @@ -589,6 +589,26 @@ href="refS.html#stem">stem</a></code>. -> 100000000000000000000 </code></pre> +<dt><a name="stack"><code>(stack ['cnt]) -> cnt</code></a> +<dd>(64-bit version only) Maintains the stack segment size. If called without a +<code>cnt</code> argument, or if already one or more <a +href="ref.html#coroutines">coroutines</a> are running, the current size in +megabytes is returned. Otherwise, the stack segment size is set to the new +value. Default is 4 MB. See also <code><a href="refH.html#heap">heap</a></code>. + +<pre><code> +: (stack) # Get current stack segment size +-> 4 +: (stack 10) # Set to 10 MB +-> 10 +: (let N 0 (recur (N) (recurse (inc N)))) +!? (recurse (inc N)) +Stack overflow +? N +-> 109181 +? +</code></pre> + <dt><a name="stamp"><code>(stamp ['dat 'tim]) -> sym</code></a> <dd>Returns a date-time string in the form "YYYY-MM-DD HH:MM:SS". If <code>dat</code> and/or <code>tim</code> is missing, the current date or time is diff --git a/doc/refY.html b/doc/refY.html @@ -11,6 +11,31 @@ <dl> +<dt><a name="yield"><code>(yield 'any ['sym]) -> any</code></a> +<dd>(64-bit version only) Transfers control from the current <a +href="ref.html#coroutines">coroutine</a> back to the caller (when the +<code>sym</code> tag is not given), or to some other coroutine (specified by +<code>sym</code>) to continue execution at the point where that coroutine had +called <code>yield</code> before. In the first case, the value <code>any</code> +will be returned from the corresponding <code><a +href="refC.html#co">co</a></code> call, in the second case it will be the return +value of that <code>yield</code> call. See also <code><a +href="refS.html#stack">stack</a></code>, <code><a +href="refC.html#catch">catch</a></code> and <code><a +href="refT.html#throw">throw</a></code>. + +<pre><code> +: (co "rt1" # Start first routine + (msg (yield 1) " in rt1 from rt2") # Return '1', wait for value from "rt2" + 7 ) # Then return '7' +-> 1 + +: (co "rt2" # Start second routine + (yield 3 "rt1") ) # Send '3' to "rt1" +3 in rt1 from rt2 +-> 7 +</code></pre> + <dt><a name="yoke"><code>(yoke 'any ..) -> any</code></a> <dd>Inserts one or several new elements <code>any</code> in front of the list in the current <code><a href="refM.html#make">make</a></code> environment. diff --git a/src64/big.l b/src64/big.l @@ -1,4 +1,4 @@ -# 10jun10abu +# 11jun10abu # (c) Software Lab. Alexander Burger ### Destructive primitives ### @@ -1603,7 +1603,7 @@ test (L -III) 1 # Sign? if nz # Yes ld B (char "-") # Output sign - call (EnvPutB) + call (PutB) end ld A (Y) # Output highest word call outWordA @@ -1618,7 +1618,7 @@ div E push C # Save remainder add B (char "0") # Output next digit - call (EnvPutB) + call (PutB) cmp E 1 # Done? while ne # No ld C 0 # Divide digit scale by 10 diff --git a/src64/err.l b/src64/err.l @@ -1,4 +1,4 @@ -# 10jun10abu +# 11jun10abu # (c) Software Lab. Alexander Burger # Debug print routine @@ -10,11 +10,11 @@ push F # And flags push (OutFile) # Save output channel ld (OutFile) ((OutFiles) II) # Set to OutFiles[2] (stderr) - push (EnvPutB) # Save 'put' - ld (EnvPutB) putStdoutB # Set new + push (PutB) # Save 'put' + ld (PutB) putStdoutB # Set new call printE # Print argument call newline # and a newline - pop (EnvPutB) # Restore 'put' + pop (PutB) # Restore 'put' pop (OutFile) # and output channel pop F pop A @@ -95,14 +95,14 @@ null C if nz # Yes ld B (char "[") # Output location - call (EnvPutB) + call (PutB) call outStringC # Print filename ld B (char ":") # Separator ':' - call (EnvPutB) + call (PutB) ld A (Y V) # Get 'src' call outWordA # Print line number ld B (char "]") - call (EnvPutB) + call (PutB) call space end end @@ -253,7 +253,7 @@ loop ld Z (EnvCo7) # Get coroutines do - cmp Z (X "EnvCo7-Env") # Skipped? + cmp Z (X "EnvCo7-EnvCo") # Skipped? while ne # Yes ld C (Stack0) # Find stack segment ld A 1 diff --git a/src64/flow.l b/src64/flow.l @@ -1,11 +1,11 @@ -# 10jun10abu +# 11jun10abu # (c) Software Lab. Alexander Burger (code 'redefMsgEC) push (OutFile) # Save output channel ld (OutFile) ((OutFiles) II) # Set to OutFiles[2] (stderr) - push (EnvPutB) # Save 'put' - ld (EnvPutB) putStdoutB # Set new + push (PutB) # Save 'put' + ld (PutB) putStdoutB # Set new push C # Save optional class ld C HashBlank # Print comment call outStringC @@ -18,7 +18,7 @@ end ld C Redefined # Print message call outStringC - pop (EnvPutB) # Restore 'put' + pop (PutB) # Restore 'put' pop (OutFile) # and output channel ret : HashBlank asciz "# " @@ -2572,7 +2572,7 @@ push Y push Z push L - sub S "EnvMid-Env" # Space for env + sub S "EnvMid-EnvCo" # Space for env ld Y (Stack0) # Search through stack segments ld C (Stacks) # Segment bitmask do @@ -2588,14 +2588,14 @@ push (EnvCo7) # Link ld (EnvCo7) S # Close coroutine frame ld Z S # Point Z to main frame - save (Env) (EnvMid) (Z III) # Save environment + save (EnvCo) (EnvMid) (Z III) # Save environment : resumeCoroutine ld S (Y -II) # Restore stack pointer ld (Y -II) 0 # Mark as active lea A (Y 4096) # Set stack limit sub A (StkSize) ld (StkLimit) A - load (Env) (EnvMid) (Y (pack -II "-(EnvMid-Env)")) # Restore environment + load (EnvCo) (EnvMid) (Y (pack -II "-(EnvMid-EnvCo)")) # Restore environment ld X (EnvBind) # Reversed bindings ld C (Z III) # Main bindings do @@ -2618,16 +2618,16 @@ loop ld (EnvBind) C # Set local bindings ld X EnvInFrames # Pointer to input frames - ld C (Z (pack III "+(EnvInFrames-Env)")) # Local input frames + ld C (Z (pack III "+(EnvInFrames-EnvCo)")) # Local input frames call joinLocalCX # Join locals ld X EnvOutFrames # Pointer to output frames - ld C (Z (pack III "+(EnvOutFrames-Env)")) # Local output frames + ld C (Z (pack III "+(EnvOutFrames-EnvCo)")) # Local output frames call joinLocalCX # Join locals - ld X EnvCtlFrames # Pointer to ctlput frames - ld C (Z (pack III "+(EnvCtlFrames-Env)")) # Local ctlput frames + ld X EnvCtlFrames # Pointer to control frames + ld C (Z (pack III "+(EnvCtlFrames-EnvCo)")) # Local control frames call joinLocalCX # Join locals ld X EnvMeth # Pointer to method frames - ld C (Z (pack III "+(EnvMeth-Env)")) # Local method frames + ld C (Z (pack III "+(EnvMeth-EnvCo)")) # Local method frames call joinLocalCX # Join locals ld X EnvApply # Local apply stack do @@ -2635,7 +2635,7 @@ while nz # Yes ld X ((X)) # Follow link loop - ld (X) (Z (pack III "+(EnvApply-Env)")) # Join + ld (X) (Z (pack III "+(EnvApply-EnvCo)")) # Join pop X # Get saved L null X # Any? if nz # Yes @@ -2670,7 +2670,7 @@ push (StkLimit) # and 'lim' push (EnvCo7) # Link ld (EnvCo7) S # Close coroutine frame - save (Env) (EnvMid) (S III) # Save environment + save (EnvCo) (EnvMid) (S III) # Save environment ld (EnvMake) 0 # Init local 'make' env ld (EnvYoke) 0 lea A (Y 4096) # Calculate stack limit @@ -2679,15 +2679,15 @@ ld S Y # Set stack pointer push E # Save 'tag' push 0 # Mark 'stk' as active - sub S "EnvMid-Env" # Space for 'env' + sub S "EnvMid-EnvCo" # Space for 'env' ld X (X CDR) # Run 'prg' prog X xor (Stacks) Z # Not yielded: Mark segment as unused ld S (EnvCo7) # Restore stack pointer - load (Env) (EnvMid) (S III) # Restore environment + load (EnvCo) (EnvMid) (S III) # Restore environment pop (EnvCo7) # Restore coroutine link pop (StkLimit) # 'lim' - add S (pack I "+(EnvMid-Env)") # Clean up + add S (pack I "+(EnvMid-EnvCo)") # Clean up pop L pop Z pop Y @@ -2758,7 +2758,7 @@ end ld E (L I) # Get result drop - ld C (Z (pack III "+(EnvMid-Env)")) # Main routine's link + ld C (Z (pack III "+(EnvMid-EnvCo)")) # Main routine's link cmp L C # Local stack? ldz L 0 if ne # Yes @@ -2776,22 +2776,22 @@ ld X EnvApply # Pointer to apply stack do ld A (X) - cmp A (Z (pack III "+(EnvApply-Env)")) # Local apply stack? + cmp A (Z (pack III "+(EnvApply-EnvCo)")) # Local apply stack? while ne # Yes lea X ((A) I) # Get link loop ld (X) 0 # Cut off ld X EnvMeth # Pointer to method frames - ld C (Z (pack III "+(EnvMeth-Env)")) # Local method frames + ld C (Z (pack III "+(EnvMeth-EnvCo)")) # Local method frames call cutLocalCX # Cut off locals - ld X EnvCtlFrames # Pointer to ctlput frames - ld C (Z (pack III "+(EnvCtlFrames-Env)")) # Local ctlput frames + ld X EnvCtlFrames # Pointer to control frames + ld C (Z (pack III "+(EnvCtlFrames-EnvCo)")) # Local control frames call cutLocalCX # Cut off locals ld X EnvOutFrames # Pointer to output frames - ld C (Z (pack III "+(EnvOutFrames-Env)")) # Local output frames + ld C (Z (pack III "+(EnvOutFrames-EnvCo)")) # Local output frames call cutLocalCX # Cut off locals ld X EnvInFrames # Pointer to input frames - ld C (Z (pack III "+(EnvInFrames-Env)")) # Local input frames + ld C (Z (pack III "+(EnvInFrames-EnvCo)")) # Local input frames call cutLocalCX # Cut off locals ld C 0 # Back link ld X (EnvBind) # Reverse bindings @@ -2820,14 +2820,14 @@ pop Y # Restore taget coroutine ld X (Z II) # Get segment ld (X -II) S # Save stack pointer - save (Env) (EnvMid) (X (pack -II "-(EnvMid-Env)")) # Save environment + save (EnvCo) (EnvMid) (X (pack -II "-(EnvMid-EnvCo)")) # Save environment null Y # Target coroutine? jnz resumeCoroutine # Yes ld S Z # Set stack pointer - load (Env) (EnvMid) (Z III) # Restore environment + load (EnvCo) (EnvMid) (Z III) # Restore environment pop (EnvCo7) # Restore coroutine link pop (StkLimit) # 'lim' - add S (pack I "+(EnvMid-Env)") # Clean up + add S (pack I "+(EnvMid-EnvCo)") # Clean up pop L pop Z pop Y @@ -2969,8 +2969,8 @@ push Z push (OutFile) # Save output channel ld (OutFile) ((OutFiles) II) # Set to OutFiles[2] (stderr) - push (EnvPutB) # Save 'put' - ld (EnvPutB) putStdoutB # Set new + push (PutB) # Save 'put' + ld (PutB) putStdoutB # Set new ld Y (X) # Get 'sym|lst' ld X (X CDR) ld Z (X CDR) # Get 'prg' @@ -3009,11 +3009,11 @@ end end call newline - ld (EnvPutB) (S) # Restore 'put' + ld (PutB) (S) # Restore 'put' ld (OutFile) (S I) # and output channel prog Z # Run 'prg' ld (OutFile) ((OutFiles) II) # Set output channel again - ld (EnvPutB) putStdoutB + ld (PutB) putStdoutB ld C (EnvTrace) # Get trace level dec (EnvTrace) # Decrement it call traceCY # Print trace information @@ -3021,7 +3021,7 @@ call outStringC call printE_E # Print result call newline - pop (EnvPutB) # Restore 'put' + pop (PutB) # Restore 'put' pop (OutFile) # and output channel pop Z pop Y diff --git a/src64/glob.l b/src64/glob.l @@ -1,4 +1,4 @@ -# 10jun10abu +# 11jun10abu # (c) Software Lab. Alexander Burger (data 'Globals 0) @@ -7,11 +7,6 @@ :: Home word 0 # Home directory :: Heaps word 0 # Heap list :: Avail word 0 # Avail list -:: Chr word 0 # Single-char buffer -:: EnvPutB word 0 # Character output function -:: EnvGet_A word 0 # Character input function -:: InFile word 0 # Input file -:: OutFile word 0 # Output file :: Buf word 0 # General 16-byte buffer word 0 @@ -523,7 +518,13 @@ : GcMarkEnd # Structures -: Env # <Catch III> Environment +: EnvCo # Coroutine environment +:: Chr word 0 # Single-char buffer +:: PutB word 0 # Character output function +:: Get_A word 0 # Character input function +:: InFile word 0 # Input file +:: OutFile word 0 # Output file +: Env # <Catch III> environment : EnvBind word 0 # <III> Bind frames (first item in Env) : EnvInFrames word 0 # <IV> Input frames : EnvOutFrames word 0 # <V> Output frames diff --git a/src64/ht.l b/src64/ht.l @@ -1,4 +1,4 @@ -# 19may10abu +# 11jun10abu # (c) Software Lab. Alexander Burger ### Hypertext I/O functions ### @@ -521,8 +521,8 @@ align 8 asciz "<hr>" (data 'Chunk 0) word 0 # <Y> Chunk size count -word 0 # <Y I> Saved EnvGet_A function -word 0 # <Y II> Saved EnvPutB function +word 0 # <Y I> Saved Get_A function +word 0 # <Y II> Saved PutB function skip CHUNK # <Y III> Chunk buffer : Newlines asciz "0\\r\\n\\r\\n" @@ -626,11 +626,11 @@ skip CHUNK # <Y III> Chunk buffer else push Y ld Y Chunk # Get Chunk - ld (Y I) (EnvGet_A) # Save current 'get' - ld (EnvGet_A) getChunked_A # Set new + ld (Y I) (Get_A) # Save current 'get' + ld (Get_A) getChunked_A # Set new call chunkSize prog X # Run 'prg' - ld (EnvGet_A) (Y I) # Restore 'get' + ld (Get_A) (Y I) # Restore 'get' ld (Chr) 0 # Clear look ahead char pop Y end @@ -655,7 +655,7 @@ skip CHUNK # <Y III> Chunk buffer jmp envPutB (code 'wrChunkY 0) # X - ld (EnvPutB) (Y II) # Restore 'put' + ld (PutB) (Y II) # Restore 'put' ld A (Y) # Get count call outHexA # Print as hex ld B 13 # Output 'return' @@ -673,8 +673,8 @@ skip CHUNK # <Y III> Chunk buffer call envPutB ld B 10 # Output 'newline' call envPutB - ld (Y II) (EnvPutB) # Save 'put' - ld (EnvPutB) putChunkedB # Set new + ld (Y II) (PutB) # Save 'put' + ld (PutB) putChunkedB # Set new ret (code 'putChunkedB 0) @@ -707,14 +707,14 @@ skip CHUNK # <Y III> Chunk buffer push Y ld Y Chunk # Get Chunk ld (Y) 0 # Clear count - ld (Y II) (EnvPutB) # Save current 'put' - ld (EnvPutB) putChunkedB # Set new + ld (Y II) (PutB) # Save current 'put' + ld (PutB) putChunkedB # Set new prog X # Run 'prg' null (Y) # Count? if nz # Yes call wrChunkY # Write rest end - ld (EnvPutB) (Y II) # Restore 'put' + ld (PutB) (Y II) # Restore 'put' ld C Newlines # Output termination string call outStringC pop Y diff --git a/src64/io.l b/src64/io.l @@ -1,4 +1,4 @@ -# 10jun10abu +# 11jun10abu # (c) Software Lab. Alexander Burger # Close file descriptor @@ -1716,8 +1716,8 @@ ld A -1 end ld (Chr) A # Save in 'Chr' - ld (Y III) (EnvGet_A) # Save 'get' - ld (EnvGet_A) getStdin_A # Set new + ld (Y III) (Get_A) # Save 'get' + ld (Get_A) getStdin_A # Set new ld (Y) (EnvInFrames) # Set link ld (EnvInFrames) Y # Link frame ret @@ -1727,8 +1727,8 @@ shl A 3 # Vector index add A (OutFiles) # Get OutFile ld (OutFile) (A) # Store new - ld (Y III) (EnvPutB) # Save 'put' - ld (EnvPutB) putStdoutB # Set new + ld (Y III) (PutB) # Save 'put' + ld (PutB) putStdoutB # Set new ld (Y) (EnvOutFrames) # Set link ld (EnvOutFrames) Y # Link frame ret @@ -1767,7 +1767,7 @@ ld (A III) (Chr) # Save Chr in next end end - ld (EnvGet_A) (C III) # Retrieve 'get' + ld (Get_A) (C III) # Retrieve 'get' ld C (C) # Get link ld (EnvInFrames) C # Restore InFrames null C # Any? @@ -1814,7 +1814,7 @@ loop end end - ld (EnvPutB) (C III) # Retrieve 'put' + ld (PutB) (C III) # Retrieve 'put' ld C (C) # Get link ld (EnvOutFrames) C # Restore OutFrames null C # Any? @@ -1858,13 +1858,13 @@ and B (hex "F") # First byte 1110xxxx shl A 6 # xxxx000000 push A - call (EnvGet_A) # Get second byte + call (Get_A) # Get second byte and B (hex "3F") # 10xxxxxx or A (S) # Combine shl A 6 # xxxxxxxxxx000000 ld (S) A end - call (EnvGet_A) # Get last byte + call (Get_A) # Get last byte and B (hex "3F") # 10xxxxxx or (S) A # Combine pop A # Get result @@ -1883,13 +1883,13 @@ do cmp B 32 # White space? while le # Yes - call (EnvGet_A) # Get next + call (Get_A) # Get next null A # EOF? js ret # Yes loop cmp A C # Comment char? while eq # Yes - call (EnvGet_A) + call (Get_A) cmp C (char "#") # Block comment? jne 10 # No cmp B (char "{") @@ -1899,22 +1899,22 @@ while ne #No null A # EOF? js ret # Yes - call (EnvGet_A) + call (Get_A) loop else # Block comment do - call (EnvGet_A) + call (Get_A) null A # EOF? js ret # Yes cmp B (char "}") # End of block comment? if eq - call (EnvGet_A) + call (Get_A) cmp B (char "#") break eq # Yes end loop end - call (EnvGet_A) + call (Get_A) loop ret @@ -1927,7 +1927,7 @@ end cmp B (char "\^") # Caret? if eq # Yes - call (EnvGet_A) # Skip '^' + call (Get_A) # Skip '^' cmp B (char "?") # Question-mark? if eq # Yes ld B 127 # DEL @@ -1939,11 +1939,11 @@ end cmp B (char "\\") # Backslash? jnz 10 # No - call (EnvGet_A) # Skip '\' + call (Get_A) # Skip '\' cmp B 10 # Newline? jnz 10 # No do - call (EnvGet_A) # Skip white space + call (Get_A) # Skip white space cmp B 32 continue eq cmp B 9 @@ -1995,10 +1995,10 @@ jeq 10 # Yes cmp B (char "\\") # Backslash? if eq # Yes - call (EnvGet_A) # Get next char + call (Get_A) # Get next char end call byteSymBCX_CX # Pack char - call (EnvGet_A) # Get next + call (Get_A) # Get next loop 10 ld X (L I) # Get name ld A (Scl) # Scale @@ -2021,13 +2021,13 @@ (code 'rdList_E) cmp S (StkLimit) # Stack check jlt stkErr - call (EnvGet_A) # Skip paren + call (Get_A) # Skip paren do ld C (char "#") call skipC_A # and white space cmp B (char ")") # Empty list? if eq # Yes - call (EnvGet_A) # Skip paren + call (Get_A) # Skip paren ld E Nil # Return NIL ret end @@ -2046,7 +2046,7 @@ ld E A # Keep last cell in E jmp 10 # Exit end - call (EnvGet_A) # Skip tilde + call (Get_A) # Skip tilde ld A 0 call readA_E # Read expression link @@ -2070,14 +2070,14 @@ call skipC_A # Skip white space cmp B (char ")") # Done? if eq # Yes - call (EnvGet_A) # Skip paren + call (Get_A) # Skip paren jmp 90 # Done end cmp B (char "]") # Done? jz 90 # Yes cmp B (char ".") # Dotted pair? if eq # Yes - call (EnvGet_A) # Skip dot + call (Get_A) # Skip dot memb Delim "(DelimEnd-Delim)" # Delimiter? if eq # Yes ld C (char "#") @@ -2099,7 +2099,7 @@ call skipC_A # Skip white space cmp B (char ")") # Done? if eq # Yes - call (EnvGet_A) # Skip paren + call (Get_A) # Skip paren jmp 90 # Done end cmp B (char "]") @@ -2138,7 +2138,7 @@ ld (E CDR) A # Store in last cell ld E A else - call (EnvGet_A) # Skip tilde + call (Get_A) # Skip tilde push E ld A 0 call readA_E # Read expression @@ -2191,7 +2191,7 @@ if nz # Yes cmp (Chr) (char "]") # And super-parentheses? if eq # Yes - call (EnvGet_A) # Skip ']' + call (Get_A) # Skip ']' end end jmp 99 # Return list @@ -2201,12 +2201,12 @@ call rdList_E # Read it cmp (Chr) (char "]") # Matching super-parentheses? jnz suparErrE # Yes: Error - call (EnvGet_A) # Else skip ']' + call (Get_A) # Else skip ']' jmp 99 end cmp B (char "'") # Quote? if eq # Yes - call (EnvGet_A) # Skip "'" + call (Get_A) # Skip "'" ld A 0 call readA_E # Read expression ld C E @@ -2217,7 +2217,7 @@ end cmp B (char ",") # Comma? if eq # Yes - call (EnvGet_A) # Skip ',' + call (Get_A) # Skip ',' ld A 0 call readA_E # Read expression ld (L I) E # Save it @@ -2234,7 +2234,7 @@ end cmp B (char "`") # Backquote? if eq # Yes - call (EnvGet_A) # Skip '`' + call (Get_A) # Skip '`' ld A 0 call readA_E # Read expression ld (L I) E # Save it @@ -2243,10 +2243,10 @@ end cmp B (char "\"") # String? if eq # Yes - call (EnvGet_A) # Skip '"' + call (Get_A) # Skip '"' cmp B (char "\"") # Empty string? if eq # Yes - call (EnvGet_A) # Skip '"' + call (Get_A) # Skip '"' ld E Nil # Return NIL jmp 99 end @@ -2256,13 +2256,13 @@ lea X (L I) # Safe do call byteSymBCX_CX # Pack char - call (EnvGet_A) # Get next + call (Get_A) # Get next cmp B (char "\"") # Done? while ne call testEscA_F jnc eofErr loop - call (EnvGet_A) # Skip '"' + call (Get_A) # Skip '"' ld X (L I) # Get name ld Y Transient ld E 0 # No symbol yet @@ -2271,10 +2271,10 @@ end cmp B (char "{") # External symbol? if eq # Yes - call (EnvGet_A) # Skip '{' + call (Get_A) # Skip '{' cmp B (char "}") # Empty? if eq # Yes - call (EnvGet_A) # Skip '}' + call (Get_A) # Skip '}' call cons_E # New symbol ld (E) ZERO # anonymous or E SYM @@ -2290,7 +2290,7 @@ sub B (char "@") shl E 4 # Add to file number add E A - call (EnvGet_A) # Get next char + call (Get_A) # Get next char loop cmp B (char "0") # Octal digit? jlt badInputErrB @@ -2300,7 +2300,7 @@ zxt ld C A # Init object ID do - call (EnvGet_A) # Get next char + call (Get_A) # Get next char cmp B (char "}") # Done? while ne # No cmp B (char "0") # Octal digit? @@ -2311,7 +2311,7 @@ shl C 3 # Add to object ID add C A loop - call (EnvGet_A) # Skip '}' + call (Get_A) # Skip '}' call extNmCE_X # Build external symbol name call externX_E # New external symbol jmp 99 @@ -2324,10 +2324,10 @@ jeq badInputErrB # Yes cmp B (char "\\") # Backslash? if eq # Yes - call (EnvGet_A) # Get next char + call (Get_A) # Get next char end ld Y A # Save in Y - call (EnvGet_A) # Next char + call (Get_A) # Next char xchg A Y # Get first char call rdAtomBYL_E # Read atom 99 drop @@ -2338,7 +2338,7 @@ (code 'readC_E) null (Chr) # Empty channel? if z # Yes - call (EnvGet_A) # Fill 'Chr' + call (Get_A) # Fill 'Chr' end cmp C (Chr) # Terminator? if eq # Yes @@ -2359,7 +2359,7 @@ jz 10 cmp B (char "]") while eq # Yes -10 call (EnvGet_A) +10 call (Get_A) loop pop E end @@ -2368,17 +2368,17 @@ (code 'tokenCE_E) # X null (Chr) # Look ahead char? if z # No - call (EnvGet_A) # Get next + call (Get_A) # Get next end call skipC_A # Skip white space and comments null A # EOF? js retNull # Yes cmp B (char "\"") # String? if eq # Yes - call (EnvGet_A) # Skip '"' + call (Get_A) # Skip '"' cmp B (char "\"") # Empty string? if eq # Yes - call (EnvGet_A) # Skip '"' + call (Get_A) # Skip '"' ld E Nil # Return NIL ret end @@ -2391,10 +2391,10 @@ link do call byteSymBCX_CX # Pack char - call (EnvGet_A) # Get next + call (Get_A) # Get next cmp B (char "\"") # Done? if eq # Yes - call (EnvGet_A) # Skip '"' + call (Get_A) # Skip '"' break T end call testEscA_F @@ -2414,7 +2414,7 @@ link do call byteSymBCX_CX # Pack char - call (EnvGet_A) # Get next + call (Get_A) # Get next cmp B (char ".") # Dot? continue eq # Yes cmp B (char "0") # Or digit? @@ -2449,7 +2449,7 @@ end cmp B (char "\\") # Backslash? if eq # Yes - call (EnvGet_A) # Use next char + call (Get_A) # Use next char jmp 10 end memb (S I) (S) # Member of character set? @@ -2461,7 +2461,7 @@ link do call byteSymBCX_CX # Pack char - call (EnvGet_A) # Get next + call (Get_A) # Get next cmp B (char "a") # Lower case letter? if ge cmp B (char "z") @@ -2479,7 +2479,7 @@ end cmp B (char "\\") # Backslash? if eq # Yes - call (EnvGet_A) # Use next char + call (Get_A) # Use next char continue T end memb (S IV) (S III) # Member of character set? @@ -2491,7 +2491,7 @@ call getChar_A call mkCharA_A # Return char ld E A - call (EnvGet_A) # Skip it + call (Get_A) # Skip it end ld S Z # Drop buffer pop Z @@ -3231,7 +3231,7 @@ ld A (Chr) # Look ahead char? null A if z # No - call (EnvGet_A) # Get next + call (Get_A) # Get next end null A # EOF? js retNil # Yes @@ -3252,14 +3252,14 @@ ld A (Chr) # Look ahead char? null A if z # No - call (EnvGet_A) # Get next + call (Get_A) # Get next end null A # EOF? if ns # No call getChar_A call mkCharA_A # Make char ld E A - call (EnvGet_A) # Get next + call (Get_A) # Get next else ld E Nil end @@ -3328,7 +3328,7 @@ ld A (Chr) # Look ahead char? null A if z # No - call (EnvGet_A) # Get next + call (Get_A) # Get next end null A # EOF? jns RetNil # No @@ -3358,7 +3358,7 @@ ld A (Chr) # Look ahead char? null A if z # No - call (EnvGet_A) # Get next + call (Get_A) # Get next end do null A # EOF? @@ -3373,7 +3373,7 @@ inc (Z IV) # Increment index nul (C 1) # End of string? break nz # No - call (EnvGet_A) # Skip next input byte + call (Get_A) # Skip next input byte ld E (Z II) # Return matched symbol jmp 90 end @@ -3391,7 +3391,7 @@ ld Z (Z) # Next in chain null (Z) # Any? until z # No - call (EnvGet_A) # Get next input byte + call (Get_A) # Get next input byte loop ld E Nil # Return NIL 90 pop Z # Clean up buffers @@ -3417,7 +3417,7 @@ ld A (Chr) # Look ahead char? null A if z # No - call (EnvGet_A) # Get next + call (Get_A) # Get next end null A # EOF? if ns # No @@ -3436,7 +3436,7 @@ push X # <L I> Result list link do - call (EnvGet_A) # Get next + call (Get_A) # Get next null A # EOF? while nsz # No memb (S IV) (S III) # Matched char? @@ -3459,7 +3459,7 @@ do call getChar_A # Get next character call charSymACX_CX # Insert - call (EnvGet_A) # Get next + call (Get_A) # Get next null A # EOF? while nsz # No memb (S IV) (S III) # Matched char? @@ -3487,7 +3487,7 @@ if ne # No cmp A 13 # Return? jne Ret # No - call (EnvGet_A) # Get next + call (Get_A) # Get next cmp A 10 # Linefeed? jnz retz end @@ -3499,7 +3499,7 @@ ld A (Chr) # Look ahead char? null A if z # No - call (EnvGet_A) # Get next + call (Get_A) # Get next end call eolA_F # End of line? jeq retNil # Yes @@ -3522,7 +3522,7 @@ do call getChar_A # Get next character call charSymACX_CX # Insert - call (EnvGet_A) # Get next + call (Get_A) # Get next call eolA_F # End of line? until eq # Yes ld X (L I) # Get result name @@ -3547,7 +3547,7 @@ do dec E # Decrement count while nz - call (EnvGet_A) # Get next + call (Get_A) # Get next call eolA_F # End of line? if eq # Yes ld X (Z) # Get last sub-result @@ -3564,7 +3564,7 @@ ld Y (Y CDR) # More args? atom Y jnz 10 # No - call (EnvGet_A) # Get next + call (Get_A) # Get next call eolA_F # End of line? jeq 20 # Yes call cons_A # New cell to top list @@ -3598,7 +3598,7 @@ do dec E # Decrement count while nz - call (EnvGet_A) # Get next + call (Get_A) # Get next call eolA_F # End of line? jeq 20 # Yes call getChar_A # Get next character @@ -3612,7 +3612,7 @@ ld Y (Y CDR) # More args? atom Y while z # Yes - call (EnvGet_A) # Get next + call (Get_A) # Get next call eolA_F # End of line? jeq 20 # Yes call getChar_A # Get next character @@ -3628,7 +3628,7 @@ loop end 10 do - call (EnvGet_A) # Get next + call (Get_A) # Get next call eolA_F # End of line? while ne # No call getChar_A # Get next character @@ -3693,7 +3693,7 @@ push (EnvParseX) # Save old parser status push (EnvParseC) push (EnvParseEOF) - push (EnvGet_A) # Save 'get' status + push (Get_A) # Save 'get' status push (Chr) ld E (E TAIL) call nameE_E # Get name @@ -3708,7 +3708,7 @@ ld E (hex "5D0A00") # linefeed, ']', EOF end ld (EnvParseEOF) E - ld (EnvGet_A) getParse_A # Set 'get' status + ld (Get_A) getParse_A # Set 'get' status ld (Chr) 0 or B B # Skip? if nz # Yes @@ -3754,7 +3754,7 @@ end drop pop (Chr) # Retrieve 'get' status - pop (EnvGet_A) + pop (Get_A) pop (EnvParseEOF) # Restore old parser status pop (EnvParseC) pop (EnvParseX) @@ -3775,7 +3775,7 @@ push (EnvParseX) # Save old parser status push (EnvParseC) push (EnvParseEOF) - push (EnvGet_A) # Save 'get' status + push (Get_A) # Save 'get' status push (Chr) ld E (E TAIL) call nameE_E # Get name @@ -3785,14 +3785,14 @@ ld (EnvParseX) E # Set new parser status ld (EnvParseC) 0 ld (EnvParseEOF) (hex "2000") # Blank, EOF - ld (EnvGet_A) getParse_A # Set 'get' status + ld (Get_A) getParse_A # Set 'get' status ld (Chr) 0 call getParse_A # Skip first char ld A 1 # Top level call readA_E # Read expression drop pop (Chr) # Retrieve 'get' status - pop (EnvGet_A) + pop (Get_A) pop (EnvParseEOF) # Restore old parser status pop (EnvParseC) pop (EnvParseX) @@ -3910,7 +3910,7 @@ if nz # Yes null (Chr) if z - call (EnvPutB) # Output prompt + call (PutB) # Output prompt call space call flushAll end @@ -4191,7 +4191,7 @@ ld A (Chr) # Look ahead char? null A if z # No - call (EnvGet_A) # Get next + call (Get_A) # Get next end cmp E Nil # Empty arg? if eq # Yes @@ -4200,8 +4200,8 @@ do null A # EOF? while ns # No - call (EnvPutB) # Output byte - call (EnvGet_A) # Get next + call (PutB) # Output byte + call (Get_A) # Get next loop ld E TSym # Return T pop Y @@ -4228,7 +4228,7 @@ pop X ret end - call (EnvGet_A) # Get next + call (Get_A) # Get next loop end do @@ -4241,8 +4241,8 @@ pop X ret end - call (EnvPutB) # Output byte - call (EnvGet_A) # Get next + call (PutB) # Output byte + call (Get_A) # Get next loop ld E TSym # Return T pop Y @@ -4301,12 +4301,12 @@ do # Done? while ge # No ld B (C) - call (EnvPutB) # Output bytes + call (PutB) # Output bytes inc C sub E 1 loop end - call (EnvGet_A) # Skip next input byte + call (Get_A) # Skip next input byte ld E (Z II) # Return matched symbol jmp 90 end @@ -4352,14 +4352,14 @@ lea C (Y V) # Buffer of output max do ld B (C) - call (EnvPutB) # Output bytes + call (PutB) # Output bytes inc C dec E # Done? until z # Yes pop E pop A end - call (EnvPutB) # Output current byte + call (PutB) # Output current byte else null Y # Output max? if nz @@ -4368,13 +4368,13 @@ do # Done? while ge # No ld B (C) - call (EnvPutB) # Output bytes + call (PutB) # Output bytes inc C sub E 1 loop end end - call (EnvGet_A) # Get next input byte + call (Get_A) # Get next input byte loop ld E Nil # Return NIL 90 pop Z # Clean up buffers @@ -4434,22 +4434,22 @@ (code 'newline) ld B 10 - jmp (EnvPutB) + jmp (PutB) (code 'space) ld B 32 (code 'envPutB) # DLL hook - jmp (EnvPutB) + jmp (PutB) (code 'envGet_A) # DLL hook - jmp (EnvGet_A) + jmp (Get_A) # Output decimal number (code 'outNumE) shr E 4 # Normalize if c # Sign ld B (char "-") # Output sign - call (EnvPutB) + call (PutB) end ld A E (code 'outWordA) @@ -4462,7 +4462,7 @@ pop A end add B (char "0") # Make ASCII digit - jmp (EnvPutB) + jmp (PutB) (code 'prExtNmX) call fileObjX_AC # Get file and object ID @@ -4482,7 +4482,7 @@ and B 7 # Get remainder end add B (char "0") # Make ASCII digit - jmp (EnvPutB) + jmp (PutB) # Output A-O encoding (code 'outAoA 0) @@ -4495,7 +4495,7 @@ and B 15 # Get remainder end add B (char "@") # Make ASCII letter - jmp (EnvPutB) + jmp (PutB) (code 'outStringS) # C lea C (S I) # Buffer above return address @@ -4505,7 +4505,7 @@ inc C or B B # Null? while ne # No - call (EnvPutB) + call (PutB) loop ret @@ -4522,7 +4522,7 @@ do call symByteCX_FACX # Next byte while nz - call (EnvPutB) # Output byte + call (PutB) # Output byte loop ret @@ -4555,7 +4555,7 @@ zero X # Any? if eq # No ld B (char "$") # $xxxxxx - call (EnvPutB) + call (PutB) shr E 4 # Normalize symbol pointer ld A E call outOctA @@ -4565,10 +4565,10 @@ sym (E TAIL) # External symbol? if nz # Yes ld B (char "{") # {AB123} - call (EnvPutB) + call (PutB) call prExtNmX # Print it ld B (char "}") - call (EnvPutB) + call (PutB) pop X ret end @@ -4579,9 +4579,9 @@ cmp X (hex "2E2") # Dot? if eq # Yes ld B (char "\\") # Print backslash - call (EnvPutB) + call (PutB) ld B (char ".") # Print dot - call (EnvPutB) + call (PutB) else ld C 0 call symByteCX_FACX # Get first byte @@ -4590,10 +4590,10 @@ if eq # Yes push A # Save char ld B (char "\\") # Print backslash - call (EnvPutB) + call (PutB) pop A end - call (EnvPutB) # Put byte + call (PutB) # Put byte call symByteCX_FACX # Next byte until z # Done end @@ -4601,7 +4601,7 @@ ld Y 0 # 'tsm' flag in Y atom (Tsm) # Transient symbol markup? if z # Yes - cmp (EnvPutB) putStdoutB # to stdout? + cmp (PutB) putStdoutB # to stdout? if eq # No ld Y ((OutFile) II) # and 'tty'? -> Y end @@ -4609,7 +4609,7 @@ null Y # Transient symbol markup? if z # No ld B (char "\"") - call (EnvPutB) + call (PutB) else ld E ((Tsm)) # Get CAR call outNameE # Write transient symbol markup @@ -4627,32 +4627,32 @@ if eq # Yes 20 push A # Save char ld B (char "\\") # Escape with backslash - call (EnvPutB) + call (PutB) pop A else 30 cmp B 127 # DEL? if eq # Yes ld B (char "\^") # Print ^? - call (EnvPutB) + call (PutB) ld B (char "?") else cmp B 32 # White space? if lt # Yes push A # Save char ld B (char "\^") # Escape with caret - call (EnvPutB) + call (PutB) pop A or A 64 # Make printable end end end - call (EnvPutB) # Put byte + call (PutB) # Put byte call symByteCX_FACX # Next byte until z # Done null Y # Transient symbol markup? if z # No ld B (char "\"") # Final double quote - call (EnvPutB) + call (PutB) else ld E ((Tsm) CDR) # Get CDR call outNameE # Write transient symbol markup @@ -4668,7 +4668,7 @@ cmp E (E CDR) # Circular? if ne # No ld B (char "'") # Print single quote - call (EnvPutB) + call (PutB) ld E (E CDR) # And CDR call printE pop X @@ -4677,7 +4677,7 @@ end ld X E # Keep list head ld B (char "(") # Open paren - call (EnvPutB) + call (PutB) do push (E CDR) # Save rest ld E (E) # Print CAR @@ -4689,14 +4689,14 @@ if eq # Yes call space # Print " ." ld B (char ".") - call (EnvPutB) + call (PutB) break T end atom E # Atomic tail? if nz # Yes call space # Print " . " ld B (char ".") - call (EnvPutB) + call (PutB) call space call printE # and the atom break T @@ -4704,7 +4704,7 @@ call space # Print space loop ld B (char ")") # Closing paren - call (EnvPutB) + call (PutB) pop X ret @@ -4743,10 +4743,10 @@ call prNameX else ld B (char "{") # {AB123} - call (EnvPutB) + call (PutB) call prExtNmX # Print it ld B (char "}") - call (EnvPutB) + call (PutB) end end else diff --git a/src64/main.l b/src64/main.l @@ -1,4 +1,4 @@ -# 10jun10abu +# 11jun10abu # (c) Software Lab. Alexander Burger ### Global return labels ### @@ -91,11 +91,11 @@ end cmp E SymTabEnd until gt - ld (EnvGet_A) getStdin_A + ld (Get_A) getStdin_A ld A 0 # Standard input call initInFileA_A # Create input file ld (InFile) A # Set to default InFile - ld (EnvPutB) putStdoutB + ld (PutB) putStdoutB ld A 2 # Standard error call initOutFileA_A # Create output file ld A 1 # Standard output @@ -1915,13 +1915,13 @@ ld (StrC) 4 # Build name ld (StrX) S link - push (EnvPutB) # Save 'put' - ld (EnvPutB) putStringB # Set new + push (PutB) # Save 'put' + ld (PutB) putStringB # Set new jmp (A) # Return (code 'endString_E 0) pop A # Get return address - pop (EnvPutB) # Restore 'put' + pop (PutB) # Restore 'put' ld E Nil # Preload NIL cmp (L I) ZERO # Name? if ne # Yes @@ -2722,7 +2722,7 @@ atom E while z # Yes ld B `(char ".") # Output dot - call (EnvPutB) + call (PutB) loop call newline end diff --git a/src64/version.l b/src64/version.l @@ -1,6 +1,6 @@ -# 09jun10abu +# 11jun10abu # (c) Software Lab. Alexander Burger -(de *Version 3 0 2 27) +(de *Version 3 0 2 28) # vi:et:ts=3:sw=3