diff options
| author | Irene Knapp <ireneista@irenes.space> | 2026-09-08 18:12:25 -0700 |
|---|---|---|
| committer | Irene Knapp <ireneista@irenes.space> | 2026-09-08 18:12:25 -0700 |
| commit | ecb9b0a2c65743c8d072eb1e8f13f7afbc68d505 (patch) | |
| tree | bd56646f24ed9b7449ad98fe550cd43f670dc466 | |
| parent | 5851aca9a0da81c82ba26cd66f8d5b2b00dfd391 (diff) | |
substring substitution works now
now to build out a variety of kinds... Force-Push: yes Change-Id: I331c3275c9705cacd7f634506b93d05085458754
| -rw-r--r-- | transform.e | 77 |
1 files changed, 65 insertions, 12 deletions
diff --git a/transform.e b/transform.e index b9b6cd8..4201d64 100644 --- a/transform.e +++ b/transform.e @@ -2724,7 +2724,11 @@ allocate-transformation-state s" transformation-state" variable : hex-output-metadata-is-fresh-line 4 8 * + ; : hex-output-metadata-indentation-depth 5 8 * + ; : hex-output-metadata-current-column 6 8 * + ; -: hex-output-metadata-first-entry 7 8 * + ; +: hex-output-metadata-substring-entry-stack-depth 7 8 * + ; +: hex-output-metadata-substring-entry-stack-zero 8 8 * + ; +: hex-output-metadata-substring-entry-stack-capacity 3 ; +: hex-output-metadata-first-entry + 8 hex-output-metadata-substring-entry-stack-capacity + 8 * + ; : hex-output-metadata-entry-data-start ; : hex-output-metadata-entry-data-length 8 + ; : hex-output-metadata-entry-type 2 8 * + ; @@ -2755,6 +2759,7 @@ allocate-transformation-state s" transformation-state" variable dup hex-output-metadata-is-fresh-line 1 swap ! dup hex-output-metadata-indentation-depth 0 swap ! dup hex-output-metadata-current-column 0 swap ! + dup hex-output-metadata-substring-entry-stack-depth 0 swap ! dup hex-output-metadata-first-entry 0 swap ! ; ~ (pointer -- boolean) @@ -3021,6 +3026,53 @@ allocate-transformation-state s" transformation-state" variable : advance-current-column current-column@ + current-column! ; +: describe-substring-entry-stack + transformation-state transformation-state-output-metadata @ + ." depth " + dup hex-output-metadata-substring-entry-stack-depth @ .hex64 newline + ." capacity " + hex-output-metadata-substring-entry-stack-capacity .hex64 newline + hex-output-metadata-substring-entry-stack-zero + hex-output-metadata-substring-entry-stack-capacity 8 * hexdump-from ; + +: substring-entry-stack-depth@ + transformation-state transformation-state-output-metadata @ + hex-output-metadata-substring-entry-stack-depth @ ; + +: substring-entry-stack-depth! + transformation-state transformation-state-output-metadata @ + hex-output-metadata-substring-entry-stack-depth ! ; + +: is-substring-entry-stack-empty + substring-entry-stack-depth@ 0 = ; + +: is-substring-entry-stack-full + substring-entry-stack-depth@ + hex-output-metadata-substring-entry-stack-capacity = ; + +: push-substring-entry-stack + is-substring-entry-stack-full not { + transformation-state transformation-state-output-metadata @ + hex-output-metadata-substring-entry-stack-zero + substring-entry-stack-depth@ 8 * + ! + + substring-entry-stack-depth@ 1+ substring-entry-stack-depth! + } { + drop + ." Substring entry stack overflow." newline + } if-else ; + +: pop-substring-entry-stack + is-substring-entry-stack-empty not { + substring-entry-stack-depth@ 1- substring-entry-stack-depth! + + transformation-state transformation-state-output-metadata @ + hex-output-metadata-substring-entry-stack-zero + substring-entry-stack-depth@ 8 * + @ + } { + ." Substring entry stack underflow." newline + } if-else ; + ~ Metadata entries are post-processed before they're output, in order to ~ make the structure of the output code simpler. The post-processing won't ~ happen until output actually occurs, which is important for operations that @@ -3188,7 +3240,17 @@ allocate-transformation-state s" transformation-state" variable ~ (input point, first non-word character or 0, word pointer) dup s" #" stringcmp 0 = { - ." zazen" drop + drop + + pop-substring-entry-stack + + dup hex-output-metadata-entry-type @ + hex-output-metadata-entry-type-provide-substring-hex64 = { + ." 0x" + dup hex-output-metadata-entry-string @ .hex64 + } if + + drop } { emitstring } if-else @@ -3323,17 +3385,8 @@ allocate-transformation-state s" transformation-state" variable dup hex-output-metadata-entry-type @ hex-output-metadata-entry-type-provide-substring-hex64 = { - fresh-line - indentation-depth@ dup indent advance-current-column - - ." ~ hex64 value 0x" - dup hex-output-metadata-entry-string @ .hex64 - - newline - 1 is-fresh-line! - 0 current-column! + dup push-substring-entry-stack } if - } if hex-output-metadata-next-entry } while |