You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
pollen/lang/lang-helper.rkt

48 lines
2.0 KiB
Racket

#lang racket/base
(require (for-syntax racket/base pollen/project-requires))
(require racket/contract/region)
(provide (all-defined-out) (all-from-out racket/contract/region))
(define-for-syntax (put-file-in-require-form file)
`(file ,(path->string file)))
11 years ago
(define-for-syntax (do-project-require-file-syntax stx #:provide? [provide? #f])
(define project-require-files (get-project-require-files))
(if project-require-files
11 years ago
(let ([files-in-require-form (map put-file-in-require-form project-require-files)])
(datum->syntax stx `(begin
(require ,@files-in-require-form)
,@(if provide?
(list `(provide (all-from-out ,@files-in-require-form)))
'()))))
11 years ago
; if no files to import, do nothing
#'(begin)))
11 years ago
(define-syntax (require-and-provide-project-require-files stx)
(do-project-require-file-syntax stx #:provide? #t))
11 years ago
(define-syntax (require-project-require-files stx)
(do-project-require-file-syntax stx))
11 years ago
11 years ago
(define-syntax (get-here-path stx)
11 years ago
(datum->syntax stx
'(begin
;; This macro might be used in an expression context,
11 years ago
;; so we use let, not define.
11 years ago
(let* ([ccr (current-contract-region)] ; trick for getting current module name
11 years ago
[here-path (cond
11 years ago
;; if contract-region is called from within submodule,
;; you get a list
;; in which case, just grab the path from the front
[(list? ccr) (car ccr)]
;; file isn't yet saved in drracket
11 years ago
;; 'pollen-lang-module name is applied by reader
11 years ago
[(equal? 'pollen-lang-module ccr) 'nowhere]
[else ccr])])
11 years ago
(path->string here-path)))))
11 years ago