Extending the pre-parsing concept

27 views
Skip to first unread message

Ejdsqsb Null

unread,
Jul 21, 2022, 1:20:33 PM7/21/22
to Color...@googlegroups.com
Hello all,

I'm new to Forth in general, and I really like the minimalist side of
it, including colorForth, so I'm trying to implement a small system in
a FPGA CPU (J1/Novix style) with "only" about 26K 18 bit words.
Even using Chuck's variable-length character encoding, source is really
costly compared to raw code and integer data. So I thought, what if the
pre-parsing concept could be extended a little more, and even more
actions could be moved to edit time by storing tagged references to
words instead of the textual representation of them as "source". Using
this scheme, the editor's job would simply be translating refs <-> text,
and the compiler's job would be translating refs <-> code/addresses.

To clarify, when defining a word, it would be stored like this, assuming
the base address is 200:
200 202 203
+------------+---+---+------------+
| Link, etc. | h | i | References |
+------------+---+---+------------+

Then, when referencing the word "hi" in another one, the editor would
store something like this in its references:
+-----+-----+
| Tag | 200 |
+-----+-----+
where the 0 tag means a green word, the 1 tag means yellow, 2 means an
integer, etc.

Assuming a 14 bit address space dedicated to code and a 4 bit tag, this
would use only one word per reference, and at most two words for large
integers (like in colorForth). Comments and strings could have their own
tag to be able to store them using either the variable-length encoding
or ASCII.

I think the compiler would be simplified too, because you wouldn't even
need a proper dictionary, and magenta variables could be referenced
directly, but I'm not sure.

Do you think something like this would be feasible at all? I'm open to
any feedback, changes, recommendations, etc.

Thanks,
- E.
Reply all
Reply to author
Forward
0 new messages