From dccdc4ae1d2794e472404ea89bc4db1351d542bb Mon Sep 17 00:00:00 2001 From: Matthew Butterick Date: Wed, 1 Mar 2017 13:22:05 -0800 Subject: [PATCH] adjustments --- .../basic-demo-3/expander.rkt | 11 +++++----- beautiful-racket-demo/basic-demo-3/misc.rkt | 4 ++-- .../basic-demo-3/runtime.rkt | 21 ------------------- beautiful-racket-demo/basic-demo-3/setup.rkt | 21 +++++++++++++++++++ 4 files changed, 29 insertions(+), 28 deletions(-) delete mode 100644 beautiful-racket-demo/basic-demo-3/runtime.rkt create mode 100644 beautiful-racket-demo/basic-demo-3/setup.rkt diff --git a/beautiful-racket-demo/basic-demo-3/expander.rkt b/beautiful-racket-demo/basic-demo-3/expander.rkt index 3233564..59f02f0 100644 --- a/beautiful-racket-demo/basic-demo-3/expander.rkt +++ b/beautiful-racket-demo/basic-demo-3/expander.rkt @@ -1,5 +1,5 @@ #lang br/quicklang -(require "struct.rkt" "run.rkt" "elements.rkt" "runtime.rkt") +(require "struct.rkt" "run.rkt" "elements.rkt" "setup.rkt") (provide (rename-out [b-module-begin #%module-begin]) (all-from-out "elements.rkt")) @@ -17,16 +17,17 @@ (list (suffix-id #'arg idx #:context caller-stx) val))]) #'(#%module-begin (module configure-runtime br - (require basic-demo-3/runtime) - (configure-this!)) + (require basic-demo-3/setup) + (do-setup!)) (require IMPORT-NAME) ... - (define VAR-ID 0) ... (provide EXPORT-NAME ...) + (define VAR-ID 0) ... (set! SHELL-ID SHELL-VAL) ... LINE ... (define line-table (apply hasheqv (append (list NUM LINE-FUNC) ...))) - (parameterize ([current-output-port (basic-output-port)]) + (parameterize + ([current-output-port (basic-output-port)]) (void (run line-table)))))) (begin-for-syntax diff --git a/beautiful-racket-demo/basic-demo-3/misc.rkt b/beautiful-racket-demo/basic-demo-3/misc.rkt index da687ce..3712bf4 100644 --- a/beautiful-racket-demo/basic-demo-3/misc.rkt +++ b/beautiful-racket-demo/basic-demo-3/misc.rkt @@ -14,9 +14,9 @@ [num (string->number (string-trim str))]) (or num str)))) -(define-macro (b-import IMPORT-NAME) #'(void)) +(define-macro (b-import NAME) #'(void)) -(define-macro (b-export EXPORT-NAME) #'(void)) +(define-macro (b-export NAME) #'(void)) (define-macro (b-repl . ARGS) (with-pattern ([STMTS (pattern-case-filter #'ARGS diff --git a/beautiful-racket-demo/basic-demo-3/runtime.rkt b/beautiful-racket-demo/basic-demo-3/runtime.rkt deleted file mode 100644 index 4c29eca..0000000 --- a/beautiful-racket-demo/basic-demo-3/runtime.rkt +++ /dev/null @@ -1,21 +0,0 @@ -#lang br -(require "parser.rkt" "tokenizer.rkt") -(provide basic-output-port configure-this!) - -(define basic-output-port - (make-parameter (open-output-nowhere))) - -(define repl-parser (make-rule-parser b-repl)) - -(define (configure-this!) - (basic-output-port (current-output-port)) - - (define (read-one-line path port) - (define one-line (read-line port)) - (if (eof-object? one-line) - eof - (repl-parser - (make-tokenizer (open-input-string one-line))))) - (current-read-interaction read-one-line)) - - diff --git a/beautiful-racket-demo/basic-demo-3/setup.rkt b/beautiful-racket-demo/basic-demo-3/setup.rkt new file mode 100644 index 0000000..fd0b625 --- /dev/null +++ b/beautiful-racket-demo/basic-demo-3/setup.rkt @@ -0,0 +1,21 @@ +#lang br +(require "parser.rkt" "tokenizer.rkt") +(provide basic-output-port do-setup!) + +(define basic-output-port + (make-parameter (open-output-nowhere))) + +(define (do-setup!) + (basic-output-port (current-output-port)) + (current-read-interaction read-one-line)) + +(define repl-parser (make-rule-parser b-repl)) + +(define (read-one-line path port) + (define one-line (read-line port)) + (if (eof-object? one-line) + eof + (repl-parser + (make-tokenizer (open-input-string one-line))))) + +