[<<][staapl][>>][..]
Fri May 16 10:32:27 CEST 2008

the Forth parser

Turns out that collecting Forth into separate definitions isn't a good
idea, because there is no 1-1 correspondence between names that start
with ':' and eventual word structures:

  * there are multiple entry / exit points: words can fallthrough and
    thus are connected

  * it's possible to generate words on the fly: each _label_ should be
    captured into a corresponding scheme definition for the macro that
    generates it, but code inbetween can be accumulated.

Maybe it's easier to just accumulate everything into one giant
function? Simply using 'compose' on the current structure is probably
enough.

So.. instead of

(define (wrap-macro/postponed-word name loc macro)
  (let ((w (new-target-word #:name name
                            #:realm 'code
                            #:code macro
                            #:srcloc loc)))
    (values
     (macro-prim: ',w compile)
     (lambda ()
       (compile-word w)))))

we can have

(define (wrap-macro/postponed-word name loc macro)
  (let ((w (new-target-word #:name name
                            #:realm 'code
                            #:srcloc loc)))
   (values
     (macro-prim: ',w compile)
     (compose macro (make-target-split w)))))

where everything is dumped into a single macro that generates the
code, to be executed later by 'compile-word'.

this seems to work in first try..
let's clean it up a bit.



[Reply][About]
[<<][staapl][>>][..]