blob: 983b4c3a926317d07ddbd81f8c1fd626314d8710 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
|
%% Autogenerate a list of LilyPond keywords
\version "2.23.6"
#(use-modules (ice-9 receive)
(ice-9 regex))
#(define port (open-output-file "../pygments/lexers/_lilypond_builtins.py"))
#(define output-preamble
"\"\"\"
pygments.lexers._lilypond_builtins
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
LilyPond builtins.
:copyright: Copyright 2006-2022 by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
\"\"\"
# Contents generated by the script lilypond-builtins-generator.ly
# found in the external/ directory of the source tree.
")
#(format port "~a" output-preamble)
#(define (dump-py-list name vals)
(let* ((string-vals
(map symbol->string vals))
(fixed-vals
(filter-map
(lambda (str)
; To avoid conflicts with Scheme builtins,
; a leading backslash is prepended to \<,
; \= and a few others. The lexer finds it
; itself, so remove it here.
(cond
((equal? str "\\\\")
#f)
((string-startswith str "\\")
(string-drop str 1))
(else
str)))
string-vals))
(sorted-vals ; reproducibility
; Avoid duplicates (e.g., identical pitches
; in different languages)
(uniq-list
(sort fixed-vals string<?)))
(formatted-vals
(map
(lambda (val)
(format #f " \"~a\"," val name))
sorted-vals))
(joint-vals
(string-join formatted-vals "\n")))
(format port
"~a = [
~a
]
"
name
joint-vals)))
%% KEYWORDS
#(define keywords
'(
; Lexical modes.
notemode
lyricmode
lyricsto
addlyrics
chordmode
chords
figuremode
figures
drummode
drums
; Output definitions.
header
layout
midi
paper
; Context definitions.
;; \context is also used in music. We take it as
;; a keyword in both cases.
context
with
name
type
accepts
denies
alias
defaultchild
consists
remove
description
;; Not strictly a keyword, but can be viewed so.
inherit-acceptability
; Blocks.
book
bookpart
score
; Other.
new
etc
include
language
version))
#(dump-py-list 'keywords keywords)
%% CLEFS
#(define all-clefs
(map string->symbol (map car supported-clefs)))
#(dump-py-list 'clefs all-clefs)
%% SCALES
#(define all-scales
'(major
minor
ionian
locrian
aeolian
mixolydian
lydian
phrygian
dorian))
#(dump-py-list 'scales all-scales)
%% REPEAT TYPES
#(define all-repeat-types
'(volta percent unfold segno))
#(dump-py-list 'repeat_types all-repeat-types)
%% UNITS
#(define all-units
'(mm cm in pt staff-space))
#(dump-py-list 'units all-units)
%% CHORD MODIFIERS
#(define all-chord-modifiers
'(m dim aug maj))
#(dump-py-list 'chord_modifiers all-chord-modifiers)
%% PITCHES
#(define all-pitch-language-names
(map car language-pitch-names))
#(dump-py-list 'pitch_language_names all-pitch-language-names)
#(define all-pitch-names
(append
; We highlight rests just like pitches.
'(r R)
(map car (append-map cdr language-pitch-names))
; Drum note names.
(map car drumPitchNames)))
#(dump-py-list 'pitches all-pitch-names)
%% MUSIC FUNCTIONS AND SHORTCUTS
% View these as music functions.
#(define extra-music-functions
'(set
unset
override
revert
tweak
once
undo
temporary
repeat
alternative
tempo
change))
#(let* ((module (current-module))
(module-alist (ly:module->alist module))
(all-music-functions
(filter
(lambda (entry)
(ly:music-function? (cdr entry)))
module-alist))
(all-predefined-music-objects
(filter
(lambda (entry)
(ly:music? (cdr entry)))
module-alist)))
(receive (articulations non-articulations)
(partition
(lambda (entry)
(ly:event? (cdr entry)))
all-predefined-music-objects)
(receive (dynamics non-dynamic-articulations)
(partition
(lambda (entry)
(any
(lambda (type)
(music-is-of-type? (cdr entry)
type))
'(dynamic-event crescendo-event decrescendo-event)))
articulations)
(dump-py-list 'music_functions
(append extra-music-functions
(map car all-music-functions)))
(dump-py-list 'dynamics (map car dynamics))
(dump-py-list 'articulations (map car non-dynamic-articulations))
(dump-py-list 'music_commands (map car non-articulations)))))
%% MARKUP COMMANDS
#(let* ((markup-name-regexp
(make-regexp "(.*)-markup(-list)?"))
(modules
(cons (current-module)
(map resolve-module '((lily) (lily accreg)))))
(alist
(apply append
(map ly:module->alist modules)))
(markup-commands
(filter
(lambda (entry)
(or (markup-function? (cdr entry))
(markup-list-function? (cdr entry))))
alist))
(markup-command-names
(map
(lambda (entry)
(let* ((string-name (symbol->string (car entry)))
(match (regexp-exec markup-name-regexp string-name)))
(string->symbol (match:substring match 1))))
markup-commands))
(markup-words
(append '(markup markuplist)
markup-command-names)))
(dump-py-list 'markup_commands markup-words))
%% GROBS
#(let ((grob-names (map car all-grob-descriptions)))
(dump-py-list 'grobs grob-names))
%% CONTEXTS
#(let* ((layout-module
(ly:output-def-scope $defaultlayout))
(layout-alist
(ly:module->alist layout-module))
(all-context-defs
(filter
(lambda (entry)
(ly:context-def? (cdr entry)))
layout-alist))
(context-def-names
(map car all-context-defs)))
(dump-py-list 'contexts context-def-names))
%% TRANSLATORS
#(let* ((all-translators
(ly:get-all-translators))
(translator-names
(map ly:translator-name all-translators)))
(dump-py-list 'translators translator-names))
%% SCHEME FUNCTIONS
#(let* ((module (resolve-module '(lily)))
(module-alist (ly:module->alist module))
(all-functions
(filter
(lambda (entry)
(or (procedure? (cdr entry))
(macro? (cdr entry))))
module-alist))
(all-function-names
(map car all-functions)))
(dump-py-list 'scheme_functions all-function-names))
%% PROPERTIES
#(dump-py-list 'context_properties all-translation-properties)
#(dump-py-list 'grob_properties all-backend-properties)
%% PAPER VARIABLES
% Reference: https://lilypond.org/doc/v2.22/Documentation/notation/page-layout
#(define all-paper-variables
'(paper-height
top-margin
bottom-margin
ragged-bottom
ragged-last-bottom
markup-system-spacing
score-markup-spacing
score-system-spacing
system-system-spacing
markup-markup-spacing
last-bottom-spacing
top-system-spacing
top-markup-spacing
paper-width
line-width
left-margin
right-margin
check-consistency
ragged-right
ragged-last
two-sided
inner-margin
outer-margin
binding-offset
horizontal-shift
indent
short-indent
max-systems-per-page
min-systems-per-page
systems-per-page
system-count
page-breaking
page-breaking-system-system-spacing
page-count
blank-page-penalty
blank-last-page-penalty
auto-first-page-number
first-page-number
print-first-page-number
page-number-type
page-spacing-weight
print-all-headers
system-separator-markup
footnote-separator-markup
;; Let's view these four as \paper variables.
basic-distance
minimum-distance
padding
stretchability
;; These were forgotten in the documentation.
evenHeaderMarkup
oddHeaderMarkup
evenFooterMarkup
oddFooterMarkup
bookTitleMarkup
scoreTitleMarkup
))
#(dump-py-list 'paper_variables all-paper-variables)
%% HEADER VARIABLES
% Reference: https://lilypond.org/doc/v2.22/Documentation/notation/creating-titles-headers-and-footers.html#default-layout-of-bookpart-and-score-titles
#(define all-header-variables
'(dedication
title
subtitle
subsubtitle
instrument
poet
composer
meter
arranger
tagline
copyright
piece
opus
; The following are used in LSR snippets and regression tests.
lsrtags
doctitle
texidoc))
#(dump-py-list 'header_variables all-header-variables)
#(close-port port)
|