6.17.5.5 Performing translator actions

There are the following words for performing the various translator actions:

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

Perform the interpreting action of translator. For a system-defined translator, first consume the translator and translator-specific additional stack items and possibly perform additional scanning specified for the translator, then perform the interpreting run-time specified for the translator. For a user-defined translator, remove translator from the stack and execute its int-xt.

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

Perform the compiling action of translator. For a system-defined translator, first consume the translator and translator-specific additional stack items and possibly perform additional scanning specified for the translator, then perform the compiling run-time specified for the translator, or, if none is specified, compile the interpreting run-time. For a user-defined translator, remove translator from the stack and execute its comp-xt.

postponing ( ... translator –  ) gforth-experimental

Perform the postponing action of translator. For a system-defined translator, first consume the translator and translator-specific additional stack items and possibly perform additional scanning specified for the translator, then compile the compiling run-time. For a user-defined translator, remove translator from the stack and execute its post-xt.

?found ( token|0 – token  ) gforth-experimental “question-found”

throws -13 (undefined word) if token is 0.

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 ?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 ?found postponing
   repeat
   2drop ; immediate