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 */
138 %token CHORDMODIFIERS
145 %token ELEMENTDESCRIPTIONS
184 %token COMMANDSPANREQUEST
186 %token OUTPUTPROPERTY
195 %token E_CHAR E_EXCLAMATION E_SMALLER E_BIGGER
196 %token CHORD_BASS CHORD_COLON CHORD_MINUS CHORD_CARET
198 %type <i> exclamations questions
200 %token <pitch> NOTENAME_PITCH
201 %token <pitch> TONICNAME_PITCH
202 %token <pitch> CHORDMODIFIER_PITCH
203 %token <id> DURATION_IDENTIFIER
204 %token <id> IDENTIFIER
207 %token <id> SCORE_IDENTIFIER
208 %token <id> MUSIC_OUTPUT_DEF_IDENTIFIER
210 %token <scm> NUMBER_IDENTIFIER
211 %token <scm> REQUEST_IDENTIFIER
212 %token <scm> MUSIC_IDENTIFIER TRANSLATOR_IDENTIFIER
213 %token <scm> STRING_IDENTIFIER SCM_IDENTIFIER
214 %token <scm> DURATION RESTNAME
220 %type <outputdef> output_def
221 %type <scope> mudela_header mudela_header_body
222 %type <request> open_request_parens close_request_parens open_request close_request
223 %type <request> request_with_dir request_that_take_dir verbose_request
224 %type <i> sub_quotes sup_quotes
225 %type <music> simple_element request_chord command_element Simple_music Composite_music
226 %type <music> Alternative_music Repeated_music
227 %type <i> tremolo_type
228 %type <i> bare_int bare_unsigned
231 %type <scm> identifier_init
233 %type <duration> steno_duration optional_notemode_duration
234 %type <duration> entered_notemode_duration explicit_duration
236 %type <reqvec> pre_requests post_requests
237 %type <request> gen_text_def
238 %type <pitch> steno_musical_pitch musical_pitch absolute_musical_pitch
239 %type <pitch> steno_tonic_pitch
241 %type <pitch_arr> chord_additions chord_subtractions chord_notes chord_step
243 %type <pitch> chord_note chord_inversion chord_bass
244 %type <duration> duration_length
246 %type <scm> embedded_scm scalar
247 %type <music> Music Sequential_music Simultaneous_music Music_sequence
248 %type <music> relative_music re_rhythmed_music part_combined_music
249 %type <music> property_def translator_change
250 %type <scm> Music_list
251 %type <outputdef> music_output_def_body
252 %type <request> shorthand_command_req
253 %type <request> post_request
254 %type <request> command_req verbose_command_req
255 %type <request> extender_req
256 %type <request> hyphen_req
257 %type <scm> string bare_number number_expression
258 %type <score> score_block score_body
260 %type <scm> translator_spec_block translator_spec_body
261 %type <tempo> tempo_request
262 %type <scm> notenames_body notenames_block chordmodifiers_block
263 %type <scm> script_abbreviation
274 | mudela toplevel_expression {}
275 | mudela assignment { }
277 THIS->error_level_i_ = 1;
278 //THIS->parser_error (_ ("ly invalid"));
281 THIS->error_level_i_ = 1;
282 //THIS->parser_error (_ ("ly invalid"));
288 THIS->lexer_p_->pitchname_tab_ = $1;
290 | chordmodifiers_block {
291 THIS->lexer_p_->chordmodifier_tab_ = $1;
294 delete header_global_p;
295 header_global_p = $1;
298 score_global_array.push ($1);
301 Identifier * id = new
302 Music_output_def_identifier ($1, MUSIC_OUTPUT_DEF_IDENTIFIER);
303 if (dynamic_cast<Paper_def*> ($1))
304 THIS->lexer_p_->set_identifier ("$defaultpaper", id->self_scm ());
305 else if (dynamic_cast<Midi_def*> ($1))
306 THIS->lexer_p_->set_identifier ("$defaultmidi", id->self_scm ());
319 chordmodifiers_block:
320 CHORDMODIFIERS notenames_body { $$ = $2; }
325 NOTENAMES notenames_body { $$ = $2; }
332 int i = scm_ilength ($1);
334 SCM tab = scm_make_vector (gh_int2scm (i), SCM_EOL);
335 for (SCM s = $1; s != SCM_EOL; s = gh_cdr (s)) {
336 SCM pt = gh_cdar (s);
337 if (scm_ilength (pt) != 3)
338 THIS->parser_error ("Need three args");
339 scm_hashq_set_x (tab, gh_caar(s), pt);
349 THIS->lexer_p_-> scope_l_arr_.push ($$);
351 | mudela_header_body assignment semicolon {
357 HEADER '{' mudela_header_body '}' {
359 THIS->lexer_p_-> scope_l_arr_.pop ();
369 THIS->remember_spot ();
371 /* cont */ '=' identifier_init {
372 THIS->lexer_p_->set_identifier (ly_scm2string ($1), $4);
375 TODO: devise standard for protection in parser.
377 The parser stack lives on the C-stack, which means that
378 all objects can be unprotected as soon as they're here.
381 Identifier * id =unsmob_identifier ($4);
382 Input spot = THIS->pop_spot ();
383 if (id) id->set_spot (spot);
391 $$ = (new Score_identifier ($1, SCORE_IDENTIFIER))->self_scm();
394 $$ = (new Music_output_def_identifier ($1, MUSIC_OUTPUT_DEF_IDENTIFIER))->self_scm();
396 | translator_spec_block {
400 $$ = $1->self_scm ();
401 scm_unprotect_object ($$);
404 $$ = $1->self_scm ();
405 scm_unprotect_object ($$);
407 | explicit_duration {
408 $$ = (new Duration_identifier ($1, DURATION_IDENTIFIER))->self_scm ();
410 | number_expression {
421 translator_spec_block:
422 TRANSLATOR '{' translator_spec_body '}'
428 translator_spec_body:
429 TRANSLATOR_IDENTIFIER {
430 $$ = unsmob_translator_def ($1)->clone_scm ();
431 unsmob_translator_def ($$)-> set_spot (THIS->here_input ());
433 | TYPE STRING semicolon {
434 $$ = Translator_def::make_scm ();
435 Translator_def*td = unsmob_translator_def ($$);
436 td->translator_group_type_ = $2;
437 td->set_spot (THIS->here_input ());
439 | translator_spec_body STRING '=' embedded_scm {
440 unsmob_translator_def ($$)->add_property_assign ($2, $4);
442 | translator_spec_body STRING PUSH embedded_scm '=' embedded_scm {
443 unsmob_translator_def ($$)
444 ->add_push_property (scm_string_to_symbol ($2), $4, $6);
446 | translator_spec_body STRING POP embedded_scm {
447 unsmob_translator_def($$)->add_pop_property (
448 scm_string_to_symbol ($2), $4);
450 | translator_spec_body STRING '=' identifier_init semicolon {
451 SCM v = gh_int2scm (0);
452 if (gh_string_p ($4) || gh_number_p ($4) || gh_boolean_p ($4))
455 THIS->parser_error (_("Wrong type for property value"));
458 unsmob_translator_def($$)->add_property_assign ($2, v);
460 | translator_spec_body NAME STRING semicolon {
461 unsmob_translator_def ($$)->type_name_ = $3;
463 | translator_spec_body CONSISTS STRING semicolon {
464 unsmob_translator_def ($$)->add_element ($3);
466 | translator_spec_body ELEMENTDESCRIPTIONS embedded_scm {
467 for (SCM p = $3; gh_pair_p (p); p = gh_cdr (p))
468 unsmob_translator_def ($$)
469 ->add_property_assign (scm_symbol_to_string (gh_caar (p)), gh_cdar (p));
472 | translator_spec_body CONSISTSEND STRING semicolon {
473 unsmob_translator_def ($$)->add_last_element ( $3);
475 | translator_spec_body ACCEPTS STRING semicolon {
476 unsmob_translator_def ($$)->set_acceptor ($3,true);
478 | translator_spec_body DENIES STRING semicolon {
479 unsmob_translator_def ($$)->set_acceptor ($3,false);
481 | translator_spec_body REMOVE STRING semicolon {
482 unsmob_translator_def ($$)->remove_element ($3);
491 THIS->remember_spot ();
493 /*cont*/ '{' score_body '}' {
496 if (!$$->def_p_arr_.size ())
499 unsmob_identifier (THIS->lexer_p_->lookup_identifier ("$defaultpaper"));
500 $$->add_output (id ? id->access_content_Music_output_def (true) : new Paper_def );
504 | SCORE '{' score_body error {
506 $$->set_spot (THIS->here_input ());
507 // THIS->here_input ().error ("SCORE INVALID");
508 $$->error ("SCORE INVALID");
509 THIS->parser_error (_f ("SCORE ERROR"));
518 $$->set_spot (THIS->here_input ());
519 SCM m = $1->self_scm ();
520 scm_unprotect_object (m);
524 $$ = $1->access_content_Score (true);
526 | score_body mudela_header {
529 | score_body output_def {
542 music_output_def_body '}' {
544 THIS-> lexer_p_-> scope_l_arr_.pop();
548 music_output_def_body:
550 Identifier *id = unsmob_identifier (THIS->lexer_p_->lookup_identifier ("$defaultmidi"));
555 p = dynamic_cast<Midi_def*> (id->access_content_Music_output_def (true));
560 THIS->lexer_p_->scope_l_arr_.push (p->scope_p_);
563 Identifier *id = unsmob_identifier (THIS->lexer_p_->lookup_identifier ("$defaultpaper"));
566 p = dynamic_cast<Paper_def*> (id->access_content_Music_output_def (true));
569 THIS-> lexer_p_-> scope_l_arr_.push (p->scope_p_);
572 | PAPER '{' MUSIC_OUTPUT_DEF_IDENTIFIER {
573 Music_output_def *p = $3->access_content_Music_output_def (true);
574 THIS->lexer_p_->scope_l_arr_.push (p->scope_p_);
577 | MIDI '{' MUSIC_OUTPUT_DEF_IDENTIFIER {
578 Music_output_def *p = $3->access_content_Music_output_def (true);
579 THIS->lexer_p_->scope_l_arr_.push (p->scope_p_);
582 | music_output_def_body assignment semicolon {
585 | music_output_def_body translator_spec_block {
586 $$->assign_translator ($2);
588 | music_output_def_body STYLESHEET embedded_scm {
589 dynamic_cast<Paper_def*> ($$)-> style_sheet_ = $3;
591 | music_output_def_body tempo_request semicolon {
593 junk this ? there already is tempo stuff in
596 int m = gh_scm2int ( $2->get_mus_property ("metronome-count"));
597 dynamic_cast<Midi_def*> ($$)->set_tempo ($2->dur_.length_mom (), m);
599 | music_output_def_body error {
605 TEMPO steno_duration '=' bare_unsigned {
609 $$-> set_mus_property ("metronome-count", gh_int2scm ( $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);
777 | APPLY embedded_scm Music {
778 SCM ret = gh_call1 ($2, $3->self_scm ());
779 Music *m = unsmob_music (ret);
781 THIS->parser_error ("\\apply must return a Music");
787 { THIS->lexer_p_->push_note_state (); }
790 THIS->lexer_p_->pop_state ();
793 { THIS->lexer_p_->push_chord_state (); }
797 THIS->lexer_p_->pop_state ();
800 { THIS->lexer_p_->push_lyric_state (); }
804 THIS->lexer_p_->pop_state ();
806 | relative_music { $$ = $1; }
807 | re_rhythmed_music { $$ = $1; }
808 | part_combined_music { $$ = $1; }
812 RELATIVE absolute_musical_pitch Music {
813 $$ = new Relative_octave_music ($3, *$2);
819 ADDLYRICS Music Music {
820 Lyric_combine_music * l = new Lyric_combine_music ($2, $3);
826 PARTCOMBINE STRING Music Music {
827 Part_combine_music * p = new Part_combine_music ($2, $3, $4);
833 TRANSLATOR STRING '=' STRING {
834 Music * t = new Music;
835 t->set_mus_property ("type",
836 ly_symbol2scm ("change-translator"));
837 t-> set_mus_property ("change-to-type", $2);
838 t-> set_mus_property ("change-to-id", $4);
841 $$->set_spot (THIS->here_input ());
846 PROPERTY STRING '.' STRING '=' scalar {
847 Music *t = new Music;
849 t->set_mus_property ("type", ly_symbol2scm ("property-set"));
850 t->set_mus_property ("symbol", scm_string_to_symbol ($4));
851 t->set_mus_property ("value", $6);
853 Context_specced_music *csm = new Context_specced_music (t);
855 $$->set_spot (THIS->here_input ());
857 csm-> translator_type_str_ = ly_scm2string ($2);
859 | PROPERTY STRING '.' STRING PUSH embedded_scm '=' embedded_scm {
860 Music *t = new Music;
861 t->set_mus_property ("type", ly_symbol2scm ("property-push"));
862 t->set_mus_property ("symbols", scm_string_to_symbol ($4));
863 t->set_mus_property ("element-property", $6);
864 t->set_mus_property ("element-value", $8);
865 Context_specced_music *csm = new Context_specced_music (t);
867 $$->set_spot (THIS->here_input ());
869 csm-> translator_type_str_ = ly_scm2string ($2);
871 | PROPERTY STRING '.' STRING POP embedded_scm {
872 Music *t = new Music;
873 t->set_mus_property ("type", ly_symbol2scm ("property-pop"));
874 t->set_mus_property ("symbols", scm_string_to_symbol ($4));
875 t->set_mus_property ("element-property", $6);
877 Context_specced_music *csm = new Context_specced_music (t);
879 $$->set_spot (THIS->here_input ());
881 csm-> translator_type_str_ = ly_scm2string ($2);
887 | bare_int { $$ = gh_int2scm ($1); }
888 | embedded_scm { $$ = $1; }
893 pre_requests simple_element post_requests {
894 Music_sequence *l = dynamic_cast<Music_sequence*>($2);
896 for (int i=0; i < $1->size(); i++)
897 l->append_music ($1->elem(i));
898 for (int i=0; i < $3->size(); i++)
899 l->append_music ($3->elem(i));
902 programming_error ("Need Sequence to add music to");
911 $$ = new Request_chord (gh_cons ($1->self_scm (), SCM_EOL));
912 $$-> set_spot (THIS->here_input ());
913 $1-> set_spot (THIS->here_input ());
915 | PARTIAL duration_length ';' {
916 Music * p = new Music;
917 p->set_mus_property ("symbol", ly_symbol2scm ( "measurePosition"));
918 p->set_mus_property ("type", ly_symbol2scm ("property-set"));
920 Moment m = - $2->length_mom ();
921 p->set_mus_property ("value", m.make_scm());
923 Context_specced_music * sp = new Context_specced_music (p);
925 sp-> translator_type_str_ = "Score";
930 shorthand_command_req
931 | verbose_command_req semicolon { $$ = $1; }
934 shorthand_command_req:
942 $$ = new Barcheck_req;
948 Span_req*b= new Span_req;
949 b->set_span_dir(START);
950 b->set_mus_property ("span-type", ly_str02scm ("beam"));
954 Span_req*b= new Span_req;
955 b->set_span_dir( STOP);
956 b->set_mus_property ("span-type", ly_str02scm ("beam"));
960 $$ = new Breathing_sign_req;
968 $$ = new Bar_req (ly_scm2string ($2));
970 | COMMANDSPANREQUEST bare_int STRING {
971 Span_req * sp_p = new Span_req;
972 sp_p-> set_span_dir ( Direction($2));
973 sp_p->set_mus_property ("span-type",$3);
974 sp_p->set_spot (THIS->here_input ());
978 Mark_req * m = new Mark_req;
982 Mark_req *m = new Mark_req;
983 m->set_mus_property ("label", $2);
987 | MARK bare_unsigned {
988 Mark_req *m = new Mark_req;
989 m->set_mus_property ("label", gh_int2scm ($2));
993 | TIME_T bare_unsigned '/' bare_unsigned {
994 Time_signature_change_req *m = new Time_signature_change_req;
995 m->set_mus_property ("beats", gh_int2scm ( $2));
996 m->set_mus_property ("one-beat", gh_int2scm ($4));
1000 Break_req * b = new Break_req;
1001 b->set_mus_property ("penalty", gh_double2scm ( $2 / 100.0));
1002 b->set_spot (THIS->here_input ());
1005 | SKIP duration_length {
1006 Skip_req * skip_p = new Skip_req;
1007 skip_p->duration_ = *$2;
1015 $$ = new Clef_change_req;
1016 $$->set_mus_property ("clef-type", $2);
1020 Key_change_req *key_p= new Key_change_req;
1023 | KEY NOTENAME_PITCH SCM_IDENTIFIER {
1024 Key_change_req *key_p= new Key_change_req;
1026 key_p->set_mus_property ("pitch-alist", $3);
1027 ((Music* )key_p)->transpose (* $2);
1034 $$ = new Link_array<Request>;
1036 | post_requests post_request {
1037 $2->set_spot (THIS->here_input ());
1049 request_that_take_dir:
1052 | script_abbreviation {
1053 SCM s = THIS->lexer_p_->lookup_identifier ("dash-" + ly_scm2string ($1));
1054 Articulation_req *a = new Articulation_req;
1055 if (gh_string_p (s))
1056 a->set_mus_property ("articulation-type", s);
1057 else THIS->parser_error (_ ("Expecting string as script definition"));
1063 script_dir request_that_take_dir {
1064 if (Script_req * gs = dynamic_cast<Script_req*> ($2))
1065 gs->set_direction (Direction ($1));
1067 $2->origin ()->warning (_ ("Can't specify direction for this request"));
1073 REQUEST_IDENTIFIER {
1074 $$ = dynamic_cast<Request*> (unsmob_music ($1)->clone ());
1075 $$->set_spot (THIS->here_input ());
1077 | DYNAMICSCRIPT embedded_scm {
1079 TODO: junkme, use text-type == dynamic
1081 Text_script_req *d = new Text_script_req;
1082 d->set_mus_property ("text-type" , ly_symbol2scm ("dynamic"));
1083 d->set_mus_property ("text", $2);
1084 d->set_spot (THIS->here_input ());
1087 | TEXTSCRIPT embedded_scm {
1088 Text_script_req *t = new Text_script_req;
1089 t->set_mus_property ("text", $2);
1090 t->set_spot (THIS->here_input ());
1093 | SPANREQUEST bare_int STRING {
1094 Span_req * sp_p = new Span_req;
1095 sp_p->set_span_dir( Direction($2));
1096 sp_p->set_mus_property ("span-type", $3);
1097 sp_p->set_spot (THIS->here_input ());
1101 Tremolo_req* a = new Tremolo_req;
1102 a->set_spot (THIS->here_input ());
1103 a->set_mus_property ("tremolo-type", gh_int2scm ($1));
1107 Articulation_req * a = new Articulation_req;
1108 a->set_mus_property ("articulation-type", $2);
1109 a->set_spot (THIS->here_input ());
1113 Arpeggio_req *a = new Arpeggio_req;
1114 a->set_spot (THIS->here_input ());
1137 steno_musical_pitch:
1141 | NOTENAME_PITCH sup_quotes {
1143 $$->octave_i_ += $2;
1145 | NOTENAME_PITCH sub_quotes {
1147 $$->octave_i_ += - $2;
1155 | TONICNAME_PITCH sup_quotes {
1157 $$->octave_i_ += $2;
1159 | TONICNAME_PITCH sub_quotes {
1161 $$->octave_i_ += - $2;
1166 steno_musical_pitch {
1169 | MUSICAL_PITCH embedded_scm {
1170 int sz = scm_ilength ($2);
1172 THIS->parser_error (_f ("Expecting %d arguments", 3));
1173 $2 = gh_list (gh_int2scm (0), gh_int2scm (0), gh_int2scm (0), SCM_UNDEFINED);
1175 $$ = new Musical_pitch ($2);
1180 DURATION embedded_scm {
1182 if (scm_ilength ($2) == 2)
1184 $$-> durlog_i_ = gh_scm2int (gh_car($2));
1185 $$-> dots_i_ = gh_scm2int (gh_cadr($2));
1188 THIS->parser_error (_("Must have 2 arguments for duration"));
1194 if (!THIS->lexer_p_->lyric_state_b ())
1195 THIS->parser_error (_ ("Have to be in Lyric mode for lyrics"));
1196 $$ = new Extender_req;
1202 if (!THIS->lexer_p_->lyric_state_b ())
1203 THIS->parser_error (_ ("Have to be in Lyric mode for lyrics"));
1204 $$ = new Hyphen_req;
1209 close_request_parens {
1211 dynamic_cast<Span_req*> ($$)->set_span_dir ( START);
1214 close_request_parens:
1216 Span_req* s= new Span_req;
1218 s->set_mus_property ("span-type", ly_str02scm( "slur"));
1221 Span_req*s =new Span_req;
1223 s->set_mus_property ("span-type", ly_str02scm ( "crescendo"));
1226 Span_req*s =new Span_req;
1228 s->set_mus_property ("span-type", ly_str02scm ("decrescendo"));
1234 open_request_parens {
1236 dynamic_cast<Span_req*> ($$)->set_span_dir (STOP);
1240 open_request_parens:
1242 Span_req *s = new Span_req;
1243 s->set_mus_property ("span-type", ly_str02scm ( "crescendo"));
1248 Span_req* s= new Span_req;
1250 s->set_mus_property ("span-type", ly_str02scm( "slur"));
1256 Text_script_req *t = new Text_script_req;
1257 t->set_mus_property ("text", $1);
1258 t->set_spot (THIS->here_input ());
1262 Text_script_req *t = new Text_script_req;
1263 t->set_mus_property ("text", $1);
1264 t->set_spot (THIS->here_input ());
1268 String ds = to_str ($1);
1269 Text_script_req* t = new Text_script_req;
1271 t->set_mus_property ("text", ly_str02scm (ds.ch_C()));
1272 t->set_mus_property ("text-type" , ly_symbol2scm ("finger"));
1273 t->set_spot (THIS->here_input ());
1278 script_abbreviation:
1280 $$ = gh_str02scm ("hat");
1283 $$ = gh_str02scm("plus");
1286 $$ = gh_str02scm ("dash");
1289 $$ = gh_str02scm ("bar");
1292 $$ = gh_str02scm ("larger");
1295 $$ = gh_str02scm ("dot");
1303 | '-' { $$ = CENTER; }
1308 $$ = new Link_array<Request>;
1310 | pre_requests open_request {
1315 absolute_musical_pitch:
1316 steno_musical_pitch {
1325 | duration_length '*' bare_unsigned {
1326 $$->tuplet_iso_i_ *= $3;
1328 | duration_length '/' bare_unsigned {
1329 $$->tuplet_type_i_ *= $3;
1333 entered_notemode_duration:
1335 THIS->set_last_duration ($1);
1339 optional_notemode_duration:
1341 $$ = new Duration (THIS->default_duration_);
1343 | entered_notemode_duration {
1351 if (!is_duration_b ($1))
1352 THIS->parser_error (_f ("not a duration: %d", $1));
1354 $$->durlog_i_ = intlog2 ($1);
1357 | DURATION_IDENTIFIER {
1358 $$ = $1->access_content_Duration (true);
1360 | steno_duration '.' {
1370 | ':' bare_unsigned {
1371 if (!is_duration_b ($2))
1372 THIS->parser_error (_f ("not a duration: %d", $2));
1379 musical_pitch exclamations questions optional_notemode_duration {
1380 if (!THIS->lexer_p_->note_state_b ())
1381 THIS->parser_error (_ ("Have to be in Note mode for notes"));
1384 Note_req *n = new Note_req;
1390 n->set_mus_property ("cautionary", SCM_BOOL_T);
1391 if ( $2 % 2 || $3 % 2)
1392 n->set_mus_property ("force-accidental", SCM_BOOL_T);
1395 Simultaneous_music*v = new Request_chord (gh_list (n->self_scm (), SCM_UNDEFINED));
1396 v->set_spot ($1->spot ());
1397 n->set_spot ($1->spot ());
1403 | RESTNAME optional_notemode_duration {
1405 SCM e = SCM_UNDEFINED;
1406 if (ly_scm2string ($1) =="s")
1408 Skip_req * skip_p = new Skip_req;
1409 skip_p->duration_ = *$2;
1411 skip_p->set_spot (THIS->here_input());
1412 e = skip_p->self_scm ();
1416 Rest_req * rest_req_p = new Rest_req;
1417 rest_req_p->duration_ = *$2;
1418 rest_req_p->set_spot (THIS->here_input());
1419 e = rest_req_p->self_scm ();
1421 Simultaneous_music* velt_p = new Request_chord (gh_list (e,SCM_UNDEFINED));
1422 velt_p->set_spot (THIS->here_input());
1427 | MEASURES optional_notemode_duration {
1428 Skip_req * sk = new Skip_req;
1429 sk->duration_ = *$2;
1432 Span_req *sp1 = new Span_req;
1433 Span_req *sp2 = new Span_req;
1434 sp1-> set_span_dir ( START);
1435 sp2-> set_span_dir ( STOP);
1436 SCM r = ly_str02scm ("rest");
1437 sp1->set_mus_property ("span-type", r);
1438 sp2->set_mus_property ("span-type", r);
1440 Request_chord * rqc1 = new Request_chord (gh_list (sp1->self_scm (), SCM_UNDEFINED));
1441 Request_chord * rqc2 = new Request_chord (gh_list (sk->self_scm (), SCM_UNDEFINED));;
1442 Request_chord * rqc3 = new Request_chord(gh_list (sp2->self_scm (), SCM_UNDEFINED));;
1444 SCM ms = gh_list (rqc1->self_scm (), rqc2->self_scm (), rqc3->self_scm (), SCM_UNDEFINED);
1446 $$ = new Sequential_music (ms);
1449 THIS->remember_spot ();
1452 optional_notemode_duration {
1453 if (!THIS->lexer_p_->lyric_state_b ()) {
1454 THIS->pop_spot ().error (_ ("Have to be in Lyric mode for lyrics"));
1455 THIS->error_level_i_ = 1;
1456 THIS->parser_error (_ ("Giving up"));
1460 Lyric_req* lreq_p = new Lyric_req;
1461 lreq_p->set_mus_property ("text", $1);
1462 lreq_p->duration_ = *$3;
1463 lreq_p->set_spot (THIS->here_input());
1464 Simultaneous_music* velt_p = new Request_chord (gh_list (lreq_p->self_scm (), SCM_UNDEFINED));
1471 if (!THIS->lexer_p_->chord_state_b ())
1472 THIS->parser_error (_ ("Have to be in Chord mode for chords"));
1479 steno_tonic_pitch optional_notemode_duration chord_additions chord_subtractions chord_inversion chord_bass {
1480 $$ = get_chord (*$1, $3, $4, $5, $6, *$2);
1481 $$->set_spot (THIS->here_input ());
1486 $$ = new Array<Musical_pitch>;
1488 | CHORD_COLON chord_notes {
1497 | chord_notes '.' chord_step {
1505 $$ = new Array<Musical_pitch>;
1507 | CHORD_CARET chord_notes {
1517 | '/' steno_tonic_pitch {
1519 $$->set_spot (THIS->here_input ());
1527 | CHORD_BASS steno_tonic_pitch {
1529 $$->set_spot (THIS->here_input ());
1535 $$ = new Array<Musical_pitch>;
1538 | CHORDMODIFIER_PITCH {
1539 $$ = new Array<Musical_pitch>;
1542 | CHORDMODIFIER_PITCH chord_note { /* Ugh. */
1543 $$ = new Array<Musical_pitch>;
1551 $$ = new Musical_pitch;
1552 $$->notename_i_ = ($1 - 1) % 7;
1553 $$->octave_i_ = $1 > 7 ? 1 : 0;
1554 $$->accidental_i_ = 0;
1556 | bare_unsigned '+' {
1557 $$ = new Musical_pitch;
1558 $$->notename_i_ = ($1 - 1) % 7;
1559 $$->octave_i_ = $1 > 7 ? 1 : 0;
1560 $$->accidental_i_ = 1;
1562 | bare_unsigned CHORD_MINUS {
1563 $$ = new Musical_pitch;
1564 $$->notename_i_ = ($1 - 1) % 7;
1565 $$->octave_i_ = $1 > 7 ? 1 : 0;
1566 $$->accidental_i_ = -1;
1577 | '-' number_expression %prec UNARY_MINUS {
1578 $$ = scm_difference ($2, SCM_UNDEFINED);
1580 | number_expression '*' number_expression {
1581 $$ = scm_product ($1, $3);
1583 | number_expression '/' number_expression {
1584 $$ = scm_divide ($1, $3);
1586 | number_expression '+' number_expression {
1587 $$ = scm_sum ($1, $3);
1589 | number_expression '-' number_expression {
1590 $$ = scm_difference ($1, $3);
1592 | '(' number_expression ')' {
1599 $$ = gh_int2scm ($1);
1602 $$ = gh_int2scm ($1);
1605 $$ = gh_double2scm ($1);
1607 | NUMBER_IDENTIFIER {
1611 $$ = gh_double2scm ($1 CM);
1614 $$ = gh_double2scm ($1 PT);
1617 $$ = gh_double2scm ($1 INCH);
1620 $$ = gh_double2scm ($1 MM);
1623 $$ = gh_double2scm ($1 CHAR);
1630 if (scm_integer_p ($1) == SCM_BOOL_T) {
1631 $$ = gh_scm2int ($1);
1634 THIS->parser_error (_("need integer number arg"));
1638 THIS->parser_error (_("Must be positive integer"));
1646 if (scm_integer_p ($1) == SCM_BOOL_T)
1648 int k = gh_scm2int ($1);
1652 THIS->parser_error (_("need integer number arg"));
1666 | STRING_IDENTIFIER {
1669 | string '+' string {
1670 $$ = scm_string_append (scm_listify ($1, $3, SCM_UNDEFINED));
1677 | exclamations '!' { $$ ++; }
1682 | questions '?' { $$ ++; }
1693 My_lily_parser::set_yydebug (bool b)
1700 extern My_lily_parser * current_parser;
1703 My_lily_parser::do_yyparse ()
1706 current_parser = this;;
1707 yyparse ((void*)this);