nendo 0.4.1 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -365,7 +365,13 @@ trampCall(
365
365
  ) then
366
366
  begin
367
367
  begin raise RuntimeError,
368
- "Unknown doctype type spec"
368
+ "Unknown doctype type spec" ' ' +
369
+ _write_MIMARKto_MIMARKstring(
370
+ begin
371
+ trampCall(_type)
372
+ rescue => __e ; __e.set_backtrace( ["./lib/text/html-lite.nnd:99"] + __e.backtrace ) ; raise __e
373
+ end
374
+ )
369
375
  rescue => __e
370
376
  __e.set_backtrace( ["./lib/text/html-lite.nnd:99"] + __e.backtrace )
371
377
  raise __e
data/lib/util/list.nnd ADDED
@@ -0,0 +1,184 @@
1
+ ;;;-*- mode: nendo; syntax: scheme -*-;;
2
+ ;;;
3
+ ;;; util/list.nnd - more list library
4
+ ;;;
5
+ ;;; Copyright (c) 2003-2010 Shiro Kawai <shiro@acm.org>
6
+ ;;; Copyright(C) 2003 by Alex Shinn (foof@synthcode.com)
7
+ ;;;
8
+ ;;; Permission to use, copy, modify, distribute this software and
9
+ ;;; accompanying documentation for any purpose is hereby granted,
10
+ ;;; provided that existing copyright notices are retained in all
11
+ ;;; copies and that this notice is included verbatim in all
12
+ ;;; distributions.
13
+ ;;; This software is provided as is, without express or implied
14
+ ;;; warranty. In no circumstances the author(s) shall be liable
15
+ ;;; for any damages arising out of the use of this software.
16
+ ;;;
17
+ ;;; Subsequently modified for nendo: Kiyoka Nishiyama
18
+ ;;; I removed these functions: (because init.nnd supports it.)
19
+ ;;; alist->hash-table hash-table->alist
20
+
21
+ ;; This module adds useful list utility procedures that are not in SRFI-1.
22
+
23
+ (use srfi-1)
24
+ (use srfi-26)
25
+
26
+ ;;-----------------------------------------------------------------
27
+ ;; permissive take and drop - if the length of given list is shorter
28
+ ;; than index, returns shorter list or fills the rest.
29
+
30
+ (define (split-at* lis k :optional (fill? #f) (filler #f))
31
+ (when (or (not (integer? k)) (negative? k))
32
+ (error "index must be non-negative integer" k))
33
+ (let loop ((i 0)
34
+ (lis lis)
35
+ (r '()))
36
+ (cond [(= i k) (values (reverse! r) lis)]
37
+ [(null? lis)
38
+ (values (if fill?
39
+ (append! (reverse! r) (make-list (- k i) filler))
40
+ (reverse! r))
41
+ lis)]
42
+ [else (loop (+ i 1) (cdr lis) (cons (car lis) r))])))
43
+
44
+ (define (take* lis k . args)
45
+ (receive (h t) (apply split-at* lis k args) h))
46
+
47
+ (define (drop* lis k)
48
+ (when (or (not (integer? k)) (negative? k))
49
+ (error "index must be non-negative integer" k))
50
+ (let loop ((i 0)
51
+ (lis lis))
52
+ (cond [(= i k) lis]
53
+ [(null? lis) '()]
54
+ [else (loop (+ i 1) (cdr lis))])))
55
+
56
+ (define (take-right* lis k :optional (fill? #f) (filler #f))
57
+ (when (or (not (integer? k)) (negative? k))
58
+ (error "index must be non-negative integer" k))
59
+ (let1 len (length lis)
60
+ (cond [(<= k len) (drop lis (- len k))]
61
+ [fill? (append! (make-list (- k len) filler) lis)]
62
+ [else lis])))
63
+
64
+ (define (drop-right* lis k)
65
+ (let1 len (length lis)
66
+ (if (<= k len) (take lis (- len k)) '())))
67
+
68
+ ;;-----------------------------------------------------------------
69
+ ;; slices - split a list to a bunch of sublists of length k
70
+ ;;
71
+
72
+ (define (slices lis k . args)
73
+ (unless (and (integer? k) (positive? k))
74
+ (error "index must be positive integer" k))
75
+ (let loop ((lis lis)
76
+ (r '()))
77
+ (if (null? lis)
78
+ (reverse! r)
79
+ (receive (h t) (apply split-at* lis k args)
80
+ (loop t (cons h r))))))
81
+
82
+ ;;-----------------------------------------------------------------
83
+ ;; intersperse - insert ITEM between elements in the list.
84
+ ;; (the order of arguments is taken from Haskell's intersperse)
85
+
86
+ (define (intersperse item lis)
87
+ (define (rec l r)
88
+ (if (null? l)
89
+ (reverse! r)
90
+ (rec (cdr l) (list* (car l) item r))))
91
+ (if (null? lis)
92
+ '()
93
+ (rec (cdr lis) (list (car lis)))))
94
+
95
+ ;;-----------------------------------------------------------------
96
+ ;; cond-list - a syntax to construct a list
97
+ ;;
98
+ ;; (cond-list clause clause2 ...)
99
+ ;;
100
+ ;; clause : (test expr ...)
101
+ ;; | (test => proc)
102
+ ;; | (test @ expr ...) ;; intersperse
103
+ ;; | (test => @ proc) ;; intersperse
104
+
105
+ (define-syntax cond-list
106
+ (syntax-rules (=> @)
107
+ ((_) '())
108
+ ((_ (test) . rest)
109
+ (let* ((tmp test)
110
+ (r (cond-list . rest)))
111
+ (if tmp (cons tmp r) r)))
112
+ ((_ (test => proc) . rest)
113
+ (let* ((tmp test)
114
+ (r (cond-list . rest)))
115
+ (if tmp (cons (proc tmp) r) r)))
116
+ ((_ (test => @ proc) . rest)
117
+ (let* ((tmp test)
118
+ (r (cond-list . rest)))
119
+ (if tmp (append (proc tmp) r) r)))
120
+ ((_ (test @ . expr) . rest)
121
+ (let* ((tmp test)
122
+ (r (cond-list . rest)))
123
+ (if tmp (append (begin . expr) r) r)))
124
+ ((_ (test . expr) . rest)
125
+ (let* ((tmp test)
126
+ (r (cond-list . rest)))
127
+ (if tmp (cons (begin . expr) r) r)))
128
+ ))
129
+
130
+ ;;-----------------------------------------------------------------
131
+ ;; Associative list library - based on Alex Shinn's implementation
132
+ ;;
133
+
134
+ ;; conversion to/from hash-table
135
+ (define (alist->hash-table a . opt-eq)
136
+ (let ((tb (apply make-hash-table opt-eq)))
137
+ (for-each (lambda (x) (hash-table-put! tb (car x) (cdr x))) a)
138
+ tb))
139
+
140
+ (define (hash-table->alist h)
141
+ (hash-table-map h cons))
142
+
143
+ ;; `reverse' alist search fn
144
+ (define (rassoc key alist :optional (eq equal?))
145
+ (find (lambda (elt) (and (pair? elt) (eq (cdr elt) key))) alist))
146
+
147
+ (define rassq (cut rassoc <> <> eq?))
148
+ (define rassv (cut rassoc <> <> eqv?))
149
+
150
+
151
+ ;; -- These functions are disable for Nendo, because Nendo unsupport
152
+ ;; multi-method dispatch feature.
153
+
154
+ ;; 'assoc-ref', a shortcut of value retrieval w/ default value
155
+ ;; Default parameter comes first, following the convention of
156
+ ;; other *-ref functions.
157
+
158
+ ;;(define (assoc-ref alist key :optional (default #f) (eq equal?))
159
+ ;; (cond [(assoc key alist eq) => cdr]
160
+ ;; [else default]))
161
+ ;;
162
+ ;;(define (assq-ref alist key . opts)
163
+ ;; (assoc-ref alist key (get-optional opts #f) eq?))
164
+ ;;(define (assv-ref alist key . opts)
165
+ ;; (assoc-ref alist key (get-optional opts #f) eqv?))
166
+ ;;
167
+ ;;(define (rassoc-ref alist key :optional (default #f) (eq equal?))
168
+ ;; (cond [(rassoc key alist eq) => car]
169
+ ;; [else default]))
170
+ ;;
171
+ ;;(define (rassq-ref alist key . opts)
172
+ ;; (rassoc-ref alist key (get-optional opts #f) eq?))
173
+ ;;(define (rassv-ref alist key . opts)
174
+ ;; (rassoc-ref alist key (get-optional opts #f) eqv?))
175
+ ;;
176
+ ;;;; 'assoc-set!'
177
+ ;;(define (assoc-set! alist key val :optional (eq equal?))
178
+ ;; (cond [(assoc key alist eq)
179
+ ;; => (lambda (p) (set-cdr! p val) alist)]
180
+ ;; [else (acons key val alist)]))
181
+ ;;
182
+ ;;(define assq-set! (cut assoc-set! <> <> <> eq?))
183
+ ;;(define assv-set! (cut assoc-set! <> <> <> eqv?))
184
+