[honu] recognize linq literals
This commit is contained in:
parent
b6972a3b7f
commit
aaed60493a
|
@ -2,7 +2,8 @@
|
||||||
|
|
||||||
(provide (all-defined-out))
|
(provide (all-defined-out))
|
||||||
(require syntax/parse
|
(require syntax/parse
|
||||||
(for-syntax racket/base))
|
(for-syntax racket/base
|
||||||
|
syntax/parse))
|
||||||
|
|
||||||
;; macro for defining literal tokens that can be used in macros
|
;; macro for defining literal tokens that can be used in macros
|
||||||
(define-syntax-rule (define-literal name ...)
|
(define-syntax-rule (define-literal name ...)
|
||||||
|
@ -30,4 +31,10 @@
|
||||||
honu-for-template
|
honu-for-template
|
||||||
honu-prefix)
|
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-<-))
|
(define-literal-set cruft (#%parens #%brackets #%braces semicolon colon honu-comma honu-<-))
|
||||||
|
|
|
@ -10,20 +10,23 @@
|
||||||
honu/core/private/parse2
|
honu/core/private/parse2
|
||||||
syntax/parse))
|
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]
|
(provide linq (rename-out [linq-from from]
|
||||||
|
[linq-where where]
|
||||||
[linq-select select]))
|
[linq-select select]))
|
||||||
|
|
||||||
(define-honu-syntax linq
|
(define-honu-syntax linq
|
||||||
(lambda (code context)
|
(lambda (code context)
|
||||||
(syntax-parse code #:literal-sets (cruft)
|
(syntax-parse code #:literal-sets (cruft linq-literals)
|
||||||
#:literals (honu-in)
|
#:literals (honu-in)
|
||||||
[(_ linq-from name:id honu-in
|
[(_ linq-from name:id honu-in
|
||||||
(~var store honu-expression)
|
(~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
|
(define out
|
||||||
#'(for/list ([name store.result])
|
#'(for/list ([name store.result])
|
||||||
what.result))
|
select.result))
|
||||||
(values out #'rest #f)])))
|
(values out #'rest #f)])))
|
||||||
|
|
||||||
#|
|
#|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user