]> 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>
Sat, 15 Feb 2014 18:13:25 +0000 (19: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 e241582952b371c15b1dece7fbd7dae3c5fefe84..592d9d2944ab64ce26fb5d0ed806de7e0d09540a 100644 (file)
@@ -406,6 +406,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);
@@ -437,6 +444,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"));
        }
@@ -753,6 +764,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"));
        }
@@ -819,6 +834,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"));
        }