1 %{ // -*-Fundamental-*-
4 parser.yy -- Bison/C++ parser for lilypond
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 "change-iterator.hh"
17 #include "my-lily-lexer.hh"
18 #include "paper-def.hh"
19 #include "midi-def.hh"
21 #include "file-path.hh"
23 #include "dimensions.hh"
24 #include "identifier.hh"
25 #include "command-request.hh"
26 #include "musical-request.hh"
27 #include "my-lily-parser.hh"
28 #include "context-specced-music.hh"
30 #include "music-list.hh"
31 #include "output-property-music-iterator.hh"
32 #include "property-iterator.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 "lilypond-input-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 set_music_properties (Music *p, SCM a)
58 for (SCM k = a; gh_pair_p (k); k = gh_cdr (k))
60 p->set_mus_property (gh_caar (k), gh_cdar (k));
66 Lilypond_version oldest_version ("1.3.59");
69 print_lilypond_versions (ostream &os)
71 os << _f ("Oldest supported input version: %s", oldest_version.str ())
76 // needed for bison.simple's malloc() and free()
83 #define YYERROR_VERBOSE 1
85 #define YYPARSE_PARAM my_lily_parser_l
86 #define YYLEX_PARAM my_lily_parser_l
87 #define THIS ((My_lily_parser *) my_lily_parser_l)
89 #define yyerror THIS->parser_error
90 #define ARRAY_SIZE(a,s) if (a.size () != s) THIS->parser_error (_f ("Expecting %d arguments", s))
97 Link_array<Request> *reqvec;
105 Music_output_def * outputdef;
111 /* We use SCMs to do strings, because it saves us the trouble of
112 deleting them. Let's hope that a stack overflow doesnt trigger a move
113 of the parse stack onto the heap. */
123 yylex (YYSTYPE *s, void * v_l)
125 My_lily_parser *pars_l = (My_lily_parser*) v_l;
126 My_lily_lexer * lex_l = pars_l->lexer_p_;
128 lex_l->lexval_l = (void*) s;
129 return lex_l->yylex ();
137 /* tokens which are not keywords */
147 %token CHORDMODIFIERS
155 %token ELEMENTDESCRIPTIONS
194 %token COMMANDSPANREQUEST
196 %token OUTPUTPROPERTY
205 %token E_CHAR E_EXCLAMATION E_SMALLER E_BIGGER
206 %token CHORD_BASS CHORD_COLON CHORD_MINUS CHORD_CARET
208 %type <i> exclamations questions dots
210 %token <scm> NOTENAME_PITCH
211 %token <scm> TONICNAME_PITCH
212 %token <scm> CHORDMODIFIER_PITCH
213 %token <scm> DURATION_IDENTIFIER
214 %token <id> IDENTIFIER
217 %token <id> SCORE_IDENTIFIER
218 %token <id> MUSIC_OUTPUT_DEF_IDENTIFIER
220 %token <scm> NUMBER_IDENTIFIER
221 %token <scm> REQUEST_IDENTIFIER
222 %token <scm> MUSIC_IDENTIFIER TRANSLATOR_IDENTIFIER
223 %token <scm> STRING_IDENTIFIER SCM_IDENTIFIER
224 %token <scm> RESTNAME
230 %type <outputdef> output_def
231 %type <scope> lilypond_header lilypond_header_body
232 %type <request> open_request_parens close_request_parens open_request close_request
233 %type <request> request_with_dir request_that_take_dir verbose_request
234 %type <i> sub_quotes sup_quotes
235 %type <music> simple_element request_chord command_element Simple_music Composite_music
236 %type <music> Alternative_music Repeated_music
237 %type <i> tremolo_type
238 %type <i> bare_int bare_unsigned
241 %type <scm> identifier_init
243 %type <scm> steno_duration optional_notemode_duration
244 %type <scm> entered_notemode_duration explicit_duration
246 %type <reqvec> pre_requests post_requests
247 %type <request> gen_text_def
248 %type <scm> steno_musical_pitch musical_pitch absolute_musical_pitch
249 %type <scm> steno_tonic_pitch
251 %type <scm> chord_additions chord_subtractions chord_notes chord_step
253 %type <scm> chord_note chord_inversion chord_bass
254 %type <scm> duration_length
256 %type <scm> embedded_scm scalar
257 %type <music> Music Sequential_music Simultaneous_music Music_sequence
258 %type <music> relative_music re_rhythmed_music part_combined_music
259 %type <music> property_def translator_change
260 %type <scm> Music_list
261 %type <outputdef> music_output_def_body
262 %type <request> shorthand_command_req
263 %type <request> post_request
264 %type <music> command_req verbose_command_req
265 %type <request> extender_req
266 %type <request> hyphen_req
267 %type <scm> string bare_number number_expression
268 %type <score> score_block score_body
270 %type <scm> translator_spec_block translator_spec_body
271 %type <tempo> tempo_request
272 %type <scm> notenames_body notenames_block chordmodifiers_block
273 %type <scm> script_abbreviation
283 lilypond: /* empty */
284 | lilypond toplevel_expression {}
285 | lilypond assignment { }
287 THIS->error_level_i_ = 1;
288 //THIS->parser_error (_ ("ly invalid"));
291 THIS->error_level_i_ = 1;
292 //THIS->parser_error (_ ("ly invalid"));
298 THIS->lexer_p_->pitchname_tab_ = $1;
300 | chordmodifiers_block {
301 THIS->lexer_p_->chordmodifier_tab_ = $1;
304 delete header_global_p;
305 header_global_p = $1;
308 score_global_array.push ($1);
311 Identifier * id = new
312 Music_output_def_identifier ($1, MUSIC_OUTPUT_DEF_IDENTIFIER);
313 if (dynamic_cast<Paper_def*> ($1))
314 THIS->lexer_p_->set_identifier ("$defaultpaper", id->self_scm ());
315 else if (dynamic_cast<Midi_def*> ($1))
316 THIS->lexer_p_->set_identifier ("$defaultmidi", id->self_scm ());
329 chordmodifiers_block:
330 CHORDMODIFIERS notenames_body { $$ = $2; }
335 NOTENAMES notenames_body { $$ = $2; }
342 int i = scm_ilength ($1);
344 SCM tab = scm_make_vector (gh_int2scm (i), SCM_EOL);
345 for (SCM s = $1; gh_pair_p (s); s = gh_cdr (s)) {
346 SCM pt = gh_cdar (s);
347 if (!unsmob_pitch (pt))
348 THIS->parser_error ("Need pitch object.");
350 scm_hashq_set_x (tab, gh_caar(s), pt);
357 lilypond_header_body:
360 THIS->lexer_p_-> scope_l_arr_.push ($$);
362 | lilypond_header_body assignment semicolon {
368 HEADER '{' lilypond_header_body '}' {
370 THIS->lexer_p_-> scope_l_arr_.pop ();
380 THIS->remember_spot ();
382 /* cont */ '=' identifier_init {
383 THIS->lexer_p_->set_identifier (ly_scm2string ($1), $4);
386 TODO: devise standard for protection in parser.
388 The parser stack lives on the C-stack, which means that
389 all objects can be unprotected as soon as they're here.
392 Identifier * id =unsmob_identifier ($4);
393 Input spot = THIS->pop_spot ();
394 if (id) id->set_spot (spot);
402 $$ = (new Score_identifier ($1, SCORE_IDENTIFIER))->self_scm();
405 $$ = (new Music_output_def_identifier ($1, MUSIC_OUTPUT_DEF_IDENTIFIER))->self_scm();
407 | translator_spec_block {
411 $$ = $1->self_scm ();
412 scm_unprotect_object ($$);
415 $$ = $1->self_scm ();
416 scm_unprotect_object ($$);
418 | explicit_duration {
421 | number_expression {
432 translator_spec_block:
433 TRANSLATOR '{' translator_spec_body '}'
439 translator_spec_body:
440 TRANSLATOR_IDENTIFIER {
441 $$ = unsmob_translator_def ($1)->clone_scm ();
442 unsmob_translator_def ($$)-> set_spot (THIS->here_input ());
444 | TYPE STRING semicolon {
445 $$ = Translator_def::make_scm ();
446 Translator_def*td = unsmob_translator_def ($$);
447 td->translator_group_type_ = $2;
448 td->set_spot (THIS->here_input ());
450 | translator_spec_body STRING '=' embedded_scm {
451 unsmob_translator_def ($$)->add_property_assign ($2, $4);
453 | translator_spec_body STRING PUSH embedded_scm '=' embedded_scm {
454 unsmob_translator_def ($$)
455 ->add_push_property (scm_string_to_symbol ($2), $4, $6);
457 | translator_spec_body STRING POP embedded_scm {
458 unsmob_translator_def($$)->add_pop_property (
459 scm_string_to_symbol ($2), $4);
461 | translator_spec_body STRING '=' identifier_init semicolon {
462 SCM v = gh_int2scm (0);
463 if (gh_string_p ($4) || gh_number_p ($4) || gh_boolean_p ($4))
466 THIS->parser_error (_("Wrong type for property value"));
469 unsmob_translator_def($$)->add_property_assign ($2, v);
471 | translator_spec_body NAME STRING semicolon {
472 unsmob_translator_def ($$)->type_name_ = $3;
474 | translator_spec_body CONSISTS STRING semicolon {
475 unsmob_translator_def ($$)->add_element ($3);
477 | translator_spec_body ELEMENTDESCRIPTIONS embedded_scm {
478 for (SCM p = $3; gh_pair_p (p); p = gh_cdr (p))
479 unsmob_translator_def ($$)
480 ->add_property_assign (scm_symbol_to_string (gh_caar (p)), gh_cdar (p));
483 | translator_spec_body CONSISTSEND STRING semicolon {
484 unsmob_translator_def ($$)->add_last_element ( $3);
486 | translator_spec_body ACCEPTS STRING semicolon {
487 unsmob_translator_def ($$)->set_acceptor ($3,true);
489 | translator_spec_body DENIES STRING semicolon {
490 unsmob_translator_def ($$)->set_acceptor ($3,false);
492 | translator_spec_body REMOVE STRING semicolon {
493 unsmob_translator_def ($$)->remove_element ($3);
502 THIS->remember_spot ();
504 /*cont*/ '{' score_body '}' {
507 if (!$$->def_p_arr_.size ())
510 unsmob_identifier (THIS->lexer_p_->lookup_identifier ("$defaultpaper"));
511 $$->add_output (id ? id->access_content_Music_output_def (true) : new Paper_def );
515 | SCORE '{' score_body error {
517 $$->set_spot (THIS->here_input ());
518 // THIS->here_input ().error ("SCORE INVALID");
519 $$->error ("SCORE INVALID");
520 THIS->parser_error (_f ("SCORE ERROR"));
529 $$->set_spot (THIS->here_input ());
530 SCM m = $1->self_scm ();
531 scm_unprotect_object (m);
535 $$ = $1->access_content_Score (true);
537 | score_body lilypond_header {
540 | score_body output_def {
553 music_output_def_body '}' {
555 THIS-> lexer_p_-> scope_l_arr_.pop();
559 music_output_def_body:
561 Identifier *id = unsmob_identifier (THIS->lexer_p_->lookup_identifier ("$defaultmidi"));
566 p = dynamic_cast<Midi_def*> (id->access_content_Music_output_def (true));
571 THIS->lexer_p_->scope_l_arr_.push (p->scope_p_);
574 Identifier *id = unsmob_identifier (THIS->lexer_p_->lookup_identifier ("$defaultpaper"));
577 p = dynamic_cast<Paper_def*> (id->access_content_Music_output_def (true));
580 THIS-> lexer_p_-> scope_l_arr_.push (p->scope_p_);
583 | PAPER '{' MUSIC_OUTPUT_DEF_IDENTIFIER {
584 Music_output_def *p = $3->access_content_Music_output_def (true);
585 THIS->lexer_p_->scope_l_arr_.push (p->scope_p_);
588 | MIDI '{' MUSIC_OUTPUT_DEF_IDENTIFIER {
589 Music_output_def *p = $3->access_content_Music_output_def (true);
590 THIS->lexer_p_->scope_l_arr_.push (p->scope_p_);
593 | music_output_def_body assignment semicolon {
596 | music_output_def_body translator_spec_block {
597 $$->assign_translator ($2);
599 | music_output_def_body STYLESHEET embedded_scm {
600 dynamic_cast<Paper_def*> ($$)-> style_sheet_ = $3;
602 | music_output_def_body tempo_request semicolon {
604 junk this ? there already is tempo stuff in
607 int m = gh_scm2int ( $2->get_mus_property ("metronome-count"));
608 Duration *d = unsmob_duration ($2->get_mus_property ("duration"));
609 dynamic_cast<Midi_def*> ($$)->set_tempo (d->length_mom (), m);
611 | music_output_def_body error {
617 TEMPO steno_duration '=' bare_unsigned {
619 $$->set_mus_property ("duration", $2);
620 $$->set_mus_property ("metronome-count", gh_int2scm ( $4));
624 Music_list: /* empty */ {
625 $$ = gh_cons (SCM_EOL, SCM_EOL);
629 SCM c = gh_cons ($2->self_scm (), SCM_EOL);
630 scm_unprotect_object ($2->self_scm ()); /* UGH */
633 if (gh_pair_p (gh_cdr (s)))
634 gh_set_cdr_x (gh_cdr (s), c); /* append */
636 gh_set_car_x (s, c); /* set first cons */
637 gh_set_cdr_x (s, c) ; /* remember last cell */
653 | ALTERNATIVE Music_sequence {
655 $2->set_spot (THIS->here_input ());
663 REPEAT STRING bare_unsigned Music Alternative_music
665 Music_sequence* m = dynamic_cast <Music_sequence*> ($5);
666 if (m && $3 < m->length_i ())
667 $5->origin ()->warning (_ ("More alternatives than repeats. Junking excess alternatives."));
669 SCM func = scm_eval2 (ly_symbol2scm ("repeat-name-to-ctor"), SCM_EOL);
670 SCM result = gh_call1 (func, $2);
671 Repeated_music * r = new Repeated_music ($4, $3 >? 1, m);
672 set_music_properties (r, result);
674 r->set_spot (*$4->origin ());
679 Music_sequence: '{' Music_list '}' {
680 $$ = new Music_sequence (gh_car ($2));
685 SEQUENTIAL '{' Music_list '}' {
686 $$ = new Sequential_music (gh_car ($3));
688 | '{' Music_list '}' {
689 $$ = new Sequential_music (gh_car ($2));
694 SIMULTANEOUS '{' Music_list '}'{
695 $$ = new Simultaneous_music (gh_car ($3));
697 | '<' Music_list '>' {
698 $$ = new Simultaneous_music (gh_car ($2));
703 request_chord { $$ = $1; }
704 | OUTPUTPROPERTY embedded_scm embedded_scm '=' embedded_scm {
706 if (!gh_symbol_p ($3))
708 THIS->parser_error (_("Second argument must be a symbol"));
710 /*hould check # args */
711 if (!gh_procedure_p (pred))
713 THIS->parser_error (_("First argument must be a procedure taking 1 argument"));
716 Music *m = new Music;
717 m->set_mus_property ("predicate", pred);
718 m->set_mus_property ("symbol", $3);
719 m->set_mus_property ("value", $5);
720 m->set_mus_property ("type",
721 Output_property_music_iterator::constructor_cxx_function);
726 $$ = unsmob_music ($1)->clone ();
730 | Simple_music '*' bare_unsigned '/' bare_unsigned {
732 $$->compress (Moment($3, $5 ));
734 | Simple_music '*' bare_unsigned {
736 $$->compress (Moment ($3, 1));
742 CONTEXT STRING Music {
743 Context_specced_music *csm = new Context_specced_music ($3);
745 csm->set_mus_property ("context-type",$2);
746 csm->set_mus_property ("context-id", ly_str02scm (""));
750 | AUTOCHANGE STRING Music {
751 Auto_change_music * chm = new Auto_change_music ($3);
752 chm->set_mus_property ("what", $2);
755 chm->set_spot (*$3->origin ());
758 $$ = new Grace_music ($2);
760 | CONTEXT STRING '=' STRING Music {
761 Context_specced_music *csm = new Context_specced_music ($5);
763 csm->set_mus_property ("context-type", $2);
764 csm->set_mus_property ("context-id", $4);
769 THIS->remember_spot ();
772 bare_unsigned '/' bare_unsigned Music
775 $$ = new Time_scaled_music ($3, $5, $6);
776 $$->set_spot (THIS->pop_spot ());
778 | Repeated_music { $$ = $1; }
779 | Simultaneous_music { $$ = $1; }
780 | Sequential_music { $$ = $1; }
781 | TRANSPOSE musical_pitch Music {
782 $$ = new Transposed_music ($3, *unsmob_pitch ($2));
784 | TRANSPOSE steno_tonic_pitch Music {
785 $$ = new Transposed_music ($3, *unsmob_pitch ($2));
787 | APPLY embedded_scm Music {
788 SCM ret = gh_call1 ($2, $3->self_scm ());
789 Music *m = unsmob_music (ret);
791 THIS->parser_error ("\\apply must return a Music");
797 { THIS->lexer_p_->push_note_state (); }
800 THIS->lexer_p_->pop_state ();
803 { THIS->lexer_p_->push_chord_state (); }
807 THIS->lexer_p_->pop_state ();
810 { THIS->lexer_p_->push_lyric_state (); }
814 THIS->lexer_p_->pop_state ();
816 | relative_music { $$ = $1; }
817 | re_rhythmed_music { $$ = $1; }
818 | part_combined_music { $$ = $1; }
822 RELATIVE absolute_musical_pitch Music {
823 $$ = new Relative_octave_music ($3, *unsmob_pitch ($2));
828 ADDLYRICS Music Music {
829 Lyric_combine_music * l = new Lyric_combine_music ($2, $3);
835 PARTCOMBINE STRING Music Music {
836 Part_combine_music * p = new Part_combine_music ($2, $3, $4);
842 TRANSLATOR STRING '=' STRING {
843 Music * t = new Music;
844 t->set_mus_property ("type",
845 Change_iterator::constructor_cxx_function);
846 t-> set_mus_property ("change-to-type", $2);
847 t-> set_mus_property ("change-to-id", $4);
850 $$->set_spot (THIS->here_input ());
855 PROPERTY STRING '.' STRING '=' scalar {
856 Music *t = new Music;
858 t->set_mus_property ("type",
859 Property_iterator::constructor_cxx_function);
860 t->set_mus_property ("symbol", scm_string_to_symbol ($4));
861 t->set_mus_property ("value", $6);
863 Context_specced_music *csm = new Context_specced_music (t);
865 $$->set_spot (THIS->here_input ());
867 csm-> set_mus_property ("context-type", $2);
869 | PROPERTY STRING '.' STRING PUSH embedded_scm '=' embedded_scm {
870 Music *t = new Music;
871 t->set_mus_property ("type",
872 Push_property_iterator::constructor_cxx_function);
873 t->set_mus_property ("symbols", scm_string_to_symbol ($4));
874 t->set_mus_property ("element-property", $6);
875 t->set_mus_property ("element-value", $8);
876 Context_specced_music *csm = new Context_specced_music (t);
878 $$->set_spot (THIS->here_input ());
880 csm-> set_mus_property ("context-type", $2);
882 | PROPERTY STRING '.' STRING POP embedded_scm {
883 Music *t = new Music;
884 t->set_mus_property ("type",
885 Pop_property_iterator::constructor_cxx_function);
886 t->set_mus_property ("symbols", scm_string_to_symbol ($4));
887 t->set_mus_property ("element-property", $6);
889 Context_specced_music *csm = new Context_specced_music (t);
891 $$->set_spot (THIS->here_input ());
893 csm-> set_mus_property ("context-type", $2);
899 | bare_int { $$ = gh_int2scm ($1); }
900 | embedded_scm { $$ = $1; }
905 pre_requests simple_element post_requests {
906 Music_sequence *l = dynamic_cast<Music_sequence*>($2);
908 for (int i=0; i < $1->size(); i++)
909 l->append_music ($1->elem(i));
910 for (int i=0; i < $3->size(); i++)
911 l->append_music ($3->elem(i));
914 programming_error ("Need Sequence to add music to");
923 $$ = new Request_chord (gh_cons ($1->self_scm (), SCM_EOL));
924 $$-> set_spot (THIS->here_input ());
925 $1-> set_spot (THIS->here_input ());
928 Music *t = new Music;
930 t->set_mus_property ("type",
931 Property_iterator::constructor_cxx_function);
932 t->set_mus_property ("symbol", ly_symbol2scm ("whichBar"));
933 t->set_mus_property ("value", $2);
935 Context_specced_music *csm = new Context_specced_music (t);
937 $$->set_spot (THIS->here_input ());
939 csm->set_mus_property ("context-type", ly_str02scm ("Score"));
941 | PARTIAL duration_length ';' {
942 Music * p = new Music;
943 p->set_mus_property ("symbol", ly_symbol2scm ( "measurePosition"));
944 p->set_mus_property ("type",
945 Property_iterator::constructor_cxx_function);
947 Moment m = - unsmob_duration($2)->length_mom ();
948 p->set_mus_property ("value", m.smobbed_copy ());
950 Context_specced_music * sp = new Context_specced_music (p);
952 sp-> set_mus_property ("context-type", ly_str02scm ( "Score"));
955 SCM func = scm_eval2 (ly_symbol2scm ("clef-name-to-properties"), SCM_EOL);
956 SCM result = gh_call1 (func, $2);
959 for (SCM s = result ; gh_pair_p (s); s = gh_cdr (s)) {
960 Music * p = new Music;
961 set_music_properties(p, gh_car (s));
962 l = gh_cons (p->self_scm (), l);
963 scm_unprotect_object (p->self_scm ());
965 Sequential_music * seq = new Sequential_music (l);
967 Context_specced_music * sp = new Context_specced_music (seq);
969 sp-> set_mus_property("context-type", ly_str02scm("Staff"));
971 | TIME_T bare_unsigned '/' bare_unsigned ';' {
972 Music * p = new Music;
973 p->set_mus_property ("symbol",
974 ly_symbol2scm ( "timeSignatureFraction"));
975 p->set_mus_property ("type",
976 Property_iterator::constructor_cxx_function);
978 p->set_mus_property ("value", gh_cons (gh_int2scm ($2),
981 Context_specced_music * sp = new Context_specced_music (p);
983 sp-> set_mus_property ("context-type", ly_str02scm ( "Score"));
988 shorthand_command_req { $$ = $1; }
989 | verbose_command_req semicolon { $$ = $1; }
992 shorthand_command_req:
1000 $$ = new Barcheck_req;
1006 Span_req*b= new Span_req;
1007 b->set_span_dir(START);
1008 b->set_mus_property ("span-type", ly_str02scm ("beam"));
1012 Span_req*b= new Span_req;
1013 b->set_span_dir( STOP);
1014 b->set_mus_property ("span-type", ly_str02scm ("beam"));
1018 $$ = new Breathing_sign_req;
1023 verbose_command_req:
1024 COMMANDSPANREQUEST bare_int STRING {
1025 Span_req * sp_p = new Span_req;
1026 sp_p-> set_span_dir ( Direction($2));
1027 sp_p->set_mus_property ("span-type",$3);
1028 sp_p->set_spot (THIS->here_input ());
1032 Mark_req * m = new Mark_req;
1036 Mark_req *m = new Mark_req;
1037 m->set_mus_property ("label", $2);
1041 | MARK bare_unsigned {
1042 Mark_req *m = new Mark_req;
1043 m->set_mus_property ("label", gh_int2scm ($2));
1046 | PENALTY bare_int {
1047 Break_req * b = new Break_req;
1048 b->set_mus_property ("penalty", gh_double2scm ( $2 / 100.0));
1049 b->set_spot (THIS->here_input ());
1052 | SKIP duration_length {
1053 Skip_req * skip_p = new Skip_req;
1054 skip_p->set_mus_property ("duration", $2);
1062 Key_change_req *key_p= new Key_change_req;
1065 | KEY NOTENAME_PITCH SCM_IDENTIFIER {
1066 Key_change_req *key_p= new Key_change_req;
1068 key_p->set_mus_property ("pitch-alist", $3);
1069 ((Music* )key_p)->transpose (* unsmob_pitch ($2));
1076 $$ = new Link_array<Request>;
1078 | post_requests post_request {
1079 $2->set_spot (THIS->here_input ());
1091 request_that_take_dir:
1094 | script_abbreviation {
1095 SCM s = THIS->lexer_p_->lookup_identifier ("dash-" + ly_scm2string ($1));
1096 Articulation_req *a = new Articulation_req;
1097 if (gh_string_p (s))
1098 a->set_mus_property ("articulation-type", s);
1099 else THIS->parser_error (_ ("Expecting string as script definition"));
1105 script_dir request_that_take_dir {
1106 if (Script_req * gs = dynamic_cast<Script_req*> ($2))
1107 gs->set_direction (Direction ($1));
1109 $2->origin ()->warning (_ ("Can't specify direction for this request"));
1115 REQUEST_IDENTIFIER {
1116 $$ = dynamic_cast<Request*> (unsmob_music ($1)->clone ());
1117 $$->set_spot (THIS->here_input ());
1119 | DYNAMICSCRIPT embedded_scm {
1121 TODO: junkme, use text-type == dynamic
1123 Text_script_req *d = new Text_script_req;
1124 d->set_mus_property ("text-type" , ly_symbol2scm ("dynamic"));
1125 d->set_mus_property ("text", $2);
1126 d->set_spot (THIS->here_input ());
1129 | TEXTSCRIPT embedded_scm {
1130 Text_script_req *t = new Text_script_req;
1131 t->set_mus_property ("text", $2);
1132 t->set_spot (THIS->here_input ());
1135 | SPANREQUEST bare_int STRING {
1136 Span_req * sp_p = new Span_req;
1137 sp_p->set_span_dir( Direction($2));
1138 sp_p->set_mus_property ("span-type", $3);
1139 sp_p->set_spot (THIS->here_input ());
1143 Tremolo_req* a = new Tremolo_req;
1144 a->set_spot (THIS->here_input ());
1145 a->set_mus_property ("tremolo-type", gh_int2scm ($1));
1149 Articulation_req * a = new Articulation_req;
1150 a->set_mus_property ("articulation-type", $2);
1151 a->set_spot (THIS->here_input ());
1155 Arpeggio_req *a = new Arpeggio_req;
1156 a->set_spot (THIS->here_input ());
1179 steno_musical_pitch:
1183 | NOTENAME_PITCH sup_quotes {
1184 Pitch p = *unsmob_pitch ($1);
1186 $$ = p.smobbed_copy ();
1188 | NOTENAME_PITCH sub_quotes {
1189 Pitch p =* unsmob_pitch ($1);
1192 $$ = p.smobbed_copy ();
1205 | TONICNAME_PITCH sup_quotes {
1206 Pitch p = *unsmob_pitch ($1);
1208 $$ = p.smobbed_copy ();
1210 | TONICNAME_PITCH sub_quotes {
1211 Pitch p =* unsmob_pitch ($1);
1214 $$ = p.smobbed_copy ();
1220 steno_musical_pitch {
1223 | MUSICAL_PITCH embedded_scm {
1224 if (!unsmob_pitch ($2))
1225 THIS->parser_error (_f ("Expecting musical-pitch value", 3));
1227 $$ = m.smobbed_copy ();
1232 DURATION embedded_scm {
1234 if (!unsmob_duration ($2))
1236 THIS->parser_error (_("Must have duration object"));
1237 $$ = Duration ().smobbed_copy ();
1244 if (!THIS->lexer_p_->lyric_state_b ())
1245 THIS->parser_error (_ ("Have to be in Lyric mode for lyrics"));
1246 $$ = new Extender_req;
1252 if (!THIS->lexer_p_->lyric_state_b ())
1253 THIS->parser_error (_ ("Have to be in Lyric mode for lyrics"));
1254 $$ = new Hyphen_req;
1259 close_request_parens {
1261 dynamic_cast<Span_req*> ($$)->set_span_dir ( START);
1264 close_request_parens:
1266 Span_req* s= new Span_req;
1268 s->set_mus_property ("span-type", ly_str02scm( "slur"));
1271 Span_req*s =new Span_req;
1273 s->set_mus_property ("span-type", ly_str02scm ( "crescendo"));
1276 Span_req*s =new Span_req;
1278 s->set_mus_property ("span-type", ly_str02scm ("decrescendo"));
1284 open_request_parens {
1286 dynamic_cast<Span_req*> ($$)->set_span_dir (STOP);
1290 open_request_parens:
1292 Span_req *s = new Span_req;
1293 s->set_mus_property ("span-type", ly_str02scm ( "crescendo"));
1298 Span_req* s= new Span_req;
1300 s->set_mus_property ("span-type", ly_str02scm( "slur"));
1306 Text_script_req *t = new Text_script_req;
1307 t->set_mus_property ("text", $1);
1308 t->set_spot (THIS->here_input ());
1312 Text_script_req *t = new Text_script_req;
1313 t->set_mus_property ("text", $1);
1314 t->set_spot (THIS->here_input ());
1318 String ds = to_str ($1);
1319 Text_script_req* t = new Text_script_req;
1321 t->set_mus_property ("text", ly_str02scm (ds.ch_C()));
1322 t->set_mus_property ("text-type" , ly_symbol2scm ("finger"));
1323 t->set_spot (THIS->here_input ());
1328 script_abbreviation:
1330 $$ = gh_str02scm ("hat");
1333 $$ = gh_str02scm("plus");
1336 $$ = gh_str02scm ("dash");
1339 $$ = gh_str02scm ("bar");
1342 $$ = gh_str02scm ("larger");
1345 $$ = gh_str02scm ("dot");
1353 | '-' { $$ = CENTER; }
1358 $$ = new Link_array<Request>;
1360 | pre_requests open_request {
1365 absolute_musical_pitch:
1366 steno_musical_pitch {
1375 | duration_length '*' bare_unsigned {
1376 $$ = unsmob_duration ($$)->compressed ( $3) .smobbed_copy ();
1378 | duration_length '/' bare_unsigned {
1379 $$ = unsmob_duration ($$)->compressed (Moment (1,$3)).smobbed_copy ();
1383 entered_notemode_duration:
1385 THIS->set_last_duration (unsmob_duration ($1));
1389 optional_notemode_duration:
1391 $$ = THIS->default_duration_.smobbed_copy ();
1393 | entered_notemode_duration {
1399 bare_unsigned dots {
1401 if (!is_duration_b ($1))
1402 THIS->parser_error (_f ("not a duration: %d", $1));
1406 $$ = Duration (l, $2).smobbed_copy ();
1408 | DURATION_IDENTIFIER dots {
1409 Duration *d =unsmob_duration ($1);
1410 Duration k (d->duration_log (),d->dot_count () + $2);
1411 $$ = k.smobbed_copy ();
1429 | ':' bare_unsigned {
1430 if (!is_duration_b ($2))
1431 THIS->parser_error (_f ("not a duration: %d", $2));
1438 musical_pitch exclamations questions optional_notemode_duration {
1439 if (!THIS->lexer_p_->note_state_b ())
1440 THIS->parser_error (_ ("Have to be in Note mode for notes"));
1442 Note_req *n = new Note_req;
1444 n->set_mus_property ("pitch", $1);
1445 n->set_mus_property ("duration", $4);
1448 n->set_mus_property ("cautionary", SCM_BOOL_T);
1449 if ($2 % 2 || $3 % 2)
1450 n->set_mus_property ("force-accidental", SCM_BOOL_T);
1452 Simultaneous_music*v = new Request_chord (gh_list (n->self_scm (), SCM_UNDEFINED));
1457 v->set_spot (THIS->here_input ());
1458 n->set_spot (THIS->here_input ());
1462 | RESTNAME optional_notemode_duration {
1464 SCM e = SCM_UNDEFINED;
1465 if (ly_scm2string ($1) =="s")
1467 Skip_req * skip_p = new Skip_req;
1468 skip_p->set_mus_property ("duration" ,$2);
1470 skip_p->set_spot (THIS->here_input());
1471 e = skip_p->self_scm ();
1475 Rest_req * rest_req_p = new Rest_req;
1476 rest_req_p->set_mus_property ("duration", $2);
1477 rest_req_p->set_spot (THIS->here_input());
1478 e = rest_req_p->self_scm ();
1480 Simultaneous_music* velt_p = new Request_chord (gh_list (e,SCM_UNDEFINED));
1481 velt_p->set_spot (THIS->here_input());
1486 | MEASURES optional_notemode_duration {
1487 Skip_req * sk = new Skip_req;
1488 sk->set_mus_property ("duration", $2);
1489 Span_req *sp1 = new Span_req;
1490 Span_req *sp2 = new Span_req;
1491 sp1-> set_span_dir ( START);
1492 sp2-> set_span_dir ( STOP);
1493 SCM r = ly_str02scm ("rest");
1494 sp1->set_mus_property ("span-type", r);
1495 sp2->set_mus_property ("span-type", r);
1497 Request_chord * rqc1 = new Request_chord (gh_list (sp1->self_scm (), SCM_UNDEFINED));
1498 Request_chord * rqc2 = new Request_chord (gh_list (sk->self_scm (), SCM_UNDEFINED));;
1499 Request_chord * rqc3 = new Request_chord(gh_list (sp2->self_scm (), SCM_UNDEFINED));;
1501 SCM ms = gh_list (rqc1->self_scm (), rqc2->self_scm (), rqc3->self_scm (), SCM_UNDEFINED);
1503 $$ = new Sequential_music (ms);
1506 THIS->remember_spot ();
1509 optional_notemode_duration {
1510 if (!THIS->lexer_p_->lyric_state_b ()) {
1511 THIS->pop_spot ().error (_ ("Have to be in Lyric mode for lyrics"));
1512 THIS->error_level_i_ = 1;
1513 THIS->parser_error (_ ("Giving up"));
1517 Lyric_req* lreq_p = new Lyric_req;
1518 lreq_p->set_mus_property ("text", $1);
1519 lreq_p->set_mus_property ("duration",$3);
1520 lreq_p->set_spot (THIS->here_input());
1521 Simultaneous_music* velt_p = new Request_chord (gh_list (lreq_p->self_scm (), SCM_UNDEFINED));
1528 if (!THIS->lexer_p_->chord_state_b ())
1529 THIS->parser_error (_ ("Have to be in Chord mode for chords"));
1536 steno_tonic_pitch optional_notemode_duration chord_additions chord_subtractions chord_inversion chord_bass {
1537 $$ = Chord::get_chord ($1, $3, $4, $5, $6, $2);
1538 $$->set_spot (THIS->here_input ());
1545 | CHORD_COLON chord_notes {
1554 | chord_notes '.' chord_step {
1555 $$ = gh_append2 ($$, $3);
1563 | CHORD_CARET chord_notes {
1573 | '/' steno_tonic_pitch {
1582 | CHORD_BASS steno_tonic_pitch {
1589 $$ = gh_cons ($1, SCM_EOL);
1591 | CHORDMODIFIER_PITCH {
1592 $$ = gh_cons ($1, SCM_EOL);
1594 | CHORDMODIFIER_PITCH chord_note { /* Ugh. */
1595 $$ = gh_list ($1, $2, SCM_UNDEFINED);
1602 m.notename_i_ = ($1 - 1) % 7;
1603 m.octave_i_ = $1 > 7 ? 1 : 0;
1604 m.alteration_i_ = 0;
1606 $$ = m.smobbed_copy ();
1608 | bare_unsigned '+' {
1610 m.notename_i_ = ($1 - 1) % 7;
1611 m.octave_i_ = $1 > 7 ? 1 : 0;
1612 m.alteration_i_ = 1;
1615 $$ = m.smobbed_copy ();
1617 | bare_unsigned CHORD_MINUS {
1619 m.notename_i_ = ($1 - 1) % 7;
1620 m.octave_i_ = $1 > 7 ? 1 : 0;
1621 m.alteration_i_ = -1;
1623 $$ = m.smobbed_copy ();
1634 | '-' number_expression %prec UNARY_MINUS {
1635 $$ = scm_difference ($2, SCM_UNDEFINED);
1637 | number_expression '*' number_expression {
1638 $$ = scm_product ($1, $3);
1640 | number_expression '/' number_expression {
1641 $$ = scm_divide ($1, $3);
1643 | number_expression '+' number_expression {
1644 $$ = scm_sum ($1, $3);
1646 | number_expression '-' number_expression {
1647 $$ = scm_difference ($1, $3);
1649 | '(' number_expression ')' {
1656 $$ = gh_int2scm ($1);
1659 $$ = gh_int2scm ($1);
1662 $$ = gh_double2scm ($1);
1664 | NUMBER_IDENTIFIER {
1668 $$ = gh_double2scm ($1 CM);
1671 $$ = gh_double2scm ($1 PT);
1674 $$ = gh_double2scm ($1 INCH);
1677 $$ = gh_double2scm ($1 MM);
1680 $$ = gh_double2scm ($1 CHAR);
1687 if (scm_integer_p ($1) == SCM_BOOL_T) {
1688 $$ = gh_scm2int ($1);
1691 THIS->parser_error (_("need integer number arg"));
1695 THIS->parser_error (_("Must be positive integer"));
1703 if (scm_integer_p ($1) == SCM_BOOL_T)
1705 int k = gh_scm2int ($1);
1709 THIS->parser_error (_("need integer number arg"));
1723 | STRING_IDENTIFIER {
1726 | string '+' string {
1727 $$ = scm_string_append (scm_listify ($1, $3, SCM_UNDEFINED));
1734 | exclamations '!' { $$ ++; }
1739 | questions '?' { $$ ++; }
1750 My_lily_parser::set_yydebug (bool b)
1757 extern My_lily_parser * current_parser;
1760 My_lily_parser::do_yyparse ()
1763 current_parser = this;;
1764 yyparse ((void*)this);