#lang scheme/base

;; The default organization method for all target code in Brood is
;; using PLT Scheme modules: each file has an associated language
;; (bring your own lexer and parser). This is implemented using the
;; PLT #lang directive.

;; However, for interactive use, a namespace and a REPL are necessary.
;; Namespaces are implemented using PLT Scheme namespace objects. The
;; REPL is implemented as a macro, because the forth parser expands to
;; toplevel forms.


(provide forth-compile

;; string -> code
(define-syntax (forth-compile stx)
  (syntax-case stx ()
    ((_ str)
          #,@(string->forth-syntax #'str)))))

;; path -> code
(define-syntax (forth-load/compile stx)
  (syntax-case stx ()
    ((_ path)
     #`(forth-begin #,(datum->syntax #'path 'load) path))))

;; add a path
(define-syntax (forth-path stx)
  (syntax-case stx ()
    ((_ path)
     #`(forth-begin #,(datum->syntax #'path 'path) path))))