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.
15 ;(debug-enable 'debug)
16 ;(debug-enable 'backtrace)
17 ;(read-enable 'positions)
20 (define-public (line-column-location line col file)
21 "Print an input location, including column number ."
22 (string-append (number->string line) ":"
23 (number->string col) " " file)
26 (define-public (line-location line col file)
27 "Print an input location, without column number ."
28 (string-append (number->string line) " " file)
31 ;; cpp hack to get useful error message
32 (define ifdef "First run this through cpp.")
33 (define ifndef "First run this through cpp.")
36 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
46 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
47 ;; lily specific variables.
48 (define-public default-script-alist '())
50 (define-public security-paranoia #f)
51 (if (not (defined? 'standalone))
52 (define-public standalone (not (defined? 'ly-gulp-file))))
55 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
56 ;;; Unassorted utility functions.
58 (define (uniqued-alist alist acc)
60 (if (assoc (caar alist) acc)
61 (uniqued-alist (cdr alist) acc)
62 (uniqued-alist (cdr alist) (cons (car alist) acc)))))
64 (define (other-axis a)
65 (remainder (+ a 1) 2))
68 (define-public (widen-interval iv amount)
69 (cons (- (car iv) amount)
75 (define (index-cell cell dir)
80 (define (cons-map f x)
81 "map F to contents of X"
82 (cons (f (car x)) (f (cdr x))))
85 (define-public (reduce operator list)
86 "reduce OP [A, B, C, D, ... ] =
89 (if (null? (cdr list)) (car list)
90 (operator (car list) (reduce operator (cdr list)))))
92 (define (take-from-list-until todo gathered crit?)
93 "return (G, T), where (reverse G) + T = GATHERED + TODO, and the last of G
94 is the first to satisfy CRIT
96 (take-from-list-until '(1 2 3 4 5) '() (lambda (x) (eq? x 3)))
103 (if (crit? (car todo))
104 (cons (cons (car todo) gathered) (cdr todo))
105 (take-from-list-until (cdr todo) (cons (car todo) gathered) crit?)
114 (define (write-me n x)
123 (define-public (filter-list pred? list)
124 "return that part of LIST for which PRED is true."
126 (let* ((rest (filter-list pred? (cdr list))))
127 (if (pred? (car list))
128 (cons (car list) rest)
131 (define-public (filter-out-list pred? list)
132 "return that part of LIST for which PRED is true."
134 (let* ((rest (filter-list pred? (cdr list))))
135 (if (not (pred? (car list)))
136 (cons (car list) rest)
139 (define-public (uniqued-alist alist acc)
140 (if (null? alist) acc
141 (if (assoc (caar alist) acc)
142 (uniqued-alist (cdr alist) acc)
143 (uniqued-alist (cdr alist) (cons (car alist) acc)))))
145 (define-public (uniq-list list)
147 (if (null? (cdr list))
149 (if (equal? (car list) (cadr list))
150 (uniq-list (cdr list))
151 (cons (car list) (uniq-list (cdr list)))))))
153 (define-public (alist<? x y)
154 (string<? (symbol->string (car x))
155 (symbol->string (car y))))
157 (define-public (pad-string-to str wid)
158 (string-append str (make-string (max (- wid (string-length str)) 0) #\ ))
162 (let* ((fn (%search-load-path x)))
164 (format (current-error-port) "[~A]" fn))
165 (primitive-load fn)))
168 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
170 (use-modules (scm tex)
180 ("tex" . ("TeX output. The default output form." ,tex-output-expression))
181 ("ps" . ("Direct postscript. Requires setting GS_LIB and GS_FONTPATH" ,ps-output-expression))
182 ("scm" . ("Scheme dump: debug scheme molecule expressions" ,write))
183 ("as" . ("Asci-script. Postprocess with as2txt to get ascii art" ,as-output-expression))
184 ("sketch" . ("Bare bones Sketch output. Requires sketch 0.7" ,sketch-output-expression))
185 ("pdftex" . ("PDFTeX output. Was last seen nonfunctioning." ,pdftex-output-expression))
189 (define (document-format-dumpers)
192 (display (string-append (pad-string-to 5 (car x)) (cadr x) "\n"))
196 (define-public (find-dumper format )
198 ((d (assoc format output-alist)))
202 (scm-error "Could not find dumper for format ~s" format))
205 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
215 "grob-property-description.scm"
216 "context-description.scm"
217 "interface-description.scm"
222 "music-functions.scm"
223 "music-property-description.scm"
225 "basic-properties.scm"
227 "grob-description.scm"
228 "translator-property-description.scm"