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> TRANS_IDENTIFIER
202 %token <id> INT_IDENTIFIER
203 %token <id> SCORE_IDENTIFIER
204 %token <id> MIDI_IDENTIFIER
205 %token <id> PAPER_IDENTIFIER
208 %token <scm> STRING_IDENTIFIER SCM_IDENTIFIER
209 %token <scm> DURATION RESTNAME
215 %type <outputdef> output_def
216 %type <scope> mudela_header mudela_header_body
217 %type <request> open_request_parens close_request_parens open_request close_request
218 %type <request> request_with_dir request_that_take_dir verbose_request
219 %type <i> sub_quotes sup_quotes
220 %type <music> simple_element request_chord command_element Simple_music Composite_music
221 %type <music> Alternative_music Repeated_music
222 %type <i> tremolo_type
223 %type <i> int unsigned
226 %type <scm> 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> 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", smobify (id))
299 Identifier * id = new
300 Midi_def_identifier ($1, MIDI_IDENTIFIER);
301 THIS->lexer_p_->set_identifier ("$defaultmidi", smobify (id))
314 chordmodifiers_block:
315 CHORDMODIFIERS notenames_body { $$ = $2; }
320 NOTENAMES notenames_body { $$ = $2; }
327 int i = scm_ilength ($1);
329 SCM tab = scm_make_vector (gh_int2scm (i), SCM_EOL);
330 for (SCM s = $1; s != SCM_EOL; s = gh_cdr (s)) {
331 SCM pt = gh_cdar (s);
332 if (scm_ilength (pt) != 3)
333 THIS->parser_error ("Need three args");
334 scm_hashq_set_x (tab, gh_caar(s), pt);
344 THIS->lexer_p_-> scope_l_arr_.push ($$);
346 | mudela_header_body assignment semicolon {
352 HEADER '{' mudela_header_body '}' {
354 THIS->lexer_p_-> scope_l_arr_.pop ();
364 THIS->remember_spot ();
366 /* cont */ '=' identifier_init {
367 THIS->lexer_p_->set_identifier (ly_scm2string ($1), $4);
369 Identifier * id =unsmob_identifier ($4);
370 Input spot = THIS->pop_spot ();
371 if (id) id->set_spot (spot);
379 $$ = smobify (new Score_identifier ($1, SCORE_IDENTIFIER));
383 $$ = smobify (new Paper_def_identifier ($1, PAPER_IDENTIFIER));
386 $$ = smobify (new Midi_def_identifier ($1, MIDI_IDENTIFIER));
389 | translator_spec_block {
390 $$ = smobify (new Translator_group_identifier ($1, TRANS_IDENTIFIER));
393 $$ = smobify (new Music_identifier ($1, MUSIC_IDENTIFIER));
397 $$ = smobify (new Request_identifier ($1, REQUEST_IDENTIFIER));
399 | explicit_duration {
400 $$ = smobify (new Duration_identifier ($1, DURATION_IDENTIFIER));
403 $$ = smobify (new Real_identifier (new Real ($1), REAL_IDENTIFIER));
409 $$ = smobify (new int_identifier (new int ($1), INT_IDENTIFIER));
416 translator_spec_block:
417 TRANSLATOR '{' translator_spec_body '}'
423 translator_spec_body:
425 $$ = $1->access_content_Translator_group (true);
426 $$-> set_spot (THIS->here_input ());
428 | TYPE STRING semicolon {
429 Translator* t = get_translator_l (ly_scm2string ($2));
430 Translator_group * tg = dynamic_cast<Translator_group*> (t);
433 THIS->parser_error (_("Need a translator group for a context"));
435 tg = dynamic_cast<Translator_group*> (t->clone ());
436 tg->set_spot (THIS->here_input ());
439 | translator_spec_body STRING '=' embedded_scm {
440 Translator_group* tg = dynamic_cast<Translator_group*> ($$);
441 tg->set_property (ly_scm2string ($2), $4);
443 | translator_spec_body STRING '=' identifier_init semicolon {
444 Identifier* id = unsmob_identifier ($4);
446 Real_identifier *r= dynamic_cast<Real_identifier*>(id);
447 int_identifier *i = dynamic_cast<int_identifier*> (id);
450 if (gh_string_p ($4))
452 else if (i) v = gh_int2scm (*i->access_content_int (false));
453 else if (r) v = gh_double2scm (*r->access_content_Real (false));
455 THIS->parser_error (_("Wrong type for property value"));
460 Translator_group* tg = dynamic_cast<Translator_group*> ($$);
462 tg->set_property (ly_scm2string ($2), v);
464 | translator_spec_body NAME STRING semicolon {
465 $$->type_str_ = ly_scm2string ($3);
467 | translator_spec_body CONSISTS STRING semicolon {
468 dynamic_cast<Translator_group*> ($$)-> set_element (ly_scm2string ($3), true);
470 | translator_spec_body CONSISTSEND STRING semicolon {
471 dynamic_cast<Translator_group*> ($$)-> set_element (ly_scm2string ($3), true);
473 | translator_spec_body ACCEPTS STRING semicolon {
474 dynamic_cast<Translator_group*> ($$)-> set_acceptor (ly_scm2string ($3), true);
476 | translator_spec_body REMOVE STRING semicolon {
477 dynamic_cast<Translator_group*> ($$)-> set_element (ly_scm2string ($3), false);
487 /*cont*/ '{' score_body '}' {
489 if (!$$->def_p_arr_.size ())
492 unsmob_identifier (THIS->lexer_p_->lookup_identifier ("$defaultpaper"));
493 $$->add_output (id ? id->access_content_Paper_def (true) : new Paper_def );
501 $$->set_spot (THIS->here_input ());
505 $$ = $1->access_content_Score (true);
507 | score_body mudela_header {
510 | score_body output_def {
532 PAPER '{' paper_def_body '}' {
534 THIS-> lexer_p_->scope_l_arr_.pop ();
541 Identifier *id = unsmob_identifier (THIS->lexer_p_->lookup_identifier ("$defaultpaper"));
542 Paper_def *p = id ? id->access_content_Paper_def (true) : new Paper_def;
543 THIS-> lexer_p_-> scope_l_arr_.push (p->scope_p_);
547 Paper_def *p = $1->access_content_Paper_def (true);
548 THIS->lexer_p_->scope_l_arr_.push (p->scope_p_);
551 | paper_def_body int '=' FONT STRING { // ugh, what a syntax
552 Lookup * l = new Lookup;
553 l->font_name_ = ly_scm2string ($5);
554 $$->set_lookup ($2, l);
556 | paper_def_body assignment semicolon {
559 | paper_def_body translator_spec_block {
560 $$->assign_translator ($2);
562 | paper_def_body error {
591 | real_with_dimension
593 $$= *$1->access_content_Real (false);
595 | '-' real %prec UNARY_MINUS {
622 THIS-> lexer_p_-> scope_l_arr_.pop();
626 midi_body: /* empty */ {
627 Identifier *id = unsmob_identifier (THIS->lexer_p_->lookup_identifier ("$defaultmidi"));
629 ? id->access_content_Midi_def (true) : new Midi_def ;
632 THIS->lexer_p_->scope_l_arr_.push (p->scope_p_);
635 Midi_def * p =$1-> access_content_Midi_def (true);
637 THIS->lexer_p_->scope_l_arr_.push (p->scope_p_);
639 | midi_body assignment semicolon {
642 | midi_body translator_spec_block {
643 $$-> assign_translator ($2);
645 | midi_body tempo_request semicolon {
647 junk this ? there already is tempo stuff in
650 $$->set_tempo ($2->dur_.length_mom (), $2->metronome_i_);
659 TEMPO steno_duration '=' unsigned {
663 $$-> metronome_i_ = $4;
667 Music_list: /* empty */ {
669 $$->set_spot (THIS->here_input ());
688 | ALTERNATIVE Music_sequence {
690 $2->set_spot (THIS->here_input ());
698 REPEAT STRING unsigned Music Alternative_music
700 Music_sequence* m = dynamic_cast <Music_sequence*> ($5);
701 if (m && $3 < m->length_i ())
702 $5->warning (_ ("More alternatives than repeats. Junking excess alternatives."));
704 Repeated_music * r = new Repeated_music ($4, $3 >? 1, m);
706 r->type_ = ly_scm2string ($2);
707 r->fold_b_ = (r->type_ == "fold");
708 r->volta_fold_b_ = (r->type_ == "volta");
709 r->set_spot ($4->spot ());
713 Music_sequence: '{' Music_list '}' {
714 $$ = new Music_sequence ($2);
715 $$->set_spot ($2->spot ());
720 SEQUENTIAL '{' Music_list '}' {
721 $$ = new Sequential_music ($3);
722 $$->set_spot ($3->spot ());
724 | '{' Music_list '}' {
725 $$ = new Sequential_music ($2);
726 $$->set_spot ($2->spot ());
731 SIMULTANEOUS '{' Music_list '}'{
732 $$ = new Simultaneous_music ($3);
733 $$->set_spot ($3->spot ());
735 | '<' Music_list '>' {
736 $$ = new Simultaneous_music ($2);
737 $$->set_spot ($2->spot ());
742 request_chord { $$ = $1; }
743 | OUTPUTPROPERTY embedded_scm embedded_scm '=' embedded_scm {
745 if (!gh_symbol_p ($3))
747 THIS->parser_error (_("Second argument must be a symbol"));
749 /*hould check # args */
750 if (!gh_procedure_p (pred))
752 THIS->parser_error (_("First argument must be a procedure taking 1 argument"));
755 $$ = new Output_property (pred,$3, $5);
757 | MUSIC_IDENTIFIER { $$ = $1->access_content_Music (true); }
760 | Simple_music '*' unsigned '/' unsigned {
762 $$->compress (Moment($3, $5 ));
764 | Simple_music '*' unsigned {
766 $$->compress (Moment ($3, 1));
772 CONTEXT STRING Music {
773 Context_specced_music *csm = new Context_specced_music ($3);
775 csm->translator_type_str_ = ly_scm2string ($2);
776 csm->translator_id_str_ = "";
781 | AUTOCHANGE STRING Music {
782 Auto_change_music * chm = new Auto_change_music (ly_scm2string ($2), $3);
785 chm->set_spot ($3->spot ());
788 $$ = new Grace_music ($2);
790 | CONTEXT STRING '=' STRING Music {
791 Context_specced_music *csm = new Context_specced_music ($5);
793 csm->translator_type_str_ = ly_scm2string ($2);
794 csm->translator_id_str_ = ly_scm2string ($4);
799 THIS->remember_spot ();
802 unsigned '/' unsigned Music
805 $$ = new Time_scaled_music ($3, $5, $6);
806 $$->set_spot (THIS->pop_spot ());
808 | Repeated_music { $$ = $1; }
809 | Simultaneous_music { $$ = $1; }
810 | Sequential_music { $$ = $1; }
811 | TRANSPOSE musical_pitch Music {
812 $$ = new Transposed_music ($3, *$2);
815 | TRANSPOSE steno_tonic_pitch Music {
816 $$ = new Transposed_music ($3, *$2);
820 { THIS->lexer_p_->push_note_state (); }
823 THIS->lexer_p_->pop_state ();
826 { THIS->lexer_p_->push_chord_state (); }
830 THIS->lexer_p_->pop_state ();
833 { THIS->lexer_p_->push_lyric_state (); }
837 THIS->lexer_p_->pop_state ();
839 | relative_music { $$ = $1; }
840 | re_rhythmed_music { $$ = $1; }
844 RELATIVE absolute_musical_pitch Music {
845 $$ = new Relative_octave_music ($3, *$2);
851 ADDLYRICS Music Music {
852 Lyric_combine_music * l = new Lyric_combine_music ($2, $3);
858 TRANSLATOR STRING '=' STRING {
859 Change_translator * t = new Change_translator;
860 t-> change_to_type_str_ = ly_scm2string ($2);
861 t-> change_to_id_str_ = ly_scm2string ($4);
864 $$->set_spot (THIS->here_input ());
869 PROPERTY STRING '.' STRING '=' scalar {
870 Translation_property *t = new Translation_property;
872 t->var_str_ = ly_scm2string ($4);
875 Context_specced_music *csm = new Context_specced_music (t);
877 $$->set_spot (THIS->here_input ());
879 csm-> translator_type_str_ = ly_scm2string ($2);
885 | int { $$ = gh_int2scm ($1); }
886 | embedded_scm { $$ = $1; }
891 pre_requests simple_element post_requests {
892 Music_sequence *l = dynamic_cast<Music_sequence*>($2);
894 for (int i=0; i < $1->size(); i++)
895 l->add_music ($1->elem(i));
896 for (int i=0; i < $3->size(); i++)
897 l->add_music ($3->elem(i));
900 programming_error ("Need Sequence to add music to");
909 $$ = new Request_chord;
910 $$-> set_spot (THIS->here_input ());
911 $1-> set_spot (THIS->here_input ());
912 ((Simultaneous_music*)$$) ->add_music ($1);//ugh
914 | PARTIAL duration_length ';' {
915 Translation_property * p = new Translation_property;
916 p->var_str_ = "measurePosition";
917 p->value_ = (new Moment (-$2->length_mom ()))->smobify_self ();
919 Context_specced_music * sp = new Context_specced_music (p);
921 sp-> translator_type_str_ = "Score";
926 shorthand_command_req
927 | verbose_command_req semicolon { $$ = $1; }
930 shorthand_command_req:
938 $$ = new Barcheck_req;
944 Span_req*b= new Span_req;
945 b->span_dir_ = START;
946 b->span_type_str_ = "beam";
950 Span_req*b= new Span_req;
952 b->span_type_str_ = "beam";
956 $$ = new Breathing_sign_req;
964 $$ = new Bar_req (ly_scm2string ($2));
966 | COMMANDSPANREQUEST int STRING {
967 Span_req * sp_p = new Span_req;
968 sp_p-> span_dir_ = Direction($2);
969 sp_p->span_type_str_ = ly_scm2string ($3);
970 sp_p->set_spot (THIS->here_input ());
974 Mark_req * m = new Mark_req;
978 Mark_req *m = new Mark_req;
984 Mark_req *m = new Mark_req;
985 m->mark_label_ = gh_int2scm ($2);
989 | TIME_T unsigned '/' unsigned {
990 Time_signature_change_req *m = new Time_signature_change_req;
996 Break_req * b = new Break_req;
997 b->penalty_f_ = $2 / 100.0;
998 b->set_spot (THIS->here_input ());
1001 | SKIP duration_length {
1002 Skip_req * skip_p = new Skip_req;
1003 skip_p->duration_ = *$2;
1011 $$ = new Clef_change_req (ly_scm2string ($2));
1015 Key_change_req *key_p= new Key_change_req;
1019 TODO: Support for minor/major keys; make `major-scale' settable.
1021 FIXME: force modality.
1024 | KEY NOTENAME_PITCH {
1025 Key_change_req *key_p= new Key_change_req;
1027 key_p->pitch_alist_ = scm_eval (ly_symbol2scm ("major-scale"));
1031 | KEY NOTENAME_PITCH SCM_IDENTIFIER {
1032 Key_change_req *key_p= new Key_change_req;
1034 key_p->pitch_alist_ = $3;
1035 ((Music* )key_p)->transpose (* $2);
1042 $$ = new Link_array<Request>;
1044 | post_requests post_request {
1045 $2->set_spot (THIS->here_input ());
1057 request_that_take_dir:
1060 | script_abbreviation {
1061 SCM s = THIS->lexer_p_->lookup_identifier ("dash-" + ly_scm2string ($1));
1062 Articulation_req *a = new Articulation_req;
1063 if (gh_string_p (s))
1064 a->articulation_str_ = ly_scm2string (s);
1065 else THIS->parser_error (_ ("Expecting string as script definition"));
1071 script_dir request_that_take_dir {
1072 if (Script_req * gs = dynamic_cast<Script_req*> ($2))
1073 gs->dir_ = Direction ($1);
1075 $2->warning (_ ("Can't specify direction for this request"));
1081 REQUEST_IDENTIFIER {
1082 $$ = (Request*)$1->access_content_Request (true);
1083 $$->set_spot (THIS->here_input ());
1085 | TEXTSCRIPT STRING STRING {
1086 Text_script_req *ts_p = new Text_script_req;
1087 ts_p-> text_str_ = ly_scm2string ($2);
1088 ts_p-> style_str_ = ly_scm2string ($3);
1089 ts_p->set_spot (THIS->here_input ());
1093 | SPANREQUEST int STRING {
1094 Span_req * sp_p = new Span_req;
1095 sp_p-> span_dir_ = Direction($2);
1096 sp_p->span_type_str_ = ly_scm2string ($3);
1097 sp_p->set_spot (THIS->here_input ());
1101 Tremolo_req* a = new Tremolo_req;
1102 a->set_spot (THIS->here_input ());
1107 Articulation_req * a = new Articulation_req;
1108 a->articulation_str_ = ly_scm2string ($2);
1109 a->set_spot (THIS->here_input ());
1132 steno_musical_pitch:
1136 | NOTENAME_PITCH sup_quotes {
1138 $$->octave_i_ += $2;
1140 | NOTENAME_PITCH sub_quotes {
1142 $$->octave_i_ += - $2;
1150 | TONICNAME_PITCH sup_quotes {
1152 $$->octave_i_ += $2;
1154 | TONICNAME_PITCH sub_quotes {
1156 $$->octave_i_ += - $2;
1161 steno_musical_pitch {
1164 | MUSICAL_PITCH embedded_scm {
1165 int sz = scm_ilength ($2);
1167 THIS->parser_error (_f ("Expecting %d arguments", 3));
1168 $2 = gh_list (gh_int2scm (0), gh_int2scm (0), gh_int2scm (0), SCM_UNDEFINED);
1170 $$ = new Musical_pitch ($2);
1175 DURATION '{' int_list '}' {
1177 Array<int> &a = *$3;
1180 $$-> durlog_i_ = a[0];
1181 $$-> dots_i_ = a[1];
1189 if (!THIS->lexer_p_->lyric_state_b ())
1190 THIS->parser_error (_ ("Have to be in Lyric mode for lyrics"));
1191 $$ = new Extender_req;
1197 if (!THIS->lexer_p_->lyric_state_b ())
1198 THIS->parser_error (_ ("Have to be in Lyric mode for lyrics"));
1199 $$ = new Hyphen_req;
1204 close_request_parens {
1206 dynamic_cast<Span_req*> ($$)->span_dir_ = START;
1209 close_request_parens:
1211 Span_req* s= new Span_req;
1213 s->span_type_str_ = "slur";
1216 Span_req*s =new Span_req;
1218 s->span_type_str_ = "crescendo";
1221 Span_req*s =new Span_req;
1223 s->span_type_str_ = "decrescendo";
1229 open_request_parens {
1231 dynamic_cast<Span_req*> ($$)->span_dir_ = STOP;
1235 open_request_parens:
1237 Span_req *s = new Span_req;
1238 s->span_type_str_ = "crescendo";
1242 Span_req* s= new Span_req;
1244 s->span_type_str_ = "slur";
1250 Text_script_req *t = new Text_script_req;
1252 t->text_str_ = ly_scm2string ($1);
1254 $$->set_spot (THIS->here_input ());
1257 Text_script_req* t = new Text_script_req;
1259 t->text_str_ = to_str ($1);
1260 t->style_str_ = "finger";
1261 $$->set_spot (THIS->here_input ());
1265 script_abbreviation:
1267 $$ = gh_str02scm ("hat");
1270 $$ = gh_str02scm("plus");
1273 $$ = gh_str02scm ("dash");
1276 $$ = gh_str02scm ("bar");
1279 $$ = gh_str02scm ("larger");
1282 $$ = gh_str02scm ("dot");
1290 | '-' { $$ = CENTER; }
1295 $$ = new Link_array<Request>;
1297 | pre_requests open_request {
1302 absolute_musical_pitch:
1303 steno_musical_pitch {
1312 | duration_length '*' unsigned {
1313 $$->tuplet_iso_i_ *= $3;
1315 | duration_length '/' unsigned {
1316 $$->tuplet_type_i_ *= $3;
1320 entered_notemode_duration:
1322 THIS->set_last_duration ($1);
1326 optional_notemode_duration:
1328 $$ = new Duration (THIS->default_duration_);
1330 | entered_notemode_duration {
1338 if (!is_duration_b ($1))
1339 THIS->parser_error (_f ("not a duration: %d", $1));
1341 $$->durlog_i_ = intlog2 ($1);
1344 | DURATION_IDENTIFIER {
1345 $$ = $1->access_content_Duration (true);
1347 | steno_duration '.' {
1358 if (!is_duration_b ($2))
1359 THIS->parser_error (_f ("not a duration: %d", $2));
1366 musical_pitch exclamations questions optional_notemode_duration {
1367 if (!THIS->lexer_p_->note_state_b ())
1368 THIS->parser_error (_ ("Have to be in Note mode for notes"));
1371 Note_req *n = new Note_req;
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 ($1->spot ());
1381 n->set_spot ($1->spot ());
1391 | RESTNAME optional_notemode_duration {
1392 Simultaneous_music* velt_p = new Request_chord;
1393 velt_p->set_spot (THIS->here_input());
1395 if (ly_scm2string ($1) =="s")
1397 Skip_req * skip_p = new Skip_req;
1398 skip_p->duration_ = *$2;
1400 skip_p->set_spot (THIS->here_input());
1401 velt_p->add_music (skip_p);
1405 Rest_req * rest_req_p = new Rest_req;
1406 rest_req_p->duration_ = *$2;
1407 rest_req_p->set_spot (THIS->here_input());
1409 velt_p->add_music (rest_req_p);
1415 | MEASURES optional_notemode_duration {
1416 Skip_req * sk = new Skip_req;
1417 sk->duration_ = *$2;
1418 Music_list * ms = new Music_list;
1419 Request_chord * rqc1 = new Request_chord;
1420 Request_chord * rqc2 = new Request_chord;
1421 Request_chord * rqc3 = new Request_chord;
1423 Span_req *sp1 = new Span_req;
1424 Span_req *sp2 = new Span_req;
1425 sp1-> span_dir_ = START;
1426 sp2-> span_dir_ = STOP;
1427 sp1->span_type_str_ = sp2->span_type_str_ = "rest";
1428 rqc1->add_music (sp1);
1429 rqc2->add_music (sk);
1430 rqc3->add_music (sp2);
1432 ms->add_music (rqc1);
1433 ms->add_music (rqc2);
1434 ms->add_music (rqc3);
1436 $$ = new Sequential_music (ms);
1438 | STRING optional_notemode_duration {
1439 if (!THIS->lexer_p_->lyric_state_b ())
1440 THIS->parser_error (_ ("Have to be in Lyric mode for lyrics"));
1441 Simultaneous_music* velt_p = new Request_chord;
1443 Lyric_req* lreq_p = new Lyric_req;
1444 lreq_p ->text_str_ = ly_scm2string ($1);
1445 lreq_p->duration_ = *$2;
1446 lreq_p->set_spot (THIS->here_input());
1448 velt_p->add_music (lreq_p);
1455 if (!THIS->lexer_p_->chord_state_b ())
1456 THIS->parser_error (_ ("Have to be in Chord mode for chords"));
1462 steno_tonic_pitch optional_notemode_duration chord_additions chord_subtractions chord_inversion chord_bass {
1463 $$ = THIS->get_chord (*$1, $3, $4, $5, $6, *$2);
1468 $$ = new Array<Musical_pitch>;
1470 | CHORD_COLON chord_notes {
1479 | chord_notes '.' chord_step {
1487 $$ = new Array<Musical_pitch>;
1489 | CHORD_CARET chord_notes {
1499 | '/' steno_tonic_pitch {
1501 $$->set_spot (THIS->here_input ());
1509 | CHORD_BASS steno_tonic_pitch {
1511 $$->set_spot (THIS->here_input ());
1517 $$ = new Array<Musical_pitch>;
1520 | CHORDMODIFIER_PITCH {
1521 $$ = new Array<Musical_pitch>;
1524 | CHORDMODIFIER_PITCH chord_note { /* Ugh. */
1525 $$ = new Array<Musical_pitch>;
1533 $$ = new Musical_pitch;
1534 $$->notename_i_ = ($1 - 1) % 7;
1535 $$->octave_i_ = $1 > 7 ? 1 : 0;
1536 $$->accidental_i_ = 0;
1539 $$ = new Musical_pitch;
1540 $$->notename_i_ = ($1 - 1) % 7;
1541 $$->octave_i_ = $1 > 7 ? 1 : 0;
1542 $$->accidental_i_ = 1;
1544 | unsigned CHORD_MINUS {
1545 $$ = new Musical_pitch;
1546 $$->notename_i_ = ($1 - 1) % 7;
1547 $$->octave_i_ = $1 > 7 ? 1 : 0;
1548 $$->accidental_i_ = -1;
1561 $$ = new Array<Musical_pitch>;
1563 | pitch_list musical_pitch {
1596 $$ = *$1->access_content_int (false);
1605 | STRING_IDENTIFIER {
1608 | string '+' string {
1609 $$ = scm_string_append (scm_listify ($1, $3, SCM_UNDEFINED));
1616 | exclamations '!' { $$ ++; }
1621 | questions '?' { $$ ++; }
1631 My_lily_parser::set_yydebug (bool b)
1638 My_lily_parser::do_yyparse ()
1640 yyparse ((void*)this);