From a29d64b44ab1cce5ead3c2ecf4573a7e870c346c Mon Sep 17 00:00:00 2001 From: Jon Rafkind Date: Thu, 14 Jul 2011 16:40:18 -0600 Subject: [PATCH] enable #lang honu --- collects/honu/core/main.rkt | 15 ++++++++++ .../honu/core/private/honu-typed-scheme.rkt | 4 ++- collects/honu/core/private/parse2.rkt | 14 +++++++--- collects/honu/main.rkt | 7 +++-- collects/tests/honu/basic.honu | 2 -- collects/tests/honu/test.honu | 28 +++++++++++++++++++ collects/tests/honu/test.rkt | 6 ++++ 7 files changed, 66 insertions(+), 10 deletions(-) create mode 100644 collects/tests/honu/test.honu diff --git a/collects/honu/core/main.rkt b/collects/honu/core/main.rkt index bcbeb777db..76b4343d05 100644 --- a/collects/honu/core/main.rkt +++ b/collects/honu/core/main.rkt @@ -1,5 +1,19 @@ #lang racket/base +(require "private/honu-typed-scheme.rkt" + "private/honu2.rkt" + (prefix-in literal: "private/literals.rkt")) + +(provide #%top + #%datum + print + (rename-out [#%dynamic-honu-module-begin #%module-begin] + [honu-function function] + [literal:#%braces #%braces] + [literal:#%parens #%parens]) + ) + +#| (require (for-syntax racket/base)) (require (for-meta 2 racket/base)) (require racket/class) @@ -157,3 +171,4 @@ #; (scheme-syntax scheme:syntax) )) +|# diff --git a/collects/honu/core/private/honu-typed-scheme.rkt b/collects/honu/core/private/honu-typed-scheme.rkt index 7962104610..a61b4d6c0e 100644 --- a/collects/honu/core/private/honu-typed-scheme.rkt +++ b/collects/honu/core/private/honu-typed-scheme.rkt @@ -460,7 +460,9 @@ Then, in the pattern above for 'if', 'then' would be bound to the following synt (define-syntax (honu-unparsed-begin stx) (emit-remark "Honu unparsed begin!" stx) (debug "honu unparsed begin: ~a at phase ~a\n" (syntax->datum stx) (syntax-local-phase-level)) - (honu-compile (honu-expand (stx-cdr stx)))) + (define expanded (honu-expand (stx-cdr stx))) + (debug "expanded ~a\n" expanded) + expanded) (define-syntax (#%dynamic-honu-module-begin stx) (syntax-case stx () diff --git a/collects/honu/core/private/parse2.rkt b/collects/honu/core/private/parse2.rkt index 873a0728e6..83e51b7785 100644 --- a/collects/honu/core/private/parse2.rkt +++ b/collects/honu/core/private/parse2.rkt @@ -105,7 +105,10 @@ ((syntax-local-value #'head) #'(head rest ...) #f)]) (with-syntax ([parsed parsed] [rest unparsed]) - (do-parse #'rest precedence (lambda (x) x) #'parsed) + (do-parse #'rest precedence (lambda (x) + (with-syntax ([x x]) + #'(begin parsed x))) + (left current)) #; #'(splicing-let-syntax ([more-parsing (lambda (stx) (do-parse (stx-cdr stx) @@ -144,15 +147,18 @@ precedence left #'x)] [(#%parens args ...) (debug "function call ~a\n" left) - (with-syntax ([current current]) - #'(current args ...)) + (do-parse #'(rest ...) + 0 + (lambda (x) x) + (left (with-syntax ([current current]) + #'(current args ...)))) #; (error 'parse "function call")] [else (error 'what "dont know ~a" #'head)])] )])) - (do-parse input 0 (lambda (x) x) #f)) + (do-parse input 0 (lambda (x) x) #'(void))) (define (parse2 forms) (debug "parse forms ~a\n" forms) diff --git a/collects/honu/main.rkt b/collects/honu/main.rkt index d62ee33274..afefbf576b 100644 --- a/collects/honu/main.rkt +++ b/collects/honu/main.rkt @@ -11,6 +11,7 @@ ...)) (provide-module "core/main.rkt" - "private/struct.honu" - "private/function.honu" - "private/common.honu") + ;;"private/struct.honu" + ;;"private/function.honu" + ;;"private/common.honu" + ) diff --git a/collects/tests/honu/basic.honu b/collects/tests/honu/basic.honu index 0dda5dbcc8..e5a22358cd 100644 --- a/collects/tests/honu/basic.honu +++ b/collects/tests/honu/basic.honu @@ -1,7 +1,5 @@ #lang honu - - obj test(t, a, b){ if (a != b){ display(t); diff --git a/collects/tests/honu/test.honu b/collects/tests/honu/test.honu new file mode 100644 index 0000000000..dd56efea87 --- /dev/null +++ b/collects/tests/honu/test.honu @@ -0,0 +1,28 @@ +#lang honu + +/* +function test(t, a, b){ + if (a != b){ + display(t); + display(" failed!"); + newline(); + display("Got "); + display(a); + display(". Expected "); + display(b); + newline(); + } +} +*/ + +function test1(){ + print(5) +/* + var x = 3; + const y = 2; + test("x = 3", x, 3); + test("y = 2", y, 2); + */ +} + +test1() diff --git a/collects/tests/honu/test.rkt b/collects/tests/honu/test.rkt index f2061e041f..09c7d09215 100644 --- a/collects/tests/honu/test.rkt +++ b/collects/tests/honu/test.rkt @@ -45,6 +45,12 @@ })) (test 5)) +(let () + (fake-module-begin #hx(honu_function test(x){ + print(x) + } + test(2)))) + (let () (fake-module-begin #hx(1 honu_plus 1)))