• The curse of parsing words

    From albert@albert@spenarnc.xs4all.nl to comp.lang.forth on Mon Oct 12 09:56:31 2026
    From Newsgroup: comp.lang.forth

    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.
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From dxf@dxforth@gmail.com to comp.lang.forth on Mon Oct 12 22:17:31 2026
    From Newsgroup: comp.lang.forth

    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.

    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Hans Bezemer@the.beez.speaks@gmail.com to comp.lang.forth on Mon Oct 12 18:36:47 2026
    From Newsgroup: comp.lang.forth

    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
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From albert@albert@spenarnc.xs4all.nl to comp.lang.forth on Wed Oct 14 10:06:33 2026
    From Newsgroup: comp.lang.forth

    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.
    --- Synchronet 3.22a-Linux NewsLink 1.2