1 %% Toplevel initialisation file.
3 %% switch on debugging.
4 #(if (and #t (defined? 'set-debug-cell-accesses!))
5 (set-debug-cell-accesses! 5000))
11 ;; we can't use ly:parser-include-string here since that does not
12 ;; actually do any parsing but merely switches inputs, so the
13 ;; session saved by the session initializer after calling this
14 ;; function has not actually started. A parser clone, in contrast,
15 ;; can run and complete synchronously and shares the module with
16 ;; the current parser.
17 (ly:parser-parse-string (ly:parser-clone parser)
18 "\\include \"declarations-init.ly\"")))
20 #(note-names-language parser default-language)
23 #(define toplevel-scores (list))
24 #(define toplevel-bookparts (list))
25 #(define $defaultheader #f)
26 #(define $current-book #f)
27 #(define $current-bookpart #f)
28 #(define version-seen #f)
29 #(define expect-error #f)
30 #(define output-empty-score-list #f)
31 #(define output-suffix #f)
32 #(hash-clear! default-fret-table)
33 #(hash-clear! chord-shape-table)
34 #(hash-clear! musicQuotes)
36 #(use-modules (scm clip-region))
37 #(use-modules (srfi srfi-1))
39 $(if (ly:get-option 'include-settings)
40 (ly:parser-include-string parser
41 (format #f "\\include \"~a\"" (ly:get-option 'include-settings))))
44 %% there is a problem at the end of the input file
47 %% Above and below comments compensate for the parser's look-ahead.
50 #(if (and (not version-seen)
51 (defined? 'input-file-name))
52 (version-not-seen-message input-file-name))
54 #(ly:set-option 'protected-scheme-parsing #f)
56 #(let ((book-handler (if (defined? 'default-toplevel-book-handler)
57 default-toplevel-book-handler
58 toplevel-book-handler)))
59 (cond ((pair? toplevel-bookparts)
60 (let ((book (ly:make-book $defaultpaper $defaultheader)))
62 (ly:book-add-bookpart! book part))
63 (reverse! toplevel-bookparts))
64 (set! toplevel-bookparts (list))
65 ;; if scores have been defined after the last explicit \bookpart:
66 (if (pair? toplevel-scores)
68 (ly:book-add-score! book score))
69 (reverse! toplevel-scores)))
70 (set! toplevel-scores (list))
71 (book-handler parser book)))
72 ((or (pair? toplevel-scores) output-empty-score-list)
73 (let ((book (apply ly:make-book $defaultpaper
74 $defaultheader toplevel-scores)))
75 (set! toplevel-scores (list))
76 (book-handler parser book)))))
78 #(if (eq? expect-error (ly:parser-has-error? parser))
79 (ly:parser-clear-error parser)
81 (ly:parser-error parser (_ "expected error, but none found"))))