From 8e32cf31f7fda879c63eaf6f81b08f187a370821 Mon Sep 17 00:00:00 2001 From: Matthew Butterick Date: Sun, 13 Nov 2016 08:20:29 -0800 Subject: [PATCH] rename --- beautiful-racket/br/demo/jsonic/expander.rkt | 9 +++++---- beautiful-racket/br/demo/jsonic/tokenizer.rkt | 4 ++-- brag/brag/brag.scrbl | 4 ++-- brag/brag/support.rkt | 4 ++-- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/beautiful-racket/br/demo/jsonic/expander.rkt b/beautiful-racket/br/demo/jsonic/expander.rkt index 65752c8..d264559 100644 --- a/beautiful-racket/br/demo/jsonic/expander.rkt +++ b/beautiful-racket/br/demo/jsonic/expander.rkt @@ -4,14 +4,15 @@ #'(#%module-begin (define result-string PARSE-TREE) (define validated-jsexpr (string->jsexpr result-string)) - (display (jsexpr->string validated-jsexpr)))) + (display result-string))) (provide (rename-out [js-module-begin #%module-begin])) -(define-macro (jsonic-program S-EXP-OR-JSON-CHAR ...) - #'(string-append S-EXP-OR-JSON-CHAR ...)) +(define-macro (jsonic-program SEXP-OR-JSON-STR ...) + #'(string-trim (string-append SEXP-OR-JSON-STR ...))) (provide jsonic-program) -(define-macro (json-char CHAR-STR) #'CHAR-STR) +(define-macro (json-char CHAR-STR) + #'CHAR-STR) (provide json-char) (define-macro (s-exp SEXP-STR) diff --git a/beautiful-racket/br/demo/jsonic/tokenizer.rkt b/beautiful-racket/br/demo/jsonic/tokenizer.rkt index f7173b3..56e3d00 100644 --- a/beautiful-racket/br/demo/jsonic/tokenizer.rkt +++ b/beautiful-racket/br/demo/jsonic/tokenizer.rkt @@ -5,8 +5,8 @@ (define our-lexer (lexer [(eof) eof] - [(between "//" "\n") (next-token)] - [(between "@$" "$@") + [(from/to "//" "\n") (next-token)] + [(from/to "@$" "$@") (token 'SEXP-TOK (trim-ends "@$" lexeme "$@"))] [any-char (token 'CHAR-TOK lexeme)])) (our-lexer port)) diff --git a/brag/brag/brag.scrbl b/brag/brag/brag.scrbl index f628c45..2981a12 100755 --- a/brag/brag/brag.scrbl +++ b/brag/brag/brag.scrbl @@ -987,7 +987,7 @@ Repeatedly apply @racket[tokenizer] to @racket[source-string], gathering the res [str string?] [right-str string?]) string?]{ -Remove @racket[left-str] from the left side of @racket[str], and @racket[right-str] from its right side. Intended as a helper function for @racket[between]. +Remove @racket[left-str] from the left side of @racket[str], and @racket[right-str] from its right side. Intended as a helper function for @racket[from/to]. } @@ -1050,7 +1050,7 @@ one character.} Character ranges, matching characters between successive pairs of characters.} -@defform[(between open close)]{ +@defform[(from/to open close)]{ A string that is bounded by @racket[open] and @racket[close]. Matching is non-greedy (meaning, it stops at the first occurence of @racket[close]). The resulting lexeme includes @racket[open] and @racket[close]. To remove them, see @racket[trim-ends].} diff --git a/brag/brag/support.rkt b/brag/brag/support.rkt index 74b4d2b..5cf4ee7 100755 --- a/brag/brag/support.rkt +++ b/brag/brag/support.rkt @@ -10,7 +10,7 @@ [struct-out exn:fail:parsing] apply-tokenizer trim-ends - between) + from/to) (struct token-struct (type val offset line column span skip?) @@ -53,7 +53,7 @@ (define (trim-ends left lexeme right) (string-trim (string-trim lexeme left #:right? #f) right #:left? #f)) -(define-lex-trans between +(define-lex-trans from/to (λ(stx) (syntax-case stx () [(_ OPEN CLOSE)