%token BOOK_IDENTIFIER
%token CHORD_MODIFIER
%token CHORD_REPETITION
-%token CONTEXT_MOD_IDENTIFIER
%token DRUM_PITCH
/* Artificial token for durations in argument lists */
%token DURATION_ARG
| lilypond_header_body assignment {
}
- | lilypond_header_body embedded_scm {
-
+ | lilypond_header_body SCM_TOKEN {
+ // Evaluate and ignore #xxx, as opposed to \xxx
+ parser->lexer_->eval_scm_token ($2, @2);
+ }
+ | lilypond_header_body embedded_scm_active {
+ if (ly_is_module ($2))
+ ly_module_copy (scm_current_module (), $2);
+ else if (!scm_is_eq ($2, SCM_UNSPECIFIED))
+ parser->parser_error (@2, _("bad expression type"));
}
;
SCM proc = parser->lexer_->lookup_identifier ("book-score-handler");
scm_call_2 (proc, $1, $2);
} else if (Output_def *od = unsmob<Output_def> ($2)) {
- SCM id = SCM_EOL;
-
- if (to_boolean (od->c_variable ("is-paper")))
- id = ly_symbol2scm ("$defaultpaper");
- else if (to_boolean (od->c_variable ("is-midi")))
- id = ly_symbol2scm ("$defaultmidi");
- else if (to_boolean (od->c_variable ("is-layout")))
- id = ly_symbol2scm ("$defaultlayout");
-
- parser->lexer_->set_identifier (id, $2);
+ if (to_boolean (od->lookup_variable (ly_symbol2scm ("is-paper")))) {
+ unsmob<Book> ($1)->paper_ = od;
+ set_paper (parser, od);
+ } else {
+ parser->parser_error (@2, _ ("need \\paper for paper block"));
+ }
} else if (ly_is_module ($2))
{
ly_module_copy (unsmob<Book> ($1)->header_, $2);
SCM proc = parser->lexer_->lookup_identifier ("bookpart-score-handler");
scm_call_2 (proc, $1, $2);
} else if (Output_def *od = unsmob<Output_def> ($2)) {
- SCM id = SCM_EOL;
-
- if (to_boolean (od->c_variable ("is-paper")))
- id = ly_symbol2scm ("$defaultpaper");
- else if (to_boolean (od->c_variable ("is-midi")))
- id = ly_symbol2scm ("$defaultmidi");
- else if (to_boolean (od->c_variable ("is-layout")))
- id = ly_symbol2scm ("$defaultlayout");
-
- parser->lexer_->set_identifier (id, $2);
+ if (to_boolean (od->lookup_variable (ly_symbol2scm ("is-paper")))) {
+ unsmob<Book> ($1)->paper_ = od;
+ } else {
+ parser->parser_error (@2, _ ("need \\paper for paper block"));
+ }
} else if (ly_is_module ($2)) {
Book *book = unsmob<Book> ($1);
if (!ly_is_module (book->header_))
scm_set_cdr_x ($$, scm_cons ($2, scm_cdr ($$)));
else
$$ = scm_cons ($2, $$);
+ } else if (ly_is_module ($2)) {
+ SCM module = SCM_UNSPECIFIED;
+ if (score) {
+ module = score->get_header ();
+ if (!ly_is_module (module))
+ {
+ module = ly_make_module (false);
+ score->set_header (module);
+ }
+ } else if (scm_is_pair ($$) && ly_is_module (scm_car ($$)))
+ module = scm_car ($$);
+ else {
+ module = ly_make_module (false);
+ $$ = scm_cons (module, $$);
+ }
+ ly_module_copy (module, $2);
} else if (!scm_is_eq ($2, SCM_UNSPECIFIED))
parser->parser_error (@2, _("Spurious expression in \\score"));
}
parser->lexer_->pop_state ();
$$ = $4;
}
- | WITH CONTEXT_MOD_IDENTIFIER
- {
- $$ = $2;
- }
- | CONTEXT_MOD_IDENTIFIER
- {
- $$ = $1;
- }
| WITH context_modification_arg
{
if (unsmob<Music> ($2)) {
if (unsmob<Context_mod> ($2))
$$ = $2;
else {
- parser->parser_error (@2, _ ("not a context mod"));
+ // let's permit \with #*unspecified* to go for
+ // an empty context mod
+ if (!scm_is_eq ($2, SCM_UNSPECIFIED))
+ parser->parser_error (@2, _ ("not a context mod"));
$$ = Context_mod ().smobbed_copy ();
}
}
if (!SCM_UNBNDP ($2))
unsmob<Context_mod> ($1)->add_context_mod ($2);
}
- | context_mod_list CONTEXT_MOD_IDENTIFIER {
- Context_mod *md = unsmob<Context_mod> ($2);
- if (md)
- unsmob<Context_mod> ($1)->add_context_mods (md->get_mods ());
- }
| context_mod_list context_mod_arg {
- if (scm_is_eq ($2, SCM_UNSPECIFIED))
- ;
- else if (unsmob<Music> ($2)) {
+ if (unsmob<Music> ($2)) {
SCM proc = parser->lexer_->lookup_identifier ("context-mod-music-handler");
$2 = scm_call_1 (proc, $2);
}
if (unsmob<Context_mod> ($2))
unsmob<Context_mod> ($$)->add_context_mods
(unsmob<Context_mod> ($2)->get_mods ());
- else {
+ else if (!scm_is_eq ($2, SCM_UNSPECIFIED))
parser->parser_error (@2, _ ("not a context mod"));
- }
}
;
}
} %prec ':'
| CHORD_REPETITION optional_notemode_duration post_events {
- Input i;
- i.set_location (@1, @3);
- $$ = MAKE_SYNTAX (repetition_chord, i,
+ $$ = MAKE_SYNTAX (repetition_chord, @$,
$2, scm_reverse_x ($3, SCM_EOL));
} %prec ':'
| MULTI_MEASURE_REST optional_notemode_duration post_events {
- Input i;
- i.set_location (@1, @3);
- $$ = MAKE_SYNTAX (multi_measure_rest, i, $2,
+ $$ = MAKE_SYNTAX (multi_measure_rest, @$, $2,
scm_reverse_x ($3, SCM_EOL));
} %prec ':'
| tempo_event
return SCM_IDENTIFIER;
} else if (unsmob<Context_mod> (sid)) {
*destination = unsmob<Context_mod> (sid)->smobbed_copy ();
- return CONTEXT_MOD_IDENTIFIER;
+ return SCM_IDENTIFIER;
} else if (Music *mus = unsmob<Music> (sid)) {
mus = mus->clone ();
*destination = mus->self_scm ();