]> git.donarmstrong.com Git - lilypond.git/commitdiff
Issue 4874/3: Import various input session variables into parser
authorDavid Kastrup <dak@gnu.org>
Thu, 2 Jun 2016 12:18:48 +0000 (14:18 +0200)
committerDavid Kastrup <dak@gnu.org>
Thu, 9 Jun 2016 07:33:10 +0000 (09:33 +0200)
This concerns pitchnames, drumPitchNames, and chordmodifiers,
saving a lookup for each use.

lily/include/lily-imports.hh
lily/lily-imports.cc
lily/parser.yy

index 97982895f50c851ef1b993c157956fdf9fb771b6..d930f69cf940527ddd9eba2703ecf5920e220d34 100644 (file)
@@ -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;
index adc9124fb7dc948c613515dff9c2a585a9350987..62e58b603c1ff36e8c150fbf920c9e6bae711965 100644 (file)
@@ -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");
index b8849e8f4acaa79447fe0a81daa4d6e0d8a218d3..1695aea6259d838f12655f412692210e251eeb4e 100644 (file)
@@ -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<Score> ($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<Score> ($4);
                sc->origin ()->set_spot (@$);