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"
15 #include "translation-property.hh"
18 #include "my-lily-lexer.hh"
19 #include "paper-def.hh"
20 #include "midi-def.hh"
22 #include "file-path.hh"
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"
32 #include "change-translator.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"
45 #include "output-property.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 */
136 %token CHORDMODIFIERS
180 %token COMMANDSPANREQUEST
182 %token OUTPUTPROPERTY
191 %token E_CHAR E_EXCLAMATION E_SMALLER E_BIGGER
192 %token CHORD_BASS CHORD_COLON CHORD_MINUS CHORD_CARET
194 %type <i> exclamations questions
196 %token <pitch> NOTENAME_PITCH
197 %token <pitch> TONICNAME_PITCH
198 %token <pitch> CHORDMODIFIER_PITCH
199 %token <id> DURATION_IDENTIFIER
200 %token <id> IDENTIFIER
203 %token <id> SCORE_IDENTIFIER
204 %token <id> MUSIC_OUTPUT_DEF_IDENTIFIER
206 %token <scm> NUMBER_IDENTIFIER
207 %token <scm> REQUEST_IDENTIFIER
208 %token <scm> MUSIC_IDENTIFIER TRANSLATOR_IDENTIFIER
209 %token <scm> STRING_IDENTIFIER SCM_IDENTIFIER
210 %token <scm> DURATION RESTNAME
216 %type <outputdef> output_def
217 %type <scope> mudela_header mudela_header_body
218 %type <request> open_request_parens close_request_parens open_request close_request
219 %type <request> request_with_dir request_that_take_dir verbose_request
220 %type <i> sub_quotes sup_quotes
221 %type <music> simple_element request_chord command_element Simple_music Composite_music
222 %type <music> Alternative_music Repeated_music
223 %type <i> tremolo_type
224 %type <i> bare_int bare_unsigned
227 %type <scm> identifier_init
229 %type <duration> steno_duration optional_notemode_duration
230 %type <duration> entered_notemode_duration explicit_duration
232 %type <reqvec> pre_requests post_requests
233 %type <request> gen_text_def
234 %type <pitch> steno_musical_pitch musical_pitch absolute_musical_pitch
235 %type <pitch> steno_tonic_pitch
237 %type <pitch_arr> chord_additions chord_subtractions chord_notes chord_step
239 %type <pitch> chord_note chord_inversion chord_bass
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 part_combined_music
245 %type <music> property_def translator_change
246 %type <scm> Music_list
247 %type <outputdef> music_output_def_body
248 %type <request> shorthand_command_req
249 %type <request> post_request
250 %type <request> command_req verbose_command_req
251 %type <request> extender_req
252 %type <request> hyphen_req
253 %type <scm> string bare_number number_expression
254 %type <score> score_block score_body
256 %type <scm> translator_spec_block translator_spec_body
257 %type <tempo> tempo_request
258 %type <scm> notenames_body notenames_block chordmodifiers_block
259 %type <scm> script_abbreviation
270 | mudela toplevel_expression {}
271 | mudela assignment { }
273 THIS->error_level_i_ = 1;
274 //THIS->parser_error (_ ("ly invalid"));
277 THIS->error_level_i_ = 1;
278 //THIS->parser_error (_ ("ly invalid"));
284 THIS->lexer_p_->pitchname_tab_ = $1;
286 | chordmodifiers_block {
287 THIS->lexer_p_->chordmodifier_tab_ = $1;
290 delete header_global_p;
291 header_global_p = $1;
294 score_global_array.push ($1);
297 Identifier * id = new
298 Music_output_def_identifier ($1, MUSIC_OUTPUT_DEF_IDENTIFIER);
299 if (dynamic_cast<Paper_def*> ($1))
300 THIS->lexer_p_->set_identifier ("$defaultpaper", id->self_scm ());
301 else if (dynamic_cast<Midi_def*> ($1))
302 THIS->lexer_p_->set_identifier ("$defaultmidi", id->self_scm ());
315 chordmodifiers_block:
316 CHORDMODIFIERS notenames_body { $$ = $2; }
321 NOTENAMES notenames_body { $$ = $2; }
328 int i = scm_ilength ($1);
330 SCM tab = scm_make_vector (gh_int2scm (i), SCM_EOL);
331 for (SCM s = $1; s != SCM_EOL; s = gh_cdr (s)) {
332 SCM pt = gh_cdar (s);
333 if (scm_ilength (pt) != 3)
334 THIS->parser_error ("Need three args");
335 scm_hashq_set_x (tab, gh_caar(s), pt);
345 THIS->lexer_p_-> scope_l_arr_.push ($$);
347 | mudela_header_body assignment semicolon {
353 HEADER '{' mudela_header_body '}' {
355 THIS->lexer_p_-> scope_l_arr_.pop ();
365 THIS->remember_spot ();
367 /* cont */ '=' identifier_init {
368 THIS->lexer_p_->set_identifier (ly_scm2string ($1), $4);
371 TODO: devise standard for protection in parser.
373 The parser stack lives on the C-stack, which means that
374 all objects can be unprotected as soon as they're here.
377 Identifier * id =unsmob_identifier ($4);
378 Input spot = THIS->pop_spot ();
379 if (id) id->set_spot (spot);
387 $$ = (new Score_identifier ($1, SCORE_IDENTIFIER))->self_scm();
390 $$ = (new Music_output_def_identifier ($1, MUSIC_OUTPUT_DEF_IDENTIFIER))->self_scm();
392 | translator_spec_block {
396 $$ = $1->self_scm ();
397 scm_unprotect_object ($$);
400 $$ = $1->self_scm ();
401 scm_unprotect_object ($$);
403 | explicit_duration {
404 $$ = (new Duration_identifier ($1, DURATION_IDENTIFIER))->self_scm ();
406 | number_expression {
417 translator_spec_block:
418 TRANSLATOR '{' translator_spec_body '}'
424 translator_spec_body:
425 TRANSLATOR_IDENTIFIER {
426 $$ = unsmob_translator_def ($1)->clone_scm ();
427 unsmob_translator_def ($$)-> set_spot (THIS->here_input ());
429 | TYPE STRING semicolon {
430 $$ = Translator_def::make_scm ();
431 Translator_def*td = unsmob_translator_def ($$);
432 td->translator_group_type_ = $2;
433 td->set_spot (THIS->here_input ());
435 | translator_spec_body STRING '=' embedded_scm {
436 unsmob_translator_def ($$)->add_property_assign ($2, $4);
438 | translator_spec_body STRING PUSH embedded_scm '=' embedded_scm {
439 unsmob_translator_def ($$)
440 ->add_push_property (scm_string_to_symbol ($2), $4, $6);
442 | translator_spec_body STRING POP embedded_scm {
443 unsmob_translator_def($$)->add_pop_property (
444 scm_string_to_symbol ($2), $4);
446 | translator_spec_body STRING '=' identifier_init semicolon {
447 SCM v = gh_int2scm (0);
448 if (gh_string_p ($4) || gh_number_p ($4) || gh_boolean_p ($4))
451 THIS->parser_error (_("Wrong type for property value"));
454 unsmob_translator_def($$)->add_property_assign ($2, v);
456 | translator_spec_body NAME STRING semicolon {
457 unsmob_translator_def ($$)->type_name_ = $3;
459 | translator_spec_body CONSISTS STRING semicolon {
460 unsmob_translator_def ($$)->add_element ($3);
462 | translator_spec_body CONSISTSEND STRING semicolon {
463 unsmob_translator_def ($$)->add_last_element ( $3);
465 | translator_spec_body ACCEPTS STRING semicolon {
466 unsmob_translator_def ($$)->set_acceptor ($3,true);
468 | translator_spec_body DENIES STRING semicolon {
469 unsmob_translator_def ($$)->set_acceptor ($3,false);
471 | translator_spec_body REMOVE STRING semicolon {
472 unsmob_translator_def ($$)->remove_element ($3);
481 THIS->remember_spot ();
483 /*cont*/ '{' score_body '}' {
486 if (!$$->def_p_arr_.size ())
489 unsmob_identifier (THIS->lexer_p_->lookup_identifier ("$defaultpaper"));
490 $$->add_output (id ? id->access_content_Music_output_def (true) : new Paper_def );
494 | SCORE '{' score_body error {
496 $$->set_spot (THIS->here_input ());
497 // THIS->here_input ().error ("SCORE INVALID");
498 $$->error ("SCORE INVALID");
499 THIS->parser_error (_f ("SCORE ERROR"));
508 $$->set_spot (THIS->here_input ());
509 SCM m = $1->self_scm ();
510 scm_unprotect_object (m);
514 $$ = $1->access_content_Score (true);
516 | score_body mudela_header {
519 | score_body output_def {
532 music_output_def_body '}' {
534 THIS-> lexer_p_-> scope_l_arr_.pop();
538 music_output_def_body:
540 Identifier *id = unsmob_identifier (THIS->lexer_p_->lookup_identifier ("$defaultmidi"));
545 p = dynamic_cast<Midi_def*> (id->access_content_Music_output_def (true));
550 THIS->lexer_p_->scope_l_arr_.push (p->scope_p_);
553 Identifier *id = unsmob_identifier (THIS->lexer_p_->lookup_identifier ("$defaultpaper"));
556 p = dynamic_cast<Paper_def*> (id->access_content_Music_output_def (true));
559 THIS-> lexer_p_-> scope_l_arr_.push (p->scope_p_);
562 | PAPER '{' MUSIC_OUTPUT_DEF_IDENTIFIER {
563 Music_output_def *p = $3->access_content_Music_output_def (true);
564 THIS->lexer_p_->scope_l_arr_.push (p->scope_p_);
567 | MIDI '{' MUSIC_OUTPUT_DEF_IDENTIFIER {
568 Music_output_def *p = $3->access_content_Music_output_def (true);
569 THIS->lexer_p_->scope_l_arr_.push (p->scope_p_);
572 | music_output_def_body assignment semicolon {
575 | music_output_def_body translator_spec_block {
576 $$->assign_translator ($2);
578 | music_output_def_body tempo_request semicolon {
580 junk this ? there already is tempo stuff in
583 dynamic_cast<Midi_def*> ($$)->set_tempo ($2->dur_.length_mom (), $2->metronome_i_);
585 | music_output_def_body bare_int '=' FONT STRING { // ugh, what a syntax
586 SCM sl = Lookup::make_lookup();
587 Lookup * l =unsmob_lookup (sl);
588 l->font_name_ = ly_scm2string ($5);
589 dynamic_cast<Paper_def*> ($$)->set_lookup ($2, sl);
591 | music_output_def_body error {
597 TEMPO steno_duration '=' bare_unsigned {
601 $$-> metronome_i_ = $4;
605 Music_list: /* empty */ {
606 $$ = gh_cons (SCM_EOL, SCM_EOL);
610 SCM c = gh_cons ($2->self_scm (), SCM_EOL);
611 scm_unprotect_object ($2->self_scm ()); /* UGH */
614 if (gh_pair_p (gh_cdr (s)))
615 gh_set_cdr_x (gh_cdr (s), c); /* append */
617 gh_set_car_x (s, c); /* set first cons */
618 gh_set_cdr_x (s, c) ; /* remember last cell */
634 | ALTERNATIVE Music_sequence {
636 $2->set_spot (THIS->here_input ());
644 REPEAT STRING bare_unsigned Music Alternative_music
646 Music_sequence* m = dynamic_cast <Music_sequence*> ($5);
647 if (m && $3 < m->length_i ())
648 $5->origin ()->warning (_ ("More alternatives than repeats. Junking excess alternatives."));
650 Repeated_music * r = new Repeated_music ($4, $3 >? 1, m);
652 r->type_ = ly_scm2string ($2);
653 r->fold_b_ = (r->type_ == "fold");
654 r->volta_fold_b_ = (r->type_ == "volta");
655 r->set_spot (*$4->origin ());
659 Music_sequence: '{' Music_list '}' {
660 $$ = new Music_sequence (gh_car ($2));
665 SEQUENTIAL '{' Music_list '}' {
666 $$ = new Sequential_music (gh_car ($3));
668 | '{' Music_list '}' {
669 $$ = new Sequential_music (gh_car ($2));
674 SIMULTANEOUS '{' Music_list '}'{
675 $$ = new Simultaneous_music (gh_car ($3));
677 | '<' Music_list '>' {
678 $$ = new Simultaneous_music (gh_car ($2));
683 request_chord { $$ = $1; }
684 | OUTPUTPROPERTY embedded_scm embedded_scm '=' embedded_scm {
686 if (!gh_symbol_p ($3))
688 THIS->parser_error (_("Second argument must be a symbol"));
690 /*hould check # args */
691 if (!gh_procedure_p (pred))
693 THIS->parser_error (_("First argument must be a procedure taking 1 argument"));
696 $$ = new Output_property (pred,$3, $5);
699 $$ = unsmob_music ($1)->clone ();
703 | Simple_music '*' bare_unsigned '/' bare_unsigned {
705 $$->compress (Moment($3, $5 ));
707 | Simple_music '*' bare_unsigned {
709 $$->compress (Moment ($3, 1));
715 CONTEXT STRING Music {
716 Context_specced_music *csm = new Context_specced_music ($3);
718 csm->translator_type_str_ = ly_scm2string ($2);
719 csm->translator_id_str_ = "";
724 | AUTOCHANGE STRING Music {
725 Auto_change_music * chm = new Auto_change_music (ly_scm2string ($2), $3);
728 chm->set_spot (*$3->origin ());
731 $$ = new Grace_music ($2);
733 | CONTEXT STRING '=' STRING Music {
734 Context_specced_music *csm = new Context_specced_music ($5);
736 csm->translator_type_str_ = ly_scm2string ($2);
737 csm->translator_id_str_ = ly_scm2string ($4);
742 THIS->remember_spot ();
745 bare_unsigned '/' bare_unsigned Music
748 $$ = new Time_scaled_music ($3, $5, $6);
749 $$->set_spot (THIS->pop_spot ());
751 | Repeated_music { $$ = $1; }
752 | Simultaneous_music { $$ = $1; }
753 | Sequential_music { $$ = $1; }
754 | TRANSPOSE musical_pitch Music {
755 $$ = new Transposed_music ($3, *$2);
758 | TRANSPOSE steno_tonic_pitch Music {
759 $$ = new Transposed_music ($3, *$2);
763 { THIS->lexer_p_->push_note_state (); }
766 THIS->lexer_p_->pop_state ();
769 { THIS->lexer_p_->push_chord_state (); }
773 THIS->lexer_p_->pop_state ();
776 { THIS->lexer_p_->push_lyric_state (); }
780 THIS->lexer_p_->pop_state ();
782 | relative_music { $$ = $1; }
783 | re_rhythmed_music { $$ = $1; }
784 | part_combined_music { $$ = $1; }
788 RELATIVE absolute_musical_pitch Music {
789 $$ = new Relative_octave_music ($3, *$2);
795 ADDLYRICS Music Music {
796 Lyric_combine_music * l = new Lyric_combine_music ($2, $3);
802 PARTCOMBINE STRING Music Music {
803 Part_combine_music * p = new Part_combine_music (ly_scm2string ($2), $3, $4);
809 TRANSLATOR STRING '=' STRING {
810 Change_translator * t = new Change_translator;
811 t-> change_to_type_str_ = ly_scm2string ($2);
812 t-> change_to_id_str_ = ly_scm2string ($4);
815 $$->set_spot (THIS->here_input ());
820 PROPERTY STRING '.' STRING '=' scalar {
821 Translation_property *t = new Translation_property;
823 t->set_mus_property ("symbol", scm_string_to_symbol ($4));
824 t->set_mus_property ("value", $6);
826 Context_specced_music *csm = new Context_specced_music (t);
828 $$->set_spot (THIS->here_input ());
830 csm-> translator_type_str_ = ly_scm2string ($2);
832 | PROPERTY STRING '.' STRING PUSH embedded_scm '=' embedded_scm {
833 Push_translation_property *t = new Push_translation_property;
835 t->set_mus_property ("symbols", scm_string_to_symbol ($4));
836 t->set_mus_property ("element-property", $6);
837 t->set_mus_property ("element-value", $8);
838 Context_specced_music *csm = new Context_specced_music (t);
840 $$->set_spot (THIS->here_input ());
842 csm-> translator_type_str_ = ly_scm2string ($2);
844 | PROPERTY STRING '.' STRING POP embedded_scm {
845 Pop_translation_property *t = new Pop_translation_property;
847 t->set_mus_property ("symbols", scm_string_to_symbol ($4));
848 t->set_mus_property ("element-property", $6);
850 Context_specced_music *csm = new Context_specced_music (t);
852 $$->set_spot (THIS->here_input ());
854 csm-> translator_type_str_ = ly_scm2string ($2);
860 | bare_int { $$ = gh_int2scm ($1); }
861 | embedded_scm { $$ = $1; }
866 pre_requests simple_element post_requests {
867 Music_sequence *l = dynamic_cast<Music_sequence*>($2);
869 for (int i=0; i < $1->size(); i++)
870 l->append_music ($1->elem(i));
871 for (int i=0; i < $3->size(); i++)
872 l->append_music ($3->elem(i));
875 programming_error ("Need Sequence to add music to");
884 $$ = new Request_chord (gh_cons ($1->self_scm (), SCM_EOL));
885 $$-> set_spot (THIS->here_input ());
886 $1-> set_spot (THIS->here_input ());
888 | PARTIAL duration_length ';' {
889 Translation_property * p = new Translation_property;
890 p->set_mus_property ("symbol", ly_symbol2scm ( "measurePosition"));
891 Moment m = - $2->length_mom ();
892 p->set_mus_property ("value", m.make_scm());
894 Context_specced_music * sp = new Context_specced_music (p);
896 sp-> translator_type_str_ = "Score";
901 shorthand_command_req
902 | verbose_command_req semicolon { $$ = $1; }
905 shorthand_command_req:
913 $$ = new Barcheck_req;
919 Span_req*b= new Span_req;
920 b->span_dir_ = START;
921 b->span_type_str_ = "beam";
925 Span_req*b= new Span_req;
927 b->span_type_str_ = "beam";
931 $$ = new Breathing_sign_req;
939 $$ = new Bar_req (ly_scm2string ($2));
941 | COMMANDSPANREQUEST bare_int STRING {
942 Span_req * sp_p = new Span_req;
943 sp_p-> span_dir_ = Direction($2);
944 sp_p->span_type_str_ = ly_scm2string ($3);
945 sp_p->set_spot (THIS->here_input ());
949 Mark_req * m = new Mark_req;
953 Mark_req *m = new Mark_req;
954 m->set_mus_property ("label", $2);
958 | MARK bare_unsigned {
959 Mark_req *m = new Mark_req;
960 m->set_mus_property ("label", gh_int2scm ($2));
964 | TIME_T bare_unsigned '/' bare_unsigned {
965 Time_signature_change_req *m = new Time_signature_change_req;
971 Break_req * b = new Break_req;
972 b->penalty_f_ = $2 / 100.0;
973 b->set_spot (THIS->here_input ());
976 | SKIP duration_length {
977 Skip_req * skip_p = new Skip_req;
978 skip_p->duration_ = *$2;
986 $$ = new Clef_change_req (ly_scm2string ($2));
990 Key_change_req *key_p= new Key_change_req;
993 | KEY NOTENAME_PITCH SCM_IDENTIFIER {
994 Key_change_req *key_p= new Key_change_req;
996 key_p->set_mus_property ("pitch-alist", $3);
997 ((Music* )key_p)->transpose (* $2);
1004 $$ = new Link_array<Request>;
1006 | post_requests post_request {
1007 $2->set_spot (THIS->here_input ());
1019 request_that_take_dir:
1022 | script_abbreviation {
1023 SCM s = THIS->lexer_p_->lookup_identifier ("dash-" + ly_scm2string ($1));
1024 Articulation_req *a = new Articulation_req;
1025 if (gh_string_p (s))
1026 a->articulation_str_ = ly_scm2string (s);
1027 else THIS->parser_error (_ ("Expecting string as script definition"));
1033 script_dir request_that_take_dir {
1034 if (Script_req * gs = dynamic_cast<Script_req*> ($2))
1035 gs->dir_ = Direction ($1);
1037 $2->origin ()->warning (_ ("Can't specify direction for this request"));
1043 REQUEST_IDENTIFIER {
1044 $$ = dynamic_cast<Request*> (unsmob_music ($1)->clone ());
1045 $$->set_spot (THIS->here_input ());
1047 | TEXTSCRIPT STRING STRING {
1048 Text_script_req *ts_p = new Text_script_req;
1049 ts_p-> text_str_ = ly_scm2string ($2);
1050 ts_p-> style_str_ = ly_scm2string ($3);
1051 ts_p->set_spot (THIS->here_input ());
1055 | SPANREQUEST bare_int STRING {
1056 Span_req * sp_p = new Span_req;
1057 sp_p->span_dir_ = Direction($2);
1058 sp_p->span_type_str_ = ly_scm2string ($3);
1059 sp_p->set_spot (THIS->here_input ());
1063 Tremolo_req* a = new Tremolo_req;
1064 a->set_spot (THIS->here_input ());
1069 Articulation_req * a = new Articulation_req;
1070 a->articulation_str_ = ly_scm2string ($2);
1071 a->set_spot (THIS->here_input ());
1075 Arpeggio_req *a = new Arpeggio_req;
1076 a->set_spot (THIS->here_input ());
1099 steno_musical_pitch:
1103 | NOTENAME_PITCH sup_quotes {
1105 $$->octave_i_ += $2;
1107 | NOTENAME_PITCH sub_quotes {
1109 $$->octave_i_ += - $2;
1117 | TONICNAME_PITCH sup_quotes {
1119 $$->octave_i_ += $2;
1121 | TONICNAME_PITCH sub_quotes {
1123 $$->octave_i_ += - $2;
1128 steno_musical_pitch {
1131 | MUSICAL_PITCH embedded_scm {
1132 int sz = scm_ilength ($2);
1134 THIS->parser_error (_f ("Expecting %d arguments", 3));
1135 $2 = gh_list (gh_int2scm (0), gh_int2scm (0), gh_int2scm (0), SCM_UNDEFINED);
1137 $$ = new Musical_pitch ($2);
1142 DURATION embedded_scm {
1144 if (scm_ilength ($2) == 2)
1146 $$-> durlog_i_ = gh_scm2int (gh_car($2));
1147 $$-> dots_i_ = gh_scm2int (gh_cadr($2));
1150 THIS->parser_error (_("Must have 2 arguments for duration"));
1156 if (!THIS->lexer_p_->lyric_state_b ())
1157 THIS->parser_error (_ ("Have to be in Lyric mode for lyrics"));
1158 $$ = new Extender_req;
1164 if (!THIS->lexer_p_->lyric_state_b ())
1165 THIS->parser_error (_ ("Have to be in Lyric mode for lyrics"));
1166 $$ = new Hyphen_req;
1171 close_request_parens {
1173 dynamic_cast<Span_req*> ($$)->span_dir_ = START;
1176 close_request_parens:
1178 Span_req* s= new Span_req;
1180 s->span_type_str_ = "slur";
1183 Span_req*s =new Span_req;
1185 s->span_type_str_ = "crescendo";
1188 Span_req*s =new Span_req;
1190 s->span_type_str_ = "decrescendo";
1196 open_request_parens {
1198 dynamic_cast<Span_req*> ($$)->span_dir_ = STOP;
1202 open_request_parens:
1204 Span_req *s = new Span_req;
1205 s->span_type_str_ = "crescendo";
1209 Span_req* s= new Span_req;
1211 s->span_type_str_ = "slur";
1217 Text_script_req *t = new Text_script_req;
1219 t->text_str_ = ly_scm2string ($1);
1221 $$->set_spot (THIS->here_input ());
1224 Text_script_req* t = new Text_script_req;
1226 t->text_str_ = to_str ($1);
1227 t->style_str_ = "finger";
1228 $$->set_spot (THIS->here_input ());
1232 script_abbreviation:
1234 $$ = gh_str02scm ("hat");
1237 $$ = gh_str02scm("plus");
1240 $$ = gh_str02scm ("dash");
1243 $$ = gh_str02scm ("bar");
1246 $$ = gh_str02scm ("larger");
1249 $$ = gh_str02scm ("dot");
1257 | '-' { $$ = CENTER; }
1262 $$ = new Link_array<Request>;
1264 | pre_requests open_request {
1269 absolute_musical_pitch:
1270 steno_musical_pitch {
1279 | duration_length '*' bare_unsigned {
1280 $$->tuplet_iso_i_ *= $3;
1282 | duration_length '/' bare_unsigned {
1283 $$->tuplet_type_i_ *= $3;
1287 entered_notemode_duration:
1289 THIS->set_last_duration ($1);
1293 optional_notemode_duration:
1295 $$ = new Duration (THIS->default_duration_);
1297 | entered_notemode_duration {
1305 if (!is_duration_b ($1))
1306 THIS->parser_error (_f ("not a duration: %d", $1));
1308 $$->durlog_i_ = intlog2 ($1);
1311 | DURATION_IDENTIFIER {
1312 $$ = $1->access_content_Duration (true);
1314 | steno_duration '.' {
1324 | ':' bare_unsigned {
1325 if (!is_duration_b ($2))
1326 THIS->parser_error (_f ("not a duration: %d", $2));
1333 musical_pitch exclamations questions optional_notemode_duration {
1334 if (!THIS->lexer_p_->note_state_b ())
1335 THIS->parser_error (_ ("Have to be in Note mode for notes"));
1338 Note_req *n = new Note_req;
1343 n->cautionary_b_ = $3 % 2;
1344 n->forceacc_b_ = $2 % 2 || n->cautionary_b_;
1347 Simultaneous_music*v = new Request_chord (gh_list (n->self_scm (), SCM_UNDEFINED));
1348 v->set_spot ($1->spot ());
1349 n->set_spot ($1->spot ());
1355 | RESTNAME optional_notemode_duration {
1357 SCM e = SCM_UNDEFINED;
1358 if (ly_scm2string ($1) =="s")
1360 Skip_req * skip_p = new Skip_req;
1361 skip_p->duration_ = *$2;
1363 skip_p->set_spot (THIS->here_input());
1364 e = skip_p->self_scm ();
1368 Rest_req * rest_req_p = new Rest_req;
1369 rest_req_p->duration_ = *$2;
1370 rest_req_p->set_spot (THIS->here_input());
1371 e = rest_req_p->self_scm ();
1373 Simultaneous_music* velt_p = new Request_chord (gh_list (e,SCM_UNDEFINED));
1374 velt_p->set_spot (THIS->here_input());
1379 | MEASURES optional_notemode_duration {
1380 Skip_req * sk = new Skip_req;
1381 sk->duration_ = *$2;
1384 Span_req *sp1 = new Span_req;
1385 Span_req *sp2 = new Span_req;
1386 sp1-> span_dir_ = START;
1387 sp2-> span_dir_ = STOP;
1388 sp1->span_type_str_ = sp2->span_type_str_ = "rest";
1390 Request_chord * rqc1 = new Request_chord (gh_list (sp1->self_scm (), SCM_UNDEFINED));
1391 Request_chord * rqc2 = new Request_chord (gh_list (sk->self_scm (), SCM_UNDEFINED));;
1392 Request_chord * rqc3 = new Request_chord(gh_list (sp2->self_scm (), SCM_UNDEFINED));;
1394 SCM ms = gh_list (rqc1->self_scm (), rqc2->self_scm (), rqc3->self_scm (), SCM_UNDEFINED);
1396 $$ = new Sequential_music (ms);
1399 THIS->remember_spot ();
1402 optional_notemode_duration {
1403 if (!THIS->lexer_p_->lyric_state_b ()) {
1404 THIS->pop_spot ().error (_ ("Have to be in Lyric mode for lyrics"));
1405 THIS->error_level_i_ = 1;
1406 THIS->parser_error (_ ("Giving up"));
1410 Lyric_req* lreq_p = new Lyric_req;
1411 lreq_p ->text_str_ = ly_scm2string ($1);
1412 lreq_p->duration_ = *$3;
1413 lreq_p->set_spot (THIS->here_input());
1414 Simultaneous_music* velt_p = new Request_chord (gh_list (lreq_p->self_scm (), SCM_UNDEFINED));
1421 if (!THIS->lexer_p_->chord_state_b ())
1422 THIS->parser_error (_ ("Have to be in Chord mode for chords"));
1429 steno_tonic_pitch optional_notemode_duration chord_additions chord_subtractions chord_inversion chord_bass {
1430 $$ = get_chord (*$1, $3, $4, $5, $6, *$2);
1431 $$->set_spot (THIS->here_input ());
1436 $$ = new Array<Musical_pitch>;
1438 | CHORD_COLON chord_notes {
1447 | chord_notes '.' chord_step {
1455 $$ = new Array<Musical_pitch>;
1457 | CHORD_CARET chord_notes {
1467 | '/' steno_tonic_pitch {
1469 $$->set_spot (THIS->here_input ());
1477 | CHORD_BASS steno_tonic_pitch {
1479 $$->set_spot (THIS->here_input ());
1485 $$ = new Array<Musical_pitch>;
1488 | CHORDMODIFIER_PITCH {
1489 $$ = new Array<Musical_pitch>;
1492 | CHORDMODIFIER_PITCH chord_note { /* Ugh. */
1493 $$ = new Array<Musical_pitch>;
1501 $$ = new Musical_pitch;
1502 $$->notename_i_ = ($1 - 1) % 7;
1503 $$->octave_i_ = $1 > 7 ? 1 : 0;
1504 $$->accidental_i_ = 0;
1506 | bare_unsigned '+' {
1507 $$ = new Musical_pitch;
1508 $$->notename_i_ = ($1 - 1) % 7;
1509 $$->octave_i_ = $1 > 7 ? 1 : 0;
1510 $$->accidental_i_ = 1;
1512 | bare_unsigned CHORD_MINUS {
1513 $$ = new Musical_pitch;
1514 $$->notename_i_ = ($1 - 1) % 7;
1515 $$->octave_i_ = $1 > 7 ? 1 : 0;
1516 $$->accidental_i_ = -1;
1527 | '-' number_expression %prec UNARY_MINUS {
1528 $$ = scm_difference ($2, SCM_UNDEFINED);
1530 | number_expression '*' number_expression {
1531 $$ = scm_product ($1, $3);
1533 | number_expression '/' number_expression {
1534 $$ = scm_divide ($1, $3);
1536 | number_expression '+' number_expression {
1537 $$ = scm_sum ($1, $3);
1539 | number_expression '-' number_expression {
1540 $$ = scm_difference ($1, $3);
1542 | '(' number_expression ')' {
1549 $$ = gh_int2scm ($1);
1552 $$ = gh_int2scm ($1);
1555 $$ = gh_double2scm ($1);
1557 | NUMBER_IDENTIFIER {
1561 $$ = gh_double2scm ($1 CM);
1564 $$ = gh_double2scm ($1 PT);
1567 $$ = gh_double2scm ($1 INCH);
1570 $$ = gh_double2scm ($1 MM);
1573 $$ = gh_double2scm ($1 CHAR);
1580 if (scm_integer_p ($1) == SCM_BOOL_T) {
1581 $$ = gh_scm2int ($1);
1584 THIS->parser_error (_("need integer number arg"));
1588 THIS->parser_error (_("Must be positive integer"));
1596 if (scm_integer_p ($1) == SCM_BOOL_T)
1598 int k = gh_scm2int ($1);
1602 THIS->parser_error (_("need integer number arg"));
1616 | STRING_IDENTIFIER {
1619 | string '+' string {
1620 $$ = scm_string_append (scm_listify ($1, $3, SCM_UNDEFINED));
1627 | exclamations '!' { $$ ++; }
1632 | questions '?' { $$ ++; }
1643 My_lily_parser::set_yydebug (bool b)
1650 My_lily_parser::do_yyparse ()
1652 yyparse ((void*)this);