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 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
43 (define-public START -1)
44 (define-public STOP 1)
45 (define-public LEFT -1)
46 (define-public RIGHT 1)
48 (define-public DOWN -1)
49 (define-public CENTER 0)
51 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
52 ;; lily specific variables.
53 (define-public default-script-alist '())
55 (define-public security-paranoia #f)
56 (if (not (defined? 'standalone))
57 (define-public standalone (not (defined? 'ly-gulp-file))))
60 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
61 ;;; Unassorted utility functions.
63 (define (uniqued-alist alist acc)
65 (if (assoc (caar alist) acc)
66 (uniqued-alist (cdr alist) acc)
67 (uniqued-alist (cdr alist) (cons (car alist) acc)))))
69 (define (other-axis a)
70 (remainder (+ a 1) 2))
73 (define-public (widen-interval iv amount)
74 (cons (- (car iv) amount)
80 (define (index-cell cell dir)
85 (define (cons-map f x)
86 "map F to contents of X"
87 (cons (f (car x)) (f (cdr x))))
90 (define-public (reduce operator list)
91 "reduce OP [A, B, C, D, ... ] =
94 (if (null? (cdr list)) (car list)
95 (operator (car list) (reduce operator (cdr list)))))
97 (define (take-from-list-until todo gathered crit?)
98 "return (G, T), where (reverse G) + T = GATHERED + TODO, and the last of G
99 is the first to satisfy CRIT
101 (take-from-list-until '(1 2 3 4 5) '() (lambda (x) (eq? x 3)))
108 (if (crit? (car todo))
109 (cons (cons (car todo) gathered) (cdr todo))
110 (take-from-list-until (cdr todo) (cons (car todo) gathered) crit?)
119 (define (write-me n x)
128 (define-public (filter-list pred? list)
129 "return that part of LIST for which PRED is true."
131 (let* ((rest (filter-list pred? (cdr list))))
132 (if (pred? (car list))
133 (cons (car list) rest)
136 (define-public (filter-out-list pred? list)
137 "return that part of LIST for which PRED is true."
139 (let* ((rest (filter-list pred? (cdr list))))
140 (if (not (pred? (car list)))
141 (cons (car list) rest)
144 (define-public (uniqued-alist alist acc)
145 (if (null? alist) acc
146 (if (assoc (caar alist) acc)
147 (uniqued-alist (cdr alist) acc)
148 (uniqued-alist (cdr alist) (cons (car alist) acc)))))
150 (define-public (uniq-list list)
152 (if (null? (cdr list))
154 (if (equal? (car list) (cadr list))
155 (uniq-list (cdr list))
156 (cons (car list) (uniq-list (cdr list)))))))
158 (define-public (alist<? x y)
159 (string<? (symbol->string (car x))
160 (symbol->string (car y))))
162 (define-public (pad-string-to str wid)
163 (string-append str (make-string (max (- wid (string-length str)) 0) #\ ))
166 (define-public (ly-load x)
167 (let* ((fn (%search-load-path x)))
169 (format (current-error-port) "[~A]" fn))
170 (primitive-load fn)))
173 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
175 (use-modules (scm tex)
185 ("tex" . ("TeX output. The default output form." ,tex-output-expression))
186 ("ps" . ("Direct postscript. Requires setting GS_LIB and GS_FONTPATH" ,ps-output-expression))
187 ("scm" . ("Scheme dump: debug scheme molecule expressions" ,write))
188 ("as" . ("Asci-script. Postprocess with as2txt to get ascii art" ,as-output-expression))
189 ("sketch" . ("Bare bones Sketch output. Requires sketch 0.7" ,sketch-output-expression))
190 ("pdftex" . ("PDFTeX output. Was last seen nonfunctioning." ,pdftex-output-expression))
194 (define (document-format-dumpers)
197 (display (string-append (pad-string-to 5 (car x)) (cadr x) "\n"))
201 (define-public (find-dumper format )
203 ((d (assoc format output-alist)))
207 (scm-error "Could not find dumper for format ~s" format))
210 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
221 "grob-property-description.scm"
222 "context-description.scm"
223 "interface-description.scm"
228 "music-functions.scm"
229 "music-property-description.scm"
231 "basic-properties.scm"
233 "grob-description.scm"
234 "translator-property-description.scm"