1 %{ // -*-Fundamental-*-
4 parser.yy -- Bison/C++ parser for mudela
6 source file of the GNU LilyPond music typesetter
8 (c) 1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
9 Jan Nieuwenhuizen <janneke@gnu.org>
13 #include "lily-guile.hh"
14 #include "notename-table.hh"
15 #include "translation-property.hh"
18 #include "my-lily-lexer.hh"
19 #include "paper-def.hh"
20 #include "midi-def.hh"
22 #include "file-path.hh"
24 #include "dimensions.hh"
25 #include "identifier.hh"
26 #include "command-request.hh"
27 #include "musical-request.hh"
28 #include "my-lily-parser.hh"
29 #include "context-specced-music.hh"
30 #include "translator-group.hh"
32 #include "music-list.hh"
33 #include "duration-convert.hh"
34 #include "change-translator.hh"
35 #include "file-results.hh"
37 #include "relative-music.hh"
38 #include "lyric-combine-music.hh"
39 #include "transposed-music.hh"
40 #include "time-scaled-music.hh"
41 #include "repeated-music.hh"
42 #include "mudela-version.hh"
43 #include "grace-music.hh"
44 #include "auto-change-music.hh"
47 Mudela_version oldest_version ("1.3.4");
52 print_mudela_versions (ostream &os)
54 os << _f ("Oldest supported input version: %s", oldest_version.str ())
57 // needed for bison.simple's malloc() and free()
64 #define YYERROR_VERBOSE 1
66 #define YYPARSE_PARAM my_lily_parser_l
67 #define YYLEX_PARAM my_lily_parser_l
68 #define THIS ((My_lily_parser *) my_lily_parser_l)
70 #define yyerror THIS->parser_error
71 #define ARRAY_SIZE(a,s) if (a.size () != s) THIS->parser_error (_f ("Expecting %d arguments", s))
77 Array<Musical_pitch> *pitch_arr;
78 Link_array<Request> *reqvec;
80 Notename_table *chordmodifiertab;
85 Music_list *music_list;
90 Music_output_def * outputdef;
91 Musical_pitch * pitch;
94 Notename_table *notenametab;
99 /* We use SCMs to do strings, because it saves us the trouble of
100 deleting them. Let's hope that a stack overflow doesnt trigger a move
101 of the parse stack onto the heap. */
105 Translator_group* trans;
113 yylex (YYSTYPE *s, void * v_l)
115 My_lily_parser *pars_l = (My_lily_parser*) v_l;
116 My_lily_lexer * lex_l = pars_l->lexer_p_;
118 lex_l->lexval_l = (void*) s;
119 return lex_l->yylex ();
127 /* tokens which are not keywords */
134 %token CHORDMODIFIERS
185 %token E_CHAR E_EXCLAMATION E_SMALLER E_BIGGER
186 %token CHORD_BASS CHORD_COLON CHORD_MINUS CHORD_CARET
188 %type <i> exclamations questions
190 %token <pitch> NOTENAME_PITCH
191 %token <pitch> TONICNAME_PITCH
192 %token <pitch> CHORDMODIFIER_PITCH
193 %token <id> DURATION_IDENTIFIER
194 %token <id> IDENTIFIER
195 %token <id> NOTENAME_TABLE_IDENTIFIER
196 %token <id> MUSIC_IDENTIFIER
197 %token <id> REQUEST_IDENTIFIER
198 %token <id> REAL_IDENTIFIER
199 %token <id> STRING_IDENTIFIER
200 %token <id> TRANS_IDENTIFIER
201 %token <id> INT_IDENTIFIER
202 %token <id> SCORE_IDENTIFIER
203 %token <id> MIDI_IDENTIFIER
204 %token <id> PAPER_IDENTIFIER
206 %token <scm> DURATION RESTNAME
212 %type <outputdef> output_def
213 %type <scope> mudela_header mudela_header_body
214 %type <request> open_request_parens close_request_parens open_request close_request
215 %type <request> request_with_dir request_that_take_dir verbose_request
216 %type <i> sub_quotes sup_quotes
217 %type <music> simple_element request_chord command_element Simple_music Composite_music
218 %type <music> Alternative_music Repeated_music
219 %type <i> abbrev_type
220 %type <i> int unsigned
222 %type <i> optional_modality
223 %type <id> identifier_init
224 %type <duration> steno_duration optional_notemode_duration
225 %type <duration> entered_notemode_duration explicit_duration
226 %type <intvec> int_list
227 %type <reqvec> pre_requests post_requests
228 %type <request> gen_text_def
229 %type <pitch> explicit_musical_pitch steno_musical_pitch musical_pitch absolute_musical_pitch
230 %type <pitch> steno_tonic_pitch
232 %type <pitch_arr> pitch_list
234 %type <pitch_arr> chord_additions chord_subtractions chord_notes chord_step
235 %type <pitch> chord_note chord_inversion chord_bass
236 %type <midi> midi_block midi_body
237 %type <duration> duration_length
239 %type <scm> embedded_scm scalar
240 %type <music> Music Sequential_music Simultaneous_music Music_sequence
241 %type <music> relative_music re_rhythmed_music
242 %type <music> property_def translator_change
243 %type <music_list> Music_list
244 %type <paper> paper_block paper_def_body
245 %type <real> real real_with_dimension
246 %type <request> abbrev_command_req
247 %type <request> post_request
248 %type <request> command_req verbose_command_req
249 %type <request> extender_req
250 %type <request> hyphen_req
252 %type <score> score_block score_body
254 %type <scm> script_abbreviation
255 %type <trans> translator_spec_block translator_spec_body
256 %type <tempo> tempo_request
257 %type <notenametab> notenames_body notenames_block chordmodifiers_block
268 | mudela toplevel_expression {}
269 | mudela assignment { }
272 THIS->error_level_i_ =1;
278 THIS->lexer_p_->set_notename_table ($1);
280 | chordmodifiers_block {
281 THIS->lexer_p_->set_chordmodifier_table ($1);
284 delete header_global_p;
285 header_global_p = $1;
288 score_global_array.push ($1);
291 Identifier * id = new
292 Paper_def_identifier ($1, PAPER_IDENTIFIER);
293 THIS->lexer_p_->set_identifier ("$defaultpaper", id)
296 Identifier * id = new
297 Midi_def_identifier ($1, MIDI_IDENTIFIER);
298 THIS->lexer_p_->set_identifier ("$defaultmidi", id)
310 chordmodifiers_block:
311 CHORDMODIFIERS '{' notenames_body '}' { $$ = $3; }
316 NOTENAMES '{' notenames_body '}' { $$ = $3; }
323 $$ = new Notename_table;
325 | NOTENAME_TABLE_IDENTIFIER {
326 $$ = $1-> access_content_Notename_table(true);
328 | notenames_body STRING '=' explicit_musical_pitch {
329 $$->add_note_name (ly_scm2string ($2), $4);
337 THIS->lexer_p_-> scope_l_arr_.push ($$);
339 | mudela_header_body assignment semicolon {
345 HEADER '{' mudela_header_body '}' {
347 THIS->lexer_p_-> scope_l_arr_.pop ();
357 THIS->remember_spot ();
359 /* cont */ '=' identifier_init {
360 THIS->lexer_p_->set_identifier (ly_scm2string ($1), $4);
361 $4->init_b_ = THIS->init_parse_b_;
362 $4->set_spot (THIS->pop_spot ());
370 $$ = new Score_identifier ($1, SCORE_IDENTIFIER);
373 | chordmodifiers_block {
374 $$ = new Notename_table_identifier ($1, NOTENAME_TABLE_IDENTIFIER);
377 $$ = new Notename_table_identifier ($1, NOTENAME_TABLE_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 ())
482 $$->add_output (THIS->default_paper_p ());
488 $$->set_spot (THIS->here_input ());
491 $$ = $1->access_content_Score (true);
493 | score_body mudela_header {
498 $2->warning (_ ("More than one music block"));
501 | score_body output_def {
523 PAPER '{' paper_def_body '}' {
525 THIS-> lexer_p_->scope_l_arr_.pop ();
532 Paper_def *p = THIS->default_paper_p ();
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 SCM_T '=' SCM_T {
550 if (!gh_symbol_p ($2))
551 THIS->parser_error ("expect a symbol as lvalue");
553 $$->default_properties_[$2] = $4;
555 | paper_def_body SCM_T '=' real semicolon {
556 if (!gh_symbol_p ($2))
557 THIS->parser_error ("expect a symbol as lvalue");
559 $$->default_properties_[$2] = gh_double2scm ($4);
561 | paper_def_body translator_spec_block {
562 $$->assign_translator ($2);
564 | paper_def_body error {
590 | real_with_dimension
592 $$= *$1->access_content_Real (false);
594 | '-' real %prec UNARY_MINUS {
621 THIS-> lexer_p_-> scope_l_arr_.pop();
625 midi_body: /* empty */ {
626 Midi_def * p =THIS->default_midi_p ();
628 THIS->lexer_p_->scope_l_arr_.push (p->scope_p_);
631 Midi_def * p =$1-> access_content_Midi_def (true);
633 THIS->lexer_p_->scope_l_arr_.push (p->scope_p_);
635 | midi_body assignment semicolon {
638 | midi_body translator_spec_block {
639 $$-> assign_translator ($2);
641 | midi_body tempo_request semicolon {
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->fold_b_ = (ly_scm2string ($2) == "fold");
699 r->volta_fold_b_ = (ly_scm2string ($2) == "volta");
700 r->set_spot ($4->spot ());
704 Music_sequence: '{' Music_list '}' {
705 $$ = new Music_sequence ($2);
706 $$->set_spot ($2->spot ());
711 SEQUENTIAL '{' Music_list '}' {
712 $$ = new Sequential_music ($3);
713 $$->set_spot ($3->spot ());
715 | '{' Music_list '}' {
716 $$ = new Sequential_music ($2);
717 $$->set_spot ($2->spot ());
722 SIMULTANEOUS '{' Music_list '}'{
723 $$ = new Simultaneous_music ($3);
724 $$->set_spot ($3->spot ());
726 | '<' Music_list '>' {
727 $$ = new Simultaneous_music ($2);
728 $$->set_spot ($2->spot ());
733 request_chord { $$ = $1; }
734 | MUSIC_IDENTIFIER { $$ = $1->access_content_Music (true); }
737 | Simple_music '*' unsigned '/' unsigned {
739 $$->compress (Moment($3, $5 ));
741 | Simple_music '*' unsigned {
743 $$->compress (Moment ($3, 1));
749 CONTEXT STRING Music {
750 Context_specced_music *csm = new Context_specced_music ($3);
752 csm->translator_type_str_ = ly_scm2string ($2);
753 csm->translator_id_str_ = "";
758 | AUTOCHANGE STRING Music {
759 Auto_change_music * chm = new Auto_change_music (ly_scm2string ($2), $3);
762 chm->set_spot ($3->spot ());
765 $$ = new Grace_music ($2);
767 | CONTEXT STRING '=' STRING Music {
768 Context_specced_music *csm = new Context_specced_music ($5);
770 csm->translator_type_str_ = ly_scm2string ($2);
771 csm->translator_id_str_ = ly_scm2string ($4);
776 THIS->remember_spot ();
779 unsigned '/' unsigned Music
782 $$ = new Time_scaled_music ($3, $5, $6);
783 $$->set_spot (THIS->pop_spot ());
785 | Repeated_music { $$ = $1; }
786 | Simultaneous_music { $$ = $1; }
787 | Sequential_music { $$ = $1; }
788 | TRANSPOSE musical_pitch Music {
789 $$ = new Transposed_music ($3, *$2);
792 | TRANSPOSE steno_tonic_pitch Music {
793 $$ = new Transposed_music ($3, *$2);
797 { THIS->lexer_p_->push_note_state (); }
800 THIS->lexer_p_->pop_state ();
803 { THIS->lexer_p_->push_chord_state (); }
807 THIS->lexer_p_->pop_state ();
810 { THIS->lexer_p_->push_lyric_state (); }
814 THIS->lexer_p_->pop_state ();
816 | relative_music { $$ = $1; }
817 | re_rhythmed_music { $$ = $1; }
821 RELATIVE absolute_musical_pitch Music {
822 $$ = new Relative_octave_music ($3, *$2);
828 ADDLYRICS Music Music {
829 Lyric_combine_music * l = new Lyric_combine_music ($2, $3);
835 TRANSLATOR STRING '=' STRING {
836 Change_translator * t = new Change_translator;
837 t-> change_to_type_str_ = ly_scm2string ($2);
838 t-> change_to_id_str_ = ly_scm2string ($4);
841 $$->set_spot (THIS->here_input ());
846 PROPERTY STRING '.' STRING '=' scalar {
847 Translation_property *t = new Translation_property;
849 t->var_str_ = ly_scm2string ($4);
852 Context_specced_music *csm = new Context_specced_music (t);
854 $$->set_spot (THIS->here_input ());
856 csm-> translator_type_str_ = ly_scm2string ($2);
862 | int { $$ = gh_int2scm ($1); }
863 | embedded_scm { $$ = $1; }
868 pre_requests simple_element post_requests {
869 Music_sequence *l = dynamic_cast<Music_sequence*>($2);
870 for (int i=0; i < $1->size(); i++)
871 l->add_music ($1->elem(i));
872 for (int i=0; i < $3->size(); i++)
873 l->add_music ($3->elem(i));
882 $$ = new Request_chord;
883 $$-> set_spot (THIS->here_input ());
884 $1-> set_spot (THIS->here_input ());
885 ((Simultaneous_music*)$$) ->add_music ($1);//ugh
887 | PARTIAL duration_length ';' {
888 Translation_property * p = new Translation_property;
889 p->var_str_ = "measurePosition";
890 p->value_ = (new Moment (-$2->length_mom ()))->smobify_self ();
892 Context_specced_music * sp = new Context_specced_music (p);
894 sp-> translator_type_str_ = "Score";
900 | verbose_command_req semicolon { $$ = $1; }
911 $$ = new Barcheck_req;
917 Span_req*b= new Span_req;
918 b->span_dir_ = START;
919 b->span_type_str_ = "beam";
923 if (!Duration::duration_type_b ($3))
924 THIS->parser_error (_f ("not a duration: %d", $3));
926 THIS->parser_error (_ ("Can't abbreviate"));
928 THIS->set_abbrev_beam ($3);
930 Chord_tremolo_req* a = new Chord_tremolo_req;
931 a->span_dir_ = START;
932 a->type_i_ = THIS->abbrev_beam_type_i_;
936 if (!THIS->abbrev_beam_type_i_)
938 Span_req*b= new Span_req;
940 b->span_type_str_ = "beam";
945 Chord_tremolo_req* a = new Chord_tremolo_req;
947 a->type_i_ = THIS->abbrev_beam_type_i_;
948 THIS->set_abbrev_beam (0);
953 $$ = new Breathing_sign_req;
960 $$ = new Bar_req (ly_scm2string ($2));
963 $$ = new Mark_req (ly_scm2string ($2));
967 $$ = new Mark_req (to_str ($2));
969 | TIME_T unsigned '/' unsigned {
970 Time_signature_change_req *m = new Time_signature_change_req;
976 Break_req * b = new Break_req;
977 b->penalty_f_ = $2 / 100.0;
978 b->set_spot (THIS->here_input ());
981 | SKIP duration_length {
982 Skip_req * skip_p = new Skip_req;
983 skip_p->duration_ = *$2;
991 $$ = new Clef_change_req (ly_scm2string ($2));
995 | KEY NOTENAME_PITCH optional_modality {
996 Key_change_req *key_p= new Key_change_req;
997 key_p->key_.pitch_arr_.push (*$2);
998 key_p->key_.ordinary_key_b_ = true;
999 key_p->key_.modality_i_ = $3;
1003 | KEYSIGNATURE pitch_list {
1004 Key_change_req *key_p= new Key_change_req;
1005 key_p->key_.pitch_arr_ = *$2;
1006 key_p->key_.ordinary_key_b_ = false;
1015 $$ = new Link_array<Request>;
1017 | post_requests post_request {
1018 $2->set_spot (THIS->here_input ());
1030 request_that_take_dir:
1033 | script_abbreviation {
1034 Identifier*i = THIS->lexer_p_->lookup_identifier ("dash-" + ly_scm2string ($1));
1035 Articulation_req *a = new Articulation_req;
1036 a->articulation_str_ = *i->access_content_String (false);
1042 script_dir request_that_take_dir {
1043 if (Script_req * gs = dynamic_cast<Script_req*> ($2))
1044 gs->dir_ = Direction ($1);
1046 $2->warning (_ ("Can't specify direction for this request"));
1052 REQUEST_IDENTIFIER {
1053 $$ = (Request*)$1->access_content_Request (true);
1054 $$->set_spot (THIS->here_input ());
1056 | TEXTSCRIPT STRING STRING {
1057 Text_script_req *ts_p = new Text_script_req;
1058 ts_p-> text_str_ = ly_scm2string ($2);
1059 ts_p-> style_str_ = ly_scm2string ($3);
1060 ts_p->set_spot (THIS->here_input ());
1064 | SPANREQUEST int STRING {
1065 Span_req * sp_p = new Span_req;
1066 sp_p-> span_dir_ = Direction($2);
1067 sp_p->span_type_str_ = ly_scm2string ($3);
1068 sp_p->set_spot (THIS->here_input ());
1072 Tremolo_req* a = new Tremolo_req;
1073 a->set_spot (THIS->here_input ());
1078 Articulation_req * a = new Articulation_req;
1079 a->articulation_str_ = ly_scm2string ($2);
1080 a->set_spot (THIS->here_input ());
1113 steno_musical_pitch:
1117 | NOTENAME_PITCH sup_quotes {
1119 $$->octave_i_ += $2;
1121 | NOTENAME_PITCH sub_quotes {
1123 $$->octave_i_ += - $2;
1131 | TONICNAME_PITCH sup_quotes {
1133 $$->octave_i_ += $2;
1135 | TONICNAME_PITCH sub_quotes {
1137 $$->octave_i_ += - $2;
1141 explicit_musical_pitch:
1142 MUSICAL_PITCH '{' int_list '}' {/* ugh */
1143 Array<int> &a = *$3;
1145 $$ = new Musical_pitch;
1146 $$->octave_i_ = a[0];
1147 $$->notename_i_ = a[1];
1148 $$->accidental_i_ = a[2];
1154 steno_musical_pitch {
1156 THIS->set_last_pitch ($1);
1158 | explicit_musical_pitch {
1160 THIS->set_last_pitch ($1);
1165 DURATION '{' int_list '}' {
1167 Array<int> &a = *$3;
1170 $$-> durlog_i_ = a[0];
1171 $$-> dots_i_ = a[1];
1179 if (!THIS->lexer_p_->lyric_state_b ())
1180 THIS->parser_error (_ ("Have to be in Lyric mode for lyrics"));
1181 $$ = new Extender_req;
1187 if (!THIS->lexer_p_->lyric_state_b ())
1188 THIS->parser_error (_ ("Have to be in Lyric mode for lyrics"));
1189 $$ = new Hyphen_req;
1194 close_request_parens {
1196 dynamic_cast<Span_req*> ($$)->span_dir_ = START;
1199 close_request_parens:
1201 Span_req* s= new Span_req;
1203 s->span_type_str_ = "slur";
1206 Span_req*s =new Span_req;
1208 s->span_type_str_ = "crescendo";
1211 Span_req*s =new Span_req;
1213 s->span_type_str_ = "decrescendo";
1219 open_request_parens {
1221 dynamic_cast<Span_req*> ($$)->span_dir_ = STOP;
1225 open_request_parens:
1227 Span_req *s = new Span_req;
1228 s->span_type_str_ = "crescendo";
1232 Span_req* s= new Span_req;
1234 s->span_type_str_ = "slur";
1240 Text_script_req *t = new Text_script_req;
1242 t->text_str_ = ly_scm2string ($1);
1244 $$->set_spot (THIS->here_input ());
1247 Text_script_req* t = new Text_script_req;
1249 t->text_str_ = to_str ($1);
1250 t->style_str_ = "finger";
1251 $$->set_spot (THIS->here_input ());
1255 script_abbreviation:
1257 $$ = gh_str02scm ("hat");
1260 $$ = gh_str02scm("plus");
1263 $$ = gh_str02scm ("dash");
1266 $$ = gh_str02scm ("bar");
1269 $$ = gh_str02scm ("larger");
1272 $$ = gh_str02scm ("dot");
1280 | '-' { $$ = CENTER; }
1285 $$ = new Link_array<Request>;
1287 | pre_requests open_request {
1292 absolute_musical_pitch:
1293 steno_musical_pitch {
1302 | duration_length '*' unsigned {
1303 $$->plet_.iso_i_ *= $3;
1305 | duration_length '/' unsigned {
1306 $$->plet_.type_i_ *= $3;
1310 entered_notemode_duration:
1312 THIS->set_last_duration ($1);
1316 optional_notemode_duration:
1318 $$ = new Duration (THIS->default_duration_);
1320 | entered_notemode_duration {
1328 if (!Duration::duration_type_b ($1))
1329 THIS->parser_error (_f ("not a duration: %d", $1));
1331 $$->durlog_i_ = Duration_convert::i2_type ($1);
1334 | DURATION_IDENTIFIER {
1335 $$ = $1->access_content_Duration (true);
1337 | steno_duration '.' {
1348 if (!Duration::duration_type_b ($2))
1349 THIS->parser_error (_f ("not a duration: %d", $2));
1351 THIS->parser_error (_ ("Can't abbreviate"));
1358 musical_pitch exclamations questions optional_notemode_duration {
1359 if (!THIS->lexer_p_->note_state_b ())
1360 THIS->parser_error (_ ("Have to be in Note mode for notes"));
1363 Note_req *n = new Note_req;
1369 if (THIS->abbrev_beam_type_i_)
1371 if (n->duration_.plet_b ())
1372 THIS->parser_error (_ ("Can't abbreviate tuplet"));
1374 n->duration_.set_plet (1, 2);
1376 n->cautionary_b_ = $3 % 2;
1377 n->forceacc_b_ = $2 % 2 || n->cautionary_b_;
1379 Simultaneous_music*v = new Request_chord;
1380 v->set_spot (THIS->here_input ());
1381 n->set_spot (THIS->here_input ());
1387 | RESTNAME optional_notemode_duration {
1388 $$ = THIS->get_rest_element (ly_scm2string ($1), $2);
1391 | MEASURES optional_notemode_duration {
1392 Multi_measure_rest_req* m = new Multi_measure_rest_req;
1396 Simultaneous_music*velt_p = new Request_chord;
1397 velt_p->set_spot (THIS->here_input ());
1398 velt_p->add_music (m);
1401 | REPETITIONS optional_notemode_duration {
1402 Repetitions_req* r = new Repetitions_req;
1406 Simultaneous_music*velt_p = new Request_chord;
1407 velt_p->set_spot (THIS->here_input ());
1408 velt_p->add_music (r);
1411 | STRING optional_notemode_duration {
1412 if (!THIS->lexer_p_->lyric_state_b ())
1413 THIS->parser_error (_ ("Have to be in Lyric mode for lyrics"));
1414 $$ = THIS->get_word_element (ly_scm2string ($1), $2);
1418 if (!THIS->lexer_p_->chord_state_b ())
1419 THIS->parser_error (_ ("Have to be in Chord mode for chords"));
1425 steno_tonic_pitch optional_notemode_duration chord_additions chord_subtractions chord_inversion chord_bass {
1426 $$ = THIS->get_chord (*$1, $3, $4, $5, $6, *$2);
1431 $$ = new Array<Musical_pitch>;
1433 | CHORD_COLON chord_notes {
1442 | chord_notes '.' chord_step {
1450 $$ = new Array<Musical_pitch>;
1452 | CHORD_CARET chord_notes {
1462 | '/' steno_tonic_pitch {
1464 $$->set_spot (THIS->here_input ());
1472 | CHORD_BASS steno_tonic_pitch {
1474 $$->set_spot (THIS->here_input ());
1480 $$ = new Array<Musical_pitch>;
1483 | CHORDMODIFIER_PITCH {
1484 $$ = new Array<Musical_pitch>;
1487 | CHORDMODIFIER_PITCH chord_note { /* Ugh. */
1488 $$ = new Array<Musical_pitch>;
1496 $$ = new Musical_pitch;
1497 $$->notename_i_ = ($1 - 1) % 7;
1498 $$->octave_i_ = $1 > 7 ? 1 : 0;
1499 $$->accidental_i_ = 0;
1502 $$ = new Musical_pitch;
1503 $$->notename_i_ = ($1 - 1) % 7;
1504 $$->octave_i_ = $1 > 7 ? 1 : 0;
1505 $$->accidental_i_ = 1;
1507 | unsigned CHORD_MINUS {
1508 $$ = new Musical_pitch;
1509 $$->notename_i_ = ($1 - 1) % 7;
1510 $$->octave_i_ = $1 > 7 ? 1 : 0;
1511 $$->accidental_i_ = -1;
1519 $$ = new Array<Musical_pitch>;
1521 | pitch_list musical_pitch {
1554 $$ = *$1->access_content_int (false);
1563 | STRING_IDENTIFIER {
1564 $$ = ly_str02scm ($1->access_content_String (true)->ch_C ());
1566 | string '+' string {
1567 $$ = scm_string_append (scm_listify ($1, $3, SCM_UNDEFINED));
1574 | exclamations '!' { $$ ++; }
1579 | questions '?' { $$ ++; }
1589 My_lily_parser::set_yydebug (bool b)
1596 My_lily_parser::do_yyparse ()
1598 yyparse ((void*)this);