? build-stamp ? context-unique.diff ? def-rel-music-funciton.diff ? delay-music-functions.diff ? exjobb.diff3 ? fonts ? lib ? lilypond.kdevelop ? lilypond.kdevelop.pcs ? lilypond.kdevses ? optimized ? os ? re ? ref1.diff ? ref2.diff ? repeat.diff ? scons.cache ? string ? sys ? Documentation/out ? Documentation/out-www ? Documentation/bibliography/out ? Documentation/bibliography/out-www ? Documentation/misc/out ? Documentation/misc/out-www ? Documentation/pictures/out ? Documentation/pictures/out-www ? Documentation/topdocs/out ? Documentation/topdocs/out-www ? Documentation/user/out ? Documentation/user/out-www ? buildscripts/out ? buildscripts/out-www ? cygwin/out ? cygwin/out-www ? debian/out ? elisp/out ? elisp/out-www ? flower/out ? flower/out-scons ? flower/out-www ? flower/include/.sconsign ? flower/include/out ? flower/include/out-www ? input/Diagram1.dia.autosave ? input/les-nereides.pdf ? input/les-nereides.ps ? input/out ? input/out-www ? input/mutopia/out ? input/mutopia/out-www ? input/mutopia/E.Satie/out ? input/mutopia/E.Satie/out-www ? input/mutopia/F.Schubert/out ? input/mutopia/F.Schubert/out-www ? input/mutopia/J.S.Bach/out ? input/mutopia/J.S.Bach/out-www ? input/mutopia/R.Schumann/out ? input/mutopia/R.Schumann/out-www ? input/mutopia/W.A.Mozart/out ? input/mutopia/W.A.Mozart/out-www ? input/no-notation/out ? input/no-notation/out-www ? input/no-notation/parse-expressions.facit ? input/no-notation/parse-expressions.ly ? input/no-notation/parse-expressions.pdf ? input/no-notation/parse-expressions.ps ? input/no-notation/to-xml.pdf ? input/no-notation/to-xml.ps ? input/regression/chord-tremolo.pdf ? input/regression/chord-tremolo.ps ? input/regression/lyric-melisma-manual.pdf ? input/regression/lyric-melisma-manual.ps ? input/regression/lyrics-melisma-beam.pdf ? input/regression/lyrics-melisma-beam.ps ? input/regression/out ? input/regression/out-www ? input/regression/tuplet-nest.pdf ? input/regression/tuplet-nest.ps ? input/template/out ? input/test/out ? input/test/out-www ? input/tutorial/out ? input/tutorial/out-www ? kpath-guile/out ? kpath-guile/out-scons ? lily/On ? lily/foo.pdf ? lily/foo.ps ? lily/lilypond ? lily/lilypond.gdt ? lily/lilypond.gpr ? lily/out ? lily/out-scons ? lily/out-www ? lily/parser.yy.ok ? lily/include/.sconsign ? lily/include/out ? lily/include/out-www ? ly/out ? ly/out-www ? make/out ? make/out-www ? mf/feta-alphabet11.600pk ? mf/feta-alphabet13.600pk ? mf/feta-alphabet14.600pk ? mf/feta-alphabet16.600pk ? mf/feta-alphabet18.600pk ? mf/feta-alphabet20.600pk ? mf/feta-alphabet23.600pk ? mf/feta-alphabet26.600pk ? mf/feta-braces-a.600pk ? mf/feta-braces-b.600pk ? mf/feta-braces-c.600pk ? mf/feta-braces-d.600pk ? mf/feta-braces-e.600pk ? mf/feta-braces-f.600pk ? mf/feta-braces-g.600pk ? mf/feta-braces-h.600pk ? mf/feta-braces-i.600pk ? mf/feta11.600pk ? mf/feta13.600pk ? mf/feta14.600pk ? mf/feta16.600pk ? mf/feta18.600pk ? mf/feta20.600pk ? mf/feta23.600pk ? mf/feta26.600pk ? mf/out ? mf/out-scons ? mf/out-www ? mf/parmesan11.600pk ? mf/parmesan13.600pk ? mf/parmesan14.600pk ? mf/parmesan16.600pk ? mf/parmesan18.600pk ? mf/parmesan20.600pk ? mf/parmesan23.600pk ? mf/parmesan26.600pk ? po/out ? po/out-www ? ps/out ? ps/out-www ? python/convertrules.pyc ? python/fontextract.pyc ? python/lilylib.pyc ? python/out ? python/out-www ? scm/out ? scm/out-www ? scripts/lilypond-book-36.py ? scripts/lilypond-book.py.new ? scripts/out ? scripts/out-www ? stepmake/out ? stepmake/out-www ? stepmake/bin/out ? stepmake/bin/out-www ? stepmake/bin/packagepython.pyc ? stepmake/stepmake/out ? stepmake/stepmake/out-www ? tex/out ? tex/out-www ? ttftool/out ? ttftool/out-scons ? ttftool/include/.sconsign ? ttftool/include/out ? vim/out ? vim/out-www Index: lily/lily-lexer.cc =================================================================== RCS file: /sources/lilypond/lilypond/lily/lily-lexer.cc,v retrieving revision 1.46 diff -u -r1.46 lily-lexer.cc --- lily/lily-lexer.cc 11 Feb 2006 11:35:17 -0000 1.46 +++ lily/lily-lexer.cc 22 May 2006 05:45:09 -0000 @@ -56,7 +56,6 @@ {"new", NEWCONTEXT}, {"notemode", NOTEMODE}, {"objectid", OBJECTID}, - {"once", ONCE}, {"override", OVERRIDE}, {"paper", PAPER}, {"partial", PARTIAL}, Index: lily/parser.yy =================================================================== RCS file: /sources/lilypond/lilypond/lily/parser.yy,v retrieving revision 1.515 diff -u -r1.515 parser.yy --- lily/parser.yy 19 May 2006 06:43:36 -0000 1.515 +++ lily/parser.yy 22 May 2006 05:45:09 -0000 @@ -115,8 +115,11 @@ - Don't use lily module, create a new module instead. - delay application of the function */ +#define LOWLEVEL_MAKE_SYNTAX(proc, args) \ + scm_apply_0 (proc, args) +/* Syntactic Sugar. */ #define MAKE_SYNTAX(name, location, ...) \ - scm_apply_0 (ly_lily_module_constant (name), scm_list_n (make_input (location), __VA_ARGS__, SCM_UNDEFINED)); + LOWLEVEL_MAKE_SYNTAX (ly_lily_module_constant (name), scm_list_n (make_input (location), __VA_ARGS__, SCM_UNDEFINED)); Music *property_op_to_music (SCM op); SCM context_spec_music (SCM type, SCM id, SCM m, SCM ops, bool create_new); @@ -135,7 +138,7 @@ SCM make_lyric_combine_music (SCM name, SCM music); SCM make_music_relative (Pitch start, SCM music); -Music *run_music_function (Lily_parser *, SCM expr); +SCM run_music_function (Lily_parser *, SCM expr); Music *set_property_music (SCM sym, SCM value); SCM get_first_context_id (SCM type, Music *m); SCM make_chord (SCM pitch, SCM dur, SCM modification_list); @@ -191,7 +194,6 @@ %token NOTEMODE "\\notemode" %token OBJECTID "\\objectid" %token OCTAVE "\\octave" -%token ONCE "\\once" %token OVERRIDE "\\override" %token PAPER "\\paper" %token PARTIAL "\\partial" @@ -989,13 +991,13 @@ Prefix_composite_music: Generic_prefix_music_scm { - $$ = run_music_function (THIS, $1)->unprotect (); + $$ = run_music_function (THIS, $1); } | CONTEXT simple_string optional_id optional_context_mod Music { - $$ = context_spec_music ($2, $3, $5, $4, false); + $$ = MAKE_SYNTAX ("context-specification", @$, $2, $3, $5, $4, SCM_BOOL_F); } | NEWCONTEXT simple_string optional_id optional_context_mod Music { - $$ = context_spec_music ($2, $3, $5, $4, true); + $$ = MAKE_SYNTAX ("context-specification", @$, $2, $3, $5, $4, SCM_BOOL_T); } | TIMES fraction Music @@ -1037,7 +1039,7 @@ THIS->lexer_->pop_state (); } | mode_changing_head_with_context optional_context_mod Grouped_music_list { - $$ = context_spec_music ($1, SCM_UNDEFINED, $3, $2, true); + $$ = MAKE_SYNTAX ("context-specification", @$, $1, SCM_EOL, $3, $2, SCM_BOOL_T); if ($1 == ly_symbol2scm ("ChordNames")) { Music *chm = MY_MAKE_MUSIC ("UnrelativableMusic"); @@ -1247,18 +1249,19 @@ music_property_def: OVERRIDE context_prop_spec embedded_scm '=' scalar { + /* TODO: do this properly */ Music *m = property_op_to_music (scm_list_4 ( ly_symbol2scm ("push"), scm_cadr ($2), $5, $3)); - $$ = context_spec_music (scm_car ($2), SCM_UNDEFINED, m->unprotect (), SCM_EOL, false); + $$ = MAKE_SYNTAX ("context-specification", @$, scm_car ($2), SCM_EOL, m->unprotect (), SCM_EOL, SCM_BOOL_F); } | OVERRIDE context_prop_spec embedded_scm embedded_scm '=' scalar { Music *m = property_op_to_music (scm_list_5 ( ly_symbol2scm ("push"), scm_cadr ($2), $6, $4, $3)); - $$ = context_spec_music (scm_car ($2), SCM_UNDEFINED, m->unprotect (), SCM_EOL, false); + $$ = MAKE_SYNTAX ("context-specification", @$, scm_car ($2), SCM_EOL, m->unprotect (), SCM_EOL, SCM_BOOL_F); } | REVERT context_prop_spec embedded_scm { Music *m = property_op_to_music (scm_list_3 ( @@ -1266,26 +1269,20 @@ scm_cadr ($2), $3)); - $$ = context_spec_music (scm_car ($2), SCM_UNDEFINED, m->unprotect (), SCM_EOL, false); + $$ = MAKE_SYNTAX ("context-specification", @$, scm_car ($2), SCM_EOL, m->unprotect (), SCM_EOL, SCM_BOOL_F); } | SET context_prop_spec '=' scalar { Music *m = property_op_to_music (scm_list_3 ( ly_symbol2scm ("assign"), scm_cadr ($2), $4)); - $$ = context_spec_music (scm_car ($2), SCM_UNDEFINED, m->unprotect (), SCM_EOL, false); + $$ = MAKE_SYNTAX ("context-specification", @$, scm_car ($2), SCM_EOL, m->unprotect (), SCM_EOL, SCM_BOOL_F); } | UNSET context_prop_spec { Music *m = property_op_to_music (scm_list_2 ( ly_symbol2scm ("unset"), scm_cadr ($2))); - $$ = context_spec_music (scm_car ($2), SCM_UNDEFINED, m->unprotect (), SCM_EOL, false); - } - | ONCE music_property_def { - Music *m = unsmob_music ($2); - SCM e = m->get_property ("element"); - unsmob_music (e)->set_property ("once", SCM_BOOL_T); - $$ = $2; + $$ = MAKE_SYNTAX ("context-specification", @$, scm_car ($2), SCM_EOL, m->unprotect (), SCM_EOL, SCM_BOOL_F); } ; @@ -1465,9 +1462,7 @@ $$ = n->unprotect (); } | music_function_chord_body { - Music *m = run_music_function (THIS, $1); - m->set_spot (@$); - $$ = m->unprotect (); + $$ = run_music_function (THIS, $1); } ; @@ -1641,9 +1636,7 @@ $$ = $1; } | '-' music_function_event { - Music *mus = run_music_function (THIS, $2); - mus->set_spot (@1); - $$ = mus->unprotect (); + $$ = run_music_function (THIS, $2); } | HYPHEN { if (!THIS->lexer_->is_lyric_state ()) @@ -2587,6 +2580,7 @@ return m; } +/* TODO: Remove this function? */ SCM context_spec_music (SCM type, SCM id, SCM m, SCM ops, bool create_new) { @@ -2622,7 +2616,7 @@ } -Music * +SCM run_music_function (Lily_parser *parser, SCM expr) { SCM func = scm_car (expr); @@ -2631,34 +2625,14 @@ SCM sig = scm_object_property (func, ly_symbol2scm ("music-function-signature")); SCM type_check_proc = ly_lily_module_constant ("type-check-list"); - bool ok = true; if (!to_boolean (scm_call_3 (type_check_proc, scm_cadr (expr), sig, args))) { parser->error_level_ = 1; - ok = false; + return MAKE_SYNTAX ("void-music", *loc, SCM_UNDEFINED); } - SCM m = SCM_EOL; - if (ok) - m = scm_apply_0 (func, scm_cons (parser->self_scm(), - scm_cdr (expr))); - - - Music* retval = 0; - if (unsmob_music (m)) - { - retval = unsmob_music (m); - retval->protect (); - } - else - { - if (ok) - loc->error (_ ("music head function must return Music object")); - retval = MY_MAKE_MUSIC ("Music"); - } - retval->set_spot (*loc); - return retval; + return MAKE_SYNTAX ("music-function", *loc, func, parser->self_scm(), args); } bool Index: ly/music-functions-init.ly =================================================================== RCS file: /sources/lilypond/lilypond/ly/music-functions-init.ly,v retrieving revision 1.58 diff -u -r1.58 music-functions-init.ly --- ly/music-functions-init.ly 17 May 2006 15:21:49 -0000 1.58 +++ ly/music-functions-init.ly 22 May 2006 05:45:09 -0000 @@ -112,6 +112,16 @@ 'origin location 'procedure proc)) +% TODO: Should this be a music macro? +once = +#(define-music-function (parser location csm) (ly:music?) + (let ((set-expr (ly:music-property csm 'element))) + (if (or (not (music-is-of-type? csm 'context-specification)) + (not (music-is-of-type? set-expr 'layout-instruction))) + (ly:warning (_ "\\once only makes sense on \\set, \\unset, \\override or \\revert expressions"))) + (set! (ly:music-property set-expr 'once) #t) + csm)) + overrideProperty = #(define-music-function (parser location name property value) (string? symbol? scheme?) Index: scm/ly-syntax-constructors.scm =================================================================== RCS file: /sources/lilypond/lilypond/scm/ly-syntax-constructors.scm,v retrieving revision 1.1 diff -u -r1.1 ly-syntax-constructors.scm --- scm/ly-syntax-constructors.scm 19 May 2006 11:07:35 -0000 1.1 +++ scm/ly-syntax-constructors.scm 22 May 2006 05:45:10 -0000 @@ -7,14 +7,29 @@ ;; TODO: use separate module for parser. (define define-ly-syntax define-public) -;; This shorthand adds a location parameter, and uses it to set the -;; origin. It can be used for most music functions. +;; Syntactic sugar which adds a location parameter, and uses it to set +;; the origin. It can be used for most music functions. (defmacro define-ly-syntax-loc (args . body) (primitive-eval `(define-ly-syntax ,(cons* (car args) 'location (cdr args)) (let ((m ((lambda ,(cdr args) . ,body) . ,(cdr args)))) (set! (ly:music-property m 'origin) location) m)))) +;; Music function: Apply function and check return value. +(define-ly-syntax (music-function loc fun parser args) + (let ((m (apply fun (cons* parser loc args)))) + (if (ly:music? m) + (begin + (set! (ly:music-property m 'origin) loc) + m) + (begin + (ly:error _ ("Music head function must return Music object")) + (make-music "Music" + 'origin loc))))) + +(define-ly-syntax-loc (void-music) + (make-music 'Music)) + (define-ly-syntax-loc (sequential-music mlist) (make-sequential-music mlist)) @@ -23,3 +38,10 @@ (define-ly-syntax-loc (repeat type num body alts) (make-repeat type num body alts)) + +(define-ly-syntax-loc (context-specification type id mus ops create-new?) + (let* ((type-sym (if (symbol? type) type (string->symbol type))) + (csm (context-spec-music mus type-sym id))) + (set! (ly:music-property csm 'property-operations) ops) + (if create-new? set! (ly:music-property csm 'create-new #t)) + csm)) Index: scm/music-functions.scm =================================================================== RCS file: /sources/lilypond/lilypond/scm/music-functions.scm,v retrieving revision 1.169 diff -u -r1.169 music-functions.scm --- scm/music-functions.scm 16 May 2006 11:19:50 -0000 1.169 +++ scm/music-functions.scm 22 May 2006 05:45:10 -0000 @@ -16,6 +16,9 @@ (make-procedure-with-setter ly:music-property ly:music-set-property!)) +(define-safe-public (music-is-of-type? mus type) + "Does @code{mus} belong to the music class @code{type}?" + (memq type (ly:music-property mus 'types))) ;; TODO move this (define-public ly:grob-property @@ -196,8 +199,6 @@ (set! (ly:music-property music 'duration) nd))) music)) - - (define-public (shift-duration-log music shift dot) (music-map (lambda (x) (shift-one-duration-log x shift dot)) music))