]> git.donarmstrong.com Git - lilypond.git/commitdiff
Issue 3728: Allow score and book identifiers at top level, and score identifiers...
authorDavid Kastrup <dak@gnu.org>
Sat, 14 Dec 2013 21:33:53 +0000 (22:33 +0100)
committerDavid Kastrup <dak@gnu.org>
Thu, 19 Dec 2013 11:13:55 +0000 (12:13 +0100)
Instead of

xxx = \score { ... }
yyy = \book { ... }
\score { \xxx }
\book { \yyy }

you can now just write

xxx = \score { ... }
yyy = \book { ... }
\xxx
\yyy

Book and bookparts at top level are distinguished by virtue of only
books having a \paper block.

lily/parser.yy

index f32330b5b56ed64f964aef2a713201e100006dee..7891a3b22d39d6e682eaa3cdc13c19ccba0f5797 100644 (file)
@@ -407,6 +407,13 @@ toplevel_expression:
                SCM proc = parser->lexer_->lookup_identifier ("toplevel-bookpart-handler");
                scm_call_2 (proc, parser->self_scm (), $1);
        }
+       | BOOK_IDENTIFIER {
+               SCM proc = parser->lexer_->lookup_identifier
+                       (unsmob_book($1)->paper_
+                        ? "toplevel-book-handler"
+                        : "toplevel-bookpart-handler");
+               scm_call_2 (proc, parser->self_scm (), $1);
+       }
        | score_block {
                SCM proc = parser->lexer_->lookup_identifier ("toplevel-score-handler");
                scm_call_2 (proc, parser->self_scm (), $1);
@@ -438,6 +445,10 @@ toplevel_expression:
                {
                        SCM proc = parser->lexer_->lookup_identifier ("toplevel-text-handler");
                        scm_call_2 (proc, parser->self_scm (), out);
+               } else if (unsmob_score ($1))
+               {
+                       SCM proc = parser->lexer_->lookup_identifier ("toplevel-score-handler");
+                       scm_call_2 (proc, parser->self_scm (), $1);
                } else if (!scm_is_eq ($1, SCM_UNSPECIFIED))
                        parser->parser_error (@1, _("bad expression type"));
        }
@@ -789,6 +800,10 @@ book_body:
                {
                        SCM proc = parser->lexer_->lookup_identifier ("book-text-handler");
                        scm_call_2 (proc, $1, out);
+               } else if (unsmob_score ($2))
+               {
+                       SCM proc = parser->lexer_->lookup_identifier ("book-score-handler");
+                       scm_call_2 (proc, $1, $2);
                } else if (!scm_is_eq ($2, SCM_UNSPECIFIED))
                        parser->parser_error (@2, _("bad expression type"));
        }
@@ -855,6 +870,10 @@ bookpart_body:
                {
                        SCM proc = parser->lexer_->lookup_identifier ("bookpart-text-handler");
                        scm_call_2 (proc, $1, out);
+               } else if (unsmob_score ($2))
+               {
+                       SCM proc = parser->lexer_->lookup_identifier ("bookpart-score-handler");
+                       scm_call_2 (proc, $1, $2);
                } else if (!scm_is_eq ($2, SCM_UNSPECIFIED))
                        parser->parser_error (@2, _("bad expression type"));
        }