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
182 %token COMMANDSPANREQUEST
184 %token OUTPUTPROPERTY
193 %token E_CHAR E_EXCLAMATION E_SMALLER E_BIGGER
194 %token CHORD_BASS CHORD_COLON CHORD_MINUS CHORD_CARET
196 %type <i> exclamations questions
198 %token <pitch> NOTENAME_PITCH
199 %token <pitch> TONICNAME_PITCH
200 %token <pitch> CHORDMODIFIER_PITCH
201 %token <id> DURATION_IDENTIFIER
202 %token <id> IDENTIFIER
205 %token <id> SCORE_IDENTIFIER
206 %token <id> MUSIC_OUTPUT_DEF_IDENTIFIER
208 %token <scm> NUMBER_IDENTIFIER
209 %token <scm> REQUEST_IDENTIFIER
210 %token <scm> MUSIC_IDENTIFIER TRANSLATOR_IDENTIFIER
211 %token <scm> STRING_IDENTIFIER SCM_IDENTIFIER
212 %token <scm> DURATION RESTNAME
218 %type <outputdef> output_def
219 %type <scope> mudela_header mudela_header_body
220 %type <request> open_request_parens close_request_parens open_request close_request
221 %type <request> request_with_dir request_that_take_dir verbose_request
222 %type <i> sub_quotes sup_quotes
223 %type <music> simple_element request_chord command_element Simple_music Composite_music
224 %type <music> Alternative_music Repeated_music
225 %type <i> tremolo_type
226 %type <i> bare_int bare_unsigned
229 %type <scm> identifier_init
231 %type <duration> steno_duration optional_notemode_duration
232 %type <duration> entered_notemode_duration explicit_duration
234 %type <reqvec> pre_requests post_requests
235 %type <request> gen_text_def
236 %type <pitch> steno_musical_pitch musical_pitch absolute_musical_pitch
237 %type <pitch> steno_tonic_pitch
239 %type <pitch_arr> chord_additions chord_subtractions chord_notes chord_step
241 %type <pitch> chord_note chord_inversion chord_bass
242 %type <duration> duration_length
244 %type <scm> embedded_scm scalar
245 %type <music> Music Sequential_music Simultaneous_music Music_sequence
246 %type <music> relative_music re_rhythmed_music part_combined_music
247 %type <music> property_def translator_change
248 %type <scm> Music_list
249 %type <outputdef> music_output_def_body
250 %type <request> shorthand_command_req
251 %type <request> post_request
252 %type <request> command_req verbose_command_req
253 %type <request> extender_req
254 %type <request> hyphen_req
255 %type <scm> string bare_number number_expression
256 %type <score> score_block score_body
258 %type <scm> translator_spec_block translator_spec_body
259 %type <tempo> tempo_request
260 %type <scm> notenames_body notenames_block chordmodifiers_block
261 %type <scm> script_abbreviation
272 | mudela toplevel_expression {}
273 | mudela assignment { }
275 THIS->error_level_i_ = 1;
276 //THIS->parser_error (_ ("ly invalid"));
279 THIS->error_level_i_ = 1;
280 //THIS->parser_error (_ ("ly invalid"));
286 THIS->lexer_p_->pitchname_tab_ = $1;
288 | chordmodifiers_block {
289 THIS->lexer_p_->chordmodifier_tab_ = $1;
292 delete header_global_p;
293 header_global_p = $1;
296 score_global_array.push ($1);
299 Identifier * id = new
300 Music_output_def_identifier ($1, MUSIC_OUTPUT_DEF_IDENTIFIER);
301 if (dynamic_cast<Paper_def*> ($1))
302 THIS->lexer_p_->set_identifier ("$defaultpaper", id->self_scm ());
303 else if (dynamic_cast<Midi_def*> ($1))
304 THIS->lexer_p_->set_identifier ("$defaultmidi", id->self_scm ());
317 chordmodifiers_block:
318 CHORDMODIFIERS notenames_body { $$ = $2; }
323 NOTENAMES notenames_body { $$ = $2; }
330 int i = scm_ilength ($1);
332 SCM tab = scm_make_vector (gh_int2scm (i), SCM_EOL);
333 for (SCM s = $1; s != SCM_EOL; s = gh_cdr (s)) {
334 SCM pt = gh_cdar (s);
335 if (scm_ilength (pt) != 3)
336 THIS->parser_error ("Need three args");
337 scm_hashq_set_x (tab, gh_caar(s), pt);
347 THIS->lexer_p_-> scope_l_arr_.push ($$);
349 | mudela_header_body assignment semicolon {
355 HEADER '{' mudela_header_body '}' {
357 THIS->lexer_p_-> scope_l_arr_.pop ();
367 THIS->remember_spot ();
369 /* cont */ '=' identifier_init {
370 THIS->lexer_p_->set_identifier (ly_scm2string ($1), $4);
373 TODO: devise standard for protection in parser.
375 The parser stack lives on the C-stack, which means that
376 all objects can be unprotected as soon as they're here.
379 Identifier * id =unsmob_identifier ($4);
380 Input spot = THIS->pop_spot ();
381 if (id) id->set_spot (spot);
389 $$ = (new Score_identifier ($1, SCORE_IDENTIFIER))->self_scm();
392 $$ = (new Music_output_def_identifier ($1, MUSIC_OUTPUT_DEF_IDENTIFIER))->self_scm();
394 | translator_spec_block {
398 $$ = $1->self_scm ();
399 scm_unprotect_object ($$);
402 $$ = $1->self_scm ();
403 scm_unprotect_object ($$);
405 | explicit_duration {
406 $$ = (new Duration_identifier ($1, DURATION_IDENTIFIER))->self_scm ();
408 | number_expression {
419 translator_spec_block:
420 TRANSLATOR '{' translator_spec_body '}'
426 translator_spec_body:
427 TRANSLATOR_IDENTIFIER {
428 $$ = unsmob_translator_def ($1)->clone_scm ();
429 unsmob_translator_def ($$)-> set_spot (THIS->here_input ());
431 | TYPE STRING semicolon {
432 $$ = Translator_def::make_scm ();
433 Translator_def*td = unsmob_translator_def ($$);
434 td->translator_group_type_ = $2;
435 td->set_spot (THIS->here_input ());
437 | translator_spec_body STRING '=' embedded_scm {
438 unsmob_translator_def ($$)->add_property_assign ($2, $4);
440 | translator_spec_body STRING PUSH embedded_scm '=' embedded_scm {
441 unsmob_translator_def ($$)
442 ->add_push_property (scm_string_to_symbol ($2), $4, $6);
444 | translator_spec_body STRING POP embedded_scm {
445 unsmob_translator_def($$)->add_pop_property (
446 scm_string_to_symbol ($2), $4);
448 | translator_spec_body STRING '=' identifier_init semicolon {
449 SCM v = gh_int2scm (0);
450 if (gh_string_p ($4) || gh_number_p ($4) || gh_boolean_p ($4))
453 THIS->parser_error (_("Wrong type for property value"));
456 unsmob_translator_def($$)->add_property_assign ($2, v);
458 | translator_spec_body NAME STRING semicolon {
459 unsmob_translator_def ($$)->type_name_ = $3;
461 | translator_spec_body CONSISTS STRING semicolon {
462 unsmob_translator_def ($$)->add_element ($3);
464 | translator_spec_body ELEMENTDESCRIPTIONS embedded_scm {
465 for (SCM p = $3; gh_pair_p (p); p = gh_cdr (p))
466 unsmob_translator_def ($$)
467 ->add_property_assign (scm_symbol_to_string (gh_caar (p)), gh_cdar (p));
470 | translator_spec_body CONSISTSEND STRING semicolon {
471 unsmob_translator_def ($$)->add_last_element ( $3);
473 | translator_spec_body ACCEPTS STRING semicolon {
474 unsmob_translator_def ($$)->set_acceptor ($3,true);
476 | translator_spec_body DENIES STRING semicolon {
477 unsmob_translator_def ($$)->set_acceptor ($3,false);
479 | translator_spec_body REMOVE STRING semicolon {
480 unsmob_translator_def ($$)->remove_element ($3);
489 THIS->remember_spot ();
491 /*cont*/ '{' score_body '}' {
494 if (!$$->def_p_arr_.size ())
497 unsmob_identifier (THIS->lexer_p_->lookup_identifier ("$defaultpaper"));
498 $$->add_output (id ? id->access_content_Music_output_def (true) : new Paper_def );
502 | SCORE '{' score_body error {
504 $$->set_spot (THIS->here_input ());
505 // THIS->here_input ().error ("SCORE INVALID");
506 $$->error ("SCORE INVALID");
507 THIS->parser_error (_f ("SCORE ERROR"));
516 $$->set_spot (THIS->here_input ());
517 SCM m = $1->self_scm ();
518 scm_unprotect_object (m);
522 $$ = $1->access_content_Score (true);
524 | score_body mudela_header {
527 | score_body output_def {
540 music_output_def_body '}' {
542 THIS-> lexer_p_-> scope_l_arr_.pop();
546 music_output_def_body:
548 Identifier *id = unsmob_identifier (THIS->lexer_p_->lookup_identifier ("$defaultmidi"));
553 p = dynamic_cast<Midi_def*> (id->access_content_Music_output_def (true));
558 THIS->lexer_p_->scope_l_arr_.push (p->scope_p_);
561 Identifier *id = unsmob_identifier (THIS->lexer_p_->lookup_identifier ("$defaultpaper"));
564 p = dynamic_cast<Paper_def*> (id->access_content_Music_output_def (true));
567 THIS-> lexer_p_-> scope_l_arr_.push (p->scope_p_);
570 | PAPER '{' MUSIC_OUTPUT_DEF_IDENTIFIER {
571 Music_output_def *p = $3->access_content_Music_output_def (true);
572 THIS->lexer_p_->scope_l_arr_.push (p->scope_p_);
575 | MIDI '{' MUSIC_OUTPUT_DEF_IDENTIFIER {
576 Music_output_def *p = $3->access_content_Music_output_def (true);
577 THIS->lexer_p_->scope_l_arr_.push (p->scope_p_);
580 | music_output_def_body assignment semicolon {
583 | music_output_def_body translator_spec_block {
584 $$->assign_translator ($2);
586 | music_output_def_body tempo_request semicolon {
588 junk this ? there already is tempo stuff in
591 dynamic_cast<Midi_def*> ($$)->set_tempo ($2->dur_.length_mom (), $2->metronome_i_);
593 | music_output_def_body bare_int '=' FONT STRING { // ugh, what a syntax
594 SCM sl = Lookup::make_lookup();
595 Lookup * l =unsmob_lookup (sl);
596 l->font_name_ = ly_scm2string ($5);
597 dynamic_cast<Paper_def*> ($$)->set_lookup ($2, sl);
599 | music_output_def_body error {
605 TEMPO steno_duration '=' bare_unsigned {
609 $$-> metronome_i_ = $4;
613 Music_list: /* empty */ {
614 $$ = gh_cons (SCM_EOL, SCM_EOL);
618 SCM c = gh_cons ($2->self_scm (), SCM_EOL);
619 scm_unprotect_object ($2->self_scm ()); /* UGH */
622 if (gh_pair_p (gh_cdr (s)))
623 gh_set_cdr_x (gh_cdr (s), c); /* append */
625 gh_set_car_x (s, c); /* set first cons */
626 gh_set_cdr_x (s, c) ; /* remember last cell */
642 | ALTERNATIVE Music_sequence {
644 $2->set_spot (THIS->here_input ());
652 REPEAT STRING bare_unsigned Music Alternative_music
654 Music_sequence* m = dynamic_cast <Music_sequence*> ($5);
655 if (m && $3 < m->length_i ())
656 $5->origin ()->warning (_ ("More alternatives than repeats. Junking excess alternatives."));
658 Repeated_music * r = new Repeated_music ($4, $3 >? 1, m);
660 r->type_ = ly_scm2string ($2);
661 r->fold_b_ = (r->type_ == "fold");
662 r->volta_fold_b_ = (r->type_ == "volta");
663 r->set_spot (*$4->origin ());
667 Music_sequence: '{' Music_list '}' {
668 $$ = new Music_sequence (gh_car ($2));
673 SEQUENTIAL '{' Music_list '}' {
674 $$ = new Sequential_music (gh_car ($3));
676 | '{' Music_list '}' {
677 $$ = new Sequential_music (gh_car ($2));
682 SIMULTANEOUS '{' Music_list '}'{
683 $$ = new Simultaneous_music (gh_car ($3));
685 | '<' Music_list '>' {
686 $$ = new Simultaneous_music (gh_car ($2));
691 request_chord { $$ = $1; }
692 | OUTPUTPROPERTY embedded_scm embedded_scm '=' embedded_scm {
694 if (!gh_symbol_p ($3))
696 THIS->parser_error (_("Second argument must be a symbol"));
698 /*hould check # args */
699 if (!gh_procedure_p (pred))
701 THIS->parser_error (_("First argument must be a procedure taking 1 argument"));
704 Music *m = new Music;
705 m->set_mus_property ("predicate", pred);
706 m->set_mus_property ("symbol", $3);
707 m->set_mus_property ("value", $5);
708 m->set_mus_property ("type", ly_symbol2scm ("output-property"));
713 $$ = unsmob_music ($1)->clone ();
717 | Simple_music '*' bare_unsigned '/' bare_unsigned {
719 $$->compress (Moment($3, $5 ));
721 | Simple_music '*' bare_unsigned {
723 $$->compress (Moment ($3, 1));
729 CONTEXT STRING Music {
730 Context_specced_music *csm = new Context_specced_music ($3);
732 csm->translator_type_str_ = ly_scm2string ($2);
733 csm->translator_id_str_ = "";
738 | AUTOCHANGE STRING Music {
739 Auto_change_music * chm = new Auto_change_music ($3);
740 chm->set_mus_property ("what", $2);
743 chm->set_spot (*$3->origin ());
746 $$ = new Grace_music ($2);
748 | CONTEXT STRING '=' STRING Music {
749 Context_specced_music *csm = new Context_specced_music ($5);
751 csm->translator_type_str_ = ly_scm2string ($2);
752 csm->translator_id_str_ = ly_scm2string ($4);
757 THIS->remember_spot ();
760 bare_unsigned '/' bare_unsigned Music
763 $$ = new Time_scaled_music ($3, $5, $6);
764 $$->set_spot (THIS->pop_spot ());
766 | Repeated_music { $$ = $1; }
767 | Simultaneous_music { $$ = $1; }
768 | Sequential_music { $$ = $1; }
769 | TRANSPOSE musical_pitch Music {
770 $$ = new Transposed_music ($3, *$2);
773 | TRANSPOSE steno_tonic_pitch Music {
774 $$ = new Transposed_music ($3, *$2);
778 { THIS->lexer_p_->push_note_state (); }
781 THIS->lexer_p_->pop_state ();
784 { THIS->lexer_p_->push_chord_state (); }
788 THIS->lexer_p_->pop_state ();
791 { THIS->lexer_p_->push_lyric_state (); }
795 THIS->lexer_p_->pop_state ();
797 | relative_music { $$ = $1; }
798 | re_rhythmed_music { $$ = $1; }
799 | part_combined_music { $$ = $1; }
803 RELATIVE absolute_musical_pitch Music {
804 $$ = new Relative_octave_music ($3, *$2);
810 ADDLYRICS Music Music {
811 Lyric_combine_music * l = new Lyric_combine_music ($2, $3);
817 PARTCOMBINE STRING Music Music {
818 Part_combine_music * p = new Part_combine_music (ly_scm2string ($2), $3, $4);
824 TRANSLATOR STRING '=' STRING {
825 Music * t = new Music;
826 t->set_mus_property ("type",
827 ly_symbol2scm ("change-translator"));
828 t-> set_mus_property ("change-to-type", $2);
829 t-> set_mus_property ("change-to-id", $4);
832 $$->set_spot (THIS->here_input ());
837 PROPERTY STRING '.' STRING '=' scalar {
838 Music *t = new Music;
840 t->set_mus_property ("type", ly_symbol2scm ("property-set"));
841 t->set_mus_property ("symbol", scm_string_to_symbol ($4));
842 t->set_mus_property ("value", $6);
844 Context_specced_music *csm = new Context_specced_music (t);
846 $$->set_spot (THIS->here_input ());
848 csm-> translator_type_str_ = ly_scm2string ($2);
850 | PROPERTY STRING '.' STRING PUSH embedded_scm '=' embedded_scm {
851 Music *t = new Music;
852 t->set_mus_property ("type", ly_symbol2scm ("property-push"));
853 t->set_mus_property ("symbols", scm_string_to_symbol ($4));
854 t->set_mus_property ("element-property", $6);
855 t->set_mus_property ("element-value", $8);
856 Context_specced_music *csm = new Context_specced_music (t);
858 $$->set_spot (THIS->here_input ());
860 csm-> translator_type_str_ = ly_scm2string ($2);
862 | PROPERTY STRING '.' STRING POP embedded_scm {
863 Music *t = new Music;
864 t->set_mus_property ("type", ly_symbol2scm ("property-pop"));
865 t->set_mus_property ("symbols", scm_string_to_symbol ($4));
866 t->set_mus_property ("element-property", $6);
868 Context_specced_music *csm = new Context_specced_music (t);
870 $$->set_spot (THIS->here_input ());
872 csm-> translator_type_str_ = ly_scm2string ($2);
878 | bare_int { $$ = gh_int2scm ($1); }
879 | embedded_scm { $$ = $1; }
884 pre_requests simple_element post_requests {
885 Music_sequence *l = dynamic_cast<Music_sequence*>($2);
887 for (int i=0; i < $1->size(); i++)
888 l->append_music ($1->elem(i));
889 for (int i=0; i < $3->size(); i++)
890 l->append_music ($3->elem(i));
893 programming_error ("Need Sequence to add music to");
902 $$ = new Request_chord (gh_cons ($1->self_scm (), SCM_EOL));
903 $$-> set_spot (THIS->here_input ());
904 $1-> set_spot (THIS->here_input ());
906 | PARTIAL duration_length ';' {
907 Music * p = new Music;
908 p->set_mus_property ("symbol", ly_symbol2scm ( "measurePosition"));
909 p->set_mus_property ("type", ly_symbol2scm ("property-set"));
911 Moment m = - $2->length_mom ();
912 p->set_mus_property ("value", m.make_scm());
914 Context_specced_music * sp = new Context_specced_music (p);
916 sp-> translator_type_str_ = "Score";
921 shorthand_command_req
922 | verbose_command_req semicolon { $$ = $1; }
925 shorthand_command_req:
933 $$ = new Barcheck_req;
939 Span_req*b= new Span_req;
940 b->span_dir_ = START;
941 b->span_type_str_ = "beam";
945 Span_req*b= new Span_req;
947 b->span_type_str_ = "beam";
951 $$ = new Breathing_sign_req;
959 $$ = new Bar_req (ly_scm2string ($2));
961 | COMMANDSPANREQUEST bare_int STRING {
962 Span_req * sp_p = new Span_req;
963 sp_p-> span_dir_ = Direction($2);
964 sp_p->span_type_str_ = ly_scm2string ($3);
965 sp_p->set_spot (THIS->here_input ());
969 Mark_req * m = new Mark_req;
973 Mark_req *m = new Mark_req;
974 m->set_mus_property ("label", $2);
978 | MARK bare_unsigned {
979 Mark_req *m = new Mark_req;
980 m->set_mus_property ("label", gh_int2scm ($2));
984 | TIME_T bare_unsigned '/' bare_unsigned {
985 Time_signature_change_req *m = new Time_signature_change_req;
991 Break_req * b = new Break_req;
992 b->penalty_f_ = $2 / 100.0;
993 b->set_spot (THIS->here_input ());
996 | SKIP duration_length {
997 Skip_req * skip_p = new Skip_req;
998 skip_p->duration_ = *$2;
1006 $$ = new Clef_change_req (ly_scm2string ($2));
1010 Key_change_req *key_p= new Key_change_req;
1013 | KEY NOTENAME_PITCH SCM_IDENTIFIER {
1014 Key_change_req *key_p= new Key_change_req;
1016 key_p->set_mus_property ("pitch-alist", $3);
1017 ((Music* )key_p)->transpose (* $2);
1024 $$ = new Link_array<Request>;
1026 | post_requests post_request {
1027 $2->set_spot (THIS->here_input ());
1039 request_that_take_dir:
1042 | script_abbreviation {
1043 SCM s = THIS->lexer_p_->lookup_identifier ("dash-" + ly_scm2string ($1));
1044 Articulation_req *a = new Articulation_req;
1045 if (gh_string_p (s))
1046 a->articulation_str_ = ly_scm2string (s);
1047 else THIS->parser_error (_ ("Expecting string as script definition"));
1053 script_dir request_that_take_dir {
1054 if (Script_req * gs = dynamic_cast<Script_req*> ($2))
1055 gs->set_direction (Direction ($1));
1057 $2->origin ()->warning (_ ("Can't specify direction for this request"));
1063 REQUEST_IDENTIFIER {
1064 $$ = dynamic_cast<Request*> (unsmob_music ($1)->clone ());
1065 $$->set_spot (THIS->here_input ());
1067 | DYNAMICSCRIPT embedded_scm {
1069 TODO: junkme, use text-type == dynamic
1071 Text_script_req *d = new Text_script_req;
1072 d->set_mus_property ("text-type" , ly_symbol2scm ("dynamic"));
1073 d->set_mus_property ("text", $2);
1074 d->set_spot (THIS->here_input ());
1077 | TEXTSCRIPT embedded_scm {
1078 Text_script_req *t = new Text_script_req;
1079 t->set_mus_property ("text", $2);
1080 t->set_spot (THIS->here_input ());
1083 | SPANREQUEST bare_int STRING {
1084 Span_req * sp_p = new Span_req;
1085 sp_p->span_dir_ = Direction($2);
1086 sp_p->span_type_str_ = ly_scm2string ($3);
1087 sp_p->set_spot (THIS->here_input ());
1091 Tremolo_req* a = new Tremolo_req;
1092 a->set_spot (THIS->here_input ());
1097 Articulation_req * a = new Articulation_req;
1098 a->articulation_str_ = ly_scm2string ($2);
1099 a->set_spot (THIS->here_input ());
1103 Arpeggio_req *a = new Arpeggio_req;
1104 a->set_spot (THIS->here_input ());
1127 steno_musical_pitch:
1131 | NOTENAME_PITCH sup_quotes {
1133 $$->octave_i_ += $2;
1135 | NOTENAME_PITCH sub_quotes {
1137 $$->octave_i_ += - $2;
1145 | TONICNAME_PITCH sup_quotes {
1147 $$->octave_i_ += $2;
1149 | TONICNAME_PITCH sub_quotes {
1151 $$->octave_i_ += - $2;
1156 steno_musical_pitch {
1159 | MUSICAL_PITCH embedded_scm {
1160 int sz = scm_ilength ($2);
1162 THIS->parser_error (_f ("Expecting %d arguments", 3));
1163 $2 = gh_list (gh_int2scm (0), gh_int2scm (0), gh_int2scm (0), SCM_UNDEFINED);
1165 $$ = new Musical_pitch ($2);
1170 DURATION embedded_scm {
1172 if (scm_ilength ($2) == 2)
1174 $$-> durlog_i_ = gh_scm2int (gh_car($2));
1175 $$-> dots_i_ = gh_scm2int (gh_cadr($2));
1178 THIS->parser_error (_("Must have 2 arguments for duration"));
1184 if (!THIS->lexer_p_->lyric_state_b ())
1185 THIS->parser_error (_ ("Have to be in Lyric mode for lyrics"));
1186 $$ = new Extender_req;
1192 if (!THIS->lexer_p_->lyric_state_b ())
1193 THIS->parser_error (_ ("Have to be in Lyric mode for lyrics"));
1194 $$ = new Hyphen_req;
1199 close_request_parens {
1201 dynamic_cast<Span_req*> ($$)->span_dir_ = START;
1204 close_request_parens:
1206 Span_req* s= new Span_req;
1208 s->span_type_str_ = "slur";
1211 Span_req*s =new Span_req;
1213 s->span_type_str_ = "crescendo";
1216 Span_req*s =new Span_req;
1218 s->span_type_str_ = "decrescendo";
1224 open_request_parens {
1226 dynamic_cast<Span_req*> ($$)->span_dir_ = STOP;
1230 open_request_parens:
1232 Span_req *s = new Span_req;
1233 s->span_type_str_ = "crescendo";
1237 Span_req* s= new Span_req;
1239 s->span_type_str_ = "slur";
1245 Text_script_req *t = new Text_script_req;
1246 t->set_mus_property ("text", $1);
1247 t->set_spot (THIS->here_input ());
1251 Text_script_req *t = new Text_script_req;
1252 t->set_mus_property ("text", $1);
1253 t->set_spot (THIS->here_input ());
1257 String ds = to_str ($1);
1258 Text_script_req* t = new Text_script_req;
1260 t->set_mus_property ("text", ly_str02scm (ds.ch_C()));
1261 t->set_mus_property ("text-type" , ly_symbol2scm ("finger"));
1262 t->set_spot (THIS->here_input ());
1267 script_abbreviation:
1269 $$ = gh_str02scm ("hat");
1272 $$ = gh_str02scm("plus");
1275 $$ = gh_str02scm ("dash");
1278 $$ = gh_str02scm ("bar");
1281 $$ = gh_str02scm ("larger");
1284 $$ = gh_str02scm ("dot");
1292 | '-' { $$ = CENTER; }
1297 $$ = new Link_array<Request>;
1299 | pre_requests open_request {
1304 absolute_musical_pitch:
1305 steno_musical_pitch {
1314 | duration_length '*' bare_unsigned {
1315 $$->tuplet_iso_i_ *= $3;
1317 | duration_length '/' bare_unsigned {
1318 $$->tuplet_type_i_ *= $3;
1322 entered_notemode_duration:
1324 THIS->set_last_duration ($1);
1328 optional_notemode_duration:
1330 $$ = new Duration (THIS->default_duration_);
1332 | entered_notemode_duration {
1340 if (!is_duration_b ($1))
1341 THIS->parser_error (_f ("not a duration: %d", $1));
1343 $$->durlog_i_ = intlog2 ($1);
1346 | DURATION_IDENTIFIER {
1347 $$ = $1->access_content_Duration (true);
1349 | steno_duration '.' {
1359 | ':' bare_unsigned {
1360 if (!is_duration_b ($2))
1361 THIS->parser_error (_f ("not a duration: %d", $2));
1368 musical_pitch exclamations questions optional_notemode_duration {
1369 if (!THIS->lexer_p_->note_state_b ())
1370 THIS->parser_error (_ ("Have to be in Note mode for notes"));
1373 Note_req *n = new Note_req;
1378 n->cautionary_b_ = $3 % 2;
1379 n->forceacc_b_ = $2 % 2 || n->cautionary_b_;
1382 Simultaneous_music*v = new Request_chord (gh_list (n->self_scm (), SCM_UNDEFINED));
1383 v->set_spot ($1->spot ());
1384 n->set_spot ($1->spot ());
1390 | RESTNAME optional_notemode_duration {
1392 SCM e = SCM_UNDEFINED;
1393 if (ly_scm2string ($1) =="s")
1395 Skip_req * skip_p = new Skip_req;
1396 skip_p->duration_ = *$2;
1398 skip_p->set_spot (THIS->here_input());
1399 e = skip_p->self_scm ();
1403 Rest_req * rest_req_p = new Rest_req;
1404 rest_req_p->duration_ = *$2;
1405 rest_req_p->set_spot (THIS->here_input());
1406 e = rest_req_p->self_scm ();
1408 Simultaneous_music* velt_p = new Request_chord (gh_list (e,SCM_UNDEFINED));
1409 velt_p->set_spot (THIS->here_input());
1414 | MEASURES optional_notemode_duration {
1415 Skip_req * sk = new Skip_req;
1416 sk->duration_ = *$2;
1419 Span_req *sp1 = new Span_req;
1420 Span_req *sp2 = new Span_req;
1421 sp1-> span_dir_ = START;
1422 sp2-> span_dir_ = STOP;
1423 sp1->span_type_str_ = sp2->span_type_str_ = "rest";
1425 Request_chord * rqc1 = new Request_chord (gh_list (sp1->self_scm (), SCM_UNDEFINED));
1426 Request_chord * rqc2 = new Request_chord (gh_list (sk->self_scm (), SCM_UNDEFINED));;
1427 Request_chord * rqc3 = new Request_chord(gh_list (sp2->self_scm (), SCM_UNDEFINED));;
1429 SCM ms = gh_list (rqc1->self_scm (), rqc2->self_scm (), rqc3->self_scm (), SCM_UNDEFINED);
1431 $$ = new Sequential_music (ms);
1434 THIS->remember_spot ();
1437 optional_notemode_duration {
1438 if (!THIS->lexer_p_->lyric_state_b ()) {
1439 THIS->pop_spot ().error (_ ("Have to be in Lyric mode for lyrics"));
1440 THIS->error_level_i_ = 1;
1441 THIS->parser_error (_ ("Giving up"));
1445 Lyric_req* lreq_p = new Lyric_req;
1446 lreq_p->set_mus_property ("text", $1);
1447 lreq_p->duration_ = *$3;
1448 lreq_p->set_spot (THIS->here_input());
1449 Simultaneous_music* velt_p = new Request_chord (gh_list (lreq_p->self_scm (), SCM_UNDEFINED));
1456 if (!THIS->lexer_p_->chord_state_b ())
1457 THIS->parser_error (_ ("Have to be in Chord mode for chords"));
1464 steno_tonic_pitch optional_notemode_duration chord_additions chord_subtractions chord_inversion chord_bass {
1465 $$ = get_chord (*$1, $3, $4, $5, $6, *$2);
1466 $$->set_spot (THIS->here_input ());
1471 $$ = new Array<Musical_pitch>;
1473 | CHORD_COLON chord_notes {
1482 | chord_notes '.' chord_step {
1490 $$ = new Array<Musical_pitch>;
1492 | CHORD_CARET chord_notes {
1502 | '/' steno_tonic_pitch {
1504 $$->set_spot (THIS->here_input ());
1512 | CHORD_BASS steno_tonic_pitch {
1514 $$->set_spot (THIS->here_input ());
1520 $$ = new Array<Musical_pitch>;
1523 | CHORDMODIFIER_PITCH {
1524 $$ = new Array<Musical_pitch>;
1527 | CHORDMODIFIER_PITCH chord_note { /* Ugh. */
1528 $$ = new Array<Musical_pitch>;
1536 $$ = new Musical_pitch;
1537 $$->notename_i_ = ($1 - 1) % 7;
1538 $$->octave_i_ = $1 > 7 ? 1 : 0;
1539 $$->accidental_i_ = 0;
1541 | bare_unsigned '+' {
1542 $$ = new Musical_pitch;
1543 $$->notename_i_ = ($1 - 1) % 7;
1544 $$->octave_i_ = $1 > 7 ? 1 : 0;
1545 $$->accidental_i_ = 1;
1547 | bare_unsigned CHORD_MINUS {
1548 $$ = new Musical_pitch;
1549 $$->notename_i_ = ($1 - 1) % 7;
1550 $$->octave_i_ = $1 > 7 ? 1 : 0;
1551 $$->accidental_i_ = -1;
1562 | '-' number_expression %prec UNARY_MINUS {
1563 $$ = scm_difference ($2, SCM_UNDEFINED);
1565 | number_expression '*' number_expression {
1566 $$ = scm_product ($1, $3);
1568 | number_expression '/' number_expression {
1569 $$ = scm_divide ($1, $3);
1571 | number_expression '+' number_expression {
1572 $$ = scm_sum ($1, $3);
1574 | number_expression '-' number_expression {
1575 $$ = scm_difference ($1, $3);
1577 | '(' number_expression ')' {
1584 $$ = gh_int2scm ($1);
1587 $$ = gh_int2scm ($1);
1590 $$ = gh_double2scm ($1);
1592 | NUMBER_IDENTIFIER {
1596 $$ = gh_double2scm ($1 CM);
1599 $$ = gh_double2scm ($1 PT);
1602 $$ = gh_double2scm ($1 INCH);
1605 $$ = gh_double2scm ($1 MM);
1608 $$ = gh_double2scm ($1 CHAR);
1615 if (scm_integer_p ($1) == SCM_BOOL_T) {
1616 $$ = gh_scm2int ($1);
1619 THIS->parser_error (_("need integer number arg"));
1623 THIS->parser_error (_("Must be positive integer"));
1631 if (scm_integer_p ($1) == SCM_BOOL_T)
1633 int k = gh_scm2int ($1);
1637 THIS->parser_error (_("need integer number arg"));
1651 | STRING_IDENTIFIER {
1654 | string '+' string {
1655 $$ = scm_string_append (scm_listify ($1, $3, SCM_UNDEFINED));
1662 | exclamations '!' { $$ ++; }
1667 | questions '?' { $$ ++; }
1678 My_lily_parser::set_yydebug (bool b)
1685 My_lily_parser::do_yyparse ()
1687 yyparse ((void*)this);