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 (ly:undead? 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 (ly:undead? lilypond-declarations)
25 (if (ly:output-def? val)
26 (ly:output-def-clone val)
28 (module-add! (current-module) (car p) var)))
29 (ly:get-undead lilypond-declarations))
30 (note-names-language parser default-language))
34 (let ((val (variable-ref v)))
35 (if (not (ly:lily-parser? val))
40 (if (ly:output-def? val)
41 (ly:output-def-clone val)
45 (set! lilypond-declarations (ly:make-undead decl)))))
47 #(ly:set-option 'old-relative #f)
48 #(define toplevel-scores (list))
49 #(define toplevel-bookparts (list))
50 #(define $defaultheader #f)
51 #(define $current-book #f)
52 #(define $current-bookpart #f)
53 #(define version-seen #f)
54 #(define expect-error #f)
55 #(define output-empty-score-list #f)
56 #(define output-suffix #f)
57 #(hash-clear! default-fret-table)
58 #(hash-clear! chord-shape-table)
59 #(hash-clear! musicQuotes)
61 #(use-modules (scm clip-region))
62 #(use-modules (srfi srfi-1))
64 $(if (ly:get-option 'include-settings)
65 (ly:parser-include-string parser
66 (format #f "\\include \"~a\"" (ly:get-option 'include-settings))))
69 %% there is a problem at the end of the input file
72 %% Above and below comments compensate for the parser's look-ahead.
75 #(if (and (ly:get-option 'old-relative)
76 (defined? 'input-file-name)
77 (not (ly:get-option 'old-relative-used)))
78 (old-relative-not-used-message input-file-name))%% there is a problem at the end of the input file
80 #(if (and (not version-seen)
81 (defined? 'input-file-name))
82 (version-not-seen-message input-file-name))
84 #(ly:set-option 'protected-scheme-parsing #f)
86 #(let ((book-handler (if (defined? 'default-toplevel-book-handler)
87 default-toplevel-book-handler
88 toplevel-book-handler)))
89 (cond ((pair? toplevel-bookparts)
90 (let ((book (ly:make-book $defaultpaper $defaultheader)))
92 (ly:book-add-bookpart! book part))
93 (reverse! toplevel-bookparts))
94 (set! toplevel-bookparts (list))
95 ;; if scores have been defined after the last explicit \bookpart:
96 (if (pair? toplevel-scores)
98 (ly:book-add-score! book score))
99 (reverse! toplevel-scores)))
100 (set! toplevel-scores (list))
101 (book-handler parser book)))
102 ((or (pair? toplevel-scores) output-empty-score-list)
103 (let ((book (apply ly:make-book $defaultpaper
104 $defaultheader toplevel-scores)))
105 (set! toplevel-scores (list))
106 (book-handler parser book)))))
108 #(if (eq? expect-error (ly:parser-has-error? parser))
109 (ly:parser-clear-error parser)
111 (ly:parser-error parser (_ "expected error, but none found"))))