]> git.donarmstrong.com Git - lilypond.git/commitdiff
* scripts/convert-ly.py (conv): add conversion.
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Sun, 12 Sep 2004 09:24:51 +0000 (09:24 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Sun, 12 Sep 2004 09:24:51 +0000 (09:24 +0000)
* lily/parser.yy: change mode changing commands to XXXmode,
eg. drummode.
(mode_changing_head): group mode changes.
(mode_changing_head_with_context): new commands: create context as
well as change mode.

This fixes: morgenlied.ly and input/regression/beam-concave.ly

ChangeLog
Documentation/topdocs/NEWS.texi
lily/lily-lexer.cc
lily/parser.yy
scripts/convert-ly.py

index 896358812dadcaa5a426ddf8dbb6cac35ab41cdf..49ce404f177feb067a4a02d369aa42e5ad282ea5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2004-09-12  Han-Wen Nienhuys   <hanwen@xs4all.nl>
 
+       * scripts/convert-ly.py (conv): add conversion.
+
+       * lily/parser.yy: change mode changing commands to XXXmode,
+       eg. drummode.
+       (mode_changing_head): group mode changes.
+       (mode_changing_head_with_context): new commands: create context as
+       well as change mode.
+
        * input/regression/system-overstrike.ly: new file.
 
        * scm/page-layout.scm (ly:optimal-page-breaks): add
index d238b0d0038e14e6f21fc1274521e15cef35bc5d..fccb0325bf1605ff0fea5a95144ca120e87d9b34 100644 (file)
@@ -8,6 +8,18 @@
 
 @itemize @bullet
 
+@item The mode changing commands  (@code{\chords}, @code{\lyrics}, etc.)
+have been renamed to @code{\chordmode}, @code{\lyricmode}, etc. The
+command @code{\chords} is an abbreviation for
+
+@example
+  \new ChordNames \chordmode ... 
+@end example
+
+@noindent
+@code{\drums}, @code{\lyrics}, @code{\chords}, @code{\figures}
+function similarly.
+
 @item The types of events quoted with @code{\quote}  can  now be tuned
 with @code{quotedEventTypes}. By default, only notes and rests end up
 in quotes.
index 07831cd264a86a01dcc2122842e0a4b7983ad70f..2b96e09ffbb466da46c5deaaf4b0a117c136ca2d 100644 (file)
@@ -35,25 +35,28 @@ static Keyword_ent the_key_tab[] = {
   {"bookpaper", BOOKPAPER},
   {"change", CHANGE},
   {"chords", CHORDS},
+  {"chordmode", CHORDMODE},
   {"clef", CLEF},
   {"consists", CONSISTS},
   {"context", CONTEXT},
   {"default", DEFAULT},
   {"denies", DENIES},
+  {"drummode", DRUMMODE},
   {"drums", DRUMS},
   {"description", DESCRIPTION},
   {"figures",FIGURES},
+  {"figuremode",FIGUREMODE},
   {"grobdescriptions", GROBDESCRIPTIONS},
   {"header", HEADER},
   {"key", KEY},
-  {"lyrics", LYRICS},
+  {"lyricmode", LYRICMODE},
   {"lyricsto", LYRICSTO},
   {"mark", MARK},
   {"markup", MARKUP},
   {"midi", MIDI},
   {"name", NAME},
   {"new", NEWCONTEXT},
-  {"notes", NOTES},
+  {"notemode", NOTEMODE},
   {"octave", OCTAVE},
   {"once", ONCE},
   {"override", OVERRIDE},
index b77a0f7b73d24777c3967d7e959d2f00c0e32493..a69ba4b34507527a76eea46fbc8be179d1778670 100644 (file)
@@ -53,7 +53,7 @@ TODO:
 #define MY_MAKE_MUSIC(x)  make_music_by_name (ly_symbol2scm (x))
 
 Music *property_op_to_music (SCM op);
-Music *context_spec_music (SCM type, SCM id, Music *m, SCM ops_);
+Music *context_spec_music (SCM type, SCM id, Music *m, SCM ops);
 SCM get_next_unique_context ();
 
 #define YYERROR_VERBOSE 1
@@ -257,6 +257,7 @@ or
 %token CHANGE
 %token CHORDMODIFIERS
 %token CHORDS
+%token CHORDMODE
 %token DOUBLE_ANGLE_OPEN
 %token DOUBLE_ANGLE_CLOSE
 %token CLEF
@@ -267,7 +268,9 @@ or
 %token DENIES
 %token DESCRIPTION
 %token EXTENDER
-%token FIGURES FIGURE_OPEN FIGURE_CLOSE
+%token FIGURES
+%token FIGUREMODE
+%token FIGURE_OPEN FIGURE_CLOSE
 %token FIGURE_BRACKET_CLOSE FIGURE_BRACKET_OPEN
 %token GROBDESCRIPTIONS
 %token HEADER
@@ -275,12 +278,13 @@ or
 %token INVALID
 %token KEY
 %token LYRICS
+%token LYRICMODE
 %token MARK
 %token MIDI
 %token MULTI_MEASURE_REST
 %token NAME
 %token NEWCONTEXT
-%token NOTES
+%token NOTEMODE
 %token OCTAVE
 %token ONCE
 %token OVERRIDE SET REVERT
@@ -361,8 +365,9 @@ or
 %token <scm> MUSIC_FUNCTION_SCM_MUSIC 
 %token <scm> MUSIC_FUNCTION_SCM_MUSIC_MUSIC 
 %token <scm> MUSIC_FUNCTION_SCM_SCM_MUSIC 
-%token DRUMS
 
+%token DRUMS
+%token DRUMMODE
 
 
 %type <book>   book_block book_body
@@ -419,6 +424,8 @@ or
 %type <scm>    lyric_element
 %type <scm>     Alternative_music
 %type <scm>    markup markup_line markup_list markup_list_body full_markup
+%type <scm>    mode_changing_head
+%type <scm>    mode_changing_head_with_context
 
 %type <score>  score_block score_body
 
@@ -1084,66 +1091,99 @@ Prefix_composite_music:
                $$->set_property ("element", p->self_scm ());
                scm_gc_unprotect_object (p->self_scm ());
        }
-       | NOTES
+       | mode_changing_head Grouped_music_list {
+               if ($1 == ly_symbol2scm ("figures"))
+               {
+                 Music *chm = MY_MAKE_MUSIC ("UntransposableMusic");
+                 chm->set_property ("element", $2->self_scm ());
+                 $$ = chm;
+                 scm_gc_unprotect_object ($2->self_scm ());
+               }
+               else
+               {
+                 $$ = $2;
+               }
+               THIS->lexer_->pop_state ();
+       }
+       | mode_changing_head_with_context optional_context_mod Grouped_music_list {
+               $$ = context_spec_music ($1, get_next_unique_context (),
+                                        $3, $2);
+               if ($1 == ly_symbol2scm ("ChordNames"))
                {
+                 Music *chm = MY_MAKE_MUSIC ("UntransposableMusic");
+                 chm->set_property ("element", $$->self_scm ());
+                 scm_gc_unprotect_object ($$->self_scm ());
+                 $$ = chm;
+               }
+               THIS->lexer_->pop_state ();
+       }
+       | relative_music        { $$ = $1; }
+       | re_rhythmed_music     { $$ = $1; }
+       | TAG embedded_scm Music {
+               tag_music ($3, $2, THIS->here_input ());
+               $$ = $3;
+       }
+       ;
+
+mode_changing_head: 
+       NOTEMODE {
                SCM nn = THIS->lexer_->lookup_identifier ("pitchnames");
                THIS->lexer_->push_note_state (alist_to_hashq (nn));
+
+               $$ = ly_symbol2scm ("notes");
        }
-       Grouped_music_list
-               { $$ = $3;
-                 THIS->lexer_->pop_state ();
-               }
-       | DRUMS
+       | DRUMMODE 
                {
                SCM nn = THIS->lexer_->lookup_identifier ("drumPitchNames");
                THIS->lexer_->push_note_state (alist_to_hashq (nn));
+
+               $$ = ly_symbol2scm ("drums");
        }
-       Grouped_music_list
-               { $$ = $3;
-                 THIS->lexer_->pop_state ();
-               }
-       | FIGURES
-               { THIS->lexer_->push_figuredbass_state (); }
-       Grouped_music_list
-               {
-                 Music *chm = MY_MAKE_MUSIC ("UntransposableMusic");
-                 chm->set_property ("element", $3->self_scm ());
-                 $$ = chm;
-                 scm_gc_unprotect_object ($3->self_scm ());
+       | FIGUREMODE {
+               THIS->lexer_->push_figuredbass_state ();
 
-                 THIS->lexer_->pop_state ();
+               $$ = ly_symbol2scm ("figures");
        }
-       | CHORDS {
+       | CHORDMODE {
                SCM nn = THIS->lexer_->lookup_identifier ("chordmodifiers");
                THIS->lexer_->chordmodifier_tab_ = alist_to_hashq (nn);
                nn = THIS->lexer_->lookup_identifier ("pitchnames");
                THIS->lexer_->push_chord_state (alist_to_hashq (nn));
+               $$ = ly_symbol2scm ("chords");
 
        }
-       Grouped_music_list
-       {
-                 Music *chm = MY_MAKE_MUSIC ("UnrelativableMusic");
-                 chm->set_property ("element", $3->self_scm ());
-                 scm_gc_unprotect_object ($3->self_scm ());
-                 $$ = chm;
+       | LYRICMODE
+               { THIS->lexer_->push_lyric_state ();
+               $$ = ly_symbol2scm ("lyrics");
+       }
+       ;
 
-                 THIS->lexer_->pop_state ();
+mode_changing_head_with_context: 
+       DRUMS {
+               SCM nn = THIS->lexer_->lookup_identifier ("drumPitchNames");
+               THIS->lexer_->push_note_state (alist_to_hashq (nn));
+
+               $$ = ly_symbol2scm ("DrumStaff");
        }
-       | LYRICS
-               { THIS->lexer_->push_lyric_state (); }
-       Grouped_music_list
-               {
-                 $$ = $3;
-                 THIS->lexer_->pop_state ();
+       | FIGURES {
+               THIS->lexer_->push_figuredbass_state ();
+
+               $$ = ly_symbol2scm ("FiguredBass");
        }
-       | relative_music        { $$ = $1; }
-       | re_rhythmed_music     { $$ = $1; }
-       | TAG embedded_scm Music {
-               tag_music ($3, $2, THIS->here_input ());
-               $$ = $3;
+       | CHORDS {
+               SCM nn = THIS->lexer_->lookup_identifier ("chordmodifiers");
+               THIS->lexer_->chordmodifier_tab_ = alist_to_hashq (nn);
+               nn = THIS->lexer_->lookup_identifier ("pitchnames");
+               THIS->lexer_->push_chord_state (alist_to_hashq (nn));
+               $$ = ly_symbol2scm ("ChordNames");
+       }
+       | LYRICS
+               { THIS->lexer_->push_lyric_state ();
+               $$ = ly_symbol2scm ("Lyrics");
        }
        ;
 
+
 relative_music:
        RELATIVE absolute_pitch Music {
                Music *m = $3;
index b683a293f33bfffdd4c98816fff3525620332825..3327953d56f3259c2a0a8146258df32a73bb3252 100644 (file)
@@ -2178,10 +2178,11 @@ soloADue -> printPartCombineTexts, #notes-to-clusters -> \\makeClusters
 '''))
 
 
-def conv_mode_experiment (str):
+def conv (str):
        str = re.sub (r'\\chords\b', r'\\chordmode', str)
        str = re.sub (r'\\lyrics\b', r'\\lyricmode', str)
        str = re.sub (r'\\figures\b', r'\\figuremode', str)
+       str = re.sub (r'\\notes\b', r'\\notemode', str)
        str = re.sub (r'\\drums\b', r'\\drummode', str)
        str = re.sub (r'\\chordmode\s*\\new ChordNames', r'\\chords', str)
        str = re.sub (r'\\new ChordNames\s*\\chordmode', r'\\chords', str)
@@ -2192,8 +2193,9 @@ def conv_mode_experiment (str):
 
        return str
 
-#conversions.append (((2, 3, 9), conv,
-#                   '''fold \new FooContext \foomode into \foo.'''))
+conversions.append (((2, 3, 16), conv,
+                    '''\foo -> \foomode (for chords, notes, etc.)
+fold \new FooContext \foomode into \foo.'''))
 
 ################################
 #      END OF CONVERSIONS