X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fparser.yy;h=065713de1a8f56ee7e6b115e31b2e51e1018cd98;hb=1478b35691bfdb6e805d7225ee44fbec0622e8fc;hp=54de4727b5b75d8f16776198ee3e0d94bff6fcce;hpb=77cf1054ff5aeb20978a1586a44f5b95fb365585;p=lilypond.git diff --git a/lily/parser.yy b/lily/parser.yy index 54de4727b5..065713de1a 100644 --- a/lily/parser.yy +++ b/lily/parser.yy @@ -229,7 +229,7 @@ static Music *make_music_with_input (SCM name, Input where); SCM check_scheme_arg (Lily_parser *parser, Input loc, SCM arg, SCM args, SCM pred, SCM disp = SCM_UNDEFINED); SCM make_music_from_simple (Lily_parser *parser, Input loc, SCM pitch); -SCM loc_on_music (Lily_parser *parser, Input loc, SCM arg); +SCM loc_on_copy (Lily_parser *parser, Input loc, SCM arg); SCM make_chord_elements (Input loc, SCM pitch, SCM dur, SCM modification_list); SCM make_chord_step (SCM step, Rational alter); SCM make_simple_markup (SCM a); @@ -346,7 +346,6 @@ If we give names, Bison complains. %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 @@ -387,8 +386,7 @@ prec levels in different prods */ start_symbol: lilypond | EMBEDDED_LILY { - SCM nn = parser->lexer_->lookup_identifier ("pitchnames"); - parser->lexer_->push_note_state (nn); + parser->lexer_->push_note_state (Lily::pitchnames); } embedded_lilypond { parser->lexer_->pop_state (); *retval = $3; @@ -410,10 +408,8 @@ lilypond: /* empty */ { $$ = SCM_UNSPECIFIED; } toplevel_expression: - { - parser->lexer_->add_scope (get_header (parser)); - } lilypond_header { - parser->lexer_->set_identifier (ly_symbol2scm ("$defaultheader"), $2); + header_block { + parser->lexer_->set_identifier (ly_symbol2scm ("$defaultheader"), $1); } | book_block { SCM proc = parser->lexer_->lookup_identifier ("toplevel-book-handler"); @@ -476,6 +472,12 @@ toplevel_expression: id = ly_symbol2scm ("$defaultlayout"); parser->lexer_->set_identifier (id, $1); + } else if (ly_is_module ($1)) + { + SCM module = get_header (parser); + ly_module_copy (module, $1); + parser->lexer_->set_identifier + (ly_symbol2scm ("$defaultheader"), module); } else if (!scm_is_eq ($1, SCM_UNSPECIFIED)) parser->parser_error (@1, _("bad expression type")); } @@ -498,8 +500,8 @@ lookup: LOOKUP_IDENTIFIER | LOOKUP_IDENTIFIER '.' symbol_list_rev { - $$ = loc_on_music (parser, @$, - nested_property ($1, scm_reverse_x ($3, SCM_EOL))); + $$ = loc_on_copy (parser, @$, + nested_property ($1, scm_reverse_x ($3, SCM_EOL))); } ; @@ -527,6 +529,7 @@ embedded_scm_bare_arg: | partial_markup | full_markup_list | context_modification + | header_block | score_block | context_def_spec_block | book_block @@ -635,8 +638,15 @@ lilypond_header_body: | 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")); } ; @@ -646,6 +656,14 @@ lilypond_header: } ; +header_block: + { + parser->lexer_->add_scope (get_header (parser)); + } lilypond_header { + $$ = $2; + } + ; + /* DECLARATIONS */ @@ -658,11 +676,6 @@ assignment: parser->lexer_->set_identifier ($1, $3); $$ = SCM_UNSPECIFIED; } - | assignment_id property_path '=' identifier_init { - SCM path = scm_cons (scm_string_to_symbol ($1), $2); - parser->lexer_->set_identifier (path, $4); - $$ = SCM_UNSPECIFIED; - } | assignment_id '.' property_path '=' identifier_init { SCM path = scm_cons (scm_string_to_symbol ($1), $3); parser->lexer_->set_identifier (path, $5); @@ -679,6 +692,14 @@ assignment: identifier_init: identifier_init_nonumber | number_expression + | symbol_list_part_bare '.' property_path + { + $$ = scm_reverse_x ($1, $3); + } + | symbol_list_part_bare ',' property_path + { + $$ = scm_reverse_x ($1, $3); + } | post_event_nofinger post_events { $$ = scm_reverse_x ($2, SCM_EOL); @@ -704,7 +725,8 @@ identifier_init: ; identifier_init_nonumber: - score_block + header_block + | score_block | book_block | bookpart_block | output_def @@ -821,8 +843,7 @@ context_mod_arg: embedded_scm | { - SCM nn = parser->lexer_->lookup_identifier ("pitchnames"); - parser->lexer_->push_note_state (nn); + parser->lexer_->push_note_state (Lily::pitchnames); } composite_music { @@ -954,16 +975,15 @@ book_body: SCM proc = parser->lexer_->lookup_identifier ("book-score-handler"); scm_call_2 (proc, $1, $2); } else if (Output_def *od = unsmob ($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 ($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 ($1)->header_, $2); } else if (!scm_is_eq ($2, SCM_UNSPECIFIED)) parser->parser_error (@2, _("bad expression type")); } @@ -1035,16 +1055,16 @@ bookpart_body: SCM proc = parser->lexer_->lookup_identifier ("bookpart-score-handler"); scm_call_2 (proc, $1, $2); } else if (Output_def *od = unsmob ($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 ($1)->paper_ = od; + } else { + parser->parser_error (@2, _ ("need \\paper for paper block")); + } + } else if (ly_is_module ($2)) { + Book *book = unsmob ($1); + if (!ly_is_module (book->header_)) + book->header_ = ly_make_module (false); + ly_module_copy (book->header_, $2); } else if (!scm_is_eq ($2, SCM_UNSPECIFIED)) parser->parser_error (@2, _("bad expression type")); } @@ -1143,6 +1163,22 @@ score_items: 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")); } @@ -1279,8 +1315,7 @@ output_def_body: { if (scm_is_pair ($1)) $1 = scm_car ($1); - SCM nn = parser->lexer_->lookup_identifier ("pitchnames"); - parser->lexer_->push_note_state (nn); + parser->lexer_->push_note_state (Lily::pitchnames); } music_or_context_def { parser->lexer_->pop_state (); @@ -1452,21 +1487,12 @@ simple_music: context_modification: WITH { - SCM nn = parser->lexer_->lookup_identifier ("pitchnames"); - parser->lexer_->push_note_state (nn); + parser->lexer_->push_note_state (Lily::pitchnames); } '{' context_mod_list '}' { parser->lexer_->pop_state (); $$ = $4; } - | WITH CONTEXT_MOD_IDENTIFIER - { - $$ = $2; - } - | CONTEXT_MOD_IDENTIFIER - { - $$ = $1; - } | WITH context_modification_arg { if (unsmob ($2)) { @@ -1476,7 +1502,10 @@ context_modification: if (unsmob ($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 (); } } @@ -1487,16 +1516,40 @@ context_modification_arg: | MUSIC_IDENTIFIER ; -optional_context_mod: - /**/ { - $$ = SCM_EOL; - } - | context_modification +/* A list of single mods collected from a (possibly empty) sequence of + * context modifications, usually written as \with ... \with ... + */ + +optional_context_mods: + context_modification_mods_list { - $$ = $1; + if (scm_is_pair ($1)) + $$ = scm_append_x (scm_reverse_x ($1, SCM_EOL)); } ; +/* The worker for optional_context_mods conses a (reversed) list where + * each element contains the list of single context mods from one + * context modification block. Context_mod::get_mods creates fresh + * copies, so it's okay to use append! on them. + */ + +context_modification_mods_list: + /**/ { + $$ = SCM_EOL; + } + | context_modification_mods_list context_modification + { + if (Context_mod *m = unsmob ($2)) + $$ = scm_cons (m->get_mods (), $1); + } + ; + +/* A Context_mod is a container for a list of context mods like + * \consists ... \override ... . context_mod_list produces a + * Context_mod from the inside of a \with { ... } statement. + */ + context_mod_list: /**/ { $$ = Context_mod ().smobbed_copy (); @@ -1505,58 +1558,34 @@ context_mod_list: if (!SCM_UNBNDP ($2)) unsmob ($1)->add_context_mod ($2); } - | context_mod_list CONTEXT_MOD_IDENTIFIER { - Context_mod *md = unsmob ($2); - if (md) - unsmob ($1)->add_context_mods (md->get_mods ()); - } | context_mod_list context_mod_arg { - if (scm_is_eq ($2, SCM_UNSPECIFIED)) - ; - else if (unsmob ($2)) { + if (unsmob ($2)) { SCM proc = parser->lexer_->lookup_identifier ("context-mod-music-handler"); $2 = scm_call_1 (proc, $2); } if (unsmob ($2)) unsmob ($$)->add_context_mods (unsmob ($2)->get_mods ()); - else { + else if (!scm_is_eq ($2, SCM_UNSPECIFIED)) parser->parser_error (@2, _ ("not a context mod")); - } } ; context_prefix: - CONTEXT symbol optional_id optional_context_mod { - Context_mod *ctxmod = unsmob ($4); - SCM mods = SCM_EOL; - if (ctxmod) - mods = ctxmod->get_mods (); - $$ = START_MAKE_SYNTAX (context_specification, $2, $3, mods, SCM_BOOL_F); + CONTEXT symbol optional_id optional_context_mods { + $$ = START_MAKE_SYNTAX (context_specification, $2, $3, $4, SCM_BOOL_F); } - | NEWCONTEXT symbol optional_id optional_context_mod { - Context_mod *ctxmod = unsmob ($4); - SCM mods = SCM_EOL; - if (ctxmod) - mods = ctxmod->get_mods (); - $$ = START_MAKE_SYNTAX (context_specification, $2, $3, mods, SCM_BOOL_T); + | NEWCONTEXT symbol optional_id optional_context_mods { + $$ = START_MAKE_SYNTAX (context_specification, $2, $3, $4, SCM_BOOL_T); } ; new_lyrics: - ADDLYRICS optional_context_mod lyric_mode_music { - Context_mod *ctxmod = unsmob ($2); - SCM mods = SCM_EOL; - if (ctxmod) - mods = ctxmod->get_mods (); - $$ = scm_acons ($3, mods, SCM_EOL); + ADDLYRICS optional_context_mods lyric_mode_music { + $$ = scm_acons ($3, $2, SCM_EOL); } - | new_lyrics ADDLYRICS optional_context_mod lyric_mode_music { - Context_mod *ctxmod = unsmob ($3); - SCM mods = SCM_EOL; - if (ctxmod) - mods = ctxmod->get_mods (); - $$ = scm_acons ($4, mods, $1); + | new_lyrics ADDLYRICS optional_context_mods lyric_mode_music { + $$ = scm_acons ($4, $3, $1); } ; @@ -1585,7 +1614,7 @@ basic_music: } | LYRICSTO symbol '=' simple_string lyric_mode_music { - $$ = MAKE_SYNTAX (lyric_combine, @$, $3, $2, $4); + $$ = MAKE_SYNTAX (lyric_combine, @$, $4, $2, $5); } ; @@ -1731,6 +1760,21 @@ symbol_list_element: | UNSIGNED ; +symbol_list_part_bare: + STRING + { + $$ = try_string_variants (Lily::key_list_p, $1); + if (SCM_UNBNDP ($$)) { + parser->parser_error (@1, _("not a key")); + $$ = SCM_EOL; + } else + $$ = scm_reverse ($$); + } + | UNSIGNED + { + $$ = scm_list_1 ($1); + } + ; function_arglist_nonbackup: function_arglist_common @@ -1902,6 +1946,8 @@ function_arglist_nonbackup_reparse: if (scm_is_true (scm_call_1 ($2, $4))) // May be 3 \cm or similar MYREPARSE (@4, $2, REAL, $4); + else if (scm_is_true (scm_call_1 ($2, scm_list_1 ($4)))) + MYREPARSE (@4, $2, SYMBOL_LIST, scm_list_1 ($4)); else { SCM d = make_duration ($4); if (!SCM_UNBNDP (d)) { @@ -1946,7 +1992,7 @@ function_arglist_backup: $$ = scm_cons ($$, $3); else { - $$ = scm_cons (loc_on_music (parser, @3, $1), $3); + $$ = scm_cons (loc_on_copy (parser, @3, $1), $3); MYBACKUP (SCM_ARG, $4, @4); } } @@ -1957,7 +2003,7 @@ function_arglist_backup: { $$ = scm_cons ($4, $3); } else { - $$ = scm_cons (loc_on_music (parser, @3, $1), $3); + $$ = scm_cons (loc_on_copy (parser, @3, $1), $3); MYBACKUP (EVENT_IDENTIFIER, $4, @4); } } @@ -1973,7 +2019,7 @@ function_arglist_backup: } else if (scm_is_true (scm_call_1 ($2, $4))) $$ = scm_cons ($4, $3); else { - $$ = scm_cons (loc_on_music (parser, @3, $1), $3); + $$ = scm_cons (loc_on_copy (parser, @3, $1), $3); MYBACKUP (PITCH_IDENTIFIER, $4, @4); } } @@ -1989,7 +2035,7 @@ function_arglist_backup: } else if (scm_is_true (scm_call_1 ($2, $4))) $$ = scm_cons ($4, $3); else { - $$ = scm_cons (loc_on_music (parser, @3, $1), $3); + $$ = scm_cons (loc_on_copy (parser, @3, $1), $3); MYBACKUP (TONICNAME_PITCH, $4, @4); } } @@ -1998,7 +2044,7 @@ function_arglist_backup: if (scm_is_true (scm_call_1 ($2, $4))) $$ = scm_cons ($4, $3); else { - $$ = scm_cons (loc_on_music (parser, @3, $1), $3); + $$ = scm_cons (loc_on_copy (parser, @3, $1), $3); MYBACKUP (SCM_IDENTIFIER, $4, @4); } } @@ -2008,6 +2054,8 @@ function_arglist_backup: if (scm_is_true (scm_call_1 ($2, $4))) // May be 3 \cm or similar MYREPARSE (@4, $2, REAL, $4); + else if (scm_is_true (scm_call_1 ($2, scm_list_1 ($4)))) + MYREPARSE (@4, $2, SYMBOL_LIST, scm_list_1 ($4)); else { SCM d = make_duration ($4); if (!SCM_UNBNDP (d)) { @@ -2018,11 +2066,11 @@ function_arglist_backup: ($2, make_music_from_simple (parser, @4, d)))) MYREPARSE (@4, $2, DURATION_ARG, d); else { - $$ = scm_cons (loc_on_music (parser, @3, $1), $3); + $$ = scm_cons (loc_on_copy (parser, @3, $1), $3); MYBACKUP (UNSIGNED, $4, @4); } } else { - $$ = scm_cons (loc_on_music (parser, @3, $1), $3); + $$ = scm_cons (loc_on_copy (parser, @3, $1), $3); MYBACKUP (UNSIGNED, $4, @4); } } @@ -2034,7 +2082,7 @@ function_arglist_backup: $$ = $3; MYREPARSE (@4, $2, REAL, $4); } else { - $$ = scm_cons (loc_on_music (parser, @3, $1), $3); + $$ = scm_cons (loc_on_copy (parser, @3, $1), $3); MYBACKUP (REAL, $4, @4); } } @@ -2044,7 +2092,7 @@ function_arglist_backup: { $$ = scm_cons ($4, $3); } else { - $$ = scm_cons (loc_on_music (parser, @3, $1), $3); + $$ = scm_cons (loc_on_copy (parser, @3, $1), $3); MYBACKUP (NUMBER_IDENTIFIER, $4, @4); } } @@ -2061,7 +2109,7 @@ function_arglist_backup: if (scm_is_true (scm_call_1 ($2, $$))) $$ = scm_cons ($$, $3); else { - $$ = scm_cons (loc_on_music (parser, @3, $1), $3); + $$ = scm_cons (loc_on_copy (parser, @3, $1), $3); MYBACKUP (UNSIGNED, $5, @5); parser->lexer_->push_extra_token (@4, '-'); } @@ -2074,7 +2122,7 @@ function_arglist_backup: MYREPARSE (@5, $2, REAL, n); $$ = $3; } else { - $$ = scm_cons (loc_on_music (parser, @3, $1), $3); + $$ = scm_cons (loc_on_copy (parser, @3, $1), $3); MYBACKUP (REAL, n, @5); } } @@ -2084,7 +2132,7 @@ function_arglist_backup: if (scm_is_true (scm_call_1 ($2, n))) { $$ = scm_cons (n, $3); } else { - $$ = scm_cons (loc_on_music (parser, @3, $1), $3); + $$ = scm_cons (loc_on_copy (parser, @3, $1), $3); MYBACKUP (NUMBER_IDENTIFIER, n, @5); } } @@ -2098,7 +2146,7 @@ function_arglist_backup: ($2, make_music_from_simple (parser, @4, $4)))) MYREPARSE (@4, $2, DURATION_ARG, $4); else { - $$ = scm_cons (loc_on_music (parser, @3, $1), $3); + $$ = scm_cons (loc_on_copy (parser, @3, $1), $3); MYBACKUP (DURATION_IDENTIFIER, $4, @4); } } @@ -2113,7 +2161,7 @@ function_arglist_backup: else $$ = scm_cons (res, $3); else { - $$ = scm_cons (loc_on_music (parser, @3, $1), $3); + $$ = scm_cons (loc_on_copy (parser, @3, $1), $3); MYBACKUP (SCM_IDENTIFIER, $4, @4); } } @@ -2128,7 +2176,7 @@ function_arglist_backup: else $$ = scm_cons (res, $3); else { - $$ = scm_cons (loc_on_music (parser, @3, $1), $3); + $$ = scm_cons (loc_on_copy (parser, @3, $1), $3); MYBACKUP (STRING, $4, @4); } } @@ -2167,7 +2215,7 @@ function_arglist: function_arglist_nonbackup | EXPECT_OPTIONAL EXPECT_SCM function_arglist_skip_nonbackup DEFAULT { - $$ = scm_cons (loc_on_music (parser, @4, $1), $3); + $$ = scm_cons (loc_on_copy (parser, @4, $1), $3); } ; @@ -2175,7 +2223,7 @@ function_arglist_skip_nonbackup: function_arglist_nonbackup | EXPECT_OPTIONAL EXPECT_SCM function_arglist_skip_nonbackup { - $$ = scm_cons (loc_on_music (parser, @3, $1), $3); + $$ = scm_cons (loc_on_copy (parser, @3, $1), $3); } ; @@ -2378,6 +2426,8 @@ function_arglist_common_reparse: if (scm_is_true (scm_call_1 ($1, $3))) // May be 3 \cm or similar MYREPARSE (@3, $1, REAL, $3); + else if (scm_is_true (scm_call_1 ($1, scm_list_1 ($3)))) + MYREPARSE (@3, $1, SYMBOL_LIST, scm_list_1 ($3)); else { SCM d = make_duration ($3); if (!SCM_UNBNDP (d)) { @@ -2433,7 +2483,7 @@ function_arglist_optional: function_arglist_backup | EXPECT_OPTIONAL EXPECT_SCM function_arglist_skip_backup DEFAULT { - $$ = scm_cons (loc_on_music (parser, @4, $1), $3); + $$ = scm_cons (loc_on_copy (parser, @4, $1), $3); } | function_arglist_skip_backup BACKUP ; @@ -2442,7 +2492,7 @@ function_arglist_skip_backup: function_arglist_backup | EXPECT_OPTIONAL EXPECT_SCM function_arglist_skip_backup { - $$ = scm_cons (loc_on_music (parser, @3, $1), $3); + $$ = scm_cons (loc_on_copy (parser, @3, $1), $3); } ; @@ -2490,12 +2540,8 @@ mode_changed_music: } parser->lexer_->pop_state (); } - | mode_changing_head_with_context optional_context_mod grouped_music_list { - Context_mod *ctxmod = unsmob ($2); - SCM mods = SCM_EOL; - if (ctxmod) - mods = ctxmod->get_mods (); - $$ = MAKE_SYNTAX (context_specification, @$, $1, SCM_EOL, mods, SCM_BOOL_T, $3); + | mode_changing_head_with_context optional_context_mods grouped_music_list { + $$ = MAKE_SYNTAX (context_specification, @$, $1, SCM_EOL, $2, SCM_BOOL_T, $3); if (scm_is_eq ($1, ly_symbol2scm ("ChordNames"))) { $$ = MAKE_SYNTAX (unrelativable_music, @$, $$); @@ -2506,15 +2552,13 @@ mode_changed_music: mode_changing_head: NOTEMODE { - SCM nn = parser->lexer_->lookup_identifier ("pitchnames"); - parser->lexer_->push_note_state (nn); + parser->lexer_->push_note_state (Lily::pitchnames); $$ = ly_symbol2scm ("notes"); } | DRUMMODE { - SCM nn = parser->lexer_->lookup_identifier ("drumPitchNames"); - parser->lexer_->push_note_state (nn); + parser->lexer_->push_note_state (Lily::drum_pitch_names); $$ = ly_symbol2scm ("drums"); } @@ -2524,10 +2568,9 @@ mode_changing_head: $$ = ly_symbol2scm ("figures"); } | CHORDMODE { - SCM nn = parser->lexer_->lookup_identifier ("chordmodifiers"); - parser->lexer_->chordmodifier_tab_ = alist_to_hashq (nn); - nn = parser->lexer_->lookup_identifier ("pitchnames"); - parser->lexer_->push_chord_state (nn); + parser->lexer_->chordmodifier_tab_ = + alist_to_hashq (Lily::chordmodifiers); + parser->lexer_->push_chord_state (Lily::pitchnames); $$ = ly_symbol2scm ("chords"); } @@ -2539,8 +2582,7 @@ mode_changing_head: mode_changing_head_with_context: DRUMS { - SCM nn = parser->lexer_->lookup_identifier ("drumPitchNames"); - parser->lexer_->push_note_state (nn); + parser->lexer_->push_note_state (Lily::drum_pitch_names); $$ = ly_symbol2scm ("DrumStaff"); } @@ -2550,10 +2592,9 @@ mode_changing_head_with_context: $$ = ly_symbol2scm ("FiguredBass"); } | CHORDS { - SCM nn = parser->lexer_->lookup_identifier ("chordmodifiers"); - parser->lexer_->chordmodifier_tab_ = alist_to_hashq (nn); - nn = parser->lexer_->lookup_identifier ("pitchnames"); - parser->lexer_->push_chord_state (nn); + parser->lexer_->chordmodifier_tab_ = + alist_to_hashq (Lily::chordmodifiers); + parser->lexer_->push_chord_state (Lily::pitchnames); $$ = ly_symbol2scm ("ChordNames"); } | LYRICS @@ -2573,9 +2614,6 @@ property_path: symbol_list_rev { $$ = scm_reverse_x ($1, SCM_EOL); } - | symbol_list_rev property_path { - $$ = scm_reverse_x ($1, $2); - } ; property_operation: @@ -2585,7 +2623,7 @@ property_operation: | UNSET symbol { $$ = scm_list_2 (ly_symbol2scm ("unset"), $2); } - | OVERRIDE property_path '=' scalar { + | OVERRIDE revert_arg '=' scalar { if (scm_ilength ($2) < 2) { parser->parser_error (@2, _("bad grob property path")); $$ = SCM_UNDEFINED; @@ -2885,6 +2923,14 @@ scalar: $$ = scm_difference ($2, SCM_UNDEFINED); } | string + | symbol_list_part_bare '.' property_path + { + $$ = scm_reverse_x ($1, $3); + } + | symbol_list_part_bare ',' property_path + { + $$ = scm_reverse_x ($1, $3); + } ; event_chord: @@ -2896,15 +2942,11 @@ event_chord: } } %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 @@ -3832,8 +3874,7 @@ markup_uncomposed_list: $$ = $2; } | SCORELINES { - SCM nn = parser->lexer_->lookup_identifier ("pitchnames"); - parser->lexer_->push_note_state (nn); + parser->lexer_->push_note_state (Lily::pitchnames); } '{' score_body '}' { Score *sc = unsmob ($4); sc->origin ()->set_spot (@$); @@ -3946,8 +3987,7 @@ simple_markup: $$ = make_simple_markup ($1); } | SCORE { - SCM nn = parser->lexer_->lookup_identifier ("pitchnames"); - parser->lexer_->push_note_state (nn); + parser->lexer_->push_note_state (Lily::pitchnames); } '{' score_body '}' { Score *sc = unsmob ($4); sc->origin ()->set_spot (@$); @@ -4030,7 +4070,7 @@ Lily_lexer::try_special_identifiers (SCM *destination, SCM sid) return SCM_IDENTIFIER; } else if (unsmob (sid)) { *destination = unsmob (sid)->smobbed_copy (); - return CONTEXT_MOD_IDENTIFIER; + return SCM_IDENTIFIER; } else if (Music *mus = unsmob (sid)) { mus = mus->clone (); *destination = mus->self_scm (); @@ -4050,7 +4090,8 @@ Lily_lexer::try_special_identifiers (SCM *destination, SCM sid) *destination = unsmob (sid)->clone ()->unprotect (); return SCM_IDENTIFIER; } else if (scm_is_pair (sid) - && scm_is_true (Lily::key_list_p (sid))) { + && scm_is_pair (scm_car (sid)) + && scm_is_true (Lily::key_p (scm_caar (sid)))) { *destination = sid; return LOOKUP_IDENTIFIER; } @@ -4105,7 +4146,7 @@ SCM check_scheme_arg (Lily_parser *parser, Input loc, return args; } -SCM loc_on_music (Lily_parser *parser, Input loc, SCM arg) +SCM loc_on_copy (Lily_parser *parser, Input loc, SCM arg) { if (Music *m = unsmob (arg)) { @@ -4113,6 +4154,34 @@ SCM loc_on_music (Lily_parser *parser, Input loc, SCM arg) m->set_spot (parser->lexer_->override_input (loc)); return m->unprotect (); } + if (Book *b = unsmob (arg)) + { + b = b->clone (); + b->origin ()->set_spot (parser->lexer_->override_input (loc)); + return b->unprotect (); + } + if (Context_def *cd = unsmob (arg)) + { + cd = cd->clone (); + cd->origin ()->set_spot (parser->lexer_->override_input (loc)); + return cd->unprotect (); + } + if (Output_def *od = unsmob (arg)) + { + od = od->clone (); + od->input_origin_ = parser->lexer_->override_input (loc); + return od->unprotect (); + } + if (Score *s = unsmob (arg)) + { + s = s->clone (); + s->origin ()->set_spot (parser->lexer_->override_input (loc)); + return s->unprotect (); + } + if (Context_mod *cm = unsmob (arg)) + { + return cm->smobbed_copy (); + } return arg; }