about summary refs log tree commit diff
path: root/transform.e
diff options
context:
space:
mode:
authorIrene Knapp <ireneista@irenes.space>2026-09-23 03:48:08 -0700
committerIrene Knapp <ireneista@irenes.space>2026-09-23 05:35:36 -0700
commitb0b79f474956f7537d2eb576c4b4cfd6795bc1bc (patch)
tree127f71efb776705fafb2095323031c94efb965cd /transform.e
parent42e213368b5382bd3f39ab10fe147a088486523f (diff)
remove the magic words
now all the command-line invocations are pleasingly short :)

Change-Id: Ibe2b9f3b85ab3a51a9d95e3511b273664e6a8807
Force-Push: yes
Diffstat (limited to 'transform.e')
-rw-r--r--transform.e74
1 files changed, 29 insertions, 45 deletions
diff --git a/transform.e b/transform.e
index e184c7e..136b790 100644
--- a/transform.e
+++ b/transform.e
@@ -331,16 +331,14 @@
 : transformation-state-output-buffer-start 2 8 * + ;
 : transformation-state-user-stack-depth 3 8 * + ;
 : transformation-state-label-scratch 4 8 * + ;
-: transformation-state-delimiter 5 8 * + ;
-: transformation-state-output-metadata 6 8 * + ;
+: transformation-state-output-metadata 5 8 * + ;
 : allocate-transformation-state
-  7 8 * allocate
+  6 8 * allocate
   dup transformation-state-saved-here 0 swap !
   dup transformation-state-saved-latest 0 swap !
   dup transformation-state-output-buffer-start 0 swap !
   dup transformation-state-user-stack-depth 0 swap !
   dup transformation-state-label-scratch 0 swap !
-  dup transformation-state-delimiter 0 swap !
   dup transformation-state-output-metadata 0 swap ! ;
 allocate-transformation-state s" transformation-state" variable
 
@@ -1349,18 +1347,14 @@ allocate-transformation-state s" transformation-state" variable
 : label-transform-one
   word
 
-  ~ If no word was returned, exit.
-  dup 0 = { drop 0 exit } if
+  ~ If no word was returned, end the transformation.
+  dup 0 = { drop 1 exit } if
 
   ~ The string is on the top of the stack, so to get a pointer to it we get
   ~ the stack address.
   ~ (string)
   value@
 
-  ~ If it's the magic word, end the transformation.
-  dup transformation-state transformation-state-delimiter @ stringcmp 0 =
-  { drop dropstring 1 exit } if
-
   ~   Check whether it's one of the words we have alternates for, and look up
   ~ the alternate if so.
   dup 0 swap
@@ -1552,7 +1546,7 @@ allocate-transformation-state s" transformation-state" variable
 ~ input string. It is directly analogous to "quit", in interpet.e, but is far
 ~ more complex.
 ~
-~ (output buffer start, output point, input string pointer, delimiter pointer
+~ (output buffer start, output point, input string pointer
 ~  -- output buffer start, output point)
 : label-transform
   ~ : blank-line
@@ -1583,7 +1577,7 @@ allocate-transformation-state s" transformation-state" variable
   ~ : blank-line
 
   main-input-buffer dup push-input-buffer
-  3roll attach-string-to-input-buffer
+  swap attach-string-to-input-buffer
 
   ~   Save the old values of "here" and "latest", and set the initial values
   ~ of the internal ones. These values need to persist across iterations,
@@ -1592,25 +1586,25 @@ allocate-transformation-state s" transformation-state" variable
   ~ loop, and set it back when the loop ends.
   here @ transformation-state transformation-state-saved-here !
   latest @ transformation-state transformation-state-saved-latest !
-  2 pick transformation-state transformation-state-output-buffer-start !
-  swap here !
+  swap transformation-state transformation-state-output-buffer-start !
+  here !
   0 latest !
-  transformation-state transformation-state-delimiter !
   ~ Now the stack has nothing of ours on it, so client code can do its thing.
 
   ~   It's important that the stack has nothing of ours on it that persists
   ~ across iterations, so that client code can add and remove stuff there as
   ~ it sees fit.
   { label-transform-one
-    ~ (done)
+    ~ (..., done)
 
     ~  When the loop is done, get the real values of "here" and "latest"
     ~ back. The internal "here" is also the output point, and will become our
     ~ return value. The internal "latest" is discarded.
-    { here @
+    { transformation-state transformation-state-output-buffer-start @
+      here @
       transformation-state transformation-state-saved-here @ here !
       transformation-state transformation-state-saved-latest @ latest !
-      ~ (output point)
+      ~ (output buffer start, output point)
 
       ~   Though we don't actually use transformation-state outside of this
       ~ invocation, for tidiness we zero it out.
@@ -2561,18 +2555,14 @@ allocate-transformation-state s" transformation-state" variable
 : log-load-transform-one
   word
 
-  ~ If no word was returned, exit.
-  dup 0 = { drop 0 exit } if
+  ~ If no word was returned, end the transformation.
+  dup 0 = { drop 1 exit } if
 
   ~ The string is on the top of the stack, so to get a pointer to it we get
   ~ the stack address.
   ~ (string)
   value@
 
-  ~ If it's the magic word, end the transformation.
-  dup transformation-state transformation-state-delimiter @ stringcmp 0 =
-  { drop dropstring 1 exit } if
-
   ~   Check whether it's one of the words we have alternates for, and look up
   ~ the alternate if so.
   0 swap
@@ -2759,7 +2749,7 @@ allocate-transformation-state s" transformation-state" variable
 ~ an input string. It is directly analogous to "quit", in interpret.e, but is
 ~ far more complex.
 ~
-~ (output buffer start, output point, input string pointer, delimiter pointer
+~ (output buffer start, output point, input string pointer
 ~  -- output buffer start, output point)
 : log-load-transform
   ~ : blank-line
@@ -2788,7 +2778,7 @@ allocate-transformation-state s" transformation-state" variable
   ~ : blank-line
 
   main-input-buffer dup push-input-buffer
-  3roll attach-string-to-input-buffer
+  swap attach-string-to-input-buffer
 
   ~   Save the old values of "here" and "latest", and set the initial values
   ~ of the internal ones. These values need to persist across iterations,
@@ -2800,26 +2790,26 @@ allocate-transformation-state s" transformation-state" variable
   ~ user-stack-depth fields of transformation-state.
   here @ transformation-state transformation-state-saved-here !
   latest @ transformation-state transformation-state-saved-latest !
-  2 pick transformation-state transformation-state-output-buffer-start !
+  swap transformation-state transformation-state-output-buffer-start !
   0 transformation-state transformation-state-user-stack-depth !
-  swap here !
+  here !
   0 latest !
-  transformation-state transformation-state-delimiter !
   ~ Now the stack has nothing of ours on it, so client code can do its thing.
 
   ~   It's important that the stack has nothing of ours on it that persists
   ~ across iterations, so that client code can add and remove stuff there as
   ~ it sees fit.
   { log-load-transform-one
-    ~ (done)
+    ~ (..., done)
 
     ~  When the loop is done, get the real values of "here" and "latest"
     ~ back. The internal "here" is also the output point, and will become our
     ~ return value. The internal "latest" is discarded.
-    { here @
+    { transformation-state transformation-state-output-buffer-start @
+      here @
       transformation-state transformation-state-saved-here @ here !
       transformation-state transformation-state-saved-latest @ latest !
-      ~ (output point)
+      ~ (output buffer start, output point)
 
       ~   Though we don't actually use transformation-state outside of this
       ~ invocation, for tidiness we zero it out.
@@ -6327,18 +6317,14 @@ allocate-transformation-state s" transformation-state" variable
   hex-skip-space
   word
 
-  ~ If no word was returned, exit.
-  dup 0 = { drop 0 exit } if
+  ~ If no word was returned, end the transformation.
+  dup 0 = { drop 1 exit } if
 
   ~ The string is on the top of the stack, so to get a pointer to it we get
   ~ the stack address.
   ~ (string)
   value@
 
-  ~ If it's the magic word, end the transformation.
-  dup transformation-state transformation-state-delimiter @ stringcmp 0 =
-  { drop dropstring 1 exit } if
-
   ~ If it's anything but tilde, set the input state flag accordingly.
   dup s" ~" stringcmp 0 != { 1 has-non-space-this-input-line! } if
 
@@ -6511,13 +6497,11 @@ allocate-transformation-state s" transformation-state" variable
 ~ more complex.
 ~
 ~ (output metadata buffer start, output buffer start, output point,
-~  input string pointer, delimiter pointer
-~  -- output buffer start, output point)
+~  input string pointer -- output buffer start, output point)
 : hex-transform
   main-input-buffer dup push-input-buffer
-  3roll attach-string-to-input-buffer
-  ~ (output metadata buffer start, output buffer start, output point,
-  ~  delimiter pointer)
+  swap attach-string-to-input-buffer
+  ~ (output metadata buffer start, output buffer start, output point)
 
   ~   Save the old values of "here" and "latest", and set the initial values
   ~ of the internal ones. These values need to persist across iterations,
@@ -6531,7 +6515,6 @@ allocate-transformation-state s" transformation-state" variable
   ~ most convenient order given how we received our parameters.
   here @ transformation-state transformation-state-saved-here !
   latest @ transformation-state transformation-state-saved-latest !
-  transformation-state transformation-state-delimiter !
   here !
   0 latest !
   transformation-state transformation-state-output-buffer-start !
@@ -6573,7 +6556,8 @@ allocate-transformation-state s" transformation-state" variable
     ~  When the loop is done, get the real values of "here" and "latest"
     ~ back. The internal "here" is also the output point, and will become our
     ~ return value. The internal "latest" is discarded.
-    { here @
+    { transformation-state transformation-state-output-buffer-start @
+      here @
       transformation-state transformation-state-saved-here @ here !
       transformation-state transformation-state-saved-latest @ latest !
       ~ (output point)