#lang scheme/base

;; PLT language for SCAT with Forth syntax.

;; FIXME: This seems to be broken.. If you have use for it, I'll fix
;; it. Other than that, it's mostly a toy. Might some day be used for
;; simulating .f code or so.


 define-words scat/: 
 (rename-out (module-begin #%module-begin))
 (except-out (all-from-out scheme/base) #%module-begin)
 (all-from-out "../"))

;; macro + forth are not defined: this is a single mode language.
(define-syntax-ns (scat) : :-tx)

;; The function 'forth->records' is the entry point to the Forth
;; compiler. Here were're running it parameterized with scat
;; syntax. The macro mode is currently not supported.

(define-syntax (define-words stx)
  (syntax-case stx ()
    ((_ . code)
             (lambda (record)
               (syntax-case record (forth)
                 ((#f _ _ _)
                 ((name forth srcloc rep)
                  #`(define-ns (scat) name rep))))
              (lambda ()
                 #'forth #'void #'void

(define-syntax (module-begin stx)
  (define (top form)
    (datum->syntax stx form))
  (syntax-case stx ()
    ((_ code ...)
        #,(top '(provide
                 (all-defined-out))) ;; FIXME: add forth provide support
        (define-words code ...)))))