[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, 23 Oct 2004 12:05:05 +0200 |
User-agent: |
Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux) |
Han-Wen Nienhuys <address@hidden> writes:
> I think the embedded_scm_or_full_markup is inelegant. Why can't you
> add a separate
>
> MUSIC_FUNCTION_SCM_MARKUP
>
> to do what you want? the typechecking will be more detailed, and it's
> IMO less ugly.
Ok.
However, I must be missing something obvious, as this does not seem
cleaner:
Index: lily/lexer.ll
===================================================================
RCS file: /cvsroot/lilypond/lilypond/lily/lexer.ll,v
retrieving revision 1.149
diff -u -r1.149 lexer.ll
--- lily/lexer.ll 10 Oct 2004 19:41:07 -0000 1.149
+++ lily/lexer.ll 23 Oct 2004 09:59:27 -0000
@@ -922,6 +922,26 @@
{
return MUSIC_FUNCTION_SCM_SCM_MUSIC;
}
+ else if (type == ly_symbol2scm ("markup"))
+ {
+ return MUSIC_FUNCTION_MARKUP;
+ }
+ else if (type == ly_symbol2scm ("markup-music"))
+ {
+ return MUSIC_FUNCTION_MARKUP_MUSIC;
+ }
+ else if (type == ly_symbol2scm ("markup-markup"))
+ {
+ return MUSIC_FUNCTION_MARKUP_MARKUP;
+ }
+ else if (type == ly_symbol2scm ("markup-music-music"))
+ {
+ return MUSIC_FUNCTION_MARKUP_MUSIC_MUSIC;
+ }
+ else if (type == ly_symbol2scm ("markup-markup-music"))
+ {
+ return MUSIC_FUNCTION_MARKUP_MARKUP_MUSIC;
+ }
else if (type == ly_symbol2scm ("noarg"))
{
return MUSIC_FUNCTION;
Index: lily/music-function.cc
===================================================================
RCS file: /cvsroot/lilypond/lilypond/lily/music-function.cc,v
retrieving revision 1.6
diff -u -r1.6 music-function.cc
--- lily/music-function.cc 7 Oct 2004 19:39:50 -0000 1.6
+++ lily/music-function.cc 23 Oct 2004 09:59:27 -0000
@@ -42,8 +42,13 @@
if (scm_car (s) == Music_type_p_proc)
str += "music";
- else if (ly_c_procedure_p (scm_car (s)))
- str += "scm";
+ else if (ly_c_procedure_p (scm_car (s)))
+ {
+ if (ly_c_equal_p (scm_car (s), scm_primitive_eval (ly_symbol2scm
("markup?"))))
+ str += "markup";
+ else
+ str += "scm";
+ }
}
if (str == "") str = "noarg";
scm_set_object_property_x (func, ly_symbol2scm ("music-function-signature"),
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 23 Oct 2004 09:59:32 -0000
@@ -365,6 +365,11 @@
%token <scm> MUSIC_FUNCTION_SCM_MUSIC
%token <scm> MUSIC_FUNCTION_SCM_MUSIC_MUSIC
%token <scm> MUSIC_FUNCTION_SCM_SCM_MUSIC
+%token <scm> MUSIC_FUNCTION_MARKUP
+%token <scm> MUSIC_FUNCTION_MARKUP_MARKUP
+%token <scm> MUSIC_FUNCTION_MARKUP_MUSIC
+%token <scm> MUSIC_FUNCTION_MARKUP_MUSIC_MUSIC
+%token <scm> MUSIC_FUNCTION_MARKUP_MARKUP_MUSIC
%token DRUMS
%token DRUMMODE
@@ -989,6 +994,11 @@
} embedded_scm {
$$ = scm_list_3 ($1, make_input (THIS->pop_spot ()), $3);
}
+ | MUSIC_FUNCTION_MARKUP {
+ THIS->push_spot ();
+ } full_markup {
+ $$ = scm_list_3 ($1, make_input (THIS->pop_spot ()), $3);
+ }
| MUSIC_FUNCTION_MUSIC {
THIS->push_spot ();
} Music {
@@ -1006,6 +1016,17 @@
} embedded_scm embedded_scm {
$$ = scm_list_4 ($1, make_input (THIS->pop_spot ()), $3, $4);
}
+ | MUSIC_FUNCTION_MARKUP_MUSIC {
+ THIS->push_spot ();
+ } 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_MARKUP_MARKUP {
+ THIS->push_spot ();
+ } full_markup full_markup {
+ $$ = scm_list_4 ($1, make_input (THIS->pop_spot ()), $3, $4);
+ }
| MUSIC_FUNCTION_MUSIC_MUSIC {
THIS->push_spot ();
} Music Music {
@@ -1021,6 +1042,14 @@
scm_gc_unprotect_object ($5->self_scm ());
scm_gc_unprotect_object ($4->self_scm ());
}
+ | MUSIC_FUNCTION_MARKUP_MUSIC_MUSIC {
+ THIS->push_spot ();
+ } 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 ());
+ scm_gc_unprotect_object ($4->self_scm ());
+ }
;
Generic_prefix_music:
nicolas