From 08fbee8d085bc6e471d6614bdaf8b29eac2169b4 Mon Sep 17 00:00:00 2001 From: Nicolas Sceaux Date: Wed, 29 Oct 2008 10:58:35 +0100 Subject: [PATCH] Nested book parts: do not push $defaultpaper in $papers stack, use it separately --- lily/include/lily-parser.hh | 1 - lily/lily-parser.cc | 16 ++++++---------- lily/parser.yy | 3 --- 3 files changed, 6 insertions(+), 14 deletions(-) diff --git a/lily/include/lily-parser.hh b/lily/include/lily-parser.hh index aa65621387..c73f8f7991 100644 --- a/lily/include/lily-parser.hh +++ b/lily/include/lily-parser.hh @@ -74,7 +74,6 @@ SCM ly_parser_scorify (SCM, SCM); Output_def *get_layout (Lily_parser *parser); Output_def *get_midi (Lily_parser *parser); Output_def *get_paper (Lily_parser *parser); -void init_papers (Lily_parser *parser, Output_def *default_paper); void stack_paper (Lily_parser *parser, Output_def *paper); void unstack_paper (Lily_parser *parser); void set_paper (Lily_parser *parser, Output_def *paper); diff --git a/lily/lily-parser.cc b/lily/lily-parser.cc index a7816a154c..7e41491665 100644 --- a/lily/lily-parser.cc +++ b/lily/lily-parser.cc @@ -221,26 +221,22 @@ get_midi (Lily_parser *parser) return layout; } -/* Return a copy of the top of $papers stack */ +/* Return a copy of the top of $papers stack, or $defaultpaper if the + * stack is empty */ Output_def * get_paper (Lily_parser *parser) { SCM papers = parser->lexer_->lookup_identifier ("$papers"); - Output_def *layout = (papers == SCM_UNDEFINED || scm_is_null (papers)) ? + Output_def *layout = ((papers == SCM_UNDEFINED) || scm_is_null (papers)) ? 0 : unsmob_output_def (scm_car (papers)); + SCM default_paper = parser->lexer_->lookup_identifier ("$defaultpaper"); + layout = layout ? layout : unsmob_output_def (default_paper); + layout = layout ? dynamic_cast (layout->clone ()) : new Output_def; layout->set_variable (ly_symbol2scm ("is-paper"), SCM_BOOL_T); return layout; } -/* Initialize $papers stack with the default paper */ -void -init_papers (Lily_parser *parser, Output_def *default_paper) -{ - parser->lexer_->set_identifier (ly_symbol2scm ("$papers"), - scm_list_1 (default_paper->self_scm ())); -} - /* Stack a paper on top of $papers */ void stack_paper (Lily_parser *parser, Output_def *paper) diff --git a/lily/parser.yy b/lily/parser.yy index f821cd7efe..2e0887f954 100644 --- a/lily/parser.yy +++ b/lily/parser.yy @@ -508,10 +508,7 @@ toplevel_expression: Output_def * od = $1; if ($1->c_variable ("is-paper") == SCM_BOOL_T) - { id = ly_symbol2scm ("$defaultpaper"); - init_papers (PARSER, od); - } else if ($1->c_variable ("is-midi") == SCM_BOOL_T) id = ly_symbol2scm ("$defaultmidi"); else if ($1->c_variable ("is-layout") == SCM_BOOL_T) -- 2.39.5