[honu] actually check for separator for the separate ids class. parse constructor arguments with comma separated ids
This commit is contained in:
parent
815c3887fb
commit
219a39575a
|
@ -2,7 +2,7 @@
|
|||
|
||||
(require "macro2.rkt"
|
||||
"literals.rkt"
|
||||
(only-in "honu2.rkt" honu-declaration honu-equal)
|
||||
(only-in "honu2.rkt" honu-declaration honu-equal separate-ids)
|
||||
(for-syntax racket/base
|
||||
"literals.rkt"
|
||||
"parse2.rkt"
|
||||
|
@ -25,11 +25,12 @@
|
|||
(define-honu-syntax honu-class
|
||||
(lambda (code context)
|
||||
(syntax-parse code #:literal-sets (cruft)
|
||||
[(_ name (#%parens constructor-argument ...) (#%braces method:honu-class-thing ...) . rest)
|
||||
[(_ name (#%parens (~var constructor-argument (separate-ids #'honu-comma #'dont-care)))
|
||||
(#%braces method:honu-class-thing ...) . rest)
|
||||
(define class
|
||||
#'(%racket (define name (class* object% ()
|
||||
(super-new)
|
||||
(init-field constructor-argument ...)
|
||||
(init-field constructor-argument.id ...)
|
||||
method.result ...))))
|
||||
(values class #'rest #t)])))
|
||||
|
||||
|
|
|
@ -260,15 +260,18 @@
|
|||
#'more))])))
|
||||
|
||||
(begin-for-syntax
|
||||
(define-splicing-syntax-class (id-must-be what)
|
||||
[pattern x:id #:when (free-identifier=? #'x what)])
|
||||
(define-splicing-syntax-class (id-except ignores)
|
||||
[pattern x:id #:when (not (for/fold ([ok #t])
|
||||
[pattern x:id #:when (not (for/fold ([ok #f])
|
||||
([ignore ignores])
|
||||
(and ok (free-identifier=? #'x ignore))))])
|
||||
(or ok (free-identifier=? #'x ignore))))])
|
||||
(provide separate-ids)
|
||||
(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)))
|
||||
(~seq (~var between (id-must-be separator))
|
||||
(~var next (id-except (list separator end)))) ...)
|
||||
#:with (ids ...) #'(first.x next.x ...)]))
|
||||
#:with (id ...) #'(first.x next.x ...)]))
|
||||
|
||||
(begin-for-syntax
|
||||
(provide honu-declaration)
|
||||
|
@ -285,7 +288,7 @@
|
|||
#:literals (honu-equal honu-var)
|
||||
[pattern (~seq honu-var (~var variables (separate-ids #'honu-comma #'honu-equal))
|
||||
honu-equal one:honu-expression)
|
||||
#:with (name ...) #'(variables.ids ...)
|
||||
#:with (name ...) #'(variables.id ...)
|
||||
#:with expression #'one.result]))
|
||||
|
||||
(provide honu-var)
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
#lang honu
|
||||
|
||||
class What(x){
|
||||
class What(x, y){
|
||||
var q = 2
|
||||
foobar(z){
|
||||
z + x
|
||||
z + x + y
|
||||
}
|
||||
};
|
||||
|
||||
var instance = new What(5);
|
||||
var instance = new What(5, 8);
|
||||
printf("got ~a\n", instance->foobar(10))
|
||||
|
|
Loading…
Reference in New Issue
Block a user