6.17.5.5 Performing translation actions

There are the following words for performing the various translation token actions:

interpreting ( ... translation – ...  ) gforth-experimental

Perform the interpreting action of translation. For a system-defined translation token, first remove translation from the stack, then possibly perform additional scanning specified for the translation token, and finally perform the interpreting run-time of the translation token. For a user-defined translation token, remove it from the stack and execute its int-xt.

compiling ( ... translation – ...  ) gforth-experimental

Perform the compiling action of translation. For a system-defined translation token, first remove translation from the stack, then possibly perform additional scanning specified for the translation token, and finally perform the compiling run-time of the translation token. For a user-defined translation token, remove it from the stack and execute its comp-xt.

postponing ( ... translation –  ) gforth-experimental

Perform the postponing action of translation. For a system-defined translation token, first remove translation from the stack, then possibly perform additional scanning specified for the translation token, and finally perform the compiling run-time of the translation token. For a user-defined translation token, remove it from the stack and execute its post-xt.

doc-?rec-found

Their typical use is in a text interpreter. A simple text interpreter could look like this:

: myinterpret ( -- )
  \ refill happens outside
  begin
    parse-name dup while
      forth-recognize ?rec-found state @ if compiling else interpreting then
  repeat
  2drop ;

This text interpreter itself does not deal with postponing; ]] can be implemented as a text interpreter that performs the postponing:

: ]] ( -- )
  \ works only within a line
  begin
    parse-name dup 0= abort" [[ missing"
    2dup "[[" str= 0= while
      forth-recognize ?rec-found postponing
   repeat
   2drop ; immediate