diff --git a/collects/honu/core/main.rkt b/collects/honu/core/main.rkt index ca254836d8..e38fb839ee 100644 --- a/collects/honu/core/main.rkt +++ b/collects/honu/core/main.rkt @@ -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 |,|] diff --git a/collects/honu/core/private/honu-typed-scheme.rkt b/collects/honu/core/private/honu-typed-scheme.rkt index 563b050e70..8113b5e43d 100644 --- a/collects/honu/core/private/honu-typed-scheme.rkt +++ b/collects/honu/core/private/honu-typed-scheme.rkt @@ -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) diff --git a/collects/honu/core/private/honu2.rkt b/collects/honu/core/private/honu2.rkt index 65c05c6981..763de2f893 100644 --- a/collects/honu/core/private/honu2.rkt +++ b/collects/honu/core/private/honu2.rkt @@ -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) diff --git a/collects/honu/core/private/literals.rkt b/collects/honu/core/private/literals.rkt index 7ded90726c..a27086209a 100644 --- a/collects/honu/core/private/literals.rkt +++ b/collects/honu/core/private/literals.rkt @@ -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 diff --git a/collects/honu/main.rkt b/collects/honu/main.rkt index ae7ba5fbd5..d03f495a5e 100644 --- a/collects/honu/main.rkt +++ b/collects/honu/main.rkt @@ -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])) diff --git a/collects/honu/tests/if.rkt b/collects/honu/tests/if.rkt new file mode 100644 index 0000000000..e73429f4de --- /dev/null +++ b/collects/honu/tests/if.rkt @@ -0,0 +1,6 @@ +#lang honu + +if true then + 5 +else + 9 diff --git a/collects/honu/tests/test.rkt b/collects/honu/tests/test.rkt index 6ae4433c02..19d7d2a8d1 100644 --- a/collects/honu/tests/test.rkt +++ b/collects/honu/tests/test.rkt @@ -83,3 +83,14 @@ @output{'x1 }) + +(test + @input{ + if 2 > 1 then + 1 + else + 0 + } + + @output{1 + })