semi as lib

This commit is contained in:
Jay McCarthy 2015-12-18 19:23:53 -05:00
parent 608f2e38fc
commit f177276df1
3 changed files with 22 additions and 8 deletions

View File

@ -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])

17
remix/semi.rkt Normal file
View File

@ -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))

View File

@ -5,6 +5,7 @@
racket/generic
racket/syntax
syntax/parse)
remix/semi
syntax/quote
syntax/parse/define
remix/stx/singleton-struct0