(module phase mzscheme
(require-for-syntax (lib "plt-match.ss"))
(provide in-phase1 in-phase1/pass2)
(define-syntax (in-phase1 stx)
(syntax-case stx ()
[(ip1 e)
(match (syntax-local-context)
['expression
#'(let-syntax ([_ e]) (void))]
[(or 'module 'top-level (? pair?))
#'(begin (define-syntax (macro stx*) (begin e #'(begin)))
(macro))]
['module-begin
(raise-syntax-error #f "cannot be used as module body" stx)])]))
(define-syntax (in-phase1/pass2 stx)
(syntax-case stx ()
[(ip1/p2 e)
(match (syntax-local-context)
[(? pair?)
#'(define-values () (begin (in-phase1 e) (values)))]
[(or 'expression 'top-level 'module 'module-begin)
#'(#%expression (in-phase1 e))])]))
)