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