1 ;;;; lily.scm -- implement Scheme output routines for TeX and PostScript
3 ;;;; source file of the GNU LilyPond music typesetter
5 ;;;; (c) 1998--2002 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 (define-public point-and-click #f)
36 ;; cpp hack to get useful error message
37 (define ifdef "First run this through cpp.")
38 (define ifndef "First run this through cpp.")
42 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
46 (define-public START -1)
47 (define-public STOP 1)
48 (define-public LEFT -1)
49 (define-public RIGHT 1)
51 (define-public DOWN -1)
52 (define-public CENTER 0)
54 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
55 ;; lily specific variables.
56 (define-public default-script-alist '())
58 (define-public security-paranoia #f)
59 (if (not (defined? 'standalone))
60 (define-public standalone (not (defined? 'ly-gulp-file))))
63 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
64 ;;; Unassorted utility functions.
66 (define (uniqued-alist alist acc)
68 (if (assoc (caar alist) acc)
69 (uniqued-alist (cdr alist) acc)
70 (uniqued-alist (cdr alist) (cons (car alist) acc)))))
72 (define (other-axis a)
73 (remainder (+ a 1) 2))
76 (define-public (widen-interval iv amount)
77 (cons (- (car iv) amount)
83 (define (index-cell cell dir)
88 (define (cons-map f x)
89 "map F to contents of X"
90 (cons (f (car x)) (f (cdr x))))
93 (define-public (reduce operator list)
94 "reduce OP [A, B, C, D, ... ] =
97 (if (null? (cdr list)) (car list)
98 (operator (car list) (reduce operator (cdr list)))))
100 (define (take-from-list-until todo gathered crit?)
101 "return (G, T), where (reverse G) + T = GATHERED + TODO, and the last of G
102 is the first to satisfy CRIT
104 (take-from-list-until '(1 2 3 4 5) '() (lambda (x) (eq? x 3)))
111 (if (crit? (car todo))
112 (cons (cons (car todo) gathered) (cdr todo))
113 (take-from-list-until (cdr todo) (cons (car todo) gathered) crit?)
122 (define (write-me n x)
131 (define-public (filter-list pred? list)
132 "return that part of LIST for which PRED is true."
134 (let* ((rest (filter-list pred? (cdr list))))
135 (if (pred? (car list))
136 (cons (car list) rest)
139 (define-public (filter-out-list pred? list)
140 "return that part of LIST for which PRED is true."
142 (let* ((rest (filter-list pred? (cdr list))))
143 (if (not (pred? (car list)))
144 (cons (car list) rest)
147 (define-public (uniqued-alist alist acc)
148 (if (null? alist) acc
149 (if (assoc (caar alist) acc)
150 (uniqued-alist (cdr alist) acc)
151 (uniqued-alist (cdr alist) (cons (car alist) acc)))))
153 (define-public (uniq-list list)
155 (if (null? (cdr list))
157 (if (equal? (car list) (cadr list))
158 (uniq-list (cdr list))
159 (cons (car list) (uniq-list (cdr list)))))))
161 (define-public (alist<? x y)
162 (string<? (symbol->string (car x))
163 (symbol->string (car y))))
165 (define-public (pad-string-to str wid)
166 (string-append str (make-string (max (- wid (string-length str)) 0) #\ ))
169 (define-public (ly-load x)
170 (let* ((fn (%search-load-path x)))
172 (format (current-error-port) "[~A]" fn))
173 (primitive-load fn)))
176 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
178 (use-modules (scm tex)
188 ("tex" . ("TeX output. The default output form." ,tex-output-expression))
189 ("ps" . ("Direct postscript. Requires setting GS_LIB and GS_FONTPATH" ,ps-output-expression))
190 ("scm" . ("Scheme dump: debug scheme molecule expressions" ,write))
191 ("as" . ("Asci-script. Postprocess with as2txt to get ascii art" ,as-output-expression))
192 ("sketch" . ("Bare bones Sketch output. Requires sketch 0.7" ,sketch-output-expression))
193 ("pdftex" . ("PDFTeX output. Was last seen nonfunctioning." ,pdftex-output-expression))
197 (define (document-format-dumpers)
200 (display (string-append (pad-string-to 5 (car x)) (cadr x) "\n"))
204 (define-public (find-dumper format )
206 ((d (assoc format output-alist)))
210 (scm-error "Could not find dumper for format ~s" format))
213 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
224 "grob-property-description.scm"
225 "context-description.scm"
226 "interface-description.scm"
231 "music-functions.scm"
232 "music-property-description.scm"
234 "basic-properties.scm"
236 "grob-description.scm"
237 "translator-property-description.scm"