about summary refs log tree commit diff
path: root/transform.e
diff options
context:
space:
mode:
authorIrene Knapp <ireneista@irenes.space>2026-09-23 19:22:50 -0700
committerIrene Knapp <ireneista@irenes.space>2026-09-23 19:22:50 -0700
commit74b5a9cbbaccfad88ac8c041d85a12f419bc4148 (patch)
treea92d8655e343c81b0a2874b914058f06506b298c /transform.e
parent8867662ed86b67db5196ae055c7bd411e3704c10 (diff)
new feature "include"
this was the subject of a bunch of thought. in most languages, we'd argue against having a text-based "include" feature, because there should also be a module system, and textual include subverts the module system because you can't assume everyone will use it.

however, Evocation already very strongly encourages thinking of a program as a sequence of operations (this is after all the definition of a catenative language), and in particular the transformation system already relies very heavily on programs-as-text. so, it seems appropriate for Forth in general and for Evocation in particular.

plus it was easy to implement, because all the infrastructure for it already existed to support the transformation system

Force-Push: yes
Change-Id: I76f778e44b8189ac7052890c881654d971e43c8d
Diffstat (limited to 'transform.e')
-rw-r--r--transform.e110
1 files changed, 2 insertions, 108 deletions
diff --git a/transform.e b/transform.e
index 136b790..3c844b6 100644
--- a/transform.e
+++ b/transform.e
@@ -210,117 +210,11 @@
 ~ TODO update this note when it does work
 
 
-~ Buffer- and address-management helpers
+~ Address-management helpers
 ~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 ~
 ~   The facilities in this section are used as helper code in the
-~ implementations of both transforms.
-
-~ TODO all this buffer stuff should be in its own file
-~ (delimiter pointer, buffer size -- buffer address)
-: read-to-buffer
-  dup allocate dup dup
-  ~ (buffer size, buffer address, word start, output point)
-  { key
-    ~ Exit if it's a zero byte.
-    dup not {
-      ~ Make sure to pack the zero to serve as a null terminator.
-      pack8
-      drop drop swap drop swap drop exit } if
-
-    ~   If it's a space character, we need to check if we just consumed the
-    ~ magic word, and do some handling to reset the word tracking.
-    dup is-space
-      { ~ (buffer size, buffer address, word start, output point, key)
-        ~ Tuck the key out of the way until we've done some stuff.
-        3unroll
-
-        ~ Add a null terminator so we can use stringcmp
-        dup 0 swap 8!
-
-        ~ Check for the magic word.
-        over 6 pick stringcmp 0 =
-        { ~ It's magic, so exit.
-          ~ Make sure to pack a zero to serve as a null terminator.
-          0 pack8
-          drop drop drop swap drop swap drop exit }
-        { ~ It's not magic, so reset the word start. Of course whitespace is
-          ~ not a word but this will help us keep track of things.
-          3roll pack8
-          swap drop dup } if-else }
-      { ~ (buffer size, buffer address, word start, output point, key)
-        ~ Tuck the key out of the way again.
-        3unroll
-        ~ Check if the word just started and the previous character is space.
-        2dup = dup { drop dup @ is-space } if
-          { ~ If so, this is the actual first character of the word.
-            drop swap pack8 dup }
-          { ~ If not, leave the word start alone.
-            3roll pack8 } if-else } if-else } forever ;
-
-
-~ (output point, filename -- output point)
-: pack-file-contents
-  dup 0 0 sys-open
-  ~ (output point, filename, open result code or file descriptor)
-  dup 0 > {
-    ." Couldn't open " swap emitstring space
-    ." because " space . ." ." newline
-    2 ndrop exit
-  } if
-
-  ~ (output point, filename, file descriptor)
-  {
-    dup 3 pick 1024 sys-read
-    ~ (output point, filename, file descriptor, read result code or length)
-
-    dup 0 > {
-      ." Error while reading from " 3roll emitstring
-      ." because " space . ." ." newline
-      drop exit
-    } if
-
-    dup 0 = {
-      3 ndrop exit
-    } if
-
-    4 roll + 3unroll
-  } forever ;
-
-
-~   In logical terms, this modifies an input buffer metadata structure
-~ in-place to push a new, zeroed one into the start of the linked list formed
-~ through the next-source field.
-~
-~   In physical terms, it works by allocating a new structure, copying the
-~ fields of the existing one into it, and zeroing the existing one. That's
-~ necessary because otherwise we'd need a mutable handle (a pointer to a
-~ pointer) to update the start of the list, and there's no way to do that with
-~ the main-input-buffer variable working the way it presently does.
-~
-~ (input buffer metadata pointer --)
-: push-input-buffer
-  allocate-input-buffer-metadata
-  ~ (original metadata pointer, new metadata pointer)
-  2dup 7 8 * memcopy
-  ~ (original metadata pointer, new metadata pointer)
-  swap dup zero-input-buffer-metadata
-  input-buffer-next-source ! ;
-
-
-~   This does the inverse of push-input-buffer. In the event that the
-~ next-source field is null, it zeroes the buffer.
-~
-~   Note, however, that it doesn't deallocate the memory, because that's not
-~ how memory allocation on the log works. If necessary, it can be deallocated
-~ with "forget", though as usual that requires careful planning.
-~
-~ (input buffer metadata pointer --)
-: pop-input-buffer
-  dup input-buffer-next-source @
-  ~ (original metadata pointer, next source metadata pointer)
-  dup { swap 7 8 * memcopy }
-      { drop zero-input-buffer-metadata } if-else ;
+~ implementations of all three transforms.
 
 
 ~   We have a bunch of accessors for the transformation state structure, which