1 ;;;; lily.scm -- implement Scheme output routines for TeX and PostScript
3 ;;;; source file of the GNU LilyPond music typesetter
5 ;;;; (c) 1998--2001 Jan Nieuwenhuizen <janneke@gnu.org>
6 ;;;; Han-Wen Nienhuys <hanwen@cs.uu.nl>
10 (use-modules (ice-9 regex))
12 ;;(write standalone (current-error-port))
16 ;; debugging evaluator is slower.
19 ;(debug-enable 'backtrace)
20 (read-enable 'positions)
23 (define-public (line-column-location line col file)
24 "Print an input location, including column number ."
25 (string-append (number->string line) ":"
26 (number->string col) " " file)
29 (define-public (line-location line col file)
30 "Print an input location, without column number ."
31 (string-append (number->string line) " " file)
34 ;; cpp hack to get useful error message
35 (define ifdef "First run this through cpp.")
36 (define ifndef "First run this through cpp.")
39 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
49 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
50 ;; lily specific variables.
51 (define-public default-script-alist '())
53 (define-public security-paranoia #f)
54 (if (not (defined? 'standalone))
55 (define-public standalone (not (defined? 'ly-gulp-file))))
58 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
59 ;;; Unassorted utility functions.
61 (define (uniqued-alist alist acc)
63 (if (assoc (caar alist) acc)
64 (uniqued-alist (cdr alist) acc)
65 (uniqued-alist (cdr alist) (cons (car alist) acc)))))
67 (define (other-axis a)
68 (remainder (+ a 1) 2))
71 (define-public (widen-interval iv amount)
72 (cons (- (car iv) amount)
78 (define (index-cell cell dir)
83 (define (cons-map f x)
84 "map F to contents of X"
85 (cons (f (car x)) (f (cdr x))))
88 (define-public (reduce operator list)
89 "reduce OP [A, B, C, D, ... ] =
92 (if (null? (cdr list)) (car list)
93 (operator (car list) (reduce operator (cdr list)))))
95 (define (take-from-list-until todo gathered crit?)
96 "return (G, T), where (reverse G) + T = GATHERED + TODO, and the last of G
97 is the first to satisfy CRIT
99 (take-from-list-until '(1 2 3 4 5) '() (lambda (x) (eq? x 3)))
106 (if (crit? (car todo))
107 (cons (cons (car todo) gathered) (cdr todo))
108 (take-from-list-until (cdr todo) (cons (car todo) gathered) crit?)
117 (define (write-me n x)
126 (define-public (filter-list pred? list)
127 "return that part of LIST for which PRED is true."
129 (let* ((rest (filter-list pred? (cdr list))))
130 (if (pred? (car list))
131 (cons (car list) rest)
134 (define-public (filter-out-list pred? list)
135 "return that part of LIST for which PRED is true."
137 (let* ((rest (filter-list pred? (cdr list))))
138 (if (not (pred? (car list)))
139 (cons (car list) rest)
142 (define-public (uniqued-alist alist acc)
143 (if (null? alist) acc
144 (if (assoc (caar alist) acc)
145 (uniqued-alist (cdr alist) acc)
146 (uniqued-alist (cdr alist) (cons (car alist) acc)))))
148 (define-public (uniq-list list)
150 (if (null? (cdr list))
152 (if (equal? (car list) (cadr list))
153 (uniq-list (cdr list))
154 (cons (car list) (uniq-list (cdr list)))))))
156 (define-public (alist<? x y)
157 (string<? (symbol->string (car x))
158 (symbol->string (car y))))
160 (define-public (pad-string-to str wid)
161 (string-append str (make-string (max (- wid (string-length str)) 0) #\ ))
164 (define-public (ly-load x)
165 (let* ((fn (%search-load-path x)))
167 (format (current-error-port) "[~A]" fn))
168 (primitive-load fn)))
171 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
173 (use-modules (scm tex)
183 ("tex" . ("TeX output. The default output form." ,tex-output-expression))
184 ("ps" . ("Direct postscript. Requires setting GS_LIB and GS_FONTPATH" ,ps-output-expression))
185 ("scm" . ("Scheme dump: debug scheme molecule expressions" ,write))
186 ("as" . ("Asci-script. Postprocess with as2txt to get ascii art" ,as-output-expression))
187 ("sketch" . ("Bare bones Sketch output. Requires sketch 0.7" ,sketch-output-expression))
188 ("pdftex" . ("PDFTeX output. Was last seen nonfunctioning." ,pdftex-output-expression))
192 (define (document-format-dumpers)
195 (display (string-append (pad-string-to 5 (car x)) (cadr x) "\n"))
199 (define-public (find-dumper format )
201 ((d (assoc format output-alist)))
205 (scm-error "Could not find dumper for format ~s" format))
208 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
219 "grob-property-description.scm"
220 "context-description.scm"
221 "interface-description.scm"
226 "music-functions.scm"
227 "music-property-description.scm"
229 "basic-properties.scm"
231 "grob-description.scm"
232 "translator-property-description.scm"