diff --git a/collects/honu/core/private/honu2.rkt b/collects/honu/core/private/honu2.rkt index 017338e896..a011918d59 100644 --- a/collects/honu/core/private/honu2.rkt +++ b/collects/honu/core/private/honu2.rkt @@ -47,14 +47,14 @@ [(_ iterator:id honu-equal start:honu-expression honu-to end:honu-expression honu-do body:honu-expression . rest) (values - #'(%racket (for ([iterator (in-range start.result - end.result)]) + #'(%racket (for/list ([iterator (in-range start.result + end.result)]) body.result)) #'rest #t)] [(_ iterator:id honu-in stuff:honu-expression honu-do body:honu-expression . rest) - (values #'(%racket (for ([iterator stuff.result]) + (values #'(%racket (for/list ([iterator stuff.result]) body.result)) #'rest #t)]))) @@ -259,6 +259,17 @@ (values #'(send/apply left name (list argument.result ...)) #'more))]))) +(begin-for-syntax + (define-splicing-syntax-class (id-except ignores) + [pattern x:id #:when (not (for/fold ([ok #t]) + ([ignore ignores]) + (and ok (free-identifier=? #'x ignore))))]) + (define-splicing-syntax-class (separate-ids separator end) + [pattern (~seq (~var first (id-except (list separator end))) + (~seq (~var between (id-except (list separator end))) + (~var next (id-except (list separator end)))) ...) + #:with (ids ...) #'(first.x next.x ...)])) + (begin-for-syntax (provide honu-declaration) @@ -266,12 +277,15 @@ (define-splicing-syntax-class var-id [pattern x:id #:when (not ((literal-set->predicate declaration-literals) #'x))]) + ;; parses a declaration + ;; var x = 9 + ;; var a, b, c = values(1 + 2, 5, 9) (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 ...) + [pattern (~seq honu-var (~var variables (separate-ids #'honu-comma #'honu-equal)) + honu-equal one:honu-expression) + #:with (name ...) #'(variables.ids ...) #:with expression #'one.result])) (provide honu-var) @@ -280,5 +294,6 @@ (syntax-parse code #:literal-sets (cruft) #:literals (honu-equal) [(var:honu-declaration . rest) - (values #'var.result #'rest #t)]))) + (define result #'(%racket (define-values (var.name ...) var.expression))) + (values result #'rest #t)]))) diff --git a/collects/honu/main.rkt b/collects/honu/main.rkt index 16bb004d00..7b5e8c25d6 100644 --- a/collects/honu/main.rkt +++ b/collects/honu/main.rkt @@ -26,6 +26,9 @@ void format integer + cos sin + random + values (rename-out [honu-cond cond] [null empty] [current-inexact-milliseconds currentMilliseconds] diff --git a/collects/tests/honu/class.honu b/collects/tests/honu/class.honu index 2629fa4d9b..9470a6db94 100644 --- a/collects/tests/honu/class.honu +++ b/collects/tests/honu/class.honu @@ -8,4 +8,4 @@ class What(x){ }; var instance = new What(5); -printf("got ~a\n", instance.foobar(10)) +printf("got ~a\n", instance->foobar(10))