From ffc5387ac35ce25cc0af9510840c400d19063149 Mon Sep 17 00:00:00 2001 From: Jon Rafkind Date: Tue, 6 Sep 2011 13:22:52 -0600 Subject: [PATCH] [honu] configure honu runtime to use the honu syntax reader. this allows honu to be used at the repl --- collects/honu/core/language.rkt | 8 ++++++++ collects/honu/core/main.rkt | 1 + collects/honu/core/private/honu-typed-scheme.rkt | 4 +++- collects/honu/core/private/honu2.rkt | 7 +++++++ collects/honu/core/runtime.rkt | 7 +++++++ collects/honu/main.rkt | 2 +- collects/honu/private/lang/reader.rkt | 12 ++++++++++++ collects/honu/private/main.rkt | 4 ++++ 8 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 collects/honu/core/runtime.rkt create mode 100644 collects/honu/private/lang/reader.rkt create mode 100644 collects/honu/private/main.rkt diff --git a/collects/honu/core/language.rkt b/collects/honu/core/language.rkt index 9ad2e7b29c..7bcc4e4a34 100644 --- a/collects/honu/core/language.rkt +++ b/collects/honu/core/language.rkt @@ -4,8 +4,16 @@ (provide honu-info) (define (honu-info key default default-filter) + (printf "get info for ~a\n" key) (case key [(color-lexer) (dynamic-require 'honu/core/read 'color-lexer)] [else (default-filter key default)])) + +(provide honu-language-info) +(define (honu-language-info data) + (lambda (key default) + (case key + [(configure-runtime) '(#(honu/core/runtime configure #f))] + [else default]))) diff --git a/collects/honu/core/main.rkt b/collects/honu/core/main.rkt index 625f4a7a92..da33167812 100644 --- a/collects/honu/core/main.rkt +++ b/collects/honu/core/main.rkt @@ -11,6 +11,7 @@ print printf true false (for-syntax (rename-out [honu-expression expression])) (rename-out [#%dynamic-honu-module-begin #%module-begin] + [honu-top-interaction #%top-interaction] [honu-function function] [honu-macro macro] [honu-syntax syntax] diff --git a/collects/honu/core/private/honu-typed-scheme.rkt b/collects/honu/core/private/honu-typed-scheme.rkt index 8e4b1fcb98..cd55a79591 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 (debug "expanded ~a\n" (syntax->datum parsed)) (with-syntax ([parsed parsed] [(unparsed ...) unparsed]) - #'(begin parsed (honu-unparsed-begin unparsed ...)))])) + (if (null? (syntax->datum #'(unparsed ...))) + #'parsed + #'(begin parsed (honu-unparsed-begin unparsed ...))))])) (define-syntax (#%dynamic-honu-module-begin stx) (syntax-case stx () diff --git a/collects/honu/core/private/honu2.rkt b/collects/honu/core/private/honu2.rkt index c7e4d0f7d9..6f4a86d1fe 100644 --- a/collects/honu/core/private/honu2.rkt +++ b/collects/honu/core/private/honu2.rkt @@ -3,6 +3,7 @@ (require "macro2.rkt" "operator.rkt" "struct.rkt" + "honu-typed-scheme.rkt" (only-in "literals.rkt" honu-then semicolon) @@ -159,3 +160,9 @@ (define-binary-operator honu-map 0.09 'left map) (define-unary-operator honu-not 0.7 'left not) + +(provide honu-top-interaction) +(define-syntax (honu-top-interaction stx) + (syntax-case stx () + [(_ rest ...) + #'(printf "~a\n" (honu-unparsed-begin rest ...))])) diff --git a/collects/honu/core/runtime.rkt b/collects/honu/core/runtime.rkt new file mode 100644 index 0000000000..439689306e --- /dev/null +++ b/collects/honu/core/runtime.rkt @@ -0,0 +1,7 @@ +#lang racket/base + +(require "read.rkt") + +(provide configure) +(define (configure . args) + (current-read-interaction honu-read-syntax)) diff --git a/collects/honu/main.rkt b/collects/honu/main.rkt index c12adfe05c..d0575841c7 100644 --- a/collects/honu/main.rkt +++ b/collects/honu/main.rkt @@ -1,4 +1,4 @@ -#lang racket/base +#lang honu/private (require (prefix-in racket: (combine-in racket/base racket/list))) diff --git a/collects/honu/private/lang/reader.rkt b/collects/honu/private/lang/reader.rkt new file mode 100644 index 0000000000..53b832e2c5 --- /dev/null +++ b/collects/honu/private/lang/reader.rkt @@ -0,0 +1,12 @@ +#lang s-exp syntax/module-reader + +honu/private/main + +;;#:read honu-read +;;#:read-syntax honu-read-syntax +;;#:whole-body-readers? #t +#:language-info #(honu/core/language honu-language-info #f) +; #:language-info #(honu/core/runtime configure 'dont-care) + +(require honu/core/read + honu/core/language) diff --git a/collects/honu/private/main.rkt b/collects/honu/private/main.rkt new file mode 100644 index 0000000000..8694e2e130 --- /dev/null +++ b/collects/honu/private/main.rkt @@ -0,0 +1,4 @@ +#lang racket/base + +(require racket/base) +(provide (all-from-out racket/base))