purrr/repl.ss
#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.

(require
 "forth-begin.ss"
 (for-syntax
  "../tools.ss"
  "../forth/lexer.ss"
  scheme/base))

(provide forth-compile
         forth-load/compile
         forth-path)

;; string -> code
(define-syntax (forth-compile stx)
  (syntax-case stx ()
    ((_ str)
     #`(forth-begin
          #,@(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))))