Thread View: comp.lang.forth
4 messages
4 total messages
Started by albert
Mon, 12 Oct 2026 07:56
The curse of parsing words
Author: albert
Date: Mon, 12 Oct 2026 07:56
Date: Mon, 12 Oct 2026 07:56
21 lines
1612 bytes
1612 bytes
I was to modify the metacompiler of noforth to make it more portable, using i.a. ciforth. https://github.com/WillemOuwerkerk/noForth-T-for-the-RP2040 Enters +TO. If you add VALUE to a Forth and you don't have +TO, how would you define it? ( Fortunately ciforth has it, besides the implementation of TO is in source and hints to the implementation of +TO ). Untested: : +TO >IN @ >R BL WORD COUNT EVALUATE + R> >IN ! ['] TO EVALUATE ; Compares this to a missing +! . Untested: : +! SWAP OVER @ + SWAP ! ; Groetjes Albert -- The Chinese government is satisfied with its military superiority over USA. The next 5 year plan has as primary goal to advance life expectancy over 80 years, like Western Europe.
Re: The curse of parsing words
Author: dxf
Date: Mon, 12 Oct 2026 11:17
Date: Mon, 12 Oct 2026 11:17
30 lines
1826 bytes
1826 bytes
On 12/10/2026 6:56 pm, albert@spenarnc.xs4all.nl wrote: > I was to modify the metacompiler of noforth to make it more > portable, using i.a. ciforth. > https://github.com/WillemOuwerkerk/noForth-T-for-the-RP2040 > > Enters +TO. If you add VALUE to a Forth and you don't have > +TO, how would you define it? ( Fortunately ciforth has it, > besides the implementation of TO is in source and hints to > the implementation of +TO ). > > Untested: > : +TO >IN @ >R BL WORD COUNT EVALUATE + R> >IN ! ['] TO EVALUATE ; > > Compares this to a missing +! . > Untested: > : +! SWAP OVER @ + SWAP ! ; > > Groetjes Albert I've got this as a loadable definition: : +TO ( n "name" -- ) [compile] addr state @ if compile then +! ; immediate Not sure I've used it. The obvious <value> + TO <value> may be ugly but it works and I don't have to load anything. It's the deeper issue that bugs me. If I find myself doing +! on a VALUE, I begin to question my choice. Perhaps I should be using VARIABLE instead.
Re: The curse of parsing words
Author: Hans Bezemer
Date: Mon, 12 Oct 2026 16:36
Date: Mon, 12 Oct 2026 16:36
47 lines
3117 bytes
3117 bytes
On 12-10-2026 09:56, albert@spenarnc.xs4all.nl wrote:
> I was to modify the metacompiler of noforth to make it more
> portable, using i.a. ciforth.
> https://github.com/WillemOuwerkerk/noForth-T-for-the-RP2040
>
> Enters +TO. If you add VALUE to a Forth and you don't have
> +TO, how would you define it? ( Fortunately ciforth has it,
> besides the implementation of TO is in source and hints to
> the implementation of +TO ).
>
> Untested:
> : +TO >IN @ >R BL WORD COUNT EVALUATE + R> >IN ! ['] TO EVALUATE ;
>
> Compares this to a missing +! .
> Untested:
> : +! SWAP OVER @ + SWAP ! ;
>
> Groetjes Albert
Agreed, I don't like parsing words either in 4tH. All of these are hard
coded in my compiler (fifth column):
...
{ 2, 0, -2, "#!", EOL, DoComment },
{ 2, 0, -1, ",\"", "\"", DoCommaQuote },
{ 2, 0, -1, ",|", "|", DoCommaQuote },
{ 2, 0, -1, ".\"", "\"", DoDotQuote },
{ 2, 0, -1, ".(", ")", DoDotQuote },
{ 2, 0, -1, ".|", "|", DoDotQuote },
{ 2, 0, -2, "C,", "", DoCComma },
{ 2, 0, -2, "C\"", "\"", DoCQuote },
{ 2, 0, -2, "C|", "|", DoCQuote },
{ 2, 0, 1, ">=", "", DoGreaterEqual },
{ 2, 0, 1, "<=", "", DoLessEqual },
{ 2, 0, -1, "S\"", "\"", DoSQuote },
{ 2, 0, -1, "S|", "|", DoSQuote },
...
Before I had the preprocessor, there was no way to add any new ones
without adding a token and recompiling the whole shebang. TO, however,
is *NOT* one of my parsing words in the strictest sense. Still, without
the preprocessor I cannot handle them without changing the compiler.
I know that not all parsing words can be eradicated, but I wouldn't be
unhappy if there were less. ;-)
Hans Bezemer
Re: The curse of parsing words
Author: albert
Date: Wed, 14 Oct 2026 08:06
Date: Wed, 14 Oct 2026 08:06
61 lines
3362 bytes
3362 bytes
In article <11aj2b0$3pav1$1@dont-email.me>,
Hans Bezemer <the.beez.speaks@gmail.com> wrote:
>On 12-10-2026 09:56, albert@spenarnc.xs4all.nl wrote:
>> I was to modify the metacompiler of noforth to make it more
>> portable, using i.a. ciforth.
>> https://github.com/WillemOuwerkerk/noForth-T-for-the-RP2040
>>
>> Enters +TO. If you add VALUE to a Forth and you don't have
>> +TO, how would you define it? ( Fortunately ciforth has it,
>> besides the implementation of TO is in source and hints to
>> the implementation of +TO ).
>>
>> Untested:
>> : +TO >IN @ >R BL WORD COUNT EVALUATE + R> >IN ! ['] TO EVALUATE ;
>>
>> Compares this to a missing +! .
>> Untested:
>> : +! SWAP OVER @ + SWAP ! ;
>>
>> Groetjes Albert
>
>Agreed, I don't like parsing words either in 4tH. All of these are hard
>coded in my compiler (fifth column):
>
>...
> { 2, 0, -2, "#!", EOL, DoComment },
> { 2, 0, -1, ",\"", "\"", DoCommaQuote },
> { 2, 0, -1, ",|", "|", DoCommaQuote },
> { 2, 0, -1, ".\"", "\"", DoDotQuote },
> { 2, 0, -1, ".(", ")", DoDotQuote },
> { 2, 0, -1, ".|", "|", DoDotQuote },
> { 2, 0, -2, "C,", "", DoCComma },
> { 2, 0, -2, "C\"", "\"", DoCQuote },
> { 2, 0, -2, "C|", "|", DoCQuote },
> { 2, 0, 1, ">=", "", DoGreaterEqual },
> { 2, 0, 1, "<=", "", DoLessEqual },
> { 2, 0, -1, "S\"", "\"", DoSQuote },
> { 2, 0, -1, "S|", "|", DoSQuote },
>...
>
>Before I had the preprocessor, there was no way to add any new ones
>without adding a token and recompiling the whole shebang. TO, however,
>is *NOT* one of my parsing words in the strictest sense. Still, without
>the preprocessor I cannot handle them without changing the compiler.
>
>I know that not all parsing words can be eradicated, but I wouldn't be
>unhappy if there were less. ;-)
I replace parsing words as much as possible with denotations.
A denotation leaves a constant value on the stack and it behaves
the same in interpret and compile mode
." ape gaar" --> "ape gaar" TYPE
.( ape gaar) --> "ape gaar" TYPE
S\" APE GAAR \n" --> "ape gaar%n" FORMATTED
>
>Hans Bezemer
--
The Chinese government is satisfied with its military superiority over USA.
The next 5 year plan has as primary goal to advance life expectancy
over 80 years, like Western Europe.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads