From d4e0b1e533f217d7a28a18548753b62cd195612e Mon Sep 17 00:00:00 2001 From: Rostislav Svoboda Date: Thu, 8 Feb 2024 03:26:30 +0100 Subject: [PATCH] Better names and comments --- main.rkt | 3 ++- notes-reader.rkt | 8 ++++++-- notes.rkt | 6 +++--- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/main.rkt b/main.rkt index 00e4806..d85dac7 100644 --- a/main.rkt +++ b/main.rkt @@ -130,6 +130,7 @@ racket main.rkt -p title racket main.rkt -n -p title racket main.rkt -np title racket main.rkt -p rackjure +racket main.rkt -e ./main.rkt -p \"\\bfile\\b\" # \\b match word boundaries racket main.rkt -e ./main.rkt -p [[:blank:]]install([[:cntrl:]]|[[:blank:]]) racket main.rkt -e ./main.rkt -p \"[eeeee]\" racket main.rkt -e ./main.rkt -p \"[eéèêë]\" @@ -252,7 +253,7 @@ racket main.rkt -e \"/home/bost/der/search-notes/main.rkt /home/bost/der/search- (lambda (input-file) ;; (printf "1. input-file:\n~a\n" input-file) (define expression - `(notes + `(notes-syntax-parser ,@((compose ;; (lambda (p) (printf "13. ~a\n" p) p) (curry cons pattern-with-diacritics) diff --git a/notes-reader.rkt b/notes-reader.rkt index 70b7231..a44867d 100644 --- a/notes-reader.rkt +++ b/notes-reader.rkt @@ -1,14 +1,18 @@ #lang racket -(provide (rename-out (notes-read-syntax read-syntax)) +(provide (rename-out + ;; Every reader must export a read-syntax function. + (notes-read-syntax read-syntax)) parse-notes) (require syntax/readerr) +;; A read-syntax must return code describing a module, packaged as a syntax +;; object. (define (notes-read-syntax src in) (datum->syntax #f `(module notes racket (require "notes.rkt") - (notes + (notes-syntax-parser ,@(parse-notes src in))))) ;; `src` - context information about what file this code resides in. The value diff --git a/notes.rkt b/notes.rkt index f1b88f6..24e477a 100644 --- a/notes.rkt +++ b/notes.rkt @@ -1,5 +1,5 @@ #lang racket -(provide notes) +(provide notes-syntax-parser) (require (for-syntax syntax/parse racket/function ;; curry @@ -9,9 +9,9 @@ #;(require (rename-in racket/function (curry partial))) -(define-syntax (notes form) +(define-syntax (notes-syntax-parser form) (syntax-parse form - ((notes + ((notes-syntax-parser text:string case-sensitivity:string colorize-matches:boolean