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 "translator-def.hh"
14 #include "lily-guile.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"
31 #include "music-list.hh"
33 #include "file-results.hh"
36 #include "relative-music.hh"
37 #include "lyric-combine-music.hh"
38 #include "transposed-music.hh"
39 #include "time-scaled-music.hh"
40 #include "repeated-music.hh"
41 #include "mudela-version.hh"
42 #include "grace-music.hh"
43 #include "auto-change-music.hh"
44 #include "part-combine-music.hh"
51 return t && t == 1 << intlog2(t);
56 Mudela_version oldest_version ("1.3.59");
59 print_mudela_versions (ostream &os)
61 os << _f ("Oldest supported input version: %s", oldest_version.str ())
66 // needed for bison.simple's malloc() and free()
73 #define YYERROR_VERBOSE 1
75 #define YYPARSE_PARAM my_lily_parser_l
76 #define YYLEX_PARAM my_lily_parser_l
77 #define THIS ((My_lily_parser *) my_lily_parser_l)
79 #define yyerror THIS->parser_error
80 #define ARRAY_SIZE(a,s) if (a.size () != s) THIS->parser_error (_f ("Expecting %d arguments", s))
86 Array<Musical_pitch> *pitch_arr;
87 Link_array<Request> *reqvec;
96 Music_output_def * outputdef;
97 Musical_pitch * pitch;
102 /* We use SCMs to do strings, because it saves us the trouble of
103 deleting them. Let's hope that a stack overflow doesnt trigger a move
104 of the parse stack onto the heap. */
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 */
137 %token CHORDMODIFIERS
144 %token ELEMENTDESCRIPTIONS
183 %token COMMANDSPANREQUEST
185 %token OUTPUTPROPERTY
194 %token E_CHAR E_EXCLAMATION E_SMALLER E_BIGGER
195 %token CHORD_BASS CHORD_COLON CHORD_MINUS CHORD_CARET
197 %type <i> exclamations questions
199 %token <pitch> NOTENAME_PITCH
200 %token <pitch> TONICNAME_PITCH
201 %token <pitch> CHORDMODIFIER_PITCH
202 %token <id> DURATION_IDENTIFIER
203 %token <id> IDENTIFIER
206 %token <id> SCORE_IDENTIFIER
207 %token <id> MUSIC_OUTPUT_DEF_IDENTIFIER
209 %token <scm> NUMBER_IDENTIFIER
210 %token <scm> REQUEST_IDENTIFIER
211 %token <scm> MUSIC_IDENTIFIER TRANSLATOR_IDENTIFIER
212 %token <scm> STRING_IDENTIFIER SCM_IDENTIFIER
213 %token <scm> DURATION RESTNAME
219 %type <outputdef> output_def
220 %type <scope> mudela_header mudela_header_body
221 %type <request> open_request_parens close_request_parens open_request close_request
222 %type <request> request_with_dir request_that_take_dir verbose_request
223 %type <i> sub_quotes sup_quotes
224 %type <music> simple_element request_chord command_element Simple_music Composite_music
225 %type <music> Alternative_music Repeated_music
226 %type <i> tremolo_type
227 %type <i> bare_int bare_unsigned
230 %type <scm> identifier_init
232 %type <duration> steno_duration optional_notemode_duration
233 %type <duration> entered_notemode_duration explicit_duration
235 %type <reqvec> pre_requests post_requests
236 %type <request> gen_text_def
237 %type <pitch> steno_musical_pitch musical_pitch absolute_musical_pitch
238 %type <pitch> steno_tonic_pitch
240 %type <pitch_arr> chord_additions chord_subtractions chord_notes chord_step
242 %type <pitch> chord_note chord_inversion chord_bass
243 %type <duration> duration_length
245 %type <scm> embedded_scm scalar
246 %type <music> Music Sequential_music Simultaneous_music Music_sequence
247 %type <music> relative_music re_rhythmed_music part_combined_music
248 %type <music> property_def translator_change
249 %type <scm> Music_list
250 %type <outputdef> music_output_def_body
251 %type <request> shorthand_command_req
252 %type <request> post_request
253 %type <request> command_req verbose_command_req
254 %type <request> extender_req
255 %type <request> hyphen_req
256 %type <scm> string bare_number number_expression
257 %type <score> score_block score_body
259 %type <scm> translator_spec_block translator_spec_body
260 %type <tempo> tempo_request
261 %type <scm> notenames_body notenames_block chordmodifiers_block
262 %type <scm> script_abbreviation
273 | mudela toplevel_expression {}
274 | mudela assignment { }
276 THIS->error_level_i_ = 1;
277 //THIS->parser_error (_ ("ly invalid"));
280 THIS->error_level_i_ = 1;
281 //THIS->parser_error (_ ("ly invalid"));
287 THIS->lexer_p_->pitchname_tab_ = $1;
289 | chordmodifiers_block {
290 THIS->lexer_p_->chordmodifier_tab_ = $1;
293 delete header_global_p;
294 header_global_p = $1;
297 score_global_array.push ($1);
300 Identifier * id = new
301 Music_output_def_identifier ($1, MUSIC_OUTPUT_DEF_IDENTIFIER);
302 if (dynamic_cast<Paper_def*> ($1))
303 THIS->lexer_p_->set_identifier ("$defaultpaper", id->self_scm ());
304 else if (dynamic_cast<Midi_def*> ($1))
305 THIS->lexer_p_->set_identifier ("$defaultmidi", id->self_scm ());
318 chordmodifiers_block:
319 CHORDMODIFIERS notenames_body { $$ = $2; }
324 NOTENAMES notenames_body { $$ = $2; }
331 int i = scm_ilength ($1);
333 SCM tab = scm_make_vector (gh_int2scm (i), SCM_EOL);
334 for (SCM s = $1; s != SCM_EOL; s = gh_cdr (s)) {
335 SCM pt = gh_cdar (s);
336 if (scm_ilength (pt) != 3)
337 THIS->parser_error ("Need three args");
338 scm_hashq_set_x (tab, gh_caar(s), pt);
348 THIS->lexer_p_-> scope_l_arr_.push ($$);
350 | mudela_header_body assignment semicolon {
356 HEADER '{' mudela_header_body '}' {
358 THIS->lexer_p_-> scope_l_arr_.pop ();
368 THIS->remember_spot ();
370 /* cont */ '=' identifier_init {
371 THIS->lexer_p_->set_identifier (ly_scm2string ($1), $4);
374 TODO: devise standard for protection in parser.
376 The parser stack lives on the C-stack, which means that
377 all objects can be unprotected as soon as they're here.
380 Identifier * id =unsmob_identifier ($4);
381 Input spot = THIS->pop_spot ();
382 if (id) id->set_spot (spot);
390 $$ = (new Score_identifier ($1, SCORE_IDENTIFIER))->self_scm();
393 $$ = (new Music_output_def_identifier ($1, MUSIC_OUTPUT_DEF_IDENTIFIER))->self_scm();
395 | translator_spec_block {
399 $$ = $1->self_scm ();
400 scm_unprotect_object ($$);
403 $$ = $1->self_scm ();
404 scm_unprotect_object ($$);
406 | explicit_duration {
407 $$ = (new Duration_identifier ($1, DURATION_IDENTIFIER))->self_scm ();
409 | number_expression {
420 translator_spec_block:
421 TRANSLATOR '{' translator_spec_body '}'
427 translator_spec_body:
428 TRANSLATOR_IDENTIFIER {
429 $$ = unsmob_translator_def ($1)->clone_scm ();
430 unsmob_translator_def ($$)-> set_spot (THIS->here_input ());
432 | TYPE STRING semicolon {
433 $$ = Translator_def::make_scm ();
434 Translator_def*td = unsmob_translator_def ($$);
435 td->translator_group_type_ = $2;
436 td->set_spot (THIS->here_input ());
438 | translator_spec_body STRING '=' embedded_scm {
439 unsmob_translator_def ($$)->add_property_assign ($2, $4);
441 | translator_spec_body STRING PUSH embedded_scm '=' embedded_scm {
442 unsmob_translator_def ($$)
443 ->add_push_property (scm_string_to_symbol ($2), $4, $6);
445 | translator_spec_body STRING POP embedded_scm {
446 unsmob_translator_def($$)->add_pop_property (
447 scm_string_to_symbol ($2), $4);
449 | translator_spec_body STRING '=' identifier_init semicolon {
450 SCM v = gh_int2scm (0);
451 if (gh_string_p ($4) || gh_number_p ($4) || gh_boolean_p ($4))
454 THIS->parser_error (_("Wrong type for property value"));
457 unsmob_translator_def($$)->add_property_assign ($2, v);
459 | translator_spec_body NAME STRING semicolon {
460 unsmob_translator_def ($$)->type_name_ = $3;
462 | translator_spec_body CONSISTS STRING semicolon {
463 unsmob_translator_def ($$)->add_element ($3);
465 | translator_spec_body ELEMENTDESCRIPTIONS embedded_scm {
466 for (SCM p = $3; gh_pair_p (p); p = gh_cdr (p))
467 unsmob_translator_def ($$)
468 ->add_property_assign (scm_symbol_to_string (gh_caar (p)), gh_cdar (p));
471 | translator_spec_body CONSISTSEND STRING semicolon {
472 unsmob_translator_def ($$)->add_last_element ( $3);
474 | translator_spec_body ACCEPTS STRING semicolon {
475 unsmob_translator_def ($$)->set_acceptor ($3,true);
477 | translator_spec_body DENIES STRING semicolon {
478 unsmob_translator_def ($$)->set_acceptor ($3,false);
480 | translator_spec_body REMOVE STRING semicolon {
481 unsmob_translator_def ($$)->remove_element ($3);
490 THIS->remember_spot ();
492 /*cont*/ '{' score_body '}' {
495 if (!$$->def_p_arr_.size ())
498 unsmob_identifier (THIS->lexer_p_->lookup_identifier ("$defaultpaper"));
499 $$->add_output (id ? id->access_content_Music_output_def (true) : new Paper_def );
503 | SCORE '{' score_body error {
505 $$->set_spot (THIS->here_input ());
506 // THIS->here_input ().error ("SCORE INVALID");
507 $$->error ("SCORE INVALID");
508 THIS->parser_error (_f ("SCORE ERROR"));
517 $$->set_spot (THIS->here_input ());
518 SCM m = $1->self_scm ();
519 scm_unprotect_object (m);
523 $$ = $1->access_content_Score (true);
525 | score_body mudela_header {
528 | score_body output_def {
541 music_output_def_body '}' {
543 THIS-> lexer_p_-> scope_l_arr_.pop();
547 music_output_def_body:
549 Identifier *id = unsmob_identifier (THIS->lexer_p_->lookup_identifier ("$defaultmidi"));
554 p = dynamic_cast<Midi_def*> (id->access_content_Music_output_def (true));
559 THIS->lexer_p_->scope_l_arr_.push (p->scope_p_);
562 Identifier *id = unsmob_identifier (THIS->lexer_p_->lookup_identifier ("$defaultpaper"));
565 p = dynamic_cast<Paper_def*> (id->access_content_Music_output_def (true));
568 THIS-> lexer_p_-> scope_l_arr_.push (p->scope_p_);
571 | PAPER '{' MUSIC_OUTPUT_DEF_IDENTIFIER {
572 Music_output_def *p = $3->access_content_Music_output_def (true);
573 THIS->lexer_p_->scope_l_arr_.push (p->scope_p_);
576 | MIDI '{' MUSIC_OUTPUT_DEF_IDENTIFIER {
577 Music_output_def *p = $3->access_content_Music_output_def (true);
578 THIS->lexer_p_->scope_l_arr_.push (p->scope_p_);
581 | music_output_def_body assignment semicolon {
584 | music_output_def_body translator_spec_block {
585 $$->assign_translator ($2);
587 | music_output_def_body STYLESHEET embedded_scm {
588 dynamic_cast<Paper_def*> ($$)-> style_sheet_ = $3;
590 | music_output_def_body tempo_request semicolon {
592 junk this ? there already is tempo stuff in
595 dynamic_cast<Midi_def*> ($$)->set_tempo ($2->dur_.length_mom (), $2->metronome_i_);
597 | music_output_def_body error {
603 TEMPO steno_duration '=' bare_unsigned {
607 $$-> metronome_i_ = $4;
611 Music_list: /* empty */ {
612 $$ = gh_cons (SCM_EOL, SCM_EOL);
616 SCM c = gh_cons ($2->self_scm (), SCM_EOL);
617 scm_unprotect_object ($2->self_scm ()); /* UGH */
620 if (gh_pair_p (gh_cdr (s)))
621 gh_set_cdr_x (gh_cdr (s), c); /* append */
623 gh_set_car_x (s, c); /* set first cons */
624 gh_set_cdr_x (s, c) ; /* remember last cell */
640 | ALTERNATIVE Music_sequence {
642 $2->set_spot (THIS->here_input ());
650 REPEAT STRING bare_unsigned Music Alternative_music
652 Music_sequence* m = dynamic_cast <Music_sequence*> ($5);
653 if (m && $3 < m->length_i ())
654 $5->origin ()->warning (_ ("More alternatives than repeats. Junking excess alternatives."));
656 Repeated_music * r = new Repeated_music ($4, $3 >? 1, m);
658 r->type_ = ly_scm2string ($2);
659 r->fold_b_ = (r->type_ == "fold");
660 r->volta_fold_b_ = (r->type_ == "volta");
661 r->set_spot (*$4->origin ());
665 Music_sequence: '{' Music_list '}' {
666 $$ = new Music_sequence (gh_car ($2));
671 SEQUENTIAL '{' Music_list '}' {
672 $$ = new Sequential_music (gh_car ($3));
674 | '{' Music_list '}' {
675 $$ = new Sequential_music (gh_car ($2));
680 SIMULTANEOUS '{' Music_list '}'{
681 $$ = new Simultaneous_music (gh_car ($3));
683 | '<' Music_list '>' {
684 $$ = new Simultaneous_music (gh_car ($2));
689 request_chord { $$ = $1; }
690 | OUTPUTPROPERTY embedded_scm embedded_scm '=' embedded_scm {
692 if (!gh_symbol_p ($3))
694 THIS->parser_error (_("Second argument must be a symbol"));
696 /*hould check # args */
697 if (!gh_procedure_p (pred))
699 THIS->parser_error (_("First argument must be a procedure taking 1 argument"));
702 Music *m = new Music;
703 m->set_mus_property ("predicate", pred);
704 m->set_mus_property ("symbol", $3);
705 m->set_mus_property ("value", $5);
706 m->set_mus_property ("type", ly_symbol2scm ("output-property"));
711 $$ = unsmob_music ($1)->clone ();
715 | Simple_music '*' bare_unsigned '/' bare_unsigned {
717 $$->compress (Moment($3, $5 ));
719 | Simple_music '*' bare_unsigned {
721 $$->compress (Moment ($3, 1));
727 CONTEXT STRING Music {
728 Context_specced_music *csm = new Context_specced_music ($3);
730 csm->translator_type_str_ = ly_scm2string ($2);
731 csm->translator_id_str_ = "";
736 | AUTOCHANGE STRING Music {
737 Auto_change_music * chm = new Auto_change_music ($3);
738 chm->set_mus_property ("what", $2);
741 chm->set_spot (*$3->origin ());
744 $$ = new Grace_music ($2);
746 | CONTEXT STRING '=' STRING Music {
747 Context_specced_music *csm = new Context_specced_music ($5);
749 csm->translator_type_str_ = ly_scm2string ($2);
750 csm->translator_id_str_ = ly_scm2string ($4);
755 THIS->remember_spot ();
758 bare_unsigned '/' bare_unsigned Music
761 $$ = new Time_scaled_music ($3, $5, $6);
762 $$->set_spot (THIS->pop_spot ());
764 | Repeated_music { $$ = $1; }
765 | Simultaneous_music { $$ = $1; }
766 | Sequential_music { $$ = $1; }
767 | TRANSPOSE musical_pitch Music {
768 $$ = new Transposed_music ($3, *$2);
771 | TRANSPOSE steno_tonic_pitch Music {
772 $$ = new Transposed_music ($3, *$2);
776 { THIS->lexer_p_->push_note_state (); }
779 THIS->lexer_p_->pop_state ();
782 { THIS->lexer_p_->push_chord_state (); }
786 THIS->lexer_p_->pop_state ();
789 { THIS->lexer_p_->push_lyric_state (); }
793 THIS->lexer_p_->pop_state ();
795 | relative_music { $$ = $1; }
796 | re_rhythmed_music { $$ = $1; }
797 | part_combined_music { $$ = $1; }
801 RELATIVE absolute_musical_pitch Music {
802 $$ = new Relative_octave_music ($3, *$2);
808 ADDLYRICS Music Music {
809 Lyric_combine_music * l = new Lyric_combine_music ($2, $3);
815 PARTCOMBINE STRING Music Music {
816 Part_combine_music * p = new Part_combine_music (ly_scm2string ($2), $3, $4);
822 TRANSLATOR STRING '=' STRING {
823 Music * t = new Music;
824 t->set_mus_property ("type",
825 ly_symbol2scm ("change-translator"));
826 t-> set_mus_property ("change-to-type", $2);
827 t-> set_mus_property ("change-to-id", $4);
830 $$->set_spot (THIS->here_input ());
835 PROPERTY STRING '.' STRING '=' scalar {
836 Music *t = new Music;
838 t->set_mus_property ("type", ly_symbol2scm ("property-set"));
839 t->set_mus_property ("symbol", scm_string_to_symbol ($4));
840 t->set_mus_property ("value", $6);
842 Context_specced_music *csm = new Context_specced_music (t);
844 $$->set_spot (THIS->here_input ());
846 csm-> translator_type_str_ = ly_scm2string ($2);
848 | PROPERTY STRING '.' STRING PUSH embedded_scm '=' embedded_scm {
849 Music *t = new Music;
850 t->set_mus_property ("type", ly_symbol2scm ("property-push"));
851 t->set_mus_property ("symbols", scm_string_to_symbol ($4));
852 t->set_mus_property ("element-property", $6);
853 t->set_mus_property ("element-value", $8);
854 Context_specced_music *csm = new Context_specced_music (t);
856 $$->set_spot (THIS->here_input ());
858 csm-> translator_type_str_ = ly_scm2string ($2);
860 | PROPERTY STRING '.' STRING POP embedded_scm {
861 Music *t = new Music;
862 t->set_mus_property ("type", ly_symbol2scm ("property-pop"));
863 t->set_mus_property ("symbols", scm_string_to_symbol ($4));
864 t->set_mus_property ("element-property", $6);
866 Context_specced_music *csm = new Context_specced_music (t);
868 $$->set_spot (THIS->here_input ());
870 csm-> translator_type_str_ = ly_scm2string ($2);
876 | bare_int { $$ = gh_int2scm ($1); }
877 | embedded_scm { $$ = $1; }
882 pre_requests simple_element post_requests {
883 Music_sequence *l = dynamic_cast<Music_sequence*>($2);
885 for (int i=0; i < $1->size(); i++)
886 l->append_music ($1->elem(i));
887 for (int i=0; i < $3->size(); i++)
888 l->append_music ($3->elem(i));
891 programming_error ("Need Sequence to add music to");
900 $$ = new Request_chord (gh_cons ($1->self_scm (), SCM_EOL));
901 $$-> set_spot (THIS->here_input ());
902 $1-> set_spot (THIS->here_input ());
904 | PARTIAL duration_length ';' {
905 Music * p = new Music;
906 p->set_mus_property ("symbol", ly_symbol2scm ( "measurePosition"));
907 p->set_mus_property ("type", ly_symbol2scm ("property-set"));
909 Moment m = - $2->length_mom ();
910 p->set_mus_property ("value", m.make_scm());
912 Context_specced_music * sp = new Context_specced_music (p);
914 sp-> translator_type_str_ = "Score";
919 shorthand_command_req
920 | verbose_command_req semicolon { $$ = $1; }
923 shorthand_command_req:
931 $$ = new Barcheck_req;
937 Span_req*b= new Span_req;
938 b->span_dir_ = START;
939 b->span_type_str_ = "beam";
943 Span_req*b= new Span_req;
945 b->span_type_str_ = "beam";
949 $$ = new Breathing_sign_req;
957 $$ = new Bar_req (ly_scm2string ($2));
959 | COMMANDSPANREQUEST bare_int STRING {
960 Span_req * sp_p = new Span_req;
961 sp_p-> span_dir_ = Direction($2);
962 sp_p->span_type_str_ = ly_scm2string ($3);
963 sp_p->set_spot (THIS->here_input ());
967 Mark_req * m = new Mark_req;
971 Mark_req *m = new Mark_req;
972 m->set_mus_property ("label", $2);
976 | MARK bare_unsigned {
977 Mark_req *m = new Mark_req;
978 m->set_mus_property ("label", gh_int2scm ($2));
982 | TIME_T bare_unsigned '/' bare_unsigned {
983 Time_signature_change_req *m = new Time_signature_change_req;
989 Break_req * b = new Break_req;
990 b->penalty_f_ = $2 / 100.0;
991 b->set_spot (THIS->here_input ());
994 | SKIP duration_length {
995 Skip_req * skip_p = new Skip_req;
996 skip_p->duration_ = *$2;
1004 $$ = new Clef_change_req (ly_scm2string ($2));
1008 Key_change_req *key_p= new Key_change_req;
1011 | KEY NOTENAME_PITCH SCM_IDENTIFIER {
1012 Key_change_req *key_p= new Key_change_req;
1014 key_p->set_mus_property ("pitch-alist", $3);
1015 ((Music* )key_p)->transpose (* $2);
1022 $$ = new Link_array<Request>;
1024 | post_requests post_request {
1025 $2->set_spot (THIS->here_input ());
1037 request_that_take_dir:
1040 | script_abbreviation {
1041 SCM s = THIS->lexer_p_->lookup_identifier ("dash-" + ly_scm2string ($1));
1042 Articulation_req *a = new Articulation_req;
1043 if (gh_string_p (s))
1044 a->articulation_str_ = ly_scm2string (s);
1045 else THIS->parser_error (_ ("Expecting string as script definition"));
1051 script_dir request_that_take_dir {
1052 if (Script_req * gs = dynamic_cast<Script_req*> ($2))
1053 gs->set_direction (Direction ($1));
1055 $2->origin ()->warning (_ ("Can't specify direction for this request"));
1061 REQUEST_IDENTIFIER {
1062 $$ = dynamic_cast<Request*> (unsmob_music ($1)->clone ());
1063 $$->set_spot (THIS->here_input ());
1065 | DYNAMICSCRIPT embedded_scm {
1067 TODO: junkme, use text-type == dynamic
1069 Text_script_req *d = new Text_script_req;
1070 d->set_mus_property ("text-type" , ly_symbol2scm ("dynamic"));
1071 d->set_mus_property ("text", $2);
1072 d->set_spot (THIS->here_input ());
1075 | TEXTSCRIPT embedded_scm {
1076 Text_script_req *t = new Text_script_req;
1077 t->set_mus_property ("text", $2);
1078 t->set_spot (THIS->here_input ());
1081 | SPANREQUEST bare_int STRING {
1082 Span_req * sp_p = new Span_req;
1083 sp_p->span_dir_ = Direction($2);
1084 sp_p->span_type_str_ = ly_scm2string ($3);
1085 sp_p->set_spot (THIS->here_input ());
1089 Tremolo_req* a = new Tremolo_req;
1090 a->set_spot (THIS->here_input ());
1095 Articulation_req * a = new Articulation_req;
1096 a->articulation_str_ = ly_scm2string ($2);
1097 a->set_spot (THIS->here_input ());
1101 Arpeggio_req *a = new Arpeggio_req;
1102 a->set_spot (THIS->here_input ());
1125 steno_musical_pitch:
1129 | NOTENAME_PITCH sup_quotes {
1131 $$->octave_i_ += $2;
1133 | NOTENAME_PITCH sub_quotes {
1135 $$->octave_i_ += - $2;
1143 | TONICNAME_PITCH sup_quotes {
1145 $$->octave_i_ += $2;
1147 | TONICNAME_PITCH sub_quotes {
1149 $$->octave_i_ += - $2;
1154 steno_musical_pitch {
1157 | MUSICAL_PITCH embedded_scm {
1158 int sz = scm_ilength ($2);
1160 THIS->parser_error (_f ("Expecting %d arguments", 3));
1161 $2 = gh_list (gh_int2scm (0), gh_int2scm (0), gh_int2scm (0), SCM_UNDEFINED);
1163 $$ = new Musical_pitch ($2);
1168 DURATION embedded_scm {
1170 if (scm_ilength ($2) == 2)
1172 $$-> durlog_i_ = gh_scm2int (gh_car($2));
1173 $$-> dots_i_ = gh_scm2int (gh_cadr($2));
1176 THIS->parser_error (_("Must have 2 arguments for duration"));
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;
1244 t->set_mus_property ("text", $1);
1245 t->set_spot (THIS->here_input ());
1249 Text_script_req *t = new Text_script_req;
1250 t->set_mus_property ("text", $1);
1251 t->set_spot (THIS->here_input ());
1255 String ds = to_str ($1);
1256 Text_script_req* t = new Text_script_req;
1258 t->set_mus_property ("text", ly_str02scm (ds.ch_C()));
1259 t->set_mus_property ("text-type" , ly_symbol2scm ("finger"));
1260 t->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 '*' bare_unsigned {
1313 $$->tuplet_iso_i_ *= $3;
1315 | duration_length '/' bare_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 '.' {
1357 | ':' bare_unsigned {
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_;
1380 Simultaneous_music*v = new Request_chord (gh_list (n->self_scm (), SCM_UNDEFINED));
1381 v->set_spot ($1->spot ());
1382 n->set_spot ($1->spot ());
1388 | RESTNAME optional_notemode_duration {
1390 SCM e = SCM_UNDEFINED;
1391 if (ly_scm2string ($1) =="s")
1393 Skip_req * skip_p = new Skip_req;
1394 skip_p->duration_ = *$2;
1396 skip_p->set_spot (THIS->here_input());
1397 e = skip_p->self_scm ();
1401 Rest_req * rest_req_p = new Rest_req;
1402 rest_req_p->duration_ = *$2;
1403 rest_req_p->set_spot (THIS->here_input());
1404 e = rest_req_p->self_scm ();
1406 Simultaneous_music* velt_p = new Request_chord (gh_list (e,SCM_UNDEFINED));
1407 velt_p->set_spot (THIS->here_input());
1412 | MEASURES optional_notemode_duration {
1413 Skip_req * sk = new Skip_req;
1414 sk->duration_ = *$2;
1417 Span_req *sp1 = new Span_req;
1418 Span_req *sp2 = new Span_req;
1419 sp1-> span_dir_ = START;
1420 sp2-> span_dir_ = STOP;
1421 sp1->span_type_str_ = sp2->span_type_str_ = "rest";
1423 Request_chord * rqc1 = new Request_chord (gh_list (sp1->self_scm (), SCM_UNDEFINED));
1424 Request_chord * rqc2 = new Request_chord (gh_list (sk->self_scm (), SCM_UNDEFINED));;
1425 Request_chord * rqc3 = new Request_chord(gh_list (sp2->self_scm (), SCM_UNDEFINED));;
1427 SCM ms = gh_list (rqc1->self_scm (), rqc2->self_scm (), rqc3->self_scm (), SCM_UNDEFINED);
1429 $$ = new Sequential_music (ms);
1432 THIS->remember_spot ();
1435 optional_notemode_duration {
1436 if (!THIS->lexer_p_->lyric_state_b ()) {
1437 THIS->pop_spot ().error (_ ("Have to be in Lyric mode for lyrics"));
1438 THIS->error_level_i_ = 1;
1439 THIS->parser_error (_ ("Giving up"));
1443 Lyric_req* lreq_p = new Lyric_req;
1444 lreq_p->set_mus_property ("text", $1);
1445 lreq_p->duration_ = *$3;
1446 lreq_p->set_spot (THIS->here_input());
1447 Simultaneous_music* velt_p = new Request_chord (gh_list (lreq_p->self_scm (), SCM_UNDEFINED));
1454 if (!THIS->lexer_p_->chord_state_b ())
1455 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 $$ = get_chord (*$1, $3, $4, $5, $6, *$2);
1464 $$->set_spot (THIS->here_input ());
1469 $$ = new Array<Musical_pitch>;
1471 | CHORD_COLON chord_notes {
1480 | chord_notes '.' chord_step {
1488 $$ = new Array<Musical_pitch>;
1490 | CHORD_CARET chord_notes {
1500 | '/' steno_tonic_pitch {
1502 $$->set_spot (THIS->here_input ());
1510 | CHORD_BASS steno_tonic_pitch {
1512 $$->set_spot (THIS->here_input ());
1518 $$ = new Array<Musical_pitch>;
1521 | CHORDMODIFIER_PITCH {
1522 $$ = new Array<Musical_pitch>;
1525 | CHORDMODIFIER_PITCH chord_note { /* Ugh. */
1526 $$ = new Array<Musical_pitch>;
1534 $$ = new Musical_pitch;
1535 $$->notename_i_ = ($1 - 1) % 7;
1536 $$->octave_i_ = $1 > 7 ? 1 : 0;
1537 $$->accidental_i_ = 0;
1539 | bare_unsigned '+' {
1540 $$ = new Musical_pitch;
1541 $$->notename_i_ = ($1 - 1) % 7;
1542 $$->octave_i_ = $1 > 7 ? 1 : 0;
1543 $$->accidental_i_ = 1;
1545 | bare_unsigned CHORD_MINUS {
1546 $$ = new Musical_pitch;
1547 $$->notename_i_ = ($1 - 1) % 7;
1548 $$->octave_i_ = $1 > 7 ? 1 : 0;
1549 $$->accidental_i_ = -1;
1560 | '-' number_expression %prec UNARY_MINUS {
1561 $$ = scm_difference ($2, SCM_UNDEFINED);
1563 | number_expression '*' number_expression {
1564 $$ = scm_product ($1, $3);
1566 | number_expression '/' number_expression {
1567 $$ = scm_divide ($1, $3);
1569 | number_expression '+' number_expression {
1570 $$ = scm_sum ($1, $3);
1572 | number_expression '-' number_expression {
1573 $$ = scm_difference ($1, $3);
1575 | '(' number_expression ')' {
1582 $$ = gh_int2scm ($1);
1585 $$ = gh_int2scm ($1);
1588 $$ = gh_double2scm ($1);
1590 | NUMBER_IDENTIFIER {
1594 $$ = gh_double2scm ($1 CM);
1597 $$ = gh_double2scm ($1 PT);
1600 $$ = gh_double2scm ($1 INCH);
1603 $$ = gh_double2scm ($1 MM);
1606 $$ = gh_double2scm ($1 CHAR);
1613 if (scm_integer_p ($1) == SCM_BOOL_T) {
1614 $$ = gh_scm2int ($1);
1617 THIS->parser_error (_("need integer number arg"));
1621 THIS->parser_error (_("Must be positive integer"));
1629 if (scm_integer_p ($1) == SCM_BOOL_T)
1631 int k = gh_scm2int ($1);
1635 THIS->parser_error (_("need integer number arg"));
1649 | STRING_IDENTIFIER {
1652 | string '+' string {
1653 $$ = scm_string_append (scm_listify ($1, $3, SCM_UNDEFINED));
1660 | exclamations '!' { $$ ++; }
1665 | questions '?' { $$ ++; }
1676 My_lily_parser::set_yydebug (bool b)
1683 My_lily_parser::do_yyparse ()
1685 yyparse ((void*)this);