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))
13 ;; debugging evaluator is slower.
16 ;(debug-enable 'backtrace)
17 (read-enable 'positions)
21 (define-public (line-column-location line col file)
22 "Print an input location, including column number ."
23 (string-append (number->string line) ":"
24 (number->string col) " " file)
27 (define-public (line-location line col file)
28 "Print an input location, without column number ."
29 (string-append (number->string line) " " file)
32 ;; cpp hack to get useful error message
33 (define ifdef "First run this through cpp.")
34 (define ifndef "First run this through cpp.")
37 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
47 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
48 ;; lily specific variables.
49 (define-public default-script-alist '())
51 (define-public security-paranoia #f)
52 (if (not (defined? 'standalone))
53 (define-public standalone (not (defined? 'ly-gulp-file))))
56 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
57 ;;; Unassorted utility functions.
59 (define (uniqued-alist alist acc)
61 (if (assoc (caar alist) acc)
62 (uniqued-alist (cdr alist) acc)
63 (uniqued-alist (cdr alist) (cons (car alist) acc)))))
65 (define (other-axis a)
66 (remainder (+ a 1) 2))
69 (define-public (widen-interval iv amount)
70 (cons (- (car iv) amount)
76 (define (index-cell cell dir)
81 (define (cons-map f x)
82 "map F to contents of X"
83 (cons (f (car x)) (f (cdr x))))
86 (define (reduce operator list)
87 "reduce OP [A, B, C, D, ... ] =
90 (if (null? (cdr list)) (car list)
91 (operator (car list) (reduce operator (cdr list)))))
93 (define (take-from-list-until todo gathered crit?)
94 "return (G, T), where (reverse G) + T = GATHERED + TODO, and the last of G
95 is the first to satisfy CRIT
97 (take-from-list-until '(1 2 3 4 5) '() (lambda (x) (eq? x 3)))
104 (if (crit? (car todo))
105 (cons (cons (car todo) gathered) (cdr todo))
106 (take-from-list-until (cdr todo) (cons (car todo) gathered) crit?)
115 (define (write-me n x)
124 (define (filter-list pred? list)
125 "return that part of LIST for which PRED is true."
127 (let* ((rest (filter-list pred? (cdr list))))
128 (if (pred? (car list))
129 (cons (car list) rest)
132 (define (filter-out-list pred? list)
133 "return that part of LIST for which PRED is true."
135 (let* ((rest (filter-list pred? (cdr list))))
136 (if (not (pred? (car list)))
137 (cons (car list) rest)
140 (define (uniqued-alist alist acc)
141 (if (null? alist) acc
142 (if (assoc (caar alist) acc)
143 (uniqued-alist (cdr alist) acc)
144 (uniqued-alist (cdr alist) (cons (car alist) acc)))))
146 (define-public (uniq-list list)
148 (if (null? (cdr list))
150 (if (equal? (car list) (cadr list))
151 (uniq-list (cdr list))
152 (cons (car list) (uniq-list (cdr list)))))))
154 (define-public (alist<? x y)
155 (string<? (symbol->string (car x))
156 (symbol->string (car y))))
158 (define-public (pad-string-to str wid)
159 (string-append str (make-string (max (- wid (string-length str)) 0) #\ ))
163 (let* ((fn (%search-load-path x)))
165 (format (current-error-port) "[~A]" fn))
166 (primitive-load fn)))
169 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
171 (use-modules (scm tex)
181 ("tex" . ("TeX output. The default output form." ,tex-output-expression))
182 ("ps" . ("Direct postscript. Requires setting GS_LIB and GS_FONTPATH" ,ps-output-expression))
183 ("scm" . ("Scheme dump: debug scheme molecule expressions" ,write))
184 ("as" . ("Asci-script. Postprocess with as2txt to get ascii art" ,as-output-expression))
185 ("sketch" . ("Bare bones Sketch output. Requires sketch 0.7" ,sketch-output-expression))
186 ("pdftex" . ("PDFTeX output. Was last seen nonfunctioning." ,pdftex-output-expression))
190 (define (document-format-dumpers)
193 (display (string-append (pad-string-to 5 (car x)) (cadr x) "\n"))
197 (define-public (find-dumper format )
199 ((d (assoc format output-alist)))
203 (scm-error "Could not find dumper for format ~s" format))
206 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
216 "grob-property-description.scm"
217 "context-description.scm"
218 "interface-description.scm"
223 "music-functions.scm"
224 "music-property-description.scm"
226 "basic-properties.scm"
228 "grob-description.scm"
229 "translator-property-description.scm"