/usr/share/racket/collects/syntax/modread.rkt is in racket-common 6.3-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | (module modread racket/base
(require racket/contract/base)
(provide with-module-reading-parameterization)
(provide/contract
[check-module-form ((or/c syntax? eof-object?) (or/c symbol? list?) (or/c string? path? false/c) . -> . any)])
(define (with-module-reading-parameterization thunk)
(call-with-default-reading-parameterization
(lambda ()
(parameterize ([read-accept-reader #t]
[read-accept-lang #t]
[read-accept-compiled #t])
(thunk)))))
(define (raise-wrong-module-name filename expected-name name)
(error 'load-handler
"expected a `module' declaration for `~a' in ~s, found: ~a"
expected-name filename name))
(define (check-module-form exp expected-module filename)
(cond [(or (eof-object? exp) (eof-object? (syntax-e exp)))
(and filename
(error 'load-handler
"expected a `module' declaration for `~a' in ~s, but found end-of-file"
expected-module filename))]
[(compiled-module-expression? (syntax-e exp))
(if (or #t ; we don't check the name anymore
(eq? (module-compiled-name (syntax-e exp)) expected-module))
;; It's fine:
exp
;; Wrong name:
(and filename (raise-wrong-module-name
filename expected-module
(module-compiled-name (syntax-e exp)))))]
[(and (syntax? exp)
(syntax-case exp ()
[(mod nm . _)
(and (eq? (syntax-e #'mod) 'module) (identifier? #'nm))]
[_else #f]))
;; It's ok; need to install a specific `module' binding:
(with-syntax ([(mod nm . _) exp])
(when #f ; we don't check the name anymore
(unless (eq? (syntax-e #'nm) expected-module)
(raise-wrong-module-name filename expected-module
(syntax-e #'nm))))
(datum->syntax exp
(cons (namespace-module-identifier)
(cdr (syntax-e exp)))
exp
exp))]
[else
(and filename
(error 'load-handler
"expected a `module' declaration for `~a' in ~s, but found something else"
expected-module filename))])))
|