(module macro-tx mzscheme (require "list-utils.ss" "rpn-tx.ss") (require-for-template mzscheme "macro-runtime.ss" "rpn-runtime.ss" "rep.ss") (provide (all-defined)) (define (macro-rpn code postpone language-names) ;; Just like the ones from rpn-tx.ss, but we call this 'postpone' ;; instead of 'find'. The thing that's postponed is the forth ;; semantics: we're compiling a compiler. See macro-runtime.ss for ;; details. (define (_global c object expr) #`(apply/force (delay (#,postpone (quote #,object))) #,expr)) (define (_immediate c object expr) #`(apply (postponed-literal #,object) #,expr)) (define (_name c) (first language-names)) ;; Note that by not redefining 'program', quoted programs are also ;; macros, which will be quoted as normal constants, which means ;; postponed as literals. The forth lexer has no means of ;; generating this data type, since it doesn't support s-expressions. (define c (proto-c)) (set-c-immediate! c _immediate) (set-c-global! c _global) (set-c-language-name! c _name) (represent c code)) )