1 %{ // -*-Fundamental-*-
4 parser.yy -- Bison/C++ parser for mudela
6 source file of the GNU LilyPond music typesetter
8 (c) 1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
9 Jan Nieuwenhuizen <janneke@gnu.org>
13 #include "lily-guile.hh"
14 #include "translation-property.hh"
17 #include "my-lily-lexer.hh"
18 #include "paper-def.hh"
19 #include "midi-def.hh"
21 #include "file-path.hh"
23 #include "dimensions.hh"
24 #include "identifier.hh"
25 #include "command-request.hh"
26 #include "musical-request.hh"
27 #include "my-lily-parser.hh"
28 #include "context-specced-music.hh"
29 #include "translator-group.hh"
31 #include "music-list.hh"
32 #include "change-translator.hh"
33 #include "file-results.hh"
35 #include "relative-music.hh"
36 #include "lyric-combine-music.hh"
37 #include "transposed-music.hh"
38 #include "time-scaled-music.hh"
39 #include "repeated-music.hh"
40 #include "mudela-version.hh"
41 #include "grace-music.hh"
42 #include "auto-change-music.hh"
43 #include "output-property.hh"
48 return t && t == 1 << intlog2(t);
53 Mudela_version oldest_version ("1.3.42");
56 print_mudela_versions (ostream &os)
58 os << _f ("Oldest supported input version: %s", oldest_version.str ())
63 // needed for bison.simple's malloc() and free()
70 #define YYERROR_VERBOSE 1
72 #define YYPARSE_PARAM my_lily_parser_l
73 #define YYLEX_PARAM my_lily_parser_l
74 #define THIS ((My_lily_parser *) my_lily_parser_l)
76 #define yyerror THIS->parser_error
77 #define ARRAY_SIZE(a,s) if (a.size () != s) THIS->parser_error (_f ("Expecting %d arguments", s))
83 Array<Musical_pitch> *pitch_arr;
84 Link_array<Request> *reqvec;
90 Music_list *music_list;
95 Music_output_def * outputdef;
96 Musical_pitch * pitch;
103 /* We use SCMs to do strings, because it saves us the trouble of
104 deleting them. Let's hope that a stack overflow doesnt trigger a move
105 of the parse stack onto the heap. */
109 Translator_group* trans;
115 yylex (YYSTYPE *s, void * v_l)
117 My_lily_parser *pars_l = (My_lily_parser*) v_l;
118 My_lily_lexer * lex_l = pars_l->lexer_p_;
120 lex_l->lexval_l = (void*) s;
121 return lex_l->yylex ();
129 /* tokens which are not keywords */
136 %token CHORDMODIFIERS
179 %token COMMANDSPANREQUEST
181 %token OUTPUTPROPERTY
190 %token E_CHAR E_EXCLAMATION E_SMALLER E_BIGGER
191 %token CHORD_BASS CHORD_COLON CHORD_MINUS CHORD_CARET
193 %type <i> exclamations questions
195 %token <pitch> NOTENAME_PITCH
196 %token <pitch> TONICNAME_PITCH
197 %token <pitch> CHORDMODIFIER_PITCH
198 %token <id> DURATION_IDENTIFIER
199 %token <id> IDENTIFIER
200 %token <id> MUSIC_IDENTIFIER
201 %token <id> REQUEST_IDENTIFIER
202 %token <id> REAL_IDENTIFIER
203 %token <id> STRING_IDENTIFIER
204 %token <id> TRANS_IDENTIFIER
205 %token <id> INT_IDENTIFIER
206 %token <id> SCORE_IDENTIFIER
207 %token <id> MIDI_IDENTIFIER
208 %token <id> PAPER_IDENTIFIER
210 %token <scm> DURATION RESTNAME
216 %type <outputdef> output_def
217 %type <scope> mudela_header mudela_header_body
218 %type <request> open_request_parens close_request_parens open_request close_request
219 %type <request> request_with_dir request_that_take_dir verbose_request
220 %type <i> sub_quotes sup_quotes
221 %type <music> simple_element request_chord command_element Simple_music Composite_music
222 %type <music> Alternative_music Repeated_music
223 %type <i> tremolo_type
224 %type <i> int unsigned
226 %type <i> optional_modality
227 %type <id> identifier_init
228 %type <duration> steno_duration optional_notemode_duration
229 %type <duration> entered_notemode_duration explicit_duration
230 %type <intvec> int_list
231 %type <reqvec> pre_requests post_requests
232 %type <request> gen_text_def
233 %type <pitch> steno_musical_pitch musical_pitch absolute_musical_pitch
234 %type <pitch> steno_tonic_pitch
236 %type <pitch_arr> pitch_list chord_additions chord_subtractions chord_notes chord_step
238 %type <pitch> chord_note chord_inversion chord_bass
239 %type <midi> midi_block midi_body
240 %type <duration> duration_length
242 %type <scm> embedded_scm scalar
243 %type <music> Music Sequential_music Simultaneous_music Music_sequence
244 %type <music> relative_music re_rhythmed_music
245 %type <music> property_def translator_change
246 %type <music_list> Music_list
247 %type <paper> paper_block paper_def_body
248 %type <real> real real_with_dimension
249 %type <request> shorthand_command_req
250 %type <request> post_request
251 %type <request> command_req verbose_command_req
252 %type <request> extender_req
253 %type <request> hyphen_req
255 %type <score> score_block score_body
257 %type <trans> translator_spec_block translator_spec_body
258 %type <tempo> tempo_request
259 %type <scm> notenames_body notenames_block chordmodifiers_block
260 %type <scm> script_abbreviation
271 | mudela toplevel_expression {}
272 | mudela assignment { }
275 THIS->error_level_i_ =1;
281 THIS->lexer_p_->pitchname_tab_ = $1;
283 | chordmodifiers_block {
284 THIS->lexer_p_->chordmodifier_tab_ = $1;
287 delete header_global_p;
288 header_global_p = $1;
291 score_global_array.push ($1);
294 Identifier * id = new
295 Paper_def_identifier ($1, PAPER_IDENTIFIER);
296 THIS->lexer_p_->set_identifier ("$defaultpaper", id)
299 Identifier * id = new
300 Midi_def_identifier ($1, MIDI_IDENTIFIER);
301 THIS->lexer_p_->set_identifier ("$defaultmidi", id)
313 chordmodifiers_block:
314 CHORDMODIFIERS notenames_body { $$ = $2; }
319 NOTENAMES notenames_body { $$ = $2; }
326 int i = scm_ilength ($1);
328 SCM tab = scm_make_vector (gh_int2scm (i), SCM_EOL);
329 for (SCM s = $1; s != SCM_EOL; s = gh_cdr (s)) {
330 SCM pt = gh_cdar (s);
331 if (scm_ilength (pt) != 3)
332 THIS->parser_error ("Need three args");
333 scm_hashq_set_x (tab, gh_caar(s), pt);
343 THIS->lexer_p_-> scope_l_arr_.push ($$);
345 | mudela_header_body assignment semicolon {
351 HEADER '{' mudela_header_body '}' {
353 THIS->lexer_p_-> scope_l_arr_.pop ();
363 THIS->remember_spot ();
365 /* cont */ '=' identifier_init {
366 THIS->lexer_p_->set_identifier (ly_scm2string ($1), $4);
368 $4->set_spot (THIS->pop_spot ());
376 $$ = new Score_identifier ($1, SCORE_IDENTIFIER);
380 $$ = new Paper_def_identifier ($1, PAPER_IDENTIFIER);
383 $$ = new Midi_def_identifier ($1, MIDI_IDENTIFIER);
386 | translator_spec_block {
387 $$ = new Translator_group_identifier ($1, TRANS_IDENTIFIER);
390 $$ = new Music_identifier ($1, MUSIC_IDENTIFIER);
394 $$ = new Request_identifier ($1, REQUEST_IDENTIFIER);
396 | explicit_duration {
397 $$ = new Duration_identifier ($1, DURATION_IDENTIFIER);
400 $$ = new Real_identifier (new Real ($1), REAL_IDENTIFIER);
403 $$ = new String_identifier (new String (ly_scm2string ($1)), STRING_IDENTIFIER);
406 $$ = new int_identifier (new int ($1), INT_IDENTIFIER);
410 translator_spec_block:
411 TRANSLATOR '{' translator_spec_body '}'
417 translator_spec_body:
419 $$ = $1->access_content_Translator_group (true);
420 $$-> set_spot (THIS->here_input ());
422 | TYPE STRING semicolon {
423 Translator* t = get_translator_l (ly_scm2string ($2));
424 Translator_group * tg = dynamic_cast<Translator_group*> (t);
427 THIS->parser_error (_("Need a translator group for a context"));
429 tg = dynamic_cast<Translator_group*> (t->clone ());
430 tg->set_spot (THIS->here_input ());
433 | translator_spec_body STRING '=' embedded_scm {
434 Translator_group* tg = dynamic_cast<Translator_group*> ($$);
435 tg->set_property (ly_scm2string ($2), $4);
437 | translator_spec_body STRING '=' identifier_init semicolon {
439 String_identifier *s = dynamic_cast<String_identifier*> (id);
440 Real_identifier *r= dynamic_cast<Real_identifier*>(id);
441 int_identifier *i = dynamic_cast<int_identifier*> (id);
444 if (s) v = ly_str02scm (s->access_content_String (false)->ch_C());
445 if (i) v = gh_int2scm (*i->access_content_int (false));
446 if (r) v = gh_double2scm (*r->access_content_Real (false));
448 THIS->parser_error (_("Wrong type for property value"));
452 Translator_group* tg = dynamic_cast<Translator_group*> ($$);
454 tg->set_property (ly_scm2string ($2), v);
456 | translator_spec_body NAME STRING semicolon {
457 $$->type_str_ = ly_scm2string ($3);
459 | translator_spec_body CONSISTS STRING semicolon {
460 dynamic_cast<Translator_group*> ($$)-> set_element (ly_scm2string ($3), true);
462 | translator_spec_body CONSISTSEND STRING semicolon {
463 dynamic_cast<Translator_group*> ($$)-> set_element (ly_scm2string ($3), true);
465 | translator_spec_body ACCEPTS STRING semicolon {
466 dynamic_cast<Translator_group*> ($$)-> set_acceptor (ly_scm2string ($3), true);
468 | translator_spec_body REMOVE STRING semicolon {
469 dynamic_cast<Translator_group*> ($$)-> set_element (ly_scm2string ($3), false);
479 /*cont*/ '{' score_body '}' {
481 if (!$$->def_p_arr_.size ())
484 THIS->lexer_p_->lookup_identifier ("$defaultpaper");
485 $$->add_output (id ? id->access_content_Paper_def (true) : new Paper_def );
493 $$->set_spot (THIS->here_input ());
497 $$ = $1->access_content_Score (true);
499 | score_body mudela_header {
502 | score_body output_def {
524 PAPER '{' paper_def_body '}' {
526 THIS-> lexer_p_->scope_l_arr_.pop ();
533 Identifier *id = THIS->lexer_p_->lookup_identifier ("$defaultpaper");
534 Paper_def *p = id ? id->access_content_Paper_def (true) : new Paper_def;
535 THIS-> lexer_p_-> scope_l_arr_.push (p->scope_p_);
539 Paper_def *p = $1->access_content_Paper_def (true);
540 THIS->lexer_p_->scope_l_arr_.push (p->scope_p_);
543 | paper_def_body int '=' FONT STRING { // ugh, what a syntax
544 Lookup * l = new Lookup;
545 l->font_name_ = ly_scm2string ($5);
546 $$->set_lookup ($2, l);
548 | paper_def_body assignment semicolon {
551 | paper_def_body translator_spec_block {
552 $$->assign_translator ($2);
554 | paper_def_body error {
583 | real_with_dimension
585 $$= *$1->access_content_Real (false);
587 | '-' real %prec UNARY_MINUS {
614 THIS-> lexer_p_-> scope_l_arr_.pop();
618 midi_body: /* empty */ {
619 Identifier *id = THIS->lexer_p_->lookup_identifier ("$defaultmidi");
621 ? id->access_content_Midi_def (true) : new Midi_def ;
624 THIS->lexer_p_->scope_l_arr_.push (p->scope_p_);
627 Midi_def * p =$1-> access_content_Midi_def (true);
629 THIS->lexer_p_->scope_l_arr_.push (p->scope_p_);
631 | midi_body assignment semicolon {
634 | midi_body translator_spec_block {
635 $$-> assign_translator ($2);
637 | midi_body tempo_request semicolon {
639 junk this ? there already is tempo stuff in
642 $$->set_tempo ($2->dur_.length_mom (), $2->metronome_i_);
651 TEMPO steno_duration '=' unsigned {
655 $$-> metronome_i_ = $4;
659 Music_list: /* empty */ {
661 $$->set_spot (THIS->here_input ());
680 | ALTERNATIVE Music_sequence {
682 $2->set_spot (THIS->here_input ());
690 REPEAT STRING unsigned Music Alternative_music
692 Music_sequence* m = dynamic_cast <Music_sequence*> ($5);
693 if (m && $3 < m->length_i ())
694 $5->warning (_ ("More alternatives than repeats. Junking excess alternatives."));
696 Repeated_music * r = new Repeated_music ($4, $3 >? 1, m);
698 r->type_ = ly_scm2string ($2);
699 r->fold_b_ = (r->type_ == "fold");
700 r->volta_fold_b_ = (r->type_ == "volta");
701 r->set_spot ($4->spot ());
705 Music_sequence: '{' Music_list '}' {
706 $$ = new Music_sequence ($2);
707 $$->set_spot ($2->spot ());
712 SEQUENTIAL '{' Music_list '}' {
713 $$ = new Sequential_music ($3);
714 $$->set_spot ($3->spot ());
716 | '{' Music_list '}' {
717 $$ = new Sequential_music ($2);
718 $$->set_spot ($2->spot ());
723 SIMULTANEOUS '{' Music_list '}'{
724 $$ = new Simultaneous_music ($3);
725 $$->set_spot ($3->spot ());
727 | '<' Music_list '>' {
728 $$ = new Simultaneous_music ($2);
729 $$->set_spot ($2->spot ());
734 request_chord { $$ = $1; }
735 | OUTPUTPROPERTY embedded_scm embedded_scm '=' embedded_scm {
737 if (!gh_symbol_p ($3))
739 THIS->parser_error (_("Second argument must be a symbol"));
741 /*hould check # args */
742 if (!gh_procedure_p (pred))
744 THIS->parser_error (_("First argument must be a procedure taking 1 argument"));
747 $$ = new Output_property (pred,$3, $5);
749 | MUSIC_IDENTIFIER { $$ = $1->access_content_Music (true); }
752 | Simple_music '*' unsigned '/' unsigned {
754 $$->compress (Moment($3, $5 ));
756 | Simple_music '*' unsigned {
758 $$->compress (Moment ($3, 1));
764 CONTEXT STRING Music {
765 Context_specced_music *csm = new Context_specced_music ($3);
767 csm->translator_type_str_ = ly_scm2string ($2);
768 csm->translator_id_str_ = "";
773 | AUTOCHANGE STRING Music {
774 Auto_change_music * chm = new Auto_change_music (ly_scm2string ($2), $3);
777 chm->set_spot ($3->spot ());
780 $$ = new Grace_music ($2);
782 | CONTEXT STRING '=' STRING Music {
783 Context_specced_music *csm = new Context_specced_music ($5);
785 csm->translator_type_str_ = ly_scm2string ($2);
786 csm->translator_id_str_ = ly_scm2string ($4);
791 THIS->remember_spot ();
794 unsigned '/' unsigned Music
797 $$ = new Time_scaled_music ($3, $5, $6);
798 $$->set_spot (THIS->pop_spot ());
800 | Repeated_music { $$ = $1; }
801 | Simultaneous_music { $$ = $1; }
802 | Sequential_music { $$ = $1; }
803 | TRANSPOSE musical_pitch Music {
804 $$ = new Transposed_music ($3, *$2);
807 | TRANSPOSE steno_tonic_pitch Music {
808 $$ = new Transposed_music ($3, *$2);
812 { THIS->lexer_p_->push_note_state (); }
815 THIS->lexer_p_->pop_state ();
818 { THIS->lexer_p_->push_chord_state (); }
822 THIS->lexer_p_->pop_state ();
825 { THIS->lexer_p_->push_lyric_state (); }
829 THIS->lexer_p_->pop_state ();
831 | relative_music { $$ = $1; }
832 | re_rhythmed_music { $$ = $1; }
836 RELATIVE absolute_musical_pitch Music {
837 $$ = new Relative_octave_music ($3, *$2);
843 ADDLYRICS Music Music {
844 Lyric_combine_music * l = new Lyric_combine_music ($2, $3);
850 TRANSLATOR STRING '=' STRING {
851 Change_translator * t = new Change_translator;
852 t-> change_to_type_str_ = ly_scm2string ($2);
853 t-> change_to_id_str_ = ly_scm2string ($4);
856 $$->set_spot (THIS->here_input ());
861 PROPERTY STRING '.' STRING '=' scalar {
862 Translation_property *t = new Translation_property;
864 t->var_str_ = ly_scm2string ($4);
867 Context_specced_music *csm = new Context_specced_music (t);
869 $$->set_spot (THIS->here_input ());
871 csm-> translator_type_str_ = ly_scm2string ($2);
877 | int { $$ = gh_int2scm ($1); }
878 | embedded_scm { $$ = $1; }
883 pre_requests simple_element post_requests {
884 Music_sequence *l = dynamic_cast<Music_sequence*>($2);
886 for (int i=0; i < $1->size(); i++)
887 l->add_music ($1->elem(i));
888 for (int i=0; i < $3->size(); i++)
889 l->add_music ($3->elem(i));
892 programming_error ("Need Sequence to add music to");
901 $$ = new Request_chord;
902 $$-> set_spot (THIS->here_input ());
903 $1-> set_spot (THIS->here_input ());
904 ((Simultaneous_music*)$$) ->add_music ($1);//ugh
906 | PARTIAL duration_length ';' {
907 Translation_property * p = new Translation_property;
908 p->var_str_ = "measurePosition";
909 p->value_ = (new Moment (-$2->length_mom ()))->smobify_self ();
911 Context_specced_music * sp = new Context_specced_music (p);
913 sp-> translator_type_str_ = "Score";
918 shorthand_command_req
919 | verbose_command_req semicolon { $$ = $1; }
922 shorthand_command_req:
930 $$ = new Barcheck_req;
936 Span_req*b= new Span_req;
937 b->span_dir_ = START;
938 b->span_type_str_ = "beam";
942 Span_req*b= new Span_req;
944 b->span_type_str_ = "beam";
948 $$ = new Breathing_sign_req;
956 $$ = new Bar_req (ly_scm2string ($2));
958 | COMMANDSPANREQUEST int STRING {
959 Span_req * sp_p = new Span_req;
960 sp_p-> span_dir_ = Direction($2);
961 sp_p->span_type_str_ = ly_scm2string ($3);
962 sp_p->set_spot (THIS->here_input ());
966 Mark_req * m = new Mark_req;
970 Mark_req *m = new Mark_req;
976 Mark_req *m = new Mark_req;
977 m->mark_label_ = gh_int2scm ($2);
981 | TIME_T unsigned '/' unsigned {
982 Time_signature_change_req *m = new Time_signature_change_req;
988 Break_req * b = new Break_req;
989 b->penalty_f_ = $2 / 100.0;
990 b->set_spot (THIS->here_input ());
993 | SKIP duration_length {
994 Skip_req * skip_p = new Skip_req;
995 skip_p->duration_ = *$2;
1003 $$ = new Clef_change_req (ly_scm2string ($2));
1007 Key_change_req *key_p= new Key_change_req;
1011 /* UGH. optional. */
1013 | KEY NOTENAME_PITCH optional_modality {
1014 Key_change_req *key_p= new Key_change_req;
1016 d.pitch_arr_.push (*$2);
1017 d.ordinary_key_b_ = true;
1020 key_p->key_ = new Key_def (d);
1024 | KEYSIGNATURE pitch_list {
1025 Key_change_req *key_p= new Key_change_req;
1028 d.ordinary_key_b_ = false;
1030 key_p->key_ = new Key_def(d);
1038 $$ = new Link_array<Request>;
1040 | post_requests post_request {
1041 $2->set_spot (THIS->here_input ());
1053 request_that_take_dir:
1056 | script_abbreviation {
1057 Identifier*i = THIS->lexer_p_->lookup_identifier ("dash-" + ly_scm2string ($1));
1058 Articulation_req *a = new Articulation_req;
1059 a->articulation_str_ = *i->access_content_String (false);
1065 script_dir request_that_take_dir {
1066 if (Script_req * gs = dynamic_cast<Script_req*> ($2))
1067 gs->dir_ = Direction ($1);
1069 $2->warning (_ ("Can't specify direction for this request"));
1075 REQUEST_IDENTIFIER {
1076 $$ = (Request*)$1->access_content_Request (true);
1077 $$->set_spot (THIS->here_input ());
1079 | TEXTSCRIPT STRING STRING {
1080 Text_script_req *ts_p = new Text_script_req;
1081 ts_p-> text_str_ = ly_scm2string ($2);
1082 ts_p-> style_str_ = ly_scm2string ($3);
1083 ts_p->set_spot (THIS->here_input ());
1087 | SPANREQUEST int STRING {
1088 Span_req * sp_p = new Span_req;
1089 sp_p-> span_dir_ = Direction($2);
1090 sp_p->span_type_str_ = ly_scm2string ($3);
1091 sp_p->set_spot (THIS->here_input ());
1095 Tremolo_req* a = new Tremolo_req;
1096 a->set_spot (THIS->here_input ());
1101 Articulation_req * a = new Articulation_req;
1102 a->articulation_str_ = ly_scm2string ($2);
1103 a->set_spot (THIS->here_input ());
1135 steno_musical_pitch:
1139 | NOTENAME_PITCH sup_quotes {
1141 $$->octave_i_ += $2;
1143 | NOTENAME_PITCH sub_quotes {
1145 $$->octave_i_ += - $2;
1153 | TONICNAME_PITCH sup_quotes {
1155 $$->octave_i_ += $2;
1157 | TONICNAME_PITCH sub_quotes {
1159 $$->octave_i_ += - $2;
1164 steno_musical_pitch {
1167 | MUSICAL_PITCH embedded_scm {
1168 int sz = scm_ilength ($2);
1170 THIS->parser_error (_f ("Expecting %d arguments", 3));
1171 $2 = gh_list (gh_int2scm (0), gh_int2scm (0), gh_int2scm (0), SCM_UNDEFINED);
1173 $$ = new Musical_pitch ($2);
1178 DURATION '{' int_list '}' {
1180 Array<int> &a = *$3;
1183 $$-> durlog_i_ = a[0];
1184 $$-> dots_i_ = a[1];
1192 if (!THIS->lexer_p_->lyric_state_b ())
1193 THIS->parser_error (_ ("Have to be in Lyric mode for lyrics"));
1194 $$ = new Extender_req;
1200 if (!THIS->lexer_p_->lyric_state_b ())
1201 THIS->parser_error (_ ("Have to be in Lyric mode for lyrics"));
1202 $$ = new Hyphen_req;
1207 close_request_parens {
1209 dynamic_cast<Span_req*> ($$)->span_dir_ = START;
1212 close_request_parens:
1214 Span_req* s= new Span_req;
1216 s->span_type_str_ = "slur";
1219 Span_req*s =new Span_req;
1221 s->span_type_str_ = "crescendo";
1224 Span_req*s =new Span_req;
1226 s->span_type_str_ = "decrescendo";
1232 open_request_parens {
1234 dynamic_cast<Span_req*> ($$)->span_dir_ = STOP;
1238 open_request_parens:
1240 Span_req *s = new Span_req;
1241 s->span_type_str_ = "crescendo";
1245 Span_req* s= new Span_req;
1247 s->span_type_str_ = "slur";
1253 Text_script_req *t = new Text_script_req;
1255 t->text_str_ = ly_scm2string ($1);
1257 $$->set_spot (THIS->here_input ());
1260 Text_script_req* t = new Text_script_req;
1262 t->text_str_ = to_str ($1);
1263 t->style_str_ = "finger";
1264 $$->set_spot (THIS->here_input ());
1268 script_abbreviation:
1270 $$ = gh_str02scm ("hat");
1273 $$ = gh_str02scm("plus");
1276 $$ = gh_str02scm ("dash");
1279 $$ = gh_str02scm ("bar");
1282 $$ = gh_str02scm ("larger");
1285 $$ = gh_str02scm ("dot");
1293 | '-' { $$ = CENTER; }
1298 $$ = new Link_array<Request>;
1300 | pre_requests open_request {
1305 absolute_musical_pitch:
1306 steno_musical_pitch {
1315 | duration_length '*' unsigned {
1316 $$->tuplet_iso_i_ *= $3;
1318 | duration_length '/' unsigned {
1319 $$->tuplet_type_i_ *= $3;
1323 entered_notemode_duration:
1325 THIS->set_last_duration ($1);
1329 optional_notemode_duration:
1331 $$ = new Duration (THIS->default_duration_);
1333 | entered_notemode_duration {
1341 if (!is_duration_b ($1))
1342 THIS->parser_error (_f ("not a duration: %d", $1));
1344 $$->durlog_i_ = intlog2 ($1);
1347 | DURATION_IDENTIFIER {
1348 $$ = $1->access_content_Duration (true);
1350 | steno_duration '.' {
1361 if (!is_duration_b ($2))
1362 THIS->parser_error (_f ("not a duration: %d", $2));
1369 musical_pitch exclamations questions optional_notemode_duration {
1370 if (!THIS->lexer_p_->note_state_b ())
1371 THIS->parser_error (_ ("Have to be in Note mode for notes"));
1374 Note_req *n = new Note_req;
1379 n->cautionary_b_ = $3 % 2;
1380 n->forceacc_b_ = $2 % 2 || n->cautionary_b_;
1382 Simultaneous_music*v = new Request_chord;
1383 v->set_spot ($1->spot ());
1384 n->set_spot ($1->spot ());
1394 | RESTNAME optional_notemode_duration {
1395 Simultaneous_music* velt_p = new Request_chord;
1396 velt_p->set_spot (THIS->here_input());
1398 if (ly_scm2string ($1) =="s")
1400 Skip_req * skip_p = new Skip_req;
1401 skip_p->duration_ = *$2;
1403 skip_p->set_spot (THIS->here_input());
1404 velt_p->add_music (skip_p);
1408 Rest_req * rest_req_p = new Rest_req;
1409 rest_req_p->duration_ = *$2;
1410 rest_req_p->set_spot (THIS->here_input());
1412 velt_p->add_music (rest_req_p);
1418 | MEASURES optional_notemode_duration {
1419 Skip_req * sk = new Skip_req;
1420 sk->duration_ = *$2;
1421 Music_list * ms = new Music_list;
1422 Request_chord * rqc1 = new Request_chord;
1423 Request_chord * rqc2 = new Request_chord;
1424 Request_chord * rqc3 = new Request_chord;
1426 Span_req *sp1 = new Span_req;
1427 Span_req *sp2 = new Span_req;
1428 sp1-> span_dir_ = START;
1429 sp2-> span_dir_ = STOP;
1430 sp1->span_type_str_ = sp2->span_type_str_ = "rest";
1431 rqc1->add_music (sp1);
1432 rqc2->add_music (sk);
1433 rqc3->add_music (sp2);
1435 ms->add_music (rqc1);
1436 ms->add_music (rqc2);
1437 ms->add_music (rqc3);
1439 $$ = new Sequential_music (ms);
1441 | STRING optional_notemode_duration {
1442 if (!THIS->lexer_p_->lyric_state_b ())
1443 THIS->parser_error (_ ("Have to be in Lyric mode for lyrics"));
1444 Simultaneous_music* velt_p = new Request_chord;
1446 Lyric_req* lreq_p = new Lyric_req;
1447 lreq_p ->text_str_ = ly_scm2string ($1);
1448 lreq_p->duration_ = *$2;
1449 lreq_p->set_spot (THIS->here_input());
1451 velt_p->add_music (lreq_p);
1458 if (!THIS->lexer_p_->chord_state_b ())
1459 THIS->parser_error (_ ("Have to be in Chord mode for chords"));
1465 steno_tonic_pitch optional_notemode_duration chord_additions chord_subtractions chord_inversion chord_bass {
1466 $$ = THIS->get_chord (*$1, $3, $4, $5, $6, *$2);
1471 $$ = new Array<Musical_pitch>;
1473 | CHORD_COLON chord_notes {
1482 | chord_notes '.' chord_step {
1490 $$ = new Array<Musical_pitch>;
1492 | CHORD_CARET chord_notes {
1502 | '/' steno_tonic_pitch {
1504 $$->set_spot (THIS->here_input ());
1512 | CHORD_BASS steno_tonic_pitch {
1514 $$->set_spot (THIS->here_input ());
1520 $$ = new Array<Musical_pitch>;
1523 | CHORDMODIFIER_PITCH {
1524 $$ = new Array<Musical_pitch>;
1527 | CHORDMODIFIER_PITCH chord_note { /* Ugh. */
1528 $$ = new Array<Musical_pitch>;
1536 $$ = new Musical_pitch;
1537 $$->notename_i_ = ($1 - 1) % 7;
1538 $$->octave_i_ = $1 > 7 ? 1 : 0;
1539 $$->accidental_i_ = 0;
1542 $$ = new Musical_pitch;
1543 $$->notename_i_ = ($1 - 1) % 7;
1544 $$->octave_i_ = $1 > 7 ? 1 : 0;
1545 $$->accidental_i_ = 1;
1547 | unsigned CHORD_MINUS {
1548 $$ = new Musical_pitch;
1549 $$->notename_i_ = ($1 - 1) % 7;
1550 $$->octave_i_ = $1 > 7 ? 1 : 0;
1551 $$->accidental_i_ = -1;
1559 $$ = new Array<Musical_pitch>;
1561 | pitch_list musical_pitch {
1594 $$ = *$1->access_content_int (false);
1603 | STRING_IDENTIFIER {
1604 $$ = ly_str02scm ($1->access_content_String (true)->ch_C ());
1606 | string '+' string {
1607 $$ = scm_string_append (scm_listify ($1, $3, SCM_UNDEFINED));
1614 | exclamations '!' { $$ ++; }
1619 | questions '?' { $$ ++; }
1629 My_lily_parser::set_yydebug (bool b)
1636 My_lily_parser::do_yyparse ()
1638 yyparse ((void*)this);