[honu] add primitive macro form
This commit is contained in:
parent
60f1c85207
commit
37dc999951
|
@ -33,6 +33,7 @@
|
||||||
[honu-new new]
|
[honu-new new]
|
||||||
[honu-while while]
|
[honu-while while]
|
||||||
[honu-macro macro]
|
[honu-macro macro]
|
||||||
|
[honu-primitive-macro primitive_macro]
|
||||||
[honu-pattern pattern]
|
[honu-pattern pattern]
|
||||||
[racket:read-line readLine]
|
[racket:read-line readLine]
|
||||||
[honu-with-input-from-file withInputFromFile]
|
[honu-with-input-from-file withInputFromFile]
|
||||||
|
|
|
@ -111,7 +111,9 @@
|
||||||
syntax))
|
syntax))
|
||||||
|
|
||||||
(define (parsed-syntax? syntax)
|
(define (parsed-syntax? syntax)
|
||||||
(syntax-property syntax parsed-property))
|
(if syntax
|
||||||
|
(syntax-property syntax parsed-property)
|
||||||
|
syntax))
|
||||||
|
|
||||||
(define-syntax (racket-syntax stx)
|
(define-syntax (racket-syntax stx)
|
||||||
(syntax-case stx ()
|
(syntax-case stx ()
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
(define-syntax (parse-body stx)
|
(define-syntax (parse-body stx)
|
||||||
(syntax-parse stx
|
(syntax-parse stx
|
||||||
[(_ stuff ...)
|
[(_ stuff ...)
|
||||||
(honu->racket (parse-all #'(stuff ...)))]))
|
(parse-all #'(stuff ...))]))
|
||||||
|
|
||||||
(provide honu-function)
|
(provide honu-function)
|
||||||
(define-honu-syntax honu-function
|
(define-honu-syntax honu-function
|
||||||
|
@ -269,9 +269,6 @@
|
||||||
#'name)
|
#'name)
|
||||||
#:when (not ((literal-set->predicate cruft) #'x))]))
|
#:when (not ((literal-set->predicate cruft) #'x))]))
|
||||||
|
|
||||||
(define-for-syntax (racket-names->honu name)
|
|
||||||
(regexp-replace* #rx"-" "_"))
|
|
||||||
|
|
||||||
(provide honu-require)
|
(provide honu-require)
|
||||||
(define-honu-syntax honu-require
|
(define-honu-syntax honu-require
|
||||||
(lambda (code)
|
(lambda (code)
|
||||||
|
@ -456,3 +453,14 @@
|
||||||
body.result))
|
body.result))
|
||||||
#'rest
|
#'rest
|
||||||
#t)])))
|
#t)])))
|
||||||
|
|
||||||
|
(provide honu-primitive-macro)
|
||||||
|
(define-honu-syntax honu-primitive-macro
|
||||||
|
(lambda (code)
|
||||||
|
(syntax-parse code
|
||||||
|
[(_ name:id transformer:honu-expression/phase+1 . rest)
|
||||||
|
(values
|
||||||
|
(racket-syntax (define-honu-syntax name transformer.result))
|
||||||
|
#'rest
|
||||||
|
#t)])))
|
||||||
|
|
||||||
|
|
|
@ -347,13 +347,14 @@
|
||||||
(debug "parse ~a precedence ~a left ~a current ~a properties ~a\n"
|
(debug "parse ~a precedence ~a left ~a current ~a properties ~a\n"
|
||||||
(syntax->datum stream) precedence left current
|
(syntax->datum stream) precedence left current
|
||||||
(syntax-property-symbol-keys stream))
|
(syntax-property-symbol-keys stream))
|
||||||
(define final (if current current #f))
|
(define final (if current current #'(void)))
|
||||||
(if (parsed-syntax? stream)
|
(if (parsed-syntax? stream)
|
||||||
(values (left stream) #'())
|
(values (left stream) #'())
|
||||||
(syntax-parse stream #:literal-sets (cruft)
|
(syntax-parse stream #:literal-sets (cruft)
|
||||||
#;
|
#;
|
||||||
[x:id (values #'x #'())]
|
[x:id (values #'x #'())]
|
||||||
[()
|
[()
|
||||||
|
(debug "Empty input out: left ~a ~a\n" left (left final))
|
||||||
(values (left final) #'())]
|
(values (left final) #'())]
|
||||||
;; dont reparse pure racket code
|
;; dont reparse pure racket code
|
||||||
[(%racket racket)
|
[(%racket racket)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user