[honu] allow multiple variables to be declared at once
This commit is contained in:
parent
9ec39fd590
commit
1f8c1950fb
|
@ -19,7 +19,7 @@
|
|||
[pattern method:honu-function
|
||||
#:with result (replace-with-public #'method.result)]
|
||||
[pattern var:honu-declaration
|
||||
#:with result #'(field [var.name var.expression])]))
|
||||
#:with result #'(field [var.name var.expression] ...)]))
|
||||
|
||||
(provide honu-class)
|
||||
(define-honu-syntax honu-class
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
honu-in
|
||||
honu-prefix
|
||||
semicolon
|
||||
honu-comma
|
||||
define-literal
|
||||
%racket)
|
||||
(for-syntax syntax/parse
|
||||
|
@ -38,23 +39,6 @@
|
|||
#'rest
|
||||
#f)])))
|
||||
|
||||
(begin-for-syntax
|
||||
(provide honu-declaration)
|
||||
(define-splicing-syntax-class honu-declaration
|
||||
#:literal-sets (cruft)
|
||||
#:literals (honu-equal honu-var)
|
||||
[pattern (~seq honu-var name:id honu-equal one:honu-expression)
|
||||
#:with result #'(%racket (define name one.result))
|
||||
#:with expression #'one.result]))
|
||||
|
||||
(provide honu-var)
|
||||
(define-honu-syntax honu-var
|
||||
(lambda (code context)
|
||||
(syntax-parse code #:literal-sets (cruft)
|
||||
#:literals (honu-equal)
|
||||
[(var:honu-declaration . rest)
|
||||
(values #'var.result #'rest #t)])))
|
||||
|
||||
(provide honu-for)
|
||||
(define-honu-syntax honu-for
|
||||
(lambda (code context)
|
||||
|
@ -274,3 +258,27 @@
|
|||
(with-syntax ([left left])
|
||||
(values #'(send/apply left name (list argument.result ...))
|
||||
#'more))])))
|
||||
|
||||
(begin-for-syntax
|
||||
(provide honu-declaration)
|
||||
|
||||
(define-literal-set declaration-literals (honu-comma honu-equal))
|
||||
(define-splicing-syntax-class var-id
|
||||
[pattern x:id #:when (not ((literal-set->predicate declaration-literals) #'x))])
|
||||
|
||||
(define-splicing-syntax-class honu-declaration
|
||||
#:literal-sets (cruft)
|
||||
#:literals (honu-equal honu-var)
|
||||
[pattern (~seq honu-var (~seq name*:var-id (~optional honu-comma)) ... honu-equal one:honu-expression)
|
||||
#:with result #'(%racket (define-values (name*.x ...) one.result))
|
||||
#:with (name ...) #'(name*.x ...)
|
||||
#:with expression #'one.result]))
|
||||
|
||||
(provide honu-var)
|
||||
(define-honu-syntax honu-var
|
||||
(lambda (code context)
|
||||
(syntax-parse code #:literal-sets (cruft)
|
||||
#:literals (honu-equal)
|
||||
[(var:honu-declaration . rest)
|
||||
(values #'var.result #'rest #t)])))
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user