You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
835 B
Racket
23 lines
835 B
Racket
#lang racket
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
;;
|
|
;; Macro that generates all the little xexpr functions
|
|
;; For each tag.
|
|
;;
|
|
|
|
(require (for-syntax racket/syntax))
|
|
(define-syntax (define-tags stx)
|
|
(syntax-case stx ()
|
|
[(_ name '(tags ...)) ; match pattern of the calling form
|
|
#`(begin ; start with quasiquoted begin block & splice into it
|
|
(define name '(tags ...)) ; assign the provided name to the tags as a group
|
|
#,@(for/list ([tag (syntax->list #'(tags ...))]) ; step through list of tags
|
|
(with-syntax ((tag-as-id (format-id stx "~a" tag))) ; convert tag into identifier
|
|
; todo: edit this to use tools:tagger
|
|
#`(define (tag-as-id . x) `(tag-as-id ,@x)))))])) ; write out the xexpr function
|
|
|
|
|
|
|
|
(provide (all-defined-out)) |