#include "relative-music.hh"
#include "transposed-music.hh"
#include "compressed-music.hh"
+#include "repeated-music.hh"
// mmm
Mudela_version oldest_version ("1.0.7");
-Mudela_version version ("1.0.8");
+Mudela_version version ("1.0.12");
// needed for bison.simple's malloc() and free()
Array<Musical_pitch> *pitch_arr;
Array<String> * strvec;
Array<int> *intvec;
+ Atom * symbol;
Box *box;
- Simultaneous_music *chord;
+ Notename_table *chordmodifiertab;
Duration *duration;
+ General_script_def * script;
Identifier *id;
- Translator* trans;
Music *music;
Music_list *music_list;
Score *score;
Paper_def *paper;
Real real;
Request * request;
- General_script_def * script;
Scalar *scalar;
+ Simultaneous_music *chord;
String *string;
- Atom * symbol;
Symtable * symtable;
Symtables* symtables;
- Text_def * textdef;
Tempo_req *tempo;
+ Text_def * textdef;
+ Translator* trans;
char c;
const char *consstr;
int i;
%token ABSDYNAMIC
%token ACCEPTS
+%token ALTERNATIVE
%token BAR
%token BEAMPLET
%token CADENZA
+%token CHORDMODIFIERS
+%token CHORDS
%token CLEF
%token CM_T
%token CONSISTS
%token DURATION
%token END
+%token EXTENDER
%token FONT
%token GROUPING
%token HEADER
%token NOTENAMES
%token NOTES
%token OCTAVE
-%token OUTPUT
%token PAPER
%token PARTIAL
%token PENALTY
%token PT_T
%token RELATIVE
%token REMOVE
-%token SCHEME /* token vs typedef; can't be named SCM */
+%token REPEAT
+%token SCM_T
+%token SCMFILE
%token SCORE
%token SCRIPT
%token SHAPE
%type <i> dots
%token <i> DIGIT
%token <pitch> NOTENAME_PITCH
+%token <pitch> TONICNAME_PITCH
+%token <pitch> CHORDMODIFIER_PITCH
%token <id> DURATION_IDENTIFIER
%token <id> IDENTIFIER
%token <id> NOTENAME_TABLE_IDENTIFIER
%type <i> open_plet_parens close_plet_parens
%type <i> sub_quotes sup_quotes
%type <music> simple_element request_chord command_element Simple_music Composite_music
+%type <music> Alternative_music Repeated_music
%type <i> abbrev_type
%type <i> int unsigned
%type <i> script_dir
%type <symtables> symtables symtables_body
%type <pitch> explicit_musical_pitch steno_musical_pitch musical_pitch absolute_musical_pitch
+%type <pitch> steno_tonic_pitch
%type <notereq> steno_notepitch
%type <pitch_arr> pitch_list
+%type <music> chord notemode_chord
+%type <pitch_arr> chord_additions chord_subtractions
+%type <pitch> chord_addsub chord_note
%type <midi> midi_block midi_body
%type <duration> duration_length
%type <request> post_request structured_post_request
%type <pair> plet_fraction
%type <request> command_req verbose_command_req
-%type <request> script_req dynamic_req
+%type <request> script_req dynamic_req extender_req
%type <string> string
%type <score> score_block score_body
%type <intarr> shape_array
%type <symtable> symtable symtable_body
%type <trans> translator_spec translator_spec_body
%type <tempo> tempo_request
-%type <notenametab> notenames_body notenames_block
-%expect 3
+%type <notenametab> notenames_body notenames_block chordmodifiers_block
+
+/* 5 extra for notemode_chord */
+%expect 15
%left '-' '+'
notenames_block {
THIS->lexer_p_->set_notename_table ($1);
}
+ | chordmodifiers_block {
+ THIS->lexer_p_->set_chordmodifier_table ($1);
+ }
| mudela_header {
delete header_global_p;
header_global_p = $1;
;
embedded_scm:
- SCHEME STRING ';' {
- #ifdef HAVE_LIBGUILE
+ SCMFILE STRING ';' {
+ read_lily_scm_file (*$2);
+ delete $2;
+ }
+ | SCM_T STRING ';' {
gh_eval_str ($2->ch_l ());
- #endif
delete $2;
};
;
+chordmodifiers_block:
+ CHORDMODIFIERS '{' notenames_body '}' { $$ = $3; }
+ ;
+
+
notenames_block:
NOTENAMES '{' notenames_body '}' { $$ = $3; }
;
$$ = new Score_identifier ($1, SCORE_IDENTIFIER);
}
+ | chordmodifiers_block {
+ $$ = new Notename_table_identifier ($1, NOTENAME_TABLE_IDENTIFIER);
+ }
| notenames_block {
$$ = new Notename_table_identifier ($1, NOTENAME_TABLE_IDENTIFIER);
}
| ';'
;
+optional_dot:
+ /* empty */
+ | '.'
+ ;
+
paper_def_body:
/* empty */ {
Paper_def *p = THIS->default_paper_p ();
| Composite_music
;
+Alternative_music: {
+ Music_list* m = new Music_list;
+ $$ = new Sequential_music (m);
+ }
+ | ALTERNATIVE Simultaneous_music {
+ $$ = $2;
+ }
+ | ALTERNATIVE Sequential_music {
+ $$ = $2;
+ }
+ ;
+
+Repeated_music: REPEAT unsigned Music Alternative_music {
+ Music_sequence* m = dynamic_cast <Music_sequence*> ($4);
+ assert (m);
+ $$ = new Repeated_music ($3, $2 >? 1, m);
+ }
+ ;
+
Sequential_music: '{' Music_list '}' {
$$ = new Sequential_music ($2);
}
delete $2;
delete $4;
}
- | TIMES int '/' int Music {
- $$ = new Compressed_music ($2, $4, $5);
+ | TIMES {
+ THIS->remember_spot ();
+ }
+ /* CONTINUED */
+ int '/' int Music
+ {
+ $$ = new Compressed_music ($3, $5, $6);
+ $$->set_spot (THIS->pop_spot ());
}
+ | Repeated_music { $$ = $1; }
| Simultaneous_music { $$ = $1; }
| Sequential_music { $$ = $1; }
| TRANSPOSE musical_pitch Music {
$$ = new Transposed_music ($3, *$2);
delete $2;
}
+ | TRANSPOSE steno_tonic_pitch Music {
+ $$ = new Transposed_music ($3, *$2);
+ delete $2;
+ }
| NOTES
{ THIS->lexer_p_->push_note_state (); }
Music
{ $$ = $3;
THIS->lexer_p_->pop_state ();
}
-
+ | CHORDS
+ { THIS->lexer_p_->push_chord_state (); }
+ Music
+ {
+ $$ = $3;
+ THIS->lexer_p_->pop_state ();
+ }
| LYRICS
{ THIS->lexer_p_->push_lyric_state (); }
Music
{
$$ = $3;
THIS->lexer_p_->pop_state ();
- }
+ }
| relative_music { $$ = $1; }
;
a->type_i_ = $1;
$$ = a;
}
+ | extender_req {
+ $$ = $1;
+ }
;
optional_modality:
}
;
+steno_tonic_pitch:
+ TONICNAME_PITCH {
+ $$ = $1;
+ }
+ | TONICNAME_PITCH sup_quotes {
+ $$ = $1;
+ $$->octave_i_ += $2;
+ }
+ | TONICNAME_PITCH sub_quotes {
+ $$ = $1;
+ $$->octave_i_ += - $2;
+ }
+ ;
+
explicit_musical_pitch:
MUSICAL_PITCH '{' int_list '}' {/* ugh */
Array<int> &a = *$3;
}
;
+extender_req:
+ EXTENDER {
+ if (!THIS->lexer_p_->lyric_state_b ())
+ THIS->parser_error (_ ("have to be in Lyric mode for lyrics"));
+ Extender_req * e_p = new Extender_req;
+ e_p->spantype = Span_req::START;
+ $$ = e_p;
+ THIS->extender_req = e_p;
+ };
+
dynamic_req:
ABSDYNAMIC '{' unsigned '}' {
Absolute_dynamic_req *ad_p = new Absolute_dynamic_req;
pre_requests:
{
+ if (THIS->extender_req)
+ {
+ Extender_req * e_p = new Extender_req;
+ e_p->spantype = Span_req::STOP;
+ THIS->pre_reqs.push (e_p);
+ THIS->extender_req = 0;
+ }
+
}
| pre_requests open_request_parens {
+
Array<Request*>& r = *THIS->get_parens_request ($2);
for (int i = 0; i < r.size (); i++ )
r[i]->set_spot (THIS->here_input ());
$$ = THIS->get_word_element (*$1, $2);
delete $1;
}
+ | '@' chord {
+ if (!THIS->lexer_p_->chord_state_b ())
+ THIS->parser_error (_ ("have to be in Chord mode for chords"));
+ $$ = $2;
+ }
+ ;
+
+
+chord:
+ notemode_duration steno_musical_pitch chord_additions chord_subtractions {
+ $$ = THIS->get_chord (*$2, $3, $4, *$1);
+ };
+
+chord_additions:
+ {
+ $$ = new Array<Musical_pitch>;
+ }
+ | chord_additions chord_note {
+ $1->push (*$2);
+ $$ = $1;
+ }
+ | chord_additions CHORDMODIFIER_PITCH {
+ /*
+ urg, this is kind of ugly.
+ all but "sus" chord modifiers can be
+ handled as chord_additions...
+ */
+ $1->push (*$2);
+ $$ = $1;
+ }
;
+chord_note:
+ UNSIGNED {
+ $$ = new Musical_pitch;
+ $$->notename_i_ = ($1 - 1) % 7;
+ $$->octave_i_ = $1 > 7 ? 1 : 0;
+ $$->accidental_i_ = 0;
+ }
+ | UNSIGNED '+' {
+ $$ = new Musical_pitch;
+ $$->notename_i_ = ($1 - 1) % 7;
+ $$->octave_i_ = $1 > 7 ? 1 : 0;
+ $$->accidental_i_ = 1;
+ }
+ | UNSIGNED '-' {
+ $$ = new Musical_pitch;
+ $$->notename_i_ = ($1 - 1) % 7;
+ $$->octave_i_ = $1 > 7 ? 1 : 0;
+ $$->accidental_i_ = -1;
+ }
+ ;
+
+chord_subtractions:
+ {
+ $$ = new Array<Musical_pitch>;
+ }
+ | '^' {
+ $$ = new Array<Musical_pitch>;
+ }
+ | chord_subtractions chord_addsub {
+ $$ = $1;
+ $$->push (*$2);
+ }
+ ;
/*
UTILITIES