Skip to content

Commit ec2dccc

Browse files
committed
Merge remote-tracking branch 'origin/ul/parser-syntax-change'
2 parents 10825a4 + 6ad33d0 commit ec2dccc

File tree

7 files changed

+116
-43
lines changed

7 files changed

+116
-43
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,4 @@ script: ./test/automated_tests.py
4040
# during the installation and test scripts
4141
env:
4242
- LILY_PLATFORM=linux-64 LILY_VERSION=2.18.2-1
43-
- LILY_PLATFORM=linux-64 LILY_VERSION=2.19.17-1
43+
- LILY_PLATFORM=linux-64 LILY_VERSION=2.19.22-1

ly/_internal/module-handling.ily

Lines changed: 36 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,6 @@ declareLibrary =
159159
))
160160
options)))
161161

162-
163162
% Initialize a library before first use.
164163
% This also serves as a kind of declaration of the intent of using it.
165164
% If options are passed in a \with {} clause they are set after in
@@ -192,8 +191,10 @@ useLibrary =
192191
(if (file-exists? init-file)
193192
(begin
194193
(oll:log location "Initialize library \"~a\" ..." display-name)
195-
(ly:parser-include-string parser
196-
(format "\\include \"~a\"" init-file))))
194+
(let ((arg (format "\\include \"~a\"" init-file)))
195+
(if (lilypond-greater-than? "2.19.21")
196+
(ly:parser-include-string arg)
197+
(ly:parser-include-string parser arg)))))
197198

198199
;; If a \with clause has been given pass the options to the library.
199200
;; If the options have not been registered in the __init__ file this
@@ -210,13 +211,16 @@ useLibrary =
210211
(if (file-exists? main-file)
211212
(begin
212213
; (ly:parser-include-string parser (ly:gulp-file main-file))
213-
(ly:parser-include-string parser
214-
(format "\\include \"~a\"" main-file))
214+
(let ((arg (format "\\include \"~a\"" main-file)))
215+
(if (lilypond-greater-than? "2.19.21")
216+
(ly:parser-include-string arg)
217+
(ly:parser-include-string parser arg))
218+
215219
(set! oll-loaded-libraries
216220
(append oll-loaded-libraries
217221
`(,name)))
218222
(oll:log "... completed." ""))
219-
(oll:warn location (format "Library main file \"~a\" not found" main-file)))))))
223+
(oll:warn location (format "Library main file \"~a\" not found" main-file))))))))
220224

221225

222226
% Load a module from within a library.
@@ -275,13 +279,25 @@ useModule =
275279

276280
;; include init-file if present
277281
(if init-file
282+
(if (lilypond-greater-tha
283+
(if init-file
284+
(if (lilypond-greater-than? "2.19.21")
285+
(ly:parser-include-string
286+
(format "\\include \"~a\"" init-file))
287+
(ly:parser-include-string parser
288+
(format "\\include \"~a\"" init-file))))n? "2.19.21")
289+
(ly:parser-include-string
290+
(format "\\include \"~a\"" init-file))
278291
(ly:parser-include-string parser
279-
(format "\\include \"~a\"" init-file)))
292+
(format "\\include \"~a\"" init-file))))
280293

281294

282295
;; include module file
283-
(ly:parser-include-string parser
284-
(format "\\include \"~a\"" filename))
296+
(if (lilypond-greater-than? "2.19.21")
297+
(ly:parser-include-string
298+
(format "\\include \"~a\"" filename))
299+
(ly:parser-include-string parser
300+
(format "\\include \"~a\"" filename)))
285301

286302
;; register module
287303
(set! oll-loaded-modules
@@ -325,8 +341,12 @@ registerLibrary =
325341
(if (file-exists? lib-init-file)
326342
(begin
327343
(oll:log "initialize library \"~a\"" lib)
328-
(ly:parser-include-string parser
329-
(format "\\include \"~a\"" lib-init-file))))))))
344+
(if (lilypond-greater-than? "2.19.21")
345+
(ly:parser-include-string
346+
(format "\\include \"~a\"" lib-init-file))
347+
(ly:parser-include-string parser
348+
(format "\\include \"~a\"" lib-init-file))
349+
)))))))
330350

331351
% Load module from an openLilyLib library
332352
% A module may be an individual file or a whole library, this can also be
@@ -376,8 +396,11 @@ loadModule =
376396
#{ \registerLibrary #(first path-list) #}
377397
;; then load the requested module
378398
(oll:log "load module ~a" load-path)
379-
(ly:parser-include-string parser
380-
(format "\\include \"~a\"" load-path))
399+
(if (lilypond-greater-than? "2.19.21")
400+
(ly:parser-include-string
401+
(format "\\include \"~a\"" load-path))
402+
(ly:parser-include-string parser
403+
(format "\\include \"~a\"" load-path)))
381404
(set! oll-loaded-modules
382405
(append! oll-loaded-modules `(,load-path))))
383406
(oll:warn "module not found: ~a" load-path)))))

ly/_internal/utilities/alist-access.ily

Lines changed: 44 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,17 @@
5454

5555
% after \clralist <name> the variable <name> is initialized with an empty list
5656
#(define-public clralist
57-
(define-void-function (parser location alst)(symbol?)
58-
(ly:parser-define! parser alst (list))
59-
))
57+
(define-void-function (parser location alst)(symbol?)
58+
(if (lilypond-greater-than? "2.19.21")
59+
(ly:parser-define! alst (list))
60+
(ly:parser-define! parser alst (list)))
61+
))
6062
% sets one value - replaces the value and leaves the order of elements, if <name> is already present
6163
#(define-public setalist
6264
(define-void-function (parser location alst name val)(symbol? symbol? scheme?)
63-
(let ((l (ly:parser-lookup parser alst))
65+
(let ((l (if (lilypond-greater-than? "2.19.21")
66+
(ly:parser-lookup alst)
67+
(ly:parser-lookup parser alst)))
6468
(setv #t))
6569
(set! l (map (lambda (p)
6670
(if (and (pair? p) (equal? (car p) name))
@@ -70,28 +74,40 @@
7074
p
7175
)) l))
7276
(if setv (set! l (append l (list (cons name val)))))
73-
(ly:parser-define! parser alst l)
74-
)))
77+
(if (lilypond-greater-than? "2.19.21")
78+
(ly:parser-define! alst l)
79+
(ly:parser-define! parser alst l)))))
7580
% sets one value - <name> is always placed at the end of the list
7681
#(define-public addalist
7782
(define-void-function (parser location alst name val)
7883
(symbol? symbol? scheme?)
79-
(let ((l (ly:parser-lookup parser alst)))
84+
(let ((l (if (lilypond-greater-than? "2.19.21")
85+
(ly:parser-lookup alst)
86+
(ly:parser-lookup parser alst))))
8087
(set! l (filter (lambda (p) (and (pair? p)(not (equal? (car p) name)))) l))
81-
(ly:parser-define! parser alst (append l (list (cons name val))))
88+
(if (lilypond-greater-than? "2.19.21")
89+
(ly:parser-define! alst (append l (list (cons name val))))
90+
(ly:parser-define! parser alst (append l (list (cons name val)))))
8291
)))
8392
% removes one entry from association list
8493
#(define-public remalist
8594
(define-void-function (parser location alst name)(symbol? symbol?)
86-
(let ((l (ly:parser-lookup parser alst)))
87-
(ly:parser-define! parser alst
88-
(filter (lambda (p) (and (pair? p)(not (equal? (car p) name)))) l))
95+
(let ((l (if (lilypond-greater-than? "2.19.21")
96+
(ly:parser-lookup alst)
97+
(ly:parser-lookup parser alst))))
98+
(if (lilypond-greater-than? "2.19.21")
99+
(ly:parser-define! alst
100+
(filter (lambda (p) (and (pair? p)(not (equal? (car p) name)))) l))
101+
(ly:parser-define! parser alst
102+
(filter (lambda (p) (and (pair? p)(not (equal? (car p) name)))) l)))
89103
)))
90104

91105
% get entry from nested a-list
92106
#(define-public (get-a-tree parser location name path)
93107
(if (not (symbol? name)) (set! name (string->symbol (object->string name))))
94-
(let ((opts (ly:parser-lookup parser name)))
108+
(let ((opts (if (lilypond-greater-than? "2.19.21")
109+
(ly:parser-lookup name)
110+
(ly:parser-lookup parser name))))
95111
(define (getval ol op)
96112
(let ((sym (car op)))
97113
(cond
@@ -111,8 +127,12 @@
111127
)))
112128
% add an entry to a nested a-list
113129
#(define (add-a-tree parser location name sympath val assoc-set-append)
114-
(if (not (symbol? name)) (set! name (string->symbol (object->string name))))
115-
(let ((opts (ly:parser-lookup parser name)))
130+
(if (not (symbol? name)) (set! name (string->symbol (object->string name))))
131+
(let ((opts
132+
(if (lilypond-greater-than? "2.19.21")
133+
(ly:parser-lookup name)
134+
(ly:parser-lookup parser name)
135+
)))
116136
(define (setval ol op)
117137
(let ((sym (car op))
118138
(ol (if (list? ol) ol (begin
@@ -133,12 +153,16 @@
133153
)
134154
)))
135155
(set! opts (setval opts sympath))
136-
(ly:parser-define! parser name opts)
137-
))
156+
(if (lilypond-greater-than? "2.19.21")
157+
(ly:parser-define! name opts)
158+
(ly:parser-define! parser name opts))
159+
))
138160
% remove an entry from a nested a-list
139161
#(define (rem-a-tree parser location name sympath)
140162
(if (not (symbol? name)) (set! name (string->symbol (object->string name))))
141-
(let ((opts (ly:parser-lookup parser name)))
163+
(let ((opts (if (lilypond-greater-than? "2.19.21")
164+
(ly:parser-lookup name)
165+
(ly:parser-lookup parser name))))
142166
(define (remval ol op)
143167
(let ((sym (car op)))
144168
(if (> (length op) 1)
@@ -152,7 +176,9 @@
152176
)
153177
))
154178
(set! opts (remval opts sympath))
155-
(ly:parser-define! parser name opts)
179+
(if (lilypond-greater-than? "2.19.21")
180+
(ly:parser-define! name opts)
181+
(ly:parser-define! parser name opts))
156182
))
157183

158184
% clear/create an empty a-list

ly/_internal/utilities/include-pattern.ily

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ includePattern =
4545
(istr (format "\\include \"~A\"\n" file)))
4646
(if (and ipv (or (not (list? ipv))(> (length ipv) 0)))
4747
(oll:log "~A" istr))
48-
(ly:parser-include-string parser istr)))
48+
(if (lilypond-greater-than? "2.19.21")
49+
(ly:parser-include-string istr)
50+
(ly:parser-include-string parser istr))))
4951
includefiles)
5052
))

ly/openlilylib

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,22 @@
2121
% - Add general tools that are available for all libraries.
2222
% - lilypond-version-predicates
2323
% - logging commands
24+
%
25+
% NOTE: There has been a major syntax change in 2.19.22:
26+
% the parser argument is now obsolete with a number of functions,
27+
% e.g. ly:parser-include-string.
28+
% As the lilypond-version-predicates have not been included yet
29+
% we have to hard-code the switch here.
2430
initOpenLilyLib =
2531
#(define-void-function (parser location)()
2632
(if (not (defined? 'openlilylib-options))
27-
(begin
28-
(ly:parser-include-string parser
29-
"\\include \"_internal/init-openlilylib.ily\""))))
33+
(if (let ((v (ly:version)))
34+
(or (> (first v) 2)
35+
(> (second v) 19)
36+
(>= (third v) 22)))
37+
(ly:parser-include-string
38+
"\\include \"_internal/init-openlilylib.ily\"")
39+
(ly:parser-include-string parser
40+
"\\include \"_internal/init-openlilylib.ily\"")
41+
)))
3042
\initOpenLilyLib

ly/stylesheets/__main__.ily

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,11 @@ http://fonts.openlilylib.org.\n")
6565
#(define (use-font-extensions parser location name)
6666
(let ((filename (make-style-file name "extensions")))
6767
(if (file-exists? filename)
68-
(ly:parser-include-string parser
68+
(if (lilypond-greater-than? "2.19.21")
69+
(ly:parser-include-string
6970
(ly:gulp-file filename))
71+
(ly:parser-include-string parser
72+
(ly:gulp-file filename)))
7073
(oll:warn location
7174
(format "No extensions available for font \"~a\". Skipping." name))
7275
)))
@@ -205,11 +208,14 @@ useNotationFont =
205208
; I think one has to somehow access the current paper block
206209
; through Scheme (I suspect there are options in the paper
207210
; related ly: functions but I didn't succeed to find a solution).
208-
(ly:parser-include-string parser
209-
(format "\\include \"~a\""
210-
(string-append
211-
#{ \getOption global.root-path #}
212-
"/stylesheets/load-font")))
211+
(let ((arg
212+
(format "\\include \"~a\""
213+
(string-append
214+
#{ \getOption global.root-path #}
215+
"/stylesheets/load-font"))))
216+
(if (lilypond-greater-than? "2.19.21")
217+
(ly:parser-include-string parser arg)
218+
(ly:parser-include-string arg)))
213219
(oll:log location
214220
(format "Font \"~a\" loaded successfully" name))
215221

@@ -219,7 +225,10 @@ useNotationFont =
219225
;; include the determined style file for the font
220226
;; if not "none".
221227
(if (and style-file (not (string=? "none" style)))
228+
(if (lilypond-greater-than? "2.19.21")
229+
(ly:parser-include-string
230+
(format "\\include \"~a\"" style-file))
222231
(ly:parser-include-string parser
223-
(format "\\include \"~a\"" style-file)))
232+
(format "\\include \"~a\"" style-file))))
224233
(oll:log location (format "Associated \"~a\" stylesheet loaded successfully" style))
225234
))))
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
arnold--berg-opus-5-excerpt.ly

0 commit comments

Comments
 (0)