coma/macro-prim.ss
#lang scheme/base

;; Macro state uses the hidden datum as a compilation stack.


(provide
 (all-defined-out))
(require
 "../scat.ss"
 "../tools.ss"
 "macro-utils.ss"
 "core.ss"
 (for-syntax
  "../scat-tx.ss"
  scheme/base))


;; These names represent code and data atoms in the concrete
;; s-expression representation and are referred in macro-tx.ss. They
;; can be observed in the first expansion level of 'macro:' or
;; 'forth-rep'. The data rep can be a function. The code rep is a
;; macro that expands into a prefixed identifer. Names are kept short
;; to make representations saved as text not too verbose.

;; pick a short word here as it ends up in expansions.
(define (lit datum) (macro-prim: ',datum literal))
(define-syntax word (make-ns-ref #'(macro)))


;; All macros are wrapped in a parameter, so they are easily extended
;; with target specific optimizations.
;(define (make-macro . args)
;  (make-parameter (apply make-word args)))



;; Macro primitives are scat: functions with the hidden state
;; representing an extra stack.

;(define-syntax define-macro
;  (syntax-rules () ((_ . args) (define-2stack . args))))