;; This modules provides runtime support for the syntax transformer ;; code in rpn-tx.ss (module rpn-runtime mzscheme (provide (all-defined)) ;; A normal primitive is applied to the data stack. A delayed one ;; needs to be forced first. (define (apply/force promise stack) (apply (force promise) stack)) ;; Transform a primitive into a 'state' word, one that operates on ;; stack' if the original stack == (state . stack') (define (state-lift word) (and word (lambda (state . stack) (cons state (apply word stack))))) ;; The same is done for immediates, which are treated separatedly ;; from functions in the compiler, and can use a pre-bound procedure. (define (state-immediate thing stack) (cons (car stack) (cons thing (cdr stack)))) )