-
Notifications
You must be signed in to change notification settings - Fork 0
/
notes.rkt
48 lines (47 loc) · 1.83 KB
/
notes.rkt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#lang racket
(provide notes-syntax-parser)
(require
(for-syntax syntax/parse
racket/function ;; curry
racket/syntax
syntax/id-set))
;; Also the `partial` from (require rackjure) can be used
#;(require (rename-in racket/function
(curry partial)))
(define-syntax (notes-syntax-parser form)
(syntax-parse form
((notes-syntax-parser
text:string
case-sensitivity:string
colorize-matches:boolean
note:expr ...)
(begin
#`(begin
'(#,@((compose
(curry map bytes->string/utf-8)
#;
(lambda (s)
(display (format "matches: ~a\n" s))
s)
(curry filter
(curry regexp-match
#;#px"^.*labor.*" #;#rx"^.*labor.*"
((compose
;; See also the regexp-split-match in the main.rkt
#;
(lambda (s)
(display (format "notes: ~a\n" s))
s)
;; regexp ;; #rx
pregexp ;; #px - posix
#;
(lambda (s)
(display (format "notes: ~a\n" s))
s))
(format
;; match the whole line containing pattern
"(?~a:^.*~a.*)"
(syntax->datum #`case-sensitivity)
(syntax->datum #`text)))))
(curry map syntax->datum))
(syntax->list #`(note ...)))))))))