[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: music functions and markups
From: |
Nicolas Sceaux |
Subject: |
Re: music functions and markups |
Date: |
Sat, 16 Oct 2004 12:41:13 +0200 |
User-agent: |
Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux) |
Han-Wen Nienhuys <address@hidden> writes:
> address@hidden writes:
>> Hello
>>
>> I would like to define a music function taking a markup as an
>> argument.
>
> Check out parser.yy and lexer.yy, you would have to add
>
> %token <scm> MUSIC_FUNCTION_MARKUP
>
> in the appropriate places.
I still have to check that make web is OK (broken at the moment), but what
do you think of the following (I don't feel confortable when hacking
parser.yy):
Index: ChangeLog
===================================================================
RCS file: /cvsroot/lilypond/lilypond/ChangeLog,v
retrieving revision 1.2721
diff -u -r1.2721 ChangeLog
--- ChangeLog 16 Oct 2004 07:37:45 -0000 1.2721
+++ ChangeLog 16 Oct 2004 09:40:40 -0000
@@ -1,3 +1,9 @@
+2004-10-16 Nicolas Sceaux <address@hidden>
+
+ * lily/parser.yy: add a `embedded_scm_or_full_markup' token,
+ used in Generic_prefix_music_scm, in order to allow the use of
+ \markup expressions with music functions
+
2004-10-16 Werner Lemberg <address@hidden>
* scm/framework-tex.scm (font-load-command, define-fonts): Protect
Index: lily/parser.yy
===================================================================
RCS file: /cvsroot/lilypond/lilypond/lily/parser.yy,v
retrieving revision 1.433
diff -u -r1.433 parser.yy
--- lily/parser.yy 10 Oct 2004 19:37:58 -0000 1.433
+++ lily/parser.yy 16 Oct 2004 09:40:50 -0000
@@ -426,6 +426,7 @@
%type <scm> markup markup_line markup_list markup_list_body full_markup
%type <scm> mode_changing_head
%type <scm> mode_changing_head_with_context
+%type <scm> embedded_scm_or_full_markup
%type <score> score_block score_body
@@ -986,7 +987,7 @@
}
| MUSIC_FUNCTION_SCM {
THIS->push_spot ();
- } embedded_scm {
+ } embedded_scm_or_full_markup {
$$ = scm_list_3 ($1, make_input (THIS->pop_spot ()), $3);
}
| MUSIC_FUNCTION_MUSIC {
@@ -997,13 +998,13 @@
}
| MUSIC_FUNCTION_SCM_MUSIC {
THIS->push_spot ();
- } embedded_scm Music {
+ } embedded_scm_or_full_markup Music {
$$ = scm_list_4 ($1, make_input (THIS->pop_spot ()), $3,
$4->self_scm ());
scm_gc_unprotect_object ($4->self_scm ());
}
| MUSIC_FUNCTION_SCM_SCM {
THIS->push_spot ();
- } embedded_scm embedded_scm {
+ } embedded_scm_or_full_markup embedded_scm_or_full_markup {
$$ = scm_list_4 ($1, make_input (THIS->pop_spot ()), $3, $4);
}
| MUSIC_FUNCTION_MUSIC_MUSIC {
@@ -1015,7 +1016,7 @@
}
| MUSIC_FUNCTION_SCM_MUSIC_MUSIC {
THIS->push_spot ();
- } embedded_scm Music Music {
+ } embedded_scm_or_full_markup Music Music {
$$ = scm_list_5 ($1, make_input (THIS->pop_spot ()),
$3, $4->self_scm (), $5->self_scm ());
scm_gc_unprotect_object ($5->self_scm ());
@@ -1023,6 +1024,14 @@
}
;
+embedded_scm_or_full_markup:
+ full_markup {
+ $$ = $1;
+ }
+ | embedded_scm {
+ $$ = $1;
+ };
+
Generic_prefix_music:
Generic_prefix_music_scm {
SCM func = scm_car ($1);
a simple test file:
\version "2.3.22"
\layout { raggedright = ##t }
fnMarkup = #(def-music-function (location markp) (markup?)
#{ s1^$markp #})
fnMarkupMusic = #(def-music-function (location markp music) (markup? ly:music?)
#{ << s1^$markp \\ $music >> #})
fnMarkupMusicMusic = #(def-music-function (location markp music1 music2)
(markup? ly:music? ly:music?)
#{ $music2 << s1^$markp \\ $music1 >> #})
{
\fnMarkup \markup { function on a markup }
\break
\fnMarkupMusic
\markup { function on a markup and a music expression }
{ c''4 d'' e'' f'' }
\break
\fnMarkupMusicMusic
\markup { function on a markup and two music expressions }
{ c''4 d'' e'' f'' }
{ c'4 d' e' f' }
}
nicolas
- Re: music functions and markups,
Nicolas Sceaux <=