This commit is contained in:
Jay McCarthy 2015-11-23 14:54:40 -05:00
parent c9b706d866
commit 4668038355
4 changed files with 31 additions and 22 deletions

View File

@ -2,7 +2,7 @@
(require datalog/runtime
(prefix-in stx: datalog/stx)
(for-syntax racket/base
remix/raw-stx0
remix/stx/raw0
datalog/private/compiler
datalog/parse
syntax/parse))

View File

@ -0,0 +1,29 @@
#lang racket/base
(require syntax/parse/define)
(module singleton racket/base
(require (for-syntax racket/base
syntax/parse
racket/syntax))
(define-syntax (singleton-struct stx)
(syntax-parse stx
[(singleton-struct . struct-args)
(with-syntax ([the-singleton (generate-temporary (syntax-local-name))])
(syntax/loc stx
(let ()
(struct the-singleton () . struct-args)
(the-singleton))))]))
(provide singleton-struct))
(require (submod "." singleton)
(for-syntax (submod "." singleton)))
(define-simple-macro (define/singleton-struct singleton:id . struct-args)
(define singleton (singleton-struct . struct-args)))
(define-simple-macro (define-syntax/singleton-struct singleton:id . struct-args)
(define-syntax singleton (singleton-struct . struct-args)))
(provide
singleton-struct
(for-syntax singleton-struct)
define/singleton-struct
define-syntax/singleton-struct)

View File

@ -6,6 +6,7 @@
racket/syntax
syntax/parse)
syntax/parse/define
remix/stx/singleton-struct0
racket/stxparam)
;; xxx add extensibility
@ -51,27 +52,6 @@
(syntax/loc stx
(remix-block . body))]))
(module singleton racket/base
(require (for-syntax racket/base
syntax/parse
racket/syntax))
(define-syntax (singleton-struct stx)
(syntax-parse stx
[(singleton-struct . struct-args)
(with-syntax ([the-singleton (generate-temporary (syntax-local-name))])
(syntax/loc stx
(let ()
(struct the-singleton () . struct-args)
(the-singleton))))]))
(provide singleton-struct))
(require (submod "." singleton)
(for-syntax (submod "." singleton)))
(define-simple-macro (define/singleton-struct singleton:id . struct-args)
(define singleton (singleton-struct . struct-args)))
(define-simple-macro (define-syntax/singleton-struct singleton:id . struct-args)
(define-syntax singleton (singleton-struct . struct-args)))
(begin-for-syntax
(define-generics binary-operator
(binary-operator-precedence binary-operator))