From 843b5cd769205cb24ac30cf179798b487a1173f1 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Sun, 12 Sep 2004 09:24:51 +0000 Subject: [PATCH] * 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. This fixes: morgenlied.ly and input/regression/beam-concave.ly --- ChangeLog | 8 +++ Documentation/topdocs/NEWS.texi | 12 ++++ lily/lily-lexer.cc | 7 +- lily/parser.yy | 124 +++++++++++++++++++++----------- scripts/convert-ly.py | 8 ++- 5 files changed, 112 insertions(+), 47 deletions(-) diff --git a/ChangeLog b/ChangeLog index 896358812d..49ce404f17 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ 2004-09-12 Han-Wen Nienhuys + * 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 diff --git a/Documentation/topdocs/NEWS.texi b/Documentation/topdocs/NEWS.texi index d238b0d003..fccb0325bf 100644 --- a/Documentation/topdocs/NEWS.texi +++ b/Documentation/topdocs/NEWS.texi @@ -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. diff --git a/lily/lily-lexer.cc b/lily/lily-lexer.cc index 07831cd264..2b96e09ffb 100644 --- a/lily/lily-lexer.cc +++ b/lily/lily-lexer.cc @@ -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}, diff --git a/lily/parser.yy b/lily/parser.yy index b77a0f7b73..a69ba4b345 100644 --- a/lily/parser.yy +++ b/lily/parser.yy @@ -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 MUSIC_FUNCTION_SCM_MUSIC %token MUSIC_FUNCTION_SCM_MUSIC_MUSIC %token MUSIC_FUNCTION_SCM_SCM_MUSIC -%token DRUMS +%token DRUMS +%token DRUMMODE %type book_block book_body @@ -419,6 +424,8 @@ or %type lyric_element %type Alternative_music %type markup markup_line markup_list markup_list_body full_markup +%type mode_changing_head +%type mode_changing_head_with_context %type 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; diff --git a/scripts/convert-ly.py b/scripts/convert-ly.py index b683a293f3..3327953d56 100644 --- a/scripts/convert-ly.py +++ b/scripts/convert-ly.py @@ -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 -- 2.39.2