[honu] recognize linq literals

This commit is contained in:
Jon Rafkind 2011-09-14 10:53:35 -06:00
parent b6972a3b7f
commit aaed60493a
2 changed files with 15 additions and 5 deletions

View File

@ -2,7 +2,8 @@
(provide (all-defined-out))
(require syntax/parse
(for-syntax racket/base))
(for-syntax racket/base
syntax/parse))
;; macro for defining literal tokens that can be used in macros
(define-syntax-rule (define-literal name ...)
@ -30,4 +31,10 @@
honu-for-template
honu-prefix)
(define-syntax-rule (define-literal+set set literal ...)
(begin
(define-literal literal ...)
(begin-for-syntax
(define-literal-set set (literal ...)))))
(define-literal-set cruft (#%parens #%brackets #%braces semicolon colon honu-comma honu-<-))

View File

@ -10,20 +10,23 @@
honu/core/private/parse2
syntax/parse))
(define-literal linq-from linq-select)
(define-literal+set linq-literals
linq-from linq-select linq-where)
(provide linq (rename-out [linq-from from]
[linq-where where]
[linq-select select]))
(define-honu-syntax linq
(lambda (code context)
(syntax-parse code #:literal-sets (cruft)
(syntax-parse code #:literal-sets (cruft linq-literals)
#:literals (honu-in)
[(_ linq-from name:id honu-in
(~var store honu-expression)
linq-select what:honu-expression . rest)
(~optional (~seq linq-where where:honu-expression))
linq-select select:honu-expression . rest)
(define out
#'(for/list ([name store.result])
what.result))
select.result))
(values out #'rest #f)])))
#|