about summary refs log tree commit diff stats
path: root/src/util.scm
diff options
context:
space:
mode:
authorCase Duckworth2024-06-05 09:21:25 -0500
committerCase Duckworth2024-06-05 09:21:25 -0500
commit423ac382f9e73bf1ca7fc6b400f98db087cd7d22 (patch)
tree1992e3dc7e71cd40eb7cdbc0b6d0c3cdf82c4332 /src/util.scm
parentUpdate README, add COPYING (diff)
downloadjimmy-423ac382f9e73bf1ca7fc6b400f98db087cd7d22.tar.gz
jimmy-423ac382f9e73bf1ca7fc6b400f98db087cd7d22.zip
Write executable
This involved moving `src' to `lib' and making `bin'.
`bin' holds the program, which only imports `jimmy.main' from lib.
Diffstat (limited to 'src/util.scm')
-rw-r--r--src/util.scm49
1 files changed, 0 insertions, 49 deletions
diff --git a/src/util.scm b/src/util.scm deleted file mode 100644 index c71c600..0000000 --- a/src/util.scm +++ /dev/null
@@ -1,49 +0,0 @@
1(module (jimmy util) *
2
3 (import scheme (chicken base)
4 (chicken condition)
5 (only (chicken irregex) irregex-replace/all)
6 (chicken string))
7
8 (define-syntax define-public
9 (syntax-rules ()
10 ((define-public (name . arg) forms ...)
11 (begin (export name)
12 (define (name . arg) forms ...)))
13 ((define-public (name args ...) forms ...)
14 (begin (export name)
15 (define (name args ...) forms ...)))
16 ((define-public name value)
17 (begin (export name)
18 (define name value)))))
19
20 (define-syntax ignore-errors
21 (syntax-rules ()
22 ((ignore-errors x)
23 (handle-exceptions e #f x))))
24
25 (define (alist-walk lis . keys)
26 (if (null? keys)
27 lis
28 (let ((kv (assoc (car keys) lis)))
29 (cond
30 ((not kv) #f)
31 ((atom? (cdr kv))
32 (and (null? (cdr keys)) ; this shouldn't error...
33 (cdr kv)))
34 ((list? (cdr kv))
35 (apply alist-walk (cdr kv) (cdr keys)))))))
36
37 (define (string-join ss #!optional (sep " "))
38 (string-intersperse ss sep))
39
40 (define (flush-lines-left lines)
41 (irregex-replace/all '(: bol (* space))
42 (string-join lines) ""))
43
44 (define (join-lines lines)
45 (apply string-append lines))
46
47 )
48
49