]> git.donarmstrong.com Git - lilypond.git/commitdiff
Allow music functions to recognize strings as markup.
authorNeil Puttock <n.puttock@gmail.com>
Thu, 12 Nov 2009 21:28:24 +0000 (21:28 +0000)
committerNeil Puttock <n.puttock@gmail.com>
Fri, 13 Nov 2009 20:01:32 +0000 (20:01 +0000)
Though strings count as markup according to the type predicate `markup?',
passing a string to a music function is currently only possible if the
type predicate is `string?' or `scm?'

This patch adds parser rules which support strings passed as markup, thus
making it easier to define music functions which default to using strings
unless extra formatting is required.

input/regression/music-function-string-markup.ly [new file with mode: 0644]
lily/parser.yy

diff --git a/input/regression/music-function-string-markup.ly b/input/regression/music-function-string-markup.ly
new file mode 100644 (file)
index 0000000..e3a8035
--- /dev/null
@@ -0,0 +1,17 @@
+\version "2.13.8"
+
+\header {
+  texidoc = "Music functions accept strings as markup arguments
+when using the type predicate @code{markup?}
+"
+}
+
+testFunc =
+#(define-music-function (parser location text music) (markup? ly:music?)
+   ;; dummy function, does nothing
+   music)
+
+\relative c' {
+  \testFunc "test string"
+  c2 <c \testFunc "test string" e>
+}
index f4fa5f4e2bf29d86353fb48bf4105236d959f357..584b6e78531d0dbb4906568dd7b07137dceffbfb 100644 (file)
@@ -1053,6 +1053,9 @@ function_arglist_nonmusic_last:
        EXPECT_MARKUP function_arglist full_markup {
                $$ = scm_cons ($3, $2);
        }
+       | EXPECT_MARKUP function_arglist simple_string {
+               $$ = scm_cons ($3, $2);
+       }
        | EXPECT_SCM function_arglist function_scm_argument {
                $$ = scm_cons ($3, $2);
        }
@@ -1064,6 +1067,9 @@ function_arglist_nonmusic: EXPECT_NO_MORE_ARGS {
        | EXPECT_MARKUP function_arglist_nonmusic full_markup {
                $$ = scm_cons ($3, $2);
        }
+       | EXPECT_MARKUP function_arglist_nonmusic simple_string {
+               $$ = scm_cons ($3, $2);
+       }
        | EXPECT_SCM function_arglist_nonmusic function_scm_argument {
                $$ = scm_cons ($3, $2);
        }