From 19625d063f3c3a9cf005966284e5aa055c8767e2 Mon Sep 17 00:00:00 2001 From: David Kastrup Date: Sat, 14 Dec 2013 22:33:53 +0100 Subject: [PATCH] Issue 3728: Allow score and book identifiers at top level, and score identifiers in book(part)s 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 | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/lily/parser.yy b/lily/parser.yy index f32330b5b5..7891a3b22d 100644 --- a/lily/parser.yy +++ b/lily/parser.yy @@ -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")); } -- 2.39.2