From: David Kastrup Date: Thu, 2 Jun 2016 12:18:48 +0000 (+0200) Subject: Issue 4874/3: Import various input session variables into parser X-Git-Tag: release/2.19.43-1^2~3 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=88f80785a4eaa56c941bedcfe2c9508793eea2a5;p=lilypond.git Issue 4874/3: Import various input session variables into parser This concerns pitchnames, drumPitchNames, and chordmodifiers, saving a lookup for each use. --- diff --git a/lily/include/lily-imports.hh b/lily/include/lily-imports.hh index 97982895f5..d930f69cf9 100644 --- a/lily/include/lily-imports.hh +++ b/lily/include/lily-imports.hh @@ -58,8 +58,10 @@ namespace Lily { extern Variable beat_structure; extern Variable calc_repeat_slash_count; extern Variable car_less; + extern Variable chordmodifiers; extern Variable construct_chord_elements; extern Variable default_time_signature_settings; + extern Variable drum_pitch_names; extern Variable grob_compose_function; extern Variable grob_offset_function; extern Variable hash_table_to_alist; @@ -91,6 +93,7 @@ namespace Lily { #endif extern Variable f_parser; extern Variable percussion_p; + extern Variable pitchnames; extern Variable pure_chain_offset_callback; extern Variable remove_stencil_warnings; extern Variable scale_layout; diff --git a/lily/lily-imports.cc b/lily/lily-imports.cc index adc9124fb7..62e58b603c 100644 --- a/lily/lily-imports.cc +++ b/lily/lily-imports.cc @@ -52,8 +52,10 @@ namespace Lily { Variable beat_structure ("beat-structure"); Variable calc_repeat_slash_count ("calc-repeat-slash-count"); Variable car_less ("car<"); + Variable chordmodifiers ("chordmodifiers"); Variable construct_chord_elements ("construct-chord-elements"); Variable default_time_signature_settings ("default-time-signature-settings"); + Variable drum_pitch_names ("drumPitchNames"); Variable grob_compose_function ("grob::compose-function"); Variable grob_offset_function ("grob::offset-function"); Variable hash_table_to_alist ("hash-table->alist"); @@ -85,6 +87,7 @@ namespace Lily { #endif Variable f_parser ("%parser"); Variable percussion_p ("percussion?"); + Variable pitchnames ("pitchnames"); Variable pure_chain_offset_callback ("pure-chain-offset-callback"); Variable remove_stencil_warnings ("remove-stencil-warnings"); Variable scale_layout ("scale-layout"); diff --git a/lily/parser.yy b/lily/parser.yy index b8849e8f4a..1695aea625 100644 --- a/lily/parser.yy +++ b/lily/parser.yy @@ -387,8 +387,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; @@ -824,8 +823,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 { @@ -1282,8 +1280,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 (); @@ -1455,8 +1452,7 @@ 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 (); @@ -2530,15 +2526,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"); } @@ -2548,10 +2542,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"); } @@ -2563,8 +2556,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"); } @@ -2574,10 +2566,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 @@ -3861,8 +3852,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 (@$); @@ -3975,8 +3965,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 (@$);