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->dir_ = 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 {
1068 Dynamic_script_req *d = new Dynamic_script_req;
1069 d->set_mus_property ("text", $2);
1070 d->set_spot (THIS->here_input ());
1073 | TEXTSCRIPT embedded_scm {
1074 Text_script_req *t = new Text_script_req;
1075 t->set_mus_property ("text", $2);
1076 t->set_spot (THIS->here_input ());
1079 | SPANREQUEST bare_int STRING {
1080 Span_req * sp_p = new Span_req;
1081 sp_p->span_dir_ = Direction($2);
1082 sp_p->span_type_str_ = ly_scm2string ($3);
1083 sp_p->set_spot (THIS->here_input ());
1087 Tremolo_req* a = new Tremolo_req;
1088 a->set_spot (THIS->here_input ());
1093 Articulation_req * a = new Articulation_req;
1094 a->articulation_str_ = ly_scm2string ($2);
1095 a->set_spot (THIS->here_input ());
1099 Arpeggio_req *a = new Arpeggio_req;
1100 a->set_spot (THIS->here_input ());
1123 steno_musical_pitch:
1127 | NOTENAME_PITCH sup_quotes {
1129 $$->octave_i_ += $2;
1131 | NOTENAME_PITCH sub_quotes {
1133 $$->octave_i_ += - $2;
1141 | TONICNAME_PITCH sup_quotes {
1143 $$->octave_i_ += $2;
1145 | TONICNAME_PITCH sub_quotes {
1147 $$->octave_i_ += - $2;
1152 steno_musical_pitch {
1155 | MUSICAL_PITCH embedded_scm {
1156 int sz = scm_ilength ($2);
1158 THIS->parser_error (_f ("Expecting %d arguments", 3));
1159 $2 = gh_list (gh_int2scm (0), gh_int2scm (0), gh_int2scm (0), SCM_UNDEFINED);
1161 $$ = new Musical_pitch ($2);
1166 DURATION embedded_scm {
1168 if (scm_ilength ($2) == 2)
1170 $$-> durlog_i_ = gh_scm2int (gh_car($2));
1171 $$-> dots_i_ = gh_scm2int (gh_cadr($2));
1174 THIS->parser_error (_("Must have 2 arguments for duration"));
1180 if (!THIS->lexer_p_->lyric_state_b ())
1181 THIS->parser_error (_ ("Have to be in Lyric mode for lyrics"));
1182 $$ = new Extender_req;
1188 if (!THIS->lexer_p_->lyric_state_b ())
1189 THIS->parser_error (_ ("Have to be in Lyric mode for lyrics"));
1190 $$ = new Hyphen_req;
1195 close_request_parens {
1197 dynamic_cast<Span_req*> ($$)->span_dir_ = START;
1200 close_request_parens:
1202 Span_req* s= new Span_req;
1204 s->span_type_str_ = "slur";
1207 Span_req*s =new Span_req;
1209 s->span_type_str_ = "crescendo";
1212 Span_req*s =new Span_req;
1214 s->span_type_str_ = "decrescendo";
1220 open_request_parens {
1222 dynamic_cast<Span_req*> ($$)->span_dir_ = STOP;
1226 open_request_parens:
1228 Span_req *s = new Span_req;
1229 s->span_type_str_ = "crescendo";
1233 Span_req* s= new Span_req;
1235 s->span_type_str_ = "slur";
1241 Text_script_req *t = new Text_script_req;
1242 t->set_mus_property ("text", $1);
1243 t->set_spot (THIS->here_input ());
1247 Text_script_req *t = new Text_script_req;
1248 t->set_mus_property ("text", $1);
1249 t->set_spot (THIS->here_input ());
1254 Maybe use Finger_script_request?
1256 Text_script_req* t = new Text_script_req;
1257 t->set_mus_property ("text",
1258 gh_cons (ly_symbol2scm ("finger"),
1259 ly_str02scm (to_str ($1).ch_C ())));
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);