;; An RPN syntax for creating peephole optimizing code generator ;; macros using pattern matching applied to the already generated ;; assembly code. ;; The asm buffer can be seen as a stack of typed values, and a ;; 'asm-transforms' specification is a definition of forth words ;; (macros) operating on this stack. For the PIC18 this contains a ;; subset language mapping [qw] -> [qw], acting as a compile time ;; evaluator. (module pattern mzscheme (require-for-syntax "pattern-tx.ss") (require (lib "match.ss") "list-utils.ss" "rep.ss" "ns.ss" "comp-utils.ss" ) (provide asm-transforms asm meta) (define-syntax (asm-transforms stx) (syntax-case stx () ((_ namespace . patterns) (asm-transforms-stx #'namespace #'patterns)))) (define-syntax (asm stx) (syntax-case stx () ((_ . ins) (atyped-tx-expr #'ins)))) ;; The problem with meta-evaluation is that lexical variables can ;; already contain expressions. If so, they need to be flattened ;; when substituted. (define-syntax meta (syntax-rules () ((_ (expr ...)) (list (wrap expr) ...)))) )