#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
%token CHANGE
%token CHORDMODIFIERS
%token CHORDS
+%token CHORDMODE
%token DOUBLE_ANGLE_OPEN
%token DOUBLE_ANGLE_CLOSE
%token CLEF
%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
%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
%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
%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
$$->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;
'''))
-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)
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