Previous: Defining translation tokens, Up: Recognizers [Contents][Index]
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 postponing run-time of the translation token. For a user-defined translation token, remove it from the stack and execute its post-xt.
?rec-found ( translation – translation ) gforth-experimental “question-rec-found”
throws -13 (undefined word) if translation is
translate-none.
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
Previous: Defining translation tokens, Up: Recognizers [Contents][Index]