diff --git a/remix/core.rkt b/remix/core.rkt index 12bcdeb..d1474de 100644 --- a/remix/core.rkt +++ b/remix/core.rkt @@ -1,17 +1,13 @@ #lang racket/base -(require (for-syntax racket/base +(require remix/semi + (for-syntax racket/base syntax/parse)) -(define-syntax (#%semi stx) - (raise-syntax-error '#%semi "illegal outside of block" stx)) - (define-syntax (remix-module-begin stx) (syntax-parse stx - #:literals (#%semi) - [(_ (~seq (~and semi-form (~not #%semi)) ... #%semi) ... - (~and tail-form (~not #%semi)) ...) + [(_ s:semi-seq) (syntax/loc stx - (#%module-begin (semi-form ...) ... tail-form ...))])) + (#%module-begin s.semi-form ... s.tail-form ...))])) (provide (rename-out [remix-module-begin #%module-begin]) diff --git a/remix/semi.rkt b/remix/semi.rkt new file mode 100644 index 0000000..20a12fe --- /dev/null +++ b/remix/semi.rkt @@ -0,0 +1,17 @@ +#lang racket/base +(require (for-syntax racket/base + syntax/parse)) + +(define-syntax (#%semi stx) + (raise-syntax-error '#%semi "illegal outside of block" stx)) + +(begin-for-syntax + (define-splicing-syntax-class semi-seq + #:literals (#%semi) + #:attributes ([semi-form 1] [tail-form 1]) + (pattern (~seq (~seq (~and semi-piece-form (~not #%semi)) ... #%semi) ... + (~and tail-form (~not #%semi)) ...) + #:attr [semi-form 1] (syntax->list #'((semi-piece-form ...) ...))))) + +(provide #%semi + (for-syntax semi-seq)) diff --git a/remix/stx0.rkt b/remix/stx0.rkt index 6819d05..2a024d1 100644 --- a/remix/stx0.rkt +++ b/remix/stx0.rkt @@ -5,6 +5,7 @@ racket/generic racket/syntax syntax/parse) + remix/semi syntax/quote syntax/parse/define remix/stx/singleton-struct0