[honu] fix if
This commit is contained in:
parent
c6e35ff665
commit
816b1747e9
|
@ -12,6 +12,7 @@
|
||||||
[honu-var var]
|
[honu-var var]
|
||||||
[honu-val val]
|
[honu-val val]
|
||||||
[honu-for for]
|
[honu-for for]
|
||||||
|
[honu-if if]
|
||||||
[honu-quote quote]
|
[honu-quote quote]
|
||||||
[honu-quasiquote quasiquote]
|
[honu-quasiquote quasiquote]
|
||||||
[honu-+ +] [honu-- -]
|
[honu-+ +] [honu-- -]
|
||||||
|
@ -28,6 +29,7 @@
|
||||||
[honu-not not] [honu-not !]
|
[honu-not not] [honu-not !]
|
||||||
[honu-structure structure]
|
[honu-structure structure]
|
||||||
[honu-structure struct]
|
[honu-structure struct]
|
||||||
|
[literal:honu-then then]
|
||||||
[literal:colon :]
|
[literal:colon :]
|
||||||
[literal:semicolon |;|]
|
[literal:semicolon |;|]
|
||||||
[literal:honu-comma |,|]
|
[literal:honu-comma |,|]
|
||||||
|
|
|
@ -321,6 +321,7 @@ Then, in the pattern above for 'if', 'then' would be bound to the following synt
|
||||||
...))))
|
...))))
|
||||||
#'rest)])))
|
#'rest)])))
|
||||||
|
|
||||||
|
#|
|
||||||
(honu:define-honu-syntax honu-if
|
(honu:define-honu-syntax honu-if
|
||||||
(lambda (stx ctx)
|
(lambda (stx ctx)
|
||||||
(define (parse-complete-block stx)
|
(define (parse-complete-block stx)
|
||||||
|
@ -352,6 +353,7 @@ Then, in the pattern above for 'if', 'then' would be bound to the following synt
|
||||||
(values
|
(values
|
||||||
(lambda () result)
|
(lambda () result)
|
||||||
#'rest))])))
|
#'rest))])))
|
||||||
|
|#
|
||||||
|
|
||||||
(define true #t)
|
(define true #t)
|
||||||
(define false #f)
|
(define false #f)
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
"operator.rkt"
|
"operator.rkt"
|
||||||
"struct.rkt"
|
"struct.rkt"
|
||||||
(only-in "literals.rkt"
|
(only-in "literals.rkt"
|
||||||
|
honu-then
|
||||||
semicolon)
|
semicolon)
|
||||||
(for-syntax syntax/parse
|
(for-syntax syntax/parse
|
||||||
"literals.rkt"
|
"literals.rkt"
|
||||||
|
@ -56,6 +57,17 @@
|
||||||
#'rest
|
#'rest
|
||||||
#t)])))
|
#t)])))
|
||||||
|
|
||||||
|
(provide honu-if)
|
||||||
|
(define-honu-syntax honu-if
|
||||||
|
(lambda (code context)
|
||||||
|
(syntax-parse code #:literal-sets (cruft)
|
||||||
|
#:literals (else honu-then)
|
||||||
|
[(_ condition:honu-expression honu-then true:honu-expression else false:honu-expression . rest)
|
||||||
|
(values
|
||||||
|
#'(if condition.result true.result false.result)
|
||||||
|
#'rest
|
||||||
|
#f)])))
|
||||||
|
|
||||||
(provide honu-val)
|
(provide honu-val)
|
||||||
(define-honu-syntax honu-val
|
(define-honu-syntax honu-val
|
||||||
(lambda (code context)
|
(lambda (code context)
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
honu->> honu-<< honu->>> honu-< honu-> honu-<= honu->=
|
honu->> honu-<< honu->>> honu-< honu-> honu-<= honu->=
|
||||||
honu-!= honu-==
|
honu-!= honu-==
|
||||||
honu-literal
|
honu-literal
|
||||||
|
honu-then
|
||||||
honu-? honu-: honu-comma honu-. #%braces #%brackets #%parens colon
|
honu-? honu-: honu-comma honu-. #%braces #%brackets #%parens colon
|
||||||
honu-and
|
honu-and
|
||||||
ellipses-comma ellipses-comma* ellipses-repeat
|
ellipses-comma ellipses-comma* ellipses-repeat
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#lang racket/base
|
#lang racket/base
|
||||||
|
|
||||||
(require (prefix-in racket: racket/base))
|
(require (prefix-in racket: (combine-in racket/base racket/list)))
|
||||||
|
|
||||||
;; require's and provide's a module
|
;; require's and provide's a module
|
||||||
(define-syntax-rule (provide-module module ...)
|
(define-syntax-rule (provide-module module ...)
|
||||||
|
@ -20,4 +20,9 @@
|
||||||
(provide sqr sqrt sin max else
|
(provide sqr sqrt sin max else
|
||||||
number? symbol?
|
number? symbol?
|
||||||
null
|
null
|
||||||
(rename-out [honu-cond cond]))
|
null?
|
||||||
|
(rename-out [honu-cond cond]
|
||||||
|
[null empty]
|
||||||
|
[racket:empty? empty?]
|
||||||
|
[racket:first first]
|
||||||
|
[racket:rest rest]))
|
||||||
|
|
6
collects/honu/tests/if.rkt
Normal file
6
collects/honu/tests/if.rkt
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
#lang honu
|
||||||
|
|
||||||
|
if true then
|
||||||
|
5
|
||||||
|
else
|
||||||
|
9
|
|
@ -83,3 +83,14 @@
|
||||||
|
|
||||||
@output{'x1
|
@output{'x1
|
||||||
})
|
})
|
||||||
|
|
||||||
|
(test
|
||||||
|
@input{
|
||||||
|
if 2 > 1 then
|
||||||
|
1
|
||||||
|
else
|
||||||
|
0
|
||||||
|
}
|
||||||
|
|
||||||
|
@output{1
|
||||||
|
})
|
||||||
|
|
Loading…
Reference in New Issue
Block a user