From e68ae258f923cc3c36b1ccca93e44230862caf9a Mon Sep 17 00:00:00 2001 From: Matthew Butterick Date: Mon, 11 Apr 2016 16:57:34 -0700 Subject: [PATCH] reorg --- .../br/{read-functions.rkt => reader-utils.rkt} | 16 ++++++++-------- beautiful-racket/{br-bf/main.rkt => br/bf.rkt} | 10 +++++----- .../{br-bf => br/bf}/bf-hash-sexp.rkt | 2 +- beautiful-racket/{br-bf => br/bf}/bf-hash.rkt | 2 +- .../{br-bf => br/bf}/hello-world.rkt | 2 +- beautiful-racket/{br-bf => br/bf}/info.rkt | 0 beautiful-racket/{br-bf => br/bf}/parser.rkt | 0 .../{br-bf => br/bf}/reader-proc-test.rkt | 0 beautiful-racket/{br-bf => br/bf}/tokenizer.rkt | 0 9 files changed, 16 insertions(+), 16 deletions(-) rename beautiful-racket-lib/br/{read-functions.rkt => reader-utils.rkt} (73%) rename beautiful-racket/{br-bf/main.rkt => br/bf.rkt} (87%) rename beautiful-racket/{br-bf => br/bf}/bf-hash-sexp.rkt (64%) rename beautiful-racket/{br-bf => br/bf}/bf-hash.rkt (62%) rename beautiful-racket/{br-bf => br/bf}/hello-world.rkt (76%) rename beautiful-racket/{br-bf => br/bf}/info.rkt (100%) rename beautiful-racket/{br-bf => br/bf}/parser.rkt (100%) rename beautiful-racket/{br-bf => br/bf}/reader-proc-test.rkt (100%) rename beautiful-racket/{br-bf => br/bf}/tokenizer.rkt (100%) diff --git a/beautiful-racket-lib/br/read-functions.rkt b/beautiful-racket-lib/br/reader-utils.rkt similarity index 73% rename from beautiful-racket-lib/br/read-functions.rkt rename to beautiful-racket-lib/br/reader-utils.rkt index b9fa490..9dc9e39 100644 --- a/beautiful-racket-lib/br/read-functions.rkt +++ b/beautiful-racket-lib/br/reader-utils.rkt @@ -1,25 +1,25 @@ #lang racket/base (require (for-syntax racket/base) syntax/strip-context) -(provide define-read-functions) +(provide define-read-and-read-syntax) ;; `define-read-functions` simplifies support for the standard reading API, ;; which asks for `read` and `read-syntax`. ;; in general, `read` is just the datum from the result of `read-syntax`. -(define-syntax (define-read-functions use-site-stx) - (syntax-case use-site-stx () +(define-syntax (define-read-and-read-syntax calling-site-stx) + (syntax-case calling-site-stx () [(_ (PATH PORT) BODY ...) - (with-syntax ([READ (datum->syntax use-site-stx 'read)] - [READ-SYNTAX (datum->syntax use-site-stx 'read-syntax)]) + (with-syntax ([READ (datum->syntax calling-site-stx 'read)] + [READ-SYNTAX (datum->syntax calling-site-stx 'read-syntax)]) #'(begin (provide READ READ-SYNTAX) - (define (use-site-read-function PATH PORT) + (define (calling-site-function PATH PORT) BODY ...) ; don't care whether this produces datum or syntax (define (READ-SYNTAX path port) ;; because `read-syntax` must produce syntax ;; coerce a datum result to syntax if needed (à la `with-syntax`) - (define result-syntax (let ([output (use-site-read-function path port)]) + (define result-syntax (let ([output (calling-site-function path port)]) (if (syntax? output) output (datum->syntax #f output)))) @@ -30,7 +30,7 @@ (define (READ port) ; because `read` must produce a datum - (let ([output (use-site-read-function #f port)]) + (let ([output (calling-site-function #f port)]) (if (syntax? output) (syntax->datum output) output)))))])) diff --git a/beautiful-racket/br-bf/main.rkt b/beautiful-racket/br/bf.rkt similarity index 87% rename from beautiful-racket/br-bf/main.rkt rename to beautiful-racket/br/bf.rkt index 0f58076..1620e23 100644 --- a/beautiful-racket/br-bf/main.rkt +++ b/beautiful-racket/br/bf.rkt @@ -2,7 +2,7 @@ (module reader br (provide read-syntax) - (require "tokenizer.rkt" "parser.rkt") + (require "bf/tokenizer.rkt" "bf/parser.rkt") (define (read-syntax src-path src-port) (define parsed-syntax (parse src-path (tokenize src-port))) ;; `strip-context` because `read-syntax` promises @@ -10,14 +10,14 @@ ;; (so later operations can add it) (strip-context (inject-syntax ([parsed-syntax]) - #'(module bf-interpreter br-bf + #'(module bf-interpreter br/bf parsed-syntax))))) ;; compact version #;(module reader br - (require br/read-functions "tokenizer.rkt" "parser.rkt") - (define-read-functions (src-path src-port) - #`(module bf-interpreter br-bf + (require br/reader-utils "tokenizer.rkt" "parser.rkt") + (define-read-and-read-syntax (src-path src-port) + #`(module bf-interpreter br/bf #,(parse src-path (tokenize src-port))))) (provide (rename-out [bf-module-begin #%module-begin]) diff --git a/beautiful-racket/br-bf/bf-hash-sexp.rkt b/beautiful-racket/br/bf/bf-hash-sexp.rkt similarity index 64% rename from beautiful-racket/br-bf/bf-hash-sexp.rkt rename to beautiful-racket/br/bf/bf-hash-sexp.rkt index f298200..348d763 100644 --- a/beautiful-racket/br-bf/bf-hash-sexp.rkt +++ b/beautiful-racket/br/bf/bf-hash-sexp.rkt @@ -1,2 +1,2 @@ -#lang s-exp br-bf +#lang s-exp br/bf (bf-program (op "+") (op "+") (op "+") (op "+") (op "+") (op "+") (op "+") (loop "[" (op ">") (op "+") (op "+") (op "+") (op "+") (op "+") (op "<") (op "-") "]") (op ">") (op ".")) \ No newline at end of file diff --git a/beautiful-racket/br-bf/bf-hash.rkt b/beautiful-racket/br/bf/bf-hash.rkt similarity index 62% rename from beautiful-racket/br-bf/bf-hash.rkt rename to beautiful-racket/br/bf/bf-hash.rkt index 2281219..050b2fc 100644 --- a/beautiful-racket/br-bf/bf-hash.rkt +++ b/beautiful-racket/br/bf/bf-hash.rkt @@ -1,2 +1,2 @@ -#lang br-bf +#lang br/bf +++++++[>+++++<-]>. diff --git a/beautiful-racket/br-bf/hello-world.rkt b/beautiful-racket/br/bf/hello-world.rkt similarity index 76% rename from beautiful-racket/br-bf/hello-world.rkt rename to beautiful-racket/br/bf/hello-world.rkt index b40875c..4e189f8 100644 --- a/beautiful-racket/br-bf/hello-world.rkt +++ b/beautiful-racket/br/bf/hello-world.rkt @@ -1,4 +1,4 @@ -#lang br-bf +#lang br/bf ++++++[>++++++++++++<-]>. >++++++++++[>++++++++++<-]>+. +++++++..+++.>++++[>+++++++++++<-]>. diff --git a/beautiful-racket/br-bf/info.rkt b/beautiful-racket/br/bf/info.rkt similarity index 100% rename from beautiful-racket/br-bf/info.rkt rename to beautiful-racket/br/bf/info.rkt diff --git a/beautiful-racket/br-bf/parser.rkt b/beautiful-racket/br/bf/parser.rkt similarity index 100% rename from beautiful-racket/br-bf/parser.rkt rename to beautiful-racket/br/bf/parser.rkt diff --git a/beautiful-racket/br-bf/reader-proc-test.rkt b/beautiful-racket/br/bf/reader-proc-test.rkt similarity index 100% rename from beautiful-racket/br-bf/reader-proc-test.rkt rename to beautiful-racket/br/bf/reader-proc-test.rkt diff --git a/beautiful-racket/br-bf/tokenizer.rkt b/beautiful-racket/br/bf/tokenizer.rkt similarity index 100% rename from beautiful-racket/br-bf/tokenizer.rkt rename to beautiful-racket/br/bf/tokenizer.rkt