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
177 %token COMMANDSPANREQUEST
179 %token OUTPUTPROPERTY
188 %token E_CHAR E_EXCLAMATION E_SMALLER E_BIGGER
189 %token CHORD_BASS CHORD_COLON CHORD_MINUS CHORD_CARET
191 %type <i> exclamations questions
193 %token <pitch> NOTENAME_PITCH
194 %token <pitch> TONICNAME_PITCH
195 %token <pitch> CHORDMODIFIER_PITCH
196 %token <id> DURATION_IDENTIFIER
197 %token <id> IDENTIFIER
198 %token <id> MUSIC_IDENTIFIER
199 %token <id> REQUEST_IDENTIFIER
200 %token <id> REAL_IDENTIFIER
201 %token <id> STRING_IDENTIFIER
202 %token <id> TRANS_IDENTIFIER
203 %token <id> INT_IDENTIFIER
204 %token <id> SCORE_IDENTIFIER
205 %token <id> MIDI_IDENTIFIER
206 %token <id> PAPER_IDENTIFIER
208 %token <scm> DURATION RESTNAME
214 %type <outputdef> output_def
215 %type <scope> mudela_header mudela_header_body
216 %type <request> open_request_parens close_request_parens open_request close_request
217 %type <request> request_with_dir request_that_take_dir verbose_request
218 %type <i> sub_quotes sup_quotes
219 %type <music> simple_element request_chord command_element Simple_music Composite_music
220 %type <music> Alternative_music Repeated_music
221 %type <i> tremolo_type
222 %type <i> int unsigned
225 %type <id> identifier_init
226 %type <duration> steno_duration optional_notemode_duration
227 %type <duration> entered_notemode_duration explicit_duration
228 %type <intvec> int_list
229 %type <reqvec> pre_requests post_requests
230 %type <request> gen_text_def
231 %type <pitch> steno_musical_pitch musical_pitch absolute_musical_pitch
232 %type <pitch> steno_tonic_pitch
234 %type <pitch_arr> chord_additions chord_subtractions chord_notes chord_step
236 %type <pitch> chord_note chord_inversion chord_bass
237 %type <midi> midi_block midi_body
238 %type <duration> duration_length
240 %type <scm> embedded_scm scalar
241 %type <music> Music Sequential_music Simultaneous_music Music_sequence
242 %type <music> relative_music re_rhythmed_music
243 %type <music> property_def translator_change
244 %type <music_list> Music_list
245 %type <paper> paper_block paper_def_body
246 %type <real> real real_with_dimension
247 %type <request> shorthand_command_req
248 %type <request> post_request
249 %type <request> command_req verbose_command_req
250 %type <request> extender_req
251 %type <request> hyphen_req
253 %type <score> score_block score_body
255 %type <trans> translator_spec_block translator_spec_body
256 %type <tempo> tempo_request
257 %type <scm> notenames_body notenames_block chordmodifiers_block
258 %type <scm> script_abbreviation
269 | mudela toplevel_expression {}
270 | mudela assignment { }
273 THIS->error_level_i_ =1;
279 THIS->lexer_p_->pitchname_tab_ = $1;
281 | chordmodifiers_block {
282 THIS->lexer_p_->chordmodifier_tab_ = $1;
285 delete header_global_p;
286 header_global_p = $1;
289 score_global_array.push ($1);
292 Identifier * id = new
293 Paper_def_identifier ($1, PAPER_IDENTIFIER);
294 THIS->lexer_p_->set_identifier ("$defaultpaper", id)
297 Identifier * id = new
298 Midi_def_identifier ($1, MIDI_IDENTIFIER);
299 THIS->lexer_p_->set_identifier ("$defaultmidi", id)
311 chordmodifiers_block:
312 CHORDMODIFIERS notenames_body { $$ = $2; }
317 NOTENAMES notenames_body { $$ = $2; }
324 int i = scm_ilength ($1);
326 SCM tab = scm_make_vector (gh_int2scm (i), SCM_EOL);
327 for (SCM s = $1; s != SCM_EOL; s = gh_cdr (s)) {
328 SCM pt = gh_cdar (s);
329 if (scm_ilength (pt) != 3)
330 THIS->parser_error ("Need three args");
331 scm_hashq_set_x (tab, gh_caar(s), pt);
341 THIS->lexer_p_-> scope_l_arr_.push ($$);
343 | mudela_header_body assignment semicolon {
349 HEADER '{' mudela_header_body '}' {
351 THIS->lexer_p_-> scope_l_arr_.pop ();
361 THIS->remember_spot ();
363 /* cont */ '=' identifier_init {
364 THIS->lexer_p_->set_identifier (ly_scm2string ($1), $4);
366 $4->set_spot (THIS->pop_spot ());
374 $$ = new Score_identifier ($1, SCORE_IDENTIFIER);
378 $$ = new Paper_def_identifier ($1, PAPER_IDENTIFIER);
381 $$ = new Midi_def_identifier ($1, MIDI_IDENTIFIER);
384 | translator_spec_block {
385 $$ = new Translator_group_identifier ($1, TRANS_IDENTIFIER);
388 $$ = new Music_identifier ($1, MUSIC_IDENTIFIER);
392 $$ = new Request_identifier ($1, REQUEST_IDENTIFIER);
394 | explicit_duration {
395 $$ = new Duration_identifier ($1, DURATION_IDENTIFIER);
398 $$ = new Real_identifier (new Real ($1), REAL_IDENTIFIER);
401 $$ = new String_identifier (new String (ly_scm2string ($1)), STRING_IDENTIFIER);
404 $$ = new int_identifier (new int ($1), INT_IDENTIFIER);
408 translator_spec_block:
409 TRANSLATOR '{' translator_spec_body '}'
415 translator_spec_body:
417 $$ = $1->access_content_Translator_group (true);
418 $$-> set_spot (THIS->here_input ());
420 | TYPE STRING semicolon {
421 Translator* t = get_translator_l (ly_scm2string ($2));
422 Translator_group * tg = dynamic_cast<Translator_group*> (t);
425 THIS->parser_error (_("Need a translator group for a context"));
427 tg = dynamic_cast<Translator_group*> (t->clone ());
428 tg->set_spot (THIS->here_input ());
431 | translator_spec_body STRING '=' embedded_scm {
432 Translator_group* tg = dynamic_cast<Translator_group*> ($$);
433 tg->set_property (ly_scm2string ($2), $4);
435 | translator_spec_body STRING '=' identifier_init semicolon {
437 String_identifier *s = dynamic_cast<String_identifier*> (id);
438 Real_identifier *r= dynamic_cast<Real_identifier*>(id);
439 int_identifier *i = dynamic_cast<int_identifier*> (id);
442 if (s) v = ly_str02scm (s->access_content_String (false)->ch_C());
443 if (i) v = gh_int2scm (*i->access_content_int (false));
444 if (r) v = gh_double2scm (*r->access_content_Real (false));
446 THIS->parser_error (_("Wrong type for property value"));
450 Translator_group* tg = dynamic_cast<Translator_group*> ($$);
452 tg->set_property (ly_scm2string ($2), v);
454 | translator_spec_body NAME STRING semicolon {
455 $$->type_str_ = ly_scm2string ($3);
457 | translator_spec_body CONSISTS STRING semicolon {
458 dynamic_cast<Translator_group*> ($$)-> set_element (ly_scm2string ($3), true);
460 | translator_spec_body CONSISTSEND STRING semicolon {
461 dynamic_cast<Translator_group*> ($$)-> set_element (ly_scm2string ($3), true);
463 | translator_spec_body ACCEPTS STRING semicolon {
464 dynamic_cast<Translator_group*> ($$)-> set_acceptor (ly_scm2string ($3), true);
466 | translator_spec_body REMOVE STRING semicolon {
467 dynamic_cast<Translator_group*> ($$)-> set_element (ly_scm2string ($3), false);
477 /*cont*/ '{' score_body '}' {
479 if (!$$->def_p_arr_.size ())
482 THIS->lexer_p_->lookup_identifier ("$defaultpaper");
483 $$->add_output (id ? id->access_content_Paper_def (true) : new Paper_def );
491 $$->set_spot (THIS->here_input ());
495 $$ = $1->access_content_Score (true);
497 | score_body mudela_header {
500 | score_body output_def {
522 PAPER '{' paper_def_body '}' {
524 THIS-> lexer_p_->scope_l_arr_.pop ();
531 Identifier *id = THIS->lexer_p_->lookup_identifier ("$defaultpaper");
532 Paper_def *p = id ? id->access_content_Paper_def (true) : new Paper_def;
533 THIS-> lexer_p_-> scope_l_arr_.push (p->scope_p_);
537 Paper_def *p = $1->access_content_Paper_def (true);
538 THIS->lexer_p_->scope_l_arr_.push (p->scope_p_);
541 | paper_def_body int '=' FONT STRING { // ugh, what a syntax
542 Lookup * l = new Lookup;
543 l->font_name_ = ly_scm2string ($5);
544 $$->set_lookup ($2, l);
546 | paper_def_body assignment semicolon {
549 | paper_def_body translator_spec_block {
550 $$->assign_translator ($2);
552 | paper_def_body error {
581 | real_with_dimension
583 $$= *$1->access_content_Real (false);
585 | '-' real %prec UNARY_MINUS {
612 THIS-> lexer_p_-> scope_l_arr_.pop();
616 midi_body: /* empty */ {
617 Identifier *id = THIS->lexer_p_->lookup_identifier ("$defaultmidi");
619 ? id->access_content_Midi_def (true) : new Midi_def ;
622 THIS->lexer_p_->scope_l_arr_.push (p->scope_p_);
625 Midi_def * p =$1-> access_content_Midi_def (true);
627 THIS->lexer_p_->scope_l_arr_.push (p->scope_p_);
629 | midi_body assignment semicolon {
632 | midi_body translator_spec_block {
633 $$-> assign_translator ($2);
635 | midi_body tempo_request semicolon {
637 junk this ? there already is tempo stuff in
640 $$->set_tempo ($2->dur_.length_mom (), $2->metronome_i_);
649 TEMPO steno_duration '=' unsigned {
653 $$-> metronome_i_ = $4;
657 Music_list: /* empty */ {
659 $$->set_spot (THIS->here_input ());
678 | ALTERNATIVE Music_sequence {
680 $2->set_spot (THIS->here_input ());
688 REPEAT STRING unsigned Music Alternative_music
690 Music_sequence* m = dynamic_cast <Music_sequence*> ($5);
691 if (m && $3 < m->length_i ())
692 $5->warning (_ ("More alternatives than repeats. Junking excess alternatives."));
694 Repeated_music * r = new Repeated_music ($4, $3 >? 1, m);
696 r->type_ = ly_scm2string ($2);
697 r->fold_b_ = (r->type_ == "fold");
698 r->volta_fold_b_ = (r->type_ == "volta");
699 r->set_spot ($4->spot ());
703 Music_sequence: '{' Music_list '}' {
704 $$ = new Music_sequence ($2);
705 $$->set_spot ($2->spot ());
710 SEQUENTIAL '{' Music_list '}' {
711 $$ = new Sequential_music ($3);
712 $$->set_spot ($3->spot ());
714 | '{' Music_list '}' {
715 $$ = new Sequential_music ($2);
716 $$->set_spot ($2->spot ());
721 SIMULTANEOUS '{' Music_list '}'{
722 $$ = new Simultaneous_music ($3);
723 $$->set_spot ($3->spot ());
725 | '<' Music_list '>' {
726 $$ = new Simultaneous_music ($2);
727 $$->set_spot ($2->spot ());
732 request_chord { $$ = $1; }
733 | OUTPUTPROPERTY embedded_scm embedded_scm '=' embedded_scm {
735 if (!gh_symbol_p ($3))
737 THIS->parser_error (_("Second argument must be a symbol"));
739 /*hould check # args */
740 if (!gh_procedure_p (pred))
742 THIS->parser_error (_("First argument must be a procedure taking 1 argument"));
745 $$ = new Output_property (pred,$3, $5);
747 | MUSIC_IDENTIFIER { $$ = $1->access_content_Music (true); }
750 | Simple_music '*' unsigned '/' unsigned {
752 $$->compress (Moment($3, $5 ));
754 | Simple_music '*' unsigned {
756 $$->compress (Moment ($3, 1));
762 CONTEXT STRING Music {
763 Context_specced_music *csm = new Context_specced_music ($3);
765 csm->translator_type_str_ = ly_scm2string ($2);
766 csm->translator_id_str_ = "";
771 | AUTOCHANGE STRING Music {
772 Auto_change_music * chm = new Auto_change_music (ly_scm2string ($2), $3);
775 chm->set_spot ($3->spot ());
778 $$ = new Grace_music ($2);
780 | CONTEXT STRING '=' STRING Music {
781 Context_specced_music *csm = new Context_specced_music ($5);
783 csm->translator_type_str_ = ly_scm2string ($2);
784 csm->translator_id_str_ = ly_scm2string ($4);
789 THIS->remember_spot ();
792 unsigned '/' unsigned Music
795 $$ = new Time_scaled_music ($3, $5, $6);
796 $$->set_spot (THIS->pop_spot ());
798 | Repeated_music { $$ = $1; }
799 | Simultaneous_music { $$ = $1; }
800 | Sequential_music { $$ = $1; }
801 | TRANSPOSE musical_pitch Music {
802 $$ = new Transposed_music ($3, *$2);
805 | TRANSPOSE steno_tonic_pitch Music {
806 $$ = new Transposed_music ($3, *$2);
810 { THIS->lexer_p_->push_note_state (); }
813 THIS->lexer_p_->pop_state ();
816 { THIS->lexer_p_->push_chord_state (); }
820 THIS->lexer_p_->pop_state ();
823 { THIS->lexer_p_->push_lyric_state (); }
827 THIS->lexer_p_->pop_state ();
829 | relative_music { $$ = $1; }
830 | re_rhythmed_music { $$ = $1; }
834 RELATIVE absolute_musical_pitch Music {
835 $$ = new Relative_octave_music ($3, *$2);
841 ADDLYRICS Music Music {
842 Lyric_combine_music * l = new Lyric_combine_music ($2, $3);
848 TRANSLATOR STRING '=' STRING {
849 Change_translator * t = new Change_translator;
850 t-> change_to_type_str_ = ly_scm2string ($2);
851 t-> change_to_id_str_ = ly_scm2string ($4);
854 $$->set_spot (THIS->here_input ());
859 PROPERTY STRING '.' STRING '=' scalar {
860 Translation_property *t = new Translation_property;
862 t->var_str_ = ly_scm2string ($4);
865 Context_specced_music *csm = new Context_specced_music (t);
867 $$->set_spot (THIS->here_input ());
869 csm-> translator_type_str_ = ly_scm2string ($2);
875 | int { $$ = gh_int2scm ($1); }
876 | embedded_scm { $$ = $1; }
881 pre_requests simple_element post_requests {
882 Music_sequence *l = dynamic_cast<Music_sequence*>($2);
884 for (int i=0; i < $1->size(); i++)
885 l->add_music ($1->elem(i));
886 for (int i=0; i < $3->size(); i++)
887 l->add_music ($3->elem(i));
890 programming_error ("Need Sequence to add music to");
899 $$ = new Request_chord;
900 $$-> set_spot (THIS->here_input ());
901 $1-> set_spot (THIS->here_input ());
902 ((Simultaneous_music*)$$) ->add_music ($1);//ugh
904 | PARTIAL duration_length ';' {
905 Translation_property * p = new Translation_property;
906 p->var_str_ = "measurePosition";
907 p->value_ = (new Moment (-$2->length_mom ()))->smobify_self ();
909 Context_specced_music * sp = new Context_specced_music (p);
911 sp-> translator_type_str_ = "Score";
916 shorthand_command_req
917 | verbose_command_req semicolon { $$ = $1; }
920 shorthand_command_req:
928 $$ = new Barcheck_req;
934 Span_req*b= new Span_req;
935 b->span_dir_ = START;
936 b->span_type_str_ = "beam";
940 Span_req*b= new Span_req;
942 b->span_type_str_ = "beam";
946 $$ = new Breathing_sign_req;
954 $$ = new Bar_req (ly_scm2string ($2));
956 | COMMANDSPANREQUEST int STRING {
957 Span_req * sp_p = new Span_req;
958 sp_p-> span_dir_ = Direction($2);
959 sp_p->span_type_str_ = ly_scm2string ($3);
960 sp_p->set_spot (THIS->here_input ());
964 Mark_req * m = new Mark_req;
968 Mark_req *m = new Mark_req;
974 Mark_req *m = new Mark_req;
975 m->mark_label_ = gh_int2scm ($2);
979 | TIME_T unsigned '/' unsigned {
980 Time_signature_change_req *m = new Time_signature_change_req;
986 Break_req * b = new Break_req;
987 b->penalty_f_ = $2 / 100.0;
988 b->set_spot (THIS->here_input ());
991 | SKIP duration_length {
992 Skip_req * skip_p = new Skip_req;
993 skip_p->duration_ = *$2;
1001 $$ = new Clef_change_req (ly_scm2string ($2));
1005 Key_change_req *key_p= new Key_change_req;
1010 TODO: Support for minor/major keys; make `major-scale' settable.
1012 | KEY NOTENAME_PITCH {
1013 Key_change_req *key_p= new Key_change_req;
1014 key_p->key_ = new Newkey_def;
1016 key_p->key_->pitch_alist_ = scm_eval (ly_symbol2scm ("major-scale"));
1017 key_p->key_->transpose (* $2);
1024 $$ = new Link_array<Request>;
1026 | post_requests post_request {
1027 $2->set_spot (THIS->here_input ());
1039 request_that_take_dir:
1042 | script_abbreviation {
1043 Identifier*i = THIS->lexer_p_->lookup_identifier ("dash-" + ly_scm2string ($1));
1044 Articulation_req *a = new Articulation_req;
1045 a->articulation_str_ = *i->access_content_String (false);
1051 script_dir request_that_take_dir {
1052 if (Script_req * gs = dynamic_cast<Script_req*> ($2))
1053 gs->dir_ = Direction ($1);
1055 $2->warning (_ ("Can't specify direction for this request"));
1061 REQUEST_IDENTIFIER {
1062 $$ = (Request*)$1->access_content_Request (true);
1063 $$->set_spot (THIS->here_input ());
1065 | TEXTSCRIPT STRING STRING {
1066 Text_script_req *ts_p = new Text_script_req;
1067 ts_p-> text_str_ = ly_scm2string ($2);
1068 ts_p-> style_str_ = ly_scm2string ($3);
1069 ts_p->set_spot (THIS->here_input ());
1073 | SPANREQUEST int STRING {
1074 Span_req * sp_p = new Span_req;
1075 sp_p-> span_dir_ = Direction($2);
1076 sp_p->span_type_str_ = ly_scm2string ($3);
1077 sp_p->set_spot (THIS->here_input ());
1081 Tremolo_req* a = new Tremolo_req;
1082 a->set_spot (THIS->here_input ());
1087 Articulation_req * a = new Articulation_req;
1088 a->articulation_str_ = ly_scm2string ($2);
1089 a->set_spot (THIS->here_input ());
1112 steno_musical_pitch:
1116 | NOTENAME_PITCH sup_quotes {
1118 $$->octave_i_ += $2;
1120 | NOTENAME_PITCH sub_quotes {
1122 $$->octave_i_ += - $2;
1130 | TONICNAME_PITCH sup_quotes {
1132 $$->octave_i_ += $2;
1134 | TONICNAME_PITCH sub_quotes {
1136 $$->octave_i_ += - $2;
1141 steno_musical_pitch {
1144 | MUSICAL_PITCH embedded_scm {
1145 int sz = scm_ilength ($2);
1147 THIS->parser_error (_f ("Expecting %d arguments", 3));
1148 $2 = gh_list (gh_int2scm (0), gh_int2scm (0), gh_int2scm (0), SCM_UNDEFINED);
1150 $$ = new Musical_pitch ($2);
1155 DURATION '{' int_list '}' {
1157 Array<int> &a = *$3;
1160 $$-> durlog_i_ = a[0];
1161 $$-> dots_i_ = a[1];
1169 if (!THIS->lexer_p_->lyric_state_b ())
1170 THIS->parser_error (_ ("Have to be in Lyric mode for lyrics"));
1171 $$ = new Extender_req;
1177 if (!THIS->lexer_p_->lyric_state_b ())
1178 THIS->parser_error (_ ("Have to be in Lyric mode for lyrics"));
1179 $$ = new Hyphen_req;
1184 close_request_parens {
1186 dynamic_cast<Span_req*> ($$)->span_dir_ = START;
1189 close_request_parens:
1191 Span_req* s= new Span_req;
1193 s->span_type_str_ = "slur";
1196 Span_req*s =new Span_req;
1198 s->span_type_str_ = "crescendo";
1201 Span_req*s =new Span_req;
1203 s->span_type_str_ = "decrescendo";
1209 open_request_parens {
1211 dynamic_cast<Span_req*> ($$)->span_dir_ = STOP;
1215 open_request_parens:
1217 Span_req *s = new Span_req;
1218 s->span_type_str_ = "crescendo";
1222 Span_req* s= new Span_req;
1224 s->span_type_str_ = "slur";
1230 Text_script_req *t = new Text_script_req;
1232 t->text_str_ = ly_scm2string ($1);
1234 $$->set_spot (THIS->here_input ());
1237 Text_script_req* t = new Text_script_req;
1239 t->text_str_ = to_str ($1);
1240 t->style_str_ = "finger";
1241 $$->set_spot (THIS->here_input ());
1245 script_abbreviation:
1247 $$ = gh_str02scm ("hat");
1250 $$ = gh_str02scm("plus");
1253 $$ = gh_str02scm ("dash");
1256 $$ = gh_str02scm ("bar");
1259 $$ = gh_str02scm ("larger");
1262 $$ = gh_str02scm ("dot");
1270 | '-' { $$ = CENTER; }
1275 $$ = new Link_array<Request>;
1277 | pre_requests open_request {
1282 absolute_musical_pitch:
1283 steno_musical_pitch {
1292 | duration_length '*' unsigned {
1293 $$->tuplet_iso_i_ *= $3;
1295 | duration_length '/' unsigned {
1296 $$->tuplet_type_i_ *= $3;
1300 entered_notemode_duration:
1302 THIS->set_last_duration ($1);
1306 optional_notemode_duration:
1308 $$ = new Duration (THIS->default_duration_);
1310 | entered_notemode_duration {
1318 if (!is_duration_b ($1))
1319 THIS->parser_error (_f ("not a duration: %d", $1));
1321 $$->durlog_i_ = intlog2 ($1);
1324 | DURATION_IDENTIFIER {
1325 $$ = $1->access_content_Duration (true);
1327 | steno_duration '.' {
1338 if (!is_duration_b ($2))
1339 THIS->parser_error (_f ("not a duration: %d", $2));
1346 musical_pitch exclamations questions optional_notemode_duration {
1347 if (!THIS->lexer_p_->note_state_b ())
1348 THIS->parser_error (_ ("Have to be in Note mode for notes"));
1351 Note_req *n = new Note_req;
1356 n->cautionary_b_ = $3 % 2;
1357 n->forceacc_b_ = $2 % 2 || n->cautionary_b_;
1359 Simultaneous_music*v = new Request_chord;
1360 v->set_spot ($1->spot ());
1361 n->set_spot ($1->spot ());
1371 | RESTNAME optional_notemode_duration {
1372 Simultaneous_music* velt_p = new Request_chord;
1373 velt_p->set_spot (THIS->here_input());
1375 if (ly_scm2string ($1) =="s")
1377 Skip_req * skip_p = new Skip_req;
1378 skip_p->duration_ = *$2;
1380 skip_p->set_spot (THIS->here_input());
1381 velt_p->add_music (skip_p);
1385 Rest_req * rest_req_p = new Rest_req;
1386 rest_req_p->duration_ = *$2;
1387 rest_req_p->set_spot (THIS->here_input());
1389 velt_p->add_music (rest_req_p);
1395 | MEASURES optional_notemode_duration {
1396 Skip_req * sk = new Skip_req;
1397 sk->duration_ = *$2;
1398 Music_list * ms = new Music_list;
1399 Request_chord * rqc1 = new Request_chord;
1400 Request_chord * rqc2 = new Request_chord;
1401 Request_chord * rqc3 = new Request_chord;
1403 Span_req *sp1 = new Span_req;
1404 Span_req *sp2 = new Span_req;
1405 sp1-> span_dir_ = START;
1406 sp2-> span_dir_ = STOP;
1407 sp1->span_type_str_ = sp2->span_type_str_ = "rest";
1408 rqc1->add_music (sp1);
1409 rqc2->add_music (sk);
1410 rqc3->add_music (sp2);
1412 ms->add_music (rqc1);
1413 ms->add_music (rqc2);
1414 ms->add_music (rqc3);
1416 $$ = new Sequential_music (ms);
1418 | STRING optional_notemode_duration {
1419 if (!THIS->lexer_p_->lyric_state_b ())
1420 THIS->parser_error (_ ("Have to be in Lyric mode for lyrics"));
1421 Simultaneous_music* velt_p = new Request_chord;
1423 Lyric_req* lreq_p = new Lyric_req;
1424 lreq_p ->text_str_ = ly_scm2string ($1);
1425 lreq_p->duration_ = *$2;
1426 lreq_p->set_spot (THIS->here_input());
1428 velt_p->add_music (lreq_p);
1435 if (!THIS->lexer_p_->chord_state_b ())
1436 THIS->parser_error (_ ("Have to be in Chord mode for chords"));
1442 steno_tonic_pitch optional_notemode_duration chord_additions chord_subtractions chord_inversion chord_bass {
1443 $$ = THIS->get_chord (*$1, $3, $4, $5, $6, *$2);
1448 $$ = new Array<Musical_pitch>;
1450 | CHORD_COLON chord_notes {
1459 | chord_notes '.' chord_step {
1467 $$ = new Array<Musical_pitch>;
1469 | CHORD_CARET chord_notes {
1479 | '/' steno_tonic_pitch {
1481 $$->set_spot (THIS->here_input ());
1489 | CHORD_BASS steno_tonic_pitch {
1491 $$->set_spot (THIS->here_input ());
1497 $$ = new Array<Musical_pitch>;
1500 | CHORDMODIFIER_PITCH {
1501 $$ = new Array<Musical_pitch>;
1504 | CHORDMODIFIER_PITCH chord_note { /* Ugh. */
1505 $$ = new Array<Musical_pitch>;
1513 $$ = new Musical_pitch;
1514 $$->notename_i_ = ($1 - 1) % 7;
1515 $$->octave_i_ = $1 > 7 ? 1 : 0;
1516 $$->accidental_i_ = 0;
1519 $$ = new Musical_pitch;
1520 $$->notename_i_ = ($1 - 1) % 7;
1521 $$->octave_i_ = $1 > 7 ? 1 : 0;
1522 $$->accidental_i_ = 1;
1524 | unsigned CHORD_MINUS {
1525 $$ = new Musical_pitch;
1526 $$->notename_i_ = ($1 - 1) % 7;
1527 $$->octave_i_ = $1 > 7 ? 1 : 0;
1528 $$->accidental_i_ = -1;
1541 $$ = new Array<Musical_pitch>;
1543 | pitch_list musical_pitch {
1576 $$ = *$1->access_content_int (false);
1585 | STRING_IDENTIFIER {
1586 $$ = ly_str02scm ($1->access_content_String (true)->ch_C ());
1588 | string '+' string {
1589 $$ = scm_string_append (scm_listify ($1, $3, SCM_UNDEFINED));
1596 | exclamations '!' { $$ ++; }
1601 | questions '?' { $$ ++; }
1611 My_lily_parser::set_yydebug (bool b)
1618 My_lily_parser::do_yyparse ()
1620 yyparse ((void*)this);