[honu] fix if

This commit is contained in:
Jon Rafkind 2011-08-19 12:26:44 -06:00
parent c6e35ff665
commit 816b1747e9
7 changed files with 41 additions and 2 deletions

View File

@ -12,6 +12,7 @@
[honu-var var]
[honu-val val]
[honu-for for]
[honu-if if]
[honu-quote quote]
[honu-quasiquote quasiquote]
[honu-+ +] [honu-- -]
@ -28,6 +29,7 @@
[honu-not not] [honu-not !]
[honu-structure structure]
[honu-structure struct]
[literal:honu-then then]
[literal:colon :]
[literal:semicolon |;|]
[literal:honu-comma |,|]

View File

@ -321,6 +321,7 @@ Then, in the pattern above for 'if', 'then' would be bound to the following synt
...))))
#'rest)])))
#|
(honu:define-honu-syntax honu-if
(lambda (stx ctx)
(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
(lambda () result)
#'rest))])))
|#
(define true #t)
(define false #f)

View File

@ -4,6 +4,7 @@
"operator.rkt"
"struct.rkt"
(only-in "literals.rkt"
honu-then
semicolon)
(for-syntax syntax/parse
"literals.rkt"
@ -56,6 +57,17 @@
#'rest
#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)
(define-honu-syntax honu-val
(lambda (code context)

View File

@ -20,6 +20,7 @@
honu->> honu-<< honu->>> honu-< honu-> honu-<= honu->=
honu-!= honu-==
honu-literal
honu-then
honu-? honu-: honu-comma honu-. #%braces #%brackets #%parens colon
honu-and
ellipses-comma ellipses-comma* ellipses-repeat

View File

@ -1,6 +1,6 @@
#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
(define-syntax-rule (provide-module module ...)
@ -20,4 +20,9 @@
(provide sqr sqrt sin max else
number? symbol?
null
(rename-out [honu-cond cond]))
null?
(rename-out [honu-cond cond]
[null empty]
[racket:empty? empty?]
[racket:first first]
[racket:rest rest]))

View File

@ -0,0 +1,6 @@
#lang honu
if true then
5
else
9

View File

@ -83,3 +83,14 @@
@output{'x1
})
(test
@input{
if 2 > 1 then
1
else
0
}
@output{1
})