[honu] move when macro to the honu language
This commit is contained in:
parent
40eeeb6a72
commit
bef2f188b3
|
@ -14,12 +14,15 @@
|
|||
(provide (for-meta meta-level
|
||||
(rename-out [parse:honu-expression expression]
|
||||
[parse:honu-identifier identifier]
|
||||
[racket:else else]
|
||||
[racket:void void]
|
||||
[honu-function function]
|
||||
[honu-var var]
|
||||
[honu-equal =]
|
||||
[honu--> %arrow]
|
||||
[honu-class class]
|
||||
[honu-require require]
|
||||
[honu-provide provide]
|
||||
[honu-new new]
|
||||
[honu-while while]
|
||||
[honu-macro macro]
|
||||
|
|
|
@ -260,6 +260,15 @@
|
|||
#'rest
|
||||
#f)])))
|
||||
|
||||
(provide honu-provide)
|
||||
(define-honu-syntax honu-provide
|
||||
(lambda (code context)
|
||||
(syntax-parse code
|
||||
[(_ name:id ...)
|
||||
(values #'(%racket (provide name ...))
|
||||
#'()
|
||||
#f)])))
|
||||
|
||||
(provide honu-with-input-from-file)
|
||||
(define-honu-syntax honu-with-input-from-file
|
||||
(lambda (code context)
|
||||
|
|
|
@ -59,7 +59,7 @@
|
|||
(lambda (code context)
|
||||
(debug "Macroize ~a\n" code)
|
||||
(syntax-parse code #:literal-sets (cruft)
|
||||
[(_ name literals (#%braces pattern ...) (#%braces action ...) . rest)
|
||||
[(_ name (#%parens literal ...) (#%braces pattern ...) (#%braces action ...) . rest)
|
||||
(debug "Pattern is ~a\n" #'(pattern ...))
|
||||
(debug 2 "Pattern variables ~a\n" (find-pattern-variables #'(pattern ...)))
|
||||
(values
|
||||
|
@ -69,7 +69,9 @@
|
|||
(find-pattern-variables #'(pattern ...))])
|
||||
#'(%racket (define-honu-syntax name
|
||||
(lambda (stx context-name)
|
||||
(define-literal-set local-literals (literal ...))
|
||||
(syntax-parse stx
|
||||
#:literal-sets (cruft local-literals)
|
||||
[(_ syntax-parse-pattern ... . more)
|
||||
(values
|
||||
;; if the pattern is x:expression then x_result will
|
||||
|
|
|
@ -12,24 +12,23 @@
|
|||
|
||||
(provide-module "core/main.rkt"
|
||||
"private/common.rkt"
|
||||
"private/common.honu"
|
||||
;;"private/struct.honu"
|
||||
;;"private/function.honu"
|
||||
;;"private/common.honu"
|
||||
)
|
||||
|
||||
(provide sqr sqrt sin max else
|
||||
(racket:provide sqr sqrt sin max
|
||||
number? symbol?
|
||||
null
|
||||
null?
|
||||
length
|
||||
substring
|
||||
void
|
||||
format
|
||||
integer
|
||||
cos sin
|
||||
random
|
||||
values
|
||||
(rename-out [honu-cond cond]
|
||||
(racket:rename-out [honu-cond cond]
|
||||
[null empty]
|
||||
[current-inexact-milliseconds currentMilliseconds]
|
||||
[string-length string_length]
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
#lang honu/core
|
||||
|
||||
provide when;
|
||||
macro when (then){ condition:expression then body:expression }{
|
||||
syntax(if condition then body else { void() })
|
||||
}
|
||||
|
||||
/*
|
||||
require (forSyntax "with.honu");
|
||||
require (forSyntax "function.honu");
|
||||
require (forSyntax "patterns.honu");
|
||||
|
@ -36,3 +42,4 @@ macro condition (){ _ clause:condition_clause rest ... ;}
|
|||
}
|
||||
); }
|
||||
{ _ ; } { syntax(1;); }
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue
Block a user