purrr.ss
#lang scheme/base
(require
 "tools.ss")
(require
 "coma/macro-eval.ss")
(require/provide
 "purrr/forth-begin.ss"   ;; parser driver in the form of 'begin' macros.
 "purrr/parsing-words.ss" ;; bindings for (non-concatenative) forth parser words
 "purrr/repl.ss"          ;; string -> toplevel form expansion
 "coma.ss"                ;; single stack pure macros
 "control.ss"             ;; dual stack control macros
 "comp.ss"                ;; compiler (macro instantiation + postprocess)
 "scat.ss"                ;; intermediate language
 "asm.ss"                 ;; for convenience, export assembler interface
 "target.ss"
 "live.ss"                ;; target interaction
 )
(provide
 (all-defined-out))

;; Macros defined in .f files use a superset of the macro/2stack
;; language state to implement multiple entry and exit points for
;; instantiated code, and multiple exit for macros. All macro
;; evaluation that's not part of instantiation needs to use this
;; augmented state. (i.e. this is used in macro/constants.ss)
(macro-eval-init-state
 state:compiler)

;; The Purrr language all by itself, without specialization to a real
;; machine, is at this moment only useful for debugging.

;; Printing reverses the standard reversed order.
(define (print-asm-code chains)
  (for-each
   (lambda (x)
     (print-target-word x)
     (newline))
   (reverse chains)))

;; Since 'repl' can't run inside a parameterize env (this is because
;; of the use of toplevel forms), the only way to change what happens
;; to compiled code is to change the mode of the compiler.

(define (asm-debug!)
  (register-code-hook
   (list
    (lambda (chains . _)
      (print-asm-code chains)))))

(asm-debug!)



(loading "purrr")