1 %% Toplevel initialisation file.
3 %% switch on debugging.
4 #(if (and #t (defined? 'set-debug-cell-accesses!))
5 (set-debug-cell-accesses! 5000))
9 #(if (not (pair? lilypond-declarations))
10 (ly:parser-include-string parser
11 "\\include \"declarations-init.ly\""))
13 %% We need to save the variables of the current module along with
14 %% their values: functions defined in the module might refer to the
17 #(if lilypond-declarations
18 (if (pair? lilypond-declarations)
25 (if (ly:output-def? val)
26 (ly:output-def-clone val)
28 (module-add! (current-module) (car p) var)))
29 lilypond-declarations)
30 (note-names-language parser default-language))
33 (let ((val (variable-ref v)))
34 (if (not (ly:lily-parser? val))
35 (set! lilypond-declarations
39 (if (ly:output-def? val)
40 (ly:output-def-clone val)
42 lilypond-declarations)))))
45 #(ly:set-option 'old-relative #f)
46 #(define toplevel-scores (list))
47 #(define toplevel-bookparts (list))
48 #(define $defaultheader #f)
49 #(define $current-book #f)
50 #(define $current-bookpart #f)
51 #(define version-seen #f)
52 #(define expect-error #f)
53 #(define output-empty-score-list #f)
54 #(define output-suffix #f)
55 #(hash-clear! default-fret-table)
56 #(hash-clear! chord-shape-table)
57 #(hash-clear! musicQuotes)
59 #(use-modules (scm clip-region))
60 #(use-modules (srfi srfi-1))
62 $(if (ly:get-option 'include-settings)
63 (ly:parser-include-string parser
64 (format #f "\\include \"~a\"" (ly:get-option 'include-settings))))
67 %% there is a problem at the end of the input file
70 %% Above and below comments compensate for the parser's look-ahead.
73 #(if (and (ly:get-option 'old-relative)
74 (defined? 'input-file-name)
75 (not (ly:get-option 'old-relative-used)))
76 (old-relative-not-used-message input-file-name))%% there is a problem at the end of the input file
78 #(if (and (not version-seen)
79 (defined? 'input-file-name))
80 (version-not-seen-message input-file-name))
82 #(ly:set-option 'protected-scheme-parsing #f)
84 #(let ((book-handler (if (defined? 'default-toplevel-book-handler)
85 default-toplevel-book-handler
86 toplevel-book-handler)))
87 (cond ((pair? toplevel-bookparts)
88 (let ((book (ly:make-book $defaultpaper $defaultheader)))
90 (ly:book-add-bookpart! book part))
91 (reverse! toplevel-bookparts))
92 (set! toplevel-bookparts (list))
93 ;; if scores have been defined after the last explicit \bookpart:
94 (if (pair? toplevel-scores)
96 (ly:book-add-score! book score))
97 (reverse! toplevel-scores)))
98 (set! toplevel-scores (list))
99 (book-handler parser book)))
100 ((or (pair? toplevel-scores) output-empty-score-list)
101 (let ((book (apply ly:make-book $defaultpaper
102 $defaultheader toplevel-scores)))
103 (set! toplevel-scores (list))
104 (book-handler parser book)))))
106 #(if (eq? expect-error (ly:parser-has-error? parser))
107 (ly:parser-clear-error parser)
109 (ly:parser-error parser (_ "expected error, but none found"))))