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"
25 #include "dimensions.hh"
26 #include "identifier.hh"
27 #include "command-request.hh"
28 #include "musical-request.hh"
29 #include "my-lily-parser.hh"
30 #include "context-specced-music.hh"
31 #include "translator-group.hh"
33 #include "music-list.hh"
34 #include "duration-convert.hh"
35 #include "change-translator.hh"
36 #include "file-results.hh"
38 #include "relative-music.hh"
39 #include "lyric-combine-music.hh"
40 #include "transposed-music.hh"
41 #include "time-scaled-music.hh"
42 #include "repeated-music.hh"
43 #include "mudela-version.hh"
44 #include "grace-music.hh"
45 #include "auto-change-music.hh"
48 Mudela_version oldest_version ("1.3.4");
53 print_mudela_versions (ostream &os)
55 os << _f ("Oldest supported input version: %s", oldest_version.str ())
58 // needed for bison.simple's malloc() and free()
65 #define YYERROR_VERBOSE 1
67 #define YYPARSE_PARAM my_lily_parser_l
68 #define YYLEX_PARAM my_lily_parser_l
69 #define THIS ((My_lily_parser *) my_lily_parser_l)
71 #define yyerror THIS->parser_error
72 #define ARRAY_SIZE(a,s) if (a.size () != s) THIS->parser_error (_f ("Expecting %d arguments", s))
78 Array<Musical_pitch> *pitch_arr;
79 Link_array<Request> *reqvec;
81 Notename_table *chordmodifiertab;
86 Music_list *music_list;
91 Music_output_def * outputdef;
92 Musical_pitch * pitch;
95 Notename_table *notenametab;
100 /* We use SCMs to do strings, because it saves us the trouble of
101 deleting them. Let's hope that a stack overflow doesnt trigger a move
102 of the parse stack onto the heap. */
106 Translator_group* trans;
114 yylex (YYSTYPE *s, void * v_l)
116 My_lily_parser *pars_l = (My_lily_parser*) v_l;
117 My_lily_lexer * lex_l = pars_l->lexer_p_;
119 lex_l->lexval_l = (void*) s;
120 return lex_l->yylex ();
128 /* tokens which are not keywords */
136 %token CHORDMODIFIERS
187 %token E_CHAR E_EXCLAMATION E_SMALLER E_BIGGER
188 %token CHORD_BASS CHORD_COLON CHORD_MINUS CHORD_CARET
190 %type <i> exclamations questions
192 %token <pitch> NOTENAME_PITCH
193 %token <pitch> TONICNAME_PITCH
194 %token <pitch> CHORDMODIFIER_PITCH
195 %token <id> DURATION_IDENTIFIER
196 %token <id> IDENTIFIER
197 %token <id> NOTENAME_TABLE_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> abbrev_type
222 %type <i> int unsigned
224 %type <i> optional_modality
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> explicit_musical_pitch steno_musical_pitch musical_pitch absolute_musical_pitch
232 %type <pitch> steno_tonic_pitch
234 %type <pitch_arr> pitch_list
236 %type <pitch_arr> chord_additions chord_subtractions chord_notes chord_step
237 %type <pitch> chord_note chord_inversion chord_bass
238 %type <midi> midi_block midi_body
239 %type <duration> duration_length
241 %type <scm> embedded_scm scalar
242 %type <music> Music Sequential_music Simultaneous_music Music_sequence
243 %type <music> relative_music re_rhythmed_music
244 %type <music> property_def translator_change
245 %type <music_list> Music_list
246 %type <paper> paper_block paper_def_body
247 %type <real> real real_with_dimension
248 %type <request> abbrev_command_req
249 %type <request> post_request
250 %type <request> command_req verbose_command_req
251 %type <request> extender_req
252 %type <request> hyphen_req
254 %type <score> score_block score_body
256 %type <scm> script_abbreviation
257 %type <trans> translator_spec_block translator_spec_body
258 %type <tempo> tempo_request
259 %type <notenametab> notenames_body notenames_block chordmodifiers_block
270 | mudela toplevel_expression {}
271 | mudela assignment { }
274 THIS->error_level_i_ =1;
280 THIS->lexer_p_->set_notename_table ($1);
282 | chordmodifiers_block {
283 THIS->lexer_p_->set_chordmodifier_table ($1);
286 delete header_global_p;
287 header_global_p = $1;
290 score_global_array.push ($1);
293 Identifier * id = new
294 Paper_def_identifier ($1, PAPER_IDENTIFIER);
295 THIS->lexer_p_->set_identifier ("$defaultpaper", id)
298 Identifier * id = new
299 Midi_def_identifier ($1, MIDI_IDENTIFIER);
300 THIS->lexer_p_->set_identifier ("$defaultmidi", id)
312 chordmodifiers_block:
313 CHORDMODIFIERS '{' notenames_body '}' { $$ = $3; }
318 NOTENAMES '{' notenames_body '}' { $$ = $3; }
325 $$ = new Notename_table;
327 | NOTENAME_TABLE_IDENTIFIER {
328 $$ = $1-> access_content_Notename_table(true);
330 | notenames_body STRING '=' explicit_musical_pitch {
331 (*$$)[ly_scm2string ($2)] = *$4;
340 THIS->lexer_p_-> scope_l_arr_.push ($$);
342 | mudela_header_body assignment semicolon {
348 HEADER '{' mudela_header_body '}' {
350 THIS->lexer_p_-> scope_l_arr_.pop ();
360 THIS->remember_spot ();
362 /* cont */ '=' identifier_init {
363 THIS->lexer_p_->set_identifier (ly_scm2string ($1), $4);
364 $4->init_b_ = THIS->init_parse_b_;
365 $4->set_spot (THIS->pop_spot ());
373 $$ = new Score_identifier ($1, SCORE_IDENTIFIER);
376 | chordmodifiers_block {
377 $$ = new Notename_table_identifier ($1, NOTENAME_TABLE_IDENTIFIER);
380 $$ = new Notename_table_identifier ($1, NOTENAME_TABLE_IDENTIFIER);
383 $$ = new Paper_def_identifier ($1, PAPER_IDENTIFIER);
386 $$ = new Midi_def_identifier ($1, MIDI_IDENTIFIER);
389 | translator_spec_block {
390 $$ = new Translator_group_identifier ($1, TRANS_IDENTIFIER);
393 $$ = new Music_identifier ($1, MUSIC_IDENTIFIER);
397 $$ = new Request_identifier ($1, REQUEST_IDENTIFIER);
399 | explicit_duration {
400 $$ = new Duration_identifier ($1, DURATION_IDENTIFIER);
403 $$ = new Real_identifier (new Real ($1), REAL_IDENTIFIER);
406 $$ = new String_identifier (new String (ly_scm2string ($1)), STRING_IDENTIFIER);
409 $$ = new int_identifier (new int ($1), INT_IDENTIFIER);
413 translator_spec_block:
414 TRANSLATOR '{' translator_spec_body '}'
420 translator_spec_body:
422 $$ = $1->access_content_Translator_group (true);
423 $$-> set_spot (THIS->here_input ());
425 | TYPE STRING semicolon {
426 Translator* t = get_translator_l (ly_scm2string ($2));
427 Translator_group * tg = dynamic_cast<Translator_group*> (t);
430 THIS->parser_error (_("Need a translator group for a context"));
432 tg = dynamic_cast<Translator_group*> (t->clone ());
433 tg->set_spot (THIS->here_input ());
436 | translator_spec_body STRING '=' embedded_scm {
437 Translator_group* tg = dynamic_cast<Translator_group*> ($$);
438 tg->set_property (ly_scm2string ($2), $4);
440 | translator_spec_body STRING '=' identifier_init semicolon {
442 String_identifier *s = dynamic_cast<String_identifier*> (id);
443 Real_identifier *r= dynamic_cast<Real_identifier*>(id);
444 int_identifier *i = dynamic_cast<int_identifier*> (id);
447 if (s) v = ly_str02scm (s->access_content_String (false)->ch_C());
448 if (i) v = gh_int2scm (*i->access_content_int (false));
449 if (r) v = gh_double2scm (*r->access_content_Real (false));
451 THIS->parser_error (_("Wrong type for property value"));
455 Translator_group* tg = dynamic_cast<Translator_group*> ($$);
457 tg->set_property (ly_scm2string ($2), v);
459 | translator_spec_body NAME STRING semicolon {
460 $$->type_str_ = ly_scm2string ($3);
462 | translator_spec_body CONSISTS STRING semicolon {
463 dynamic_cast<Translator_group*> ($$)-> set_element (ly_scm2string ($3), true);
465 | translator_spec_body CONSISTSEND STRING semicolon {
466 dynamic_cast<Translator_group*> ($$)-> set_element (ly_scm2string ($3), true);
468 | translator_spec_body ACCEPTS STRING semicolon {
469 dynamic_cast<Translator_group*> ($$)-> set_acceptor (ly_scm2string ($3), true);
471 | translator_spec_body REMOVE STRING semicolon {
472 dynamic_cast<Translator_group*> ($$)-> set_element (ly_scm2string ($3), false);
482 /*cont*/ '{' score_body '}' {
484 if (!$$->def_p_arr_.size ())
485 $$->add_output (THIS->default_paper_p ());
491 $$->set_spot (THIS->here_input ());
494 $$ = $1->access_content_Score (true);
496 | score_body mudela_header {
501 $2->warning (_ ("More than one music block"));
504 | score_body output_def {
526 PAPER '{' paper_def_body '}' {
528 THIS-> lexer_p_->scope_l_arr_.pop ();
535 Paper_def *p = THIS->default_paper_p ();
536 THIS-> lexer_p_-> scope_l_arr_.push (p->scope_p_);
540 Paper_def *p = $1->access_content_Paper_def (true);
541 THIS->lexer_p_->scope_l_arr_.push (p->scope_p_);
544 | paper_def_body int '=' FONT STRING { // ugh, what a syntax
545 Lookup * l = new Lookup;
546 l->font_name_ = ly_scm2string ($5);
547 $$->set_lookup ($2, l);
549 | paper_def_body assignment semicolon {
552 | paper_def_body SCM_T '=' SCM_T {
553 if (!gh_symbol_p ($2))
554 THIS->parser_error ("expect a symbol as lvalue");
556 $$->default_properties_[$2] = $4;
558 | paper_def_body SCM_T '=' real semicolon {
559 if (!gh_symbol_p ($2))
560 THIS->parser_error ("expect a symbol as lvalue");
562 $$->default_properties_[$2] = gh_double2scm ($4);
564 | paper_def_body translator_spec_block {
565 $$->assign_translator ($2);
567 | paper_def_body error {
593 | real_with_dimension
595 $$= *$1->access_content_Real (false);
597 | '-' real %prec UNARY_MINUS {
624 THIS-> lexer_p_-> scope_l_arr_.pop();
628 midi_body: /* empty */ {
629 Midi_def * p =THIS->default_midi_p ();
631 THIS->lexer_p_->scope_l_arr_.push (p->scope_p_);
634 Midi_def * p =$1-> access_content_Midi_def (true);
636 THIS->lexer_p_->scope_l_arr_.push (p->scope_p_);
638 | midi_body assignment semicolon {
641 | midi_body translator_spec_block {
642 $$-> assign_translator ($2);
644 | midi_body tempo_request semicolon {
645 $$->set_tempo ($2->dur_.length_mom (), $2->metronome_i_);
654 TEMPO steno_duration '=' unsigned {
658 $$-> metronome_i_ = $4;
662 Music_list: /* empty */ {
664 $$->set_spot (THIS->here_input ());
683 | ALTERNATIVE Music_sequence {
685 $2->set_spot (THIS->here_input ());
693 REPEAT STRING unsigned Music Alternative_music
695 Music_sequence* m = dynamic_cast <Music_sequence*> ($5);
696 if (m && $3 < m->length_i ())
697 $5->warning (_ ("More alternatives than repeats. Junking excess alternatives."));
699 Repeated_music * r = new Repeated_music ($4, $3 >? 1, m);
701 r->fold_b_ = (ly_scm2string ($2) == "fold");
702 r->volta_fold_b_ = (ly_scm2string ($2) == "volta");
703 r->set_spot ($4->spot ());
707 Music_sequence: '{' Music_list '}' {
708 $$ = new Music_sequence ($2);
709 $$->set_spot ($2->spot ());
714 SEQUENTIAL '{' Music_list '}' {
715 $$ = new Sequential_music ($3);
716 $$->set_spot ($3->spot ());
718 | '{' Music_list '}' {
719 $$ = new Sequential_music ($2);
720 $$->set_spot ($2->spot ());
725 SIMULTANEOUS '{' Music_list '}'{
726 $$ = new Simultaneous_music ($3);
727 $$->set_spot ($3->spot ());
729 | '<' Music_list '>' {
730 $$ = new Simultaneous_music ($2);
731 $$->set_spot ($2->spot ());
736 request_chord { $$ = $1; }
737 | MUSIC_IDENTIFIER { $$ = $1->access_content_Music (true); }
740 | Simple_music '*' unsigned '/' unsigned {
742 $$->compress (Moment($3, $5 ));
744 | Simple_music '*' unsigned {
746 $$->compress (Moment ($3, 1));
752 CONTEXT STRING Music {
753 Context_specced_music *csm = new Context_specced_music ($3);
755 csm->translator_type_str_ = ly_scm2string ($2);
756 csm->translator_id_str_ = "";
761 | AUTOCHANGE STRING Music {
762 Auto_change_music * chm = new Auto_change_music (ly_scm2string ($2), $3);
765 chm->set_spot ($3->spot ());
768 $$ = new Grace_music ($2);
770 | CONTEXT STRING '=' STRING Music {
771 Context_specced_music *csm = new Context_specced_music ($5);
773 csm->translator_type_str_ = ly_scm2string ($2);
774 csm->translator_id_str_ = ly_scm2string ($4);
779 THIS->remember_spot ();
782 unsigned '/' unsigned Music
785 $$ = new Time_scaled_music ($3, $5, $6);
786 $$->set_spot (THIS->pop_spot ());
788 | Repeated_music { $$ = $1; }
789 | Simultaneous_music { $$ = $1; }
790 | Sequential_music { $$ = $1; }
791 | TRANSPOSE musical_pitch Music {
792 $$ = new Transposed_music ($3, *$2);
795 | TRANSPOSE steno_tonic_pitch Music {
796 $$ = new Transposed_music ($3, *$2);
800 { THIS->lexer_p_->push_note_state (); }
803 THIS->lexer_p_->pop_state ();
806 { THIS->lexer_p_->push_chord_state (); }
810 THIS->lexer_p_->pop_state ();
813 { THIS->lexer_p_->push_lyric_state (); }
817 THIS->lexer_p_->pop_state ();
819 | relative_music { $$ = $1; }
820 | re_rhythmed_music { $$ = $1; }
824 RELATIVE absolute_musical_pitch Music {
825 $$ = new Relative_octave_music ($3, *$2);
831 ADDLYRICS Music Music {
832 Lyric_combine_music * l = new Lyric_combine_music ($2, $3);
838 TRANSLATOR STRING '=' STRING {
839 Change_translator * t = new Change_translator;
840 t-> change_to_type_str_ = ly_scm2string ($2);
841 t-> change_to_id_str_ = ly_scm2string ($4);
844 $$->set_spot (THIS->here_input ());
849 PROPERTY STRING '.' STRING '=' scalar {
850 Translation_property *t = new Translation_property;
852 t->var_str_ = ly_scm2string ($4);
855 Context_specced_music *csm = new Context_specced_music (t);
857 $$->set_spot (THIS->here_input ());
859 csm-> translator_type_str_ = ly_scm2string ($2);
865 | int { $$ = gh_int2scm ($1); }
866 | embedded_scm { $$ = $1; }
871 pre_requests simple_element post_requests {
872 Music_sequence *l = dynamic_cast<Music_sequence*>($2);
873 for (int i=0; i < $1->size(); i++)
874 l->add_music ($1->elem(i));
875 for (int i=0; i < $3->size(); i++)
876 l->add_music ($3->elem(i));
885 $$ = new Request_chord;
886 $$-> set_spot (THIS->here_input ());
887 $1-> set_spot (THIS->here_input ());
888 ((Simultaneous_music*)$$) ->add_music ($1);//ugh
890 | PARTIAL duration_length ';' {
891 Translation_property * p = new Translation_property;
892 p->var_str_ = "measurePosition";
893 p->value_ = (new Moment (-$2->length_mom ()))->smobify_self ();
895 Context_specced_music * sp = new Context_specced_music (p);
897 sp-> translator_type_str_ = "Score";
903 | verbose_command_req semicolon { $$ = $1; }
914 $$ = new Barcheck_req;
920 Span_req*b= new Span_req;
921 b->span_dir_ = START;
922 b->span_type_str_ = "beam";
926 if (!Duration::duration_type_b ($3))
927 THIS->parser_error (_f ("not a duration: %d", $3));
929 THIS->parser_error (_ ("Can't abbreviate"));
931 THIS->set_abbrev_beam ($3);
933 Chord_tremolo_req* a = new Chord_tremolo_req;
934 a->span_dir_ = START;
935 a->type_i_ = THIS->abbrev_beam_type_i_;
939 if (!THIS->abbrev_beam_type_i_)
941 Span_req*b= new Span_req;
943 b->span_type_str_ = "beam";
948 Chord_tremolo_req* a = new Chord_tremolo_req;
950 a->type_i_ = THIS->abbrev_beam_type_i_;
951 THIS->set_abbrev_beam (0);
956 $$ = new Breathing_sign_req;
963 $$ = new Bar_req (ly_scm2string ($2));
966 $$ = new Mark_req (ly_scm2string ($2));
970 $$ = new Mark_req (to_str ($2));
972 | TIME_T unsigned '/' unsigned {
973 Time_signature_change_req *m = new Time_signature_change_req;
979 Break_req * b = new Break_req;
980 b->penalty_f_ = $2 / 100.0;
981 b->set_spot (THIS->here_input ());
984 | SKIP duration_length {
985 Skip_req * skip_p = new Skip_req;
986 skip_p->duration_ = *$2;
994 $$ = new Clef_change_req (ly_scm2string ($2));
998 | KEY NOTENAME_PITCH optional_modality {
999 Key_change_req *key_p= new Key_change_req;
1000 key_p->key_.pitch_arr_.push (*$2);
1001 key_p->key_.ordinary_key_b_ = true;
1002 key_p->key_.modality_i_ = $3;
1006 | KEYSIGNATURE pitch_list {
1007 Key_change_req *key_p= new Key_change_req;
1008 key_p->key_.pitch_arr_ = *$2;
1009 key_p->key_.ordinary_key_b_ = false;
1018 $$ = new Link_array<Request>;
1020 | post_requests post_request {
1021 $2->set_spot (THIS->here_input ());
1033 request_that_take_dir:
1036 | script_abbreviation {
1037 Identifier*i = THIS->lexer_p_->lookup_identifier ("dash-" + ly_scm2string ($1));
1038 Articulation_req *a = new Articulation_req;
1039 a->articulation_str_ = *i->access_content_String (false);
1045 script_dir request_that_take_dir {
1046 if (Script_req * gs = dynamic_cast<Script_req*> ($2))
1047 gs->dir_ = Direction ($1);
1049 $2->warning (_ ("Can't specify direction for this request"));
1055 REQUEST_IDENTIFIER {
1056 $$ = (Request*)$1->access_content_Request (true);
1057 $$->set_spot (THIS->here_input ());
1059 | TEXTSCRIPT STRING STRING {
1060 Text_script_req *ts_p = new Text_script_req;
1061 ts_p-> text_str_ = ly_scm2string ($2);
1062 ts_p-> style_str_ = ly_scm2string ($3);
1063 ts_p->set_spot (THIS->here_input ());
1067 | SPANREQUEST int STRING {
1068 Span_req * sp_p = new Span_req;
1069 sp_p-> span_dir_ = Direction($2);
1070 sp_p->span_type_str_ = ly_scm2string ($3);
1071 sp_p->set_spot (THIS->here_input ());
1075 Tremolo_req* a = new Tremolo_req;
1076 a->set_spot (THIS->here_input ());
1081 Articulation_req * a = new Articulation_req;
1082 a->articulation_str_ = ly_scm2string ($2);
1083 a->set_spot (THIS->here_input ());
1116 steno_musical_pitch:
1120 | NOTENAME_PITCH sup_quotes {
1122 $$->octave_i_ += $2;
1124 | NOTENAME_PITCH sub_quotes {
1126 $$->octave_i_ += - $2;
1134 | TONICNAME_PITCH sup_quotes {
1136 $$->octave_i_ += $2;
1138 | TONICNAME_PITCH sub_quotes {
1140 $$->octave_i_ += - $2;
1144 explicit_musical_pitch:
1145 MUSICAL_PITCH '{' int_list '}' {/* ugh */
1146 Array<int> &a = *$3;
1148 $$ = new Musical_pitch;
1149 $$->octave_i_ = a[0];
1150 $$->notename_i_ = a[1];
1151 $$->accidental_i_ = a[2];
1157 steno_musical_pitch {
1159 THIS->set_last_pitch ($1);
1161 | explicit_musical_pitch {
1163 THIS->set_last_pitch ($1);
1168 DURATION '{' int_list '}' {
1170 Array<int> &a = *$3;
1173 $$-> durlog_i_ = a[0];
1174 $$-> dots_i_ = a[1];
1182 if (!THIS->lexer_p_->lyric_state_b ())
1183 THIS->parser_error (_ ("Have to be in Lyric mode for lyrics"));
1184 $$ = new Extender_req;
1190 if (!THIS->lexer_p_->lyric_state_b ())
1191 THIS->parser_error (_ ("Have to be in Lyric mode for lyrics"));
1192 $$ = new Hyphen_req;
1197 close_request_parens {
1199 dynamic_cast<Span_req*> ($$)->span_dir_ = START;
1202 close_request_parens:
1204 Span_req* s= new Span_req;
1206 s->span_type_str_ = "slur";
1209 Span_req*s =new Span_req;
1211 s->span_type_str_ = "crescendo";
1214 Span_req*s =new Span_req;
1216 s->span_type_str_ = "decrescendo";
1222 open_request_parens {
1224 dynamic_cast<Span_req*> ($$)->span_dir_ = STOP;
1228 open_request_parens:
1230 Span_req *s = new Span_req;
1231 s->span_type_str_ = "crescendo";
1235 Span_req* s= new Span_req;
1237 s->span_type_str_ = "slur";
1243 Text_script_req *t = new Text_script_req;
1245 t->text_str_ = ly_scm2string ($1);
1247 $$->set_spot (THIS->here_input ());
1250 Text_script_req* t = new Text_script_req;
1252 t->text_str_ = to_str ($1);
1253 t->style_str_ = "finger";
1254 $$->set_spot (THIS->here_input ());
1258 script_abbreviation:
1260 $$ = gh_str02scm ("hat");
1263 $$ = gh_str02scm("plus");
1266 $$ = gh_str02scm ("dash");
1269 $$ = gh_str02scm ("bar");
1272 $$ = gh_str02scm ("larger");
1275 $$ = gh_str02scm ("dot");
1283 | '-' { $$ = CENTER; }
1288 $$ = new Link_array<Request>;
1290 | pre_requests open_request {
1295 absolute_musical_pitch:
1296 steno_musical_pitch {
1305 | duration_length '*' unsigned {
1306 $$->plet_.iso_i_ *= $3;
1308 | duration_length '/' unsigned {
1309 $$->plet_.type_i_ *= $3;
1313 entered_notemode_duration:
1315 THIS->set_last_duration ($1);
1319 optional_notemode_duration:
1321 $$ = new Duration (THIS->default_duration_);
1323 | entered_notemode_duration {
1331 if (!Duration::duration_type_b ($1))
1332 THIS->parser_error (_f ("not a duration: %d", $1));
1334 $$->durlog_i_ = Duration_convert::i2_type ($1);
1337 | DURATION_IDENTIFIER {
1338 $$ = $1->access_content_Duration (true);
1340 | steno_duration '.' {
1351 if (!Duration::duration_type_b ($2))
1352 THIS->parser_error (_f ("not a duration: %d", $2));
1354 THIS->parser_error (_ ("Can't abbreviate"));
1361 musical_pitch exclamations questions optional_notemode_duration {
1362 if (!THIS->lexer_p_->note_state_b ())
1363 THIS->parser_error (_ ("Have to be in Note mode for notes"));
1366 Note_req *n = new Note_req;
1372 if (THIS->abbrev_beam_type_i_)
1374 if (n->duration_.plet_b ())
1375 THIS->parser_error (_ ("Can't abbreviate tuplet"));
1377 n->duration_.set_plet (1, 2);
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 (THIS->here_input ());
1384 n->set_spot (THIS->here_input ());
1390 | RESTNAME optional_notemode_duration {
1391 $$ = THIS->get_rest_element (ly_scm2string ($1), $2);
1394 | MEASURES optional_notemode_duration {
1395 Multi_measure_rest_req* m = new Multi_measure_rest_req;
1399 Simultaneous_music*velt_p = new Request_chord;
1400 velt_p->set_spot (THIS->here_input ());
1401 velt_p->add_music (m);
1404 | REPETITIONS optional_notemode_duration {
1405 Repetitions_req* r = new Repetitions_req;
1409 Simultaneous_music*velt_p = new Request_chord;
1410 velt_p->set_spot (THIS->here_input ());
1411 velt_p->add_music (r);
1414 | STRING optional_notemode_duration {
1415 if (!THIS->lexer_p_->lyric_state_b ())
1416 THIS->parser_error (_ ("Have to be in Lyric mode for lyrics"));
1417 $$ = THIS->get_word_element (ly_scm2string ($1), $2);
1421 if (!THIS->lexer_p_->chord_state_b ())
1422 THIS->parser_error (_ ("Have to be in Chord mode for chords"));
1428 steno_tonic_pitch optional_notemode_duration chord_additions chord_subtractions chord_inversion chord_bass {
1429 $$ = THIS->get_chord (*$1, $3, $4, $5, $6, *$2);
1434 $$ = new Array<Musical_pitch>;
1436 | CHORD_COLON chord_notes {
1445 | chord_notes '.' chord_step {
1453 $$ = new Array<Musical_pitch>;
1455 | CHORD_CARET chord_notes {
1465 | '/' steno_tonic_pitch {
1467 $$->set_spot (THIS->here_input ());
1475 | CHORD_BASS steno_tonic_pitch {
1477 $$->set_spot (THIS->here_input ());
1483 $$ = new Array<Musical_pitch>;
1486 | CHORDMODIFIER_PITCH {
1487 $$ = new Array<Musical_pitch>;
1490 | CHORDMODIFIER_PITCH chord_note { /* Ugh. */
1491 $$ = new Array<Musical_pitch>;
1499 $$ = new Musical_pitch;
1500 $$->notename_i_ = ($1 - 1) % 7;
1501 $$->octave_i_ = $1 > 7 ? 1 : 0;
1502 $$->accidental_i_ = 0;
1505 $$ = new Musical_pitch;
1506 $$->notename_i_ = ($1 - 1) % 7;
1507 $$->octave_i_ = $1 > 7 ? 1 : 0;
1508 $$->accidental_i_ = 1;
1510 | unsigned CHORD_MINUS {
1511 $$ = new Musical_pitch;
1512 $$->notename_i_ = ($1 - 1) % 7;
1513 $$->octave_i_ = $1 > 7 ? 1 : 0;
1514 $$->accidental_i_ = -1;
1522 $$ = new Array<Musical_pitch>;
1524 | pitch_list musical_pitch {
1557 $$ = *$1->access_content_int (false);
1566 | STRING_IDENTIFIER {
1567 $$ = ly_str02scm ($1->access_content_String (true)->ch_C ());
1569 | string '+' string {
1570 $$ = scm_string_append (scm_listify ($1, $3, SCM_UNDEFINED));
1577 | exclamations '!' { $$ ++; }
1582 | questions '?' { $$ ++; }
1592 My_lily_parser::set_yydebug (bool b)
1599 My_lily_parser::do_yyparse ()
1601 yyparse ((void*)this);