You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It is enough to provide interpretation and compilation semantics for new descriptors, no need for postponing action or reproducing action.
Rationale
There are only two places when postponing action can be used: POSTPONE and ]] ... [[ construct.
And this action is applicable to the system's descriptors only. So this action isn't required for the user defined descriptors.
Conceptual solution
Proof of concept
: token>xt? ( k*x td -- xt td-xt | k*x td 0 )
td-xt over = if ( xt td-xt ) exit then
td-nt over = if over name> dup if nip nip td-xt then exit then
0
;
: xt, compile, ;
: postpone-token? ( k*x td -- true | k*x td false )
td-nt over = if drop name>compile swap lit, xt, true exit then
td-xt-imm over = if drop lit, 'execute-compiling xt, true exit then
token>xt? if lit, 'xt, xt, true exit then
false
;
: compile-compile-token? ( k*x td -- true | k*x td false )
postpone-token? ?et
postpone [: compile-token postpone ;] 'xt, xt, true
\ There is a possibility to return false
\ for some implementation defined cases
;
: next-lexeme ( -- c-addr u|0 )
begin parse-lexeme ?et ( addr ) refill ?e0 drop again
;
: ]]
begin next-lexeme 2dup "[[" equals 0= while
recognize-any dup ?nf compile-compile-token?
0= -32 and throw
repeat 2drop
;
: postpone ( "ccc" -- )
parse-lexeme perceive-lexeme dup ?nf
postpone-token? ?e -32 throw
; immediate
Where
compile-token ( i*x k*x td -- j*x )
\ perform the compilation semantics that are determined
\ by the given fully qualified token ( k*x td )
recognize-any ( c-addr u -- k*x td | 0 )
\ recognize a lexeme using the recognizer
\ that the Forth text interpreter currently uses
In this approach, neither POSTPONE nor ]] refers to "postponing action" of user-defined descriptors. And, the former isn't applicable to them at all, the latter is applicable, and they parses the input (if any).
Idea
It is enough to provide interpretation and compilation semantics for new descriptors, no need for postponing action or reproducing action.
Rationale
There are only two places when postponing action can be used:
POSTPONE
and]] ... [[
construct.And this action is applicable to the system's descriptors only. So this action isn't required for the user defined descriptors.
Conceptual solution
Proof of concept
Where
In this approach, neither
POSTPONE
nor]]
refers to "postponing action" of user-defined descriptors. And, the former isn't applicable to them at all, the latter is applicable, and they parses the input (if any).See also: "Recognizers and postponing" news:[email protected]
See also: An approach to create any token descriptor
Short URL to this issue: https://git.io/JTHlm
The text was updated successfully, but these errors were encountered: