1#lang racket/base
2(require "../syntax/syntax.rkt"
3         "../syntax/scope.rkt"
4         "../syntax/binding.rkt"
5         "../namespace/core.rkt")
6
7(provide stop-ids->all-stop-ids
8         module-expand-stop-ids)
9
10;; ----------------------------------------
11
12(define (stop-ids->all-stop-ids stop-ids phase)
13  (cond
14   [(null? stop-ids) stop-ids]
15   [else
16    (define p-core-stx (syntax-shift-phase-level core-stx phase))
17    (cond
18     [(and (= 1 (length stop-ids))
19           (free-identifier=? (car stop-ids)
20                              (datum->syntax p-core-stx 'module*)
21                              phase
22                              phase))
23      stop-ids]
24     [else (append stop-ids
25                   (for/list ([sym (in-list auto-stop-syms)])
26                     (datum->syntax p-core-stx sym)))])]))
27
28(define auto-stop-syms '(begin quote set! lambda case-lambda let-values letrec-values
29                         if begin0 with-continuation-mark letrec-syntaxes+values
30                         #%app #%expression #%top #%variable-reference))
31
32;; ----------------------------------------
33
34(define (module-expand-stop-ids phase)
35  (define p-core-stx (syntax-shift-phase-level core-stx phase))
36  (for/list ([sym (in-list module-stop-syms)])
37    (datum->syntax p-core-stx sym)))
38
39(define module-stop-syms (append auto-stop-syms
40                                 '(define-values define-syntaxes begin-for-syntax
41                                    #%require #%provide module module* #%declare
42                                    #%stratified-body)))
43