From 6e0227328154e18810d8dfa4489bf84c9c15cbf7 Mon Sep 17 00:00:00 2001 From: Irene Knapp Date: Fri, 28 Aug 2026 05:28:35 -0700 Subject: change the transforms to take their end delimiters as parameters this will not be useful until read-to-buffer also does, but it's a step towards that Force-Push: yes Change-Id: Icf03088c9e52e427a5c130949e9ba85655d59044 --- transform.e | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) (limited to 'transform.e') diff --git a/transform.e b/transform.e index ebf493f..313882d 100644 --- a/transform.e +++ b/transform.e @@ -285,13 +285,15 @@ : 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 * + ; : allocate-transformation-state - 5 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-label-scratch 0 swap ! + dup transformation-state-delimiter 0 swap ! ; allocate-transformation-state s" transformation-state" variable @@ -1248,7 +1250,8 @@ allocate-transformation-state s" transformation-state" variable value@ ~ If it's the magic word, end the transformation. - dup s" pyrzqxgl" stringcmp 0 = { drop dropstring 1 exit } if + 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. @@ -1435,11 +1438,11 @@ 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 +~ (output buffer start, output point, input string pointer, delimiter pointer ~ -- output buffer start, output point) : label-transform main-input-buffer dup push-input-buffer - swap attach-string-to-input-buffer + 3roll 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, @@ -1448,9 +1451,10 @@ 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 ! - over transformation-state transformation-state-output-buffer-start ! - here ! + 2 pick transformation-state transformation-state-output-buffer-start ! + swap 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 @@ -2356,7 +2360,8 @@ allocate-transformation-state s" transformation-state" variable value@ ~ If it's the magic word, end the transformation. - dup s" pyrzqxgl" stringcmp 0 = { drop dropstring 1 exit } if + 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. @@ -2540,11 +2545,11 @@ 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 +~ (output buffer start, output point, input string pointer, delimiter pointer ~ -- output buffer start, output point) : log-load-transform main-input-buffer dup push-input-buffer - swap attach-string-to-input-buffer + 3roll 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, @@ -2556,10 +2561,11 @@ 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 ! - over transformation-state transformation-state-output-buffer-start ! + 2 pick transformation-state transformation-state-output-buffer-start ! 0 transformation-state transformation-state-user-stack-depth ! - here ! + swap 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 -- cgit 1.4.1