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
182 %token OVERRIDE SET REVERT
195 %token COMMANDSPANREQUEST
197 %token OUTPUTPROPERTY
206 %token E_CHAR E_EXCLAMATION E_SMALLER E_BIGGER
207 %token CHORD_BASS CHORD_COLON CHORD_MINUS CHORD_CARET
209 %type <i> exclamations questions dots
211 %token <scm> NOTENAME_PITCH
212 %token <scm> TONICNAME_PITCH
213 %token <scm> CHORDMODIFIER_PITCH
214 %token <scm> DURATION_IDENTIFIER
215 %token <id> IDENTIFIER
218 %token <id> SCORE_IDENTIFIER
219 %token <id> MUSIC_OUTPUT_DEF_IDENTIFIER
221 %token <scm> NUMBER_IDENTIFIER
222 %token <scm> REQUEST_IDENTIFIER
223 %token <scm> MUSIC_IDENTIFIER TRANSLATOR_IDENTIFIER
224 %token <scm> STRING_IDENTIFIER SCM_IDENTIFIER
225 %token <scm> RESTNAME
231 %type <outputdef> output_def
232 %type <scope> lilypond_header lilypond_header_body
233 %type <request> open_request_parens close_request_parens open_request close_request
234 %type <request> request_with_dir request_that_take_dir verbose_request
235 %type <i> sub_quotes sup_quotes
236 %type <music> simple_element request_chord command_element Simple_music Composite_music
237 %type <music> Alternative_music Repeated_music
238 %type <i> tremolo_type
239 %type <i> bare_int bare_unsigned
242 %type <scm> identifier_init
244 %type <scm> steno_duration optional_notemode_duration
245 %type <scm> entered_notemode_duration explicit_duration
247 %type <reqvec> pre_requests post_requests
248 %type <request> gen_text_def
249 %type <scm> steno_musical_pitch musical_pitch absolute_musical_pitch
250 %type <scm> steno_tonic_pitch
252 %type <scm> chord_additions chord_subtractions chord_notes chord_step
254 %type <scm> chord_note chord_inversion chord_bass
255 %type <scm> duration_length
257 %type <scm> embedded_scm scalar
258 %type <music> Music Sequential_music Simultaneous_music Music_sequence
259 %type <music> relative_music re_rhythmed_music part_combined_music
260 %type <music> property_def translator_change
261 %type <scm> Music_list
262 %type <outputdef> music_output_def_body
263 %type <request> shorthand_command_req
264 %type <request> post_request
265 %type <music> command_req verbose_command_req
266 %type <request> extender_req
267 %type <request> hyphen_req
268 %type <scm> string bare_number number_expression
269 %type <score> score_block score_body
271 %type <scm> translator_spec_block translator_spec_body
272 %type <tempo> tempo_request
273 %type <scm> notenames_body notenames_block chordmodifiers_block
274 %type <scm> script_abbreviation
284 lilypond: /* empty */
285 | lilypond toplevel_expression {}
286 | lilypond assignment { }
288 THIS->error_level_i_ = 1;
289 //THIS->parser_error (_ ("ly invalid"));
292 THIS->error_level_i_ = 1;
293 //THIS->parser_error (_ ("ly invalid"));
299 THIS->lexer_p_->pitchname_tab_ = $1;
301 | chordmodifiers_block {
302 THIS->lexer_p_->chordmodifier_tab_ = $1;
305 delete header_global_p;
306 header_global_p = $1;
309 score_global_array.push ($1);
312 Identifier * id = new
313 Music_output_def_identifier ($1, MUSIC_OUTPUT_DEF_IDENTIFIER);
314 if (dynamic_cast<Paper_def*> ($1))
315 THIS->lexer_p_->set_identifier ("$defaultpaper", id->self_scm ());
316 else if (dynamic_cast<Midi_def*> ($1))
317 THIS->lexer_p_->set_identifier ("$defaultmidi", id->self_scm ());
330 chordmodifiers_block:
331 CHORDMODIFIERS notenames_body { $$ = $2; }
336 PITCHNAMES notenames_body { $$ = $2; }
343 int i = scm_ilength ($1);
345 SCM tab = scm_make_vector (gh_int2scm (i), SCM_EOL);
346 for (SCM s = $1; gh_pair_p (s); s = gh_cdr (s)) {
347 SCM pt = gh_cdar (s);
348 if (!unsmob_pitch (pt))
349 THIS->parser_error ("Need pitch object.");
351 scm_hashq_set_x (tab, gh_caar(s), pt);
358 lilypond_header_body:
361 THIS->lexer_p_-> scope_l_arr_.push ($$);
363 | lilypond_header_body assignment semicolon {
369 HEADER '{' lilypond_header_body '}' {
371 THIS->lexer_p_-> scope_l_arr_.pop ();
381 THIS->remember_spot ();
383 /* cont */ '=' identifier_init {
384 THIS->lexer_p_->set_identifier (ly_scm2string ($1), $4);
387 TODO: devise standard for protection in parser.
389 The parser stack lives on the C-stack, which means that
390 all objects can be unprotected as soon as they're here.
393 Identifier * id =unsmob_identifier ($4);
394 Input spot = THIS->pop_spot ();
395 if (id) id->set_spot (spot);
403 $$ = (new Score_identifier ($1, SCORE_IDENTIFIER))->self_scm();
406 $$ = (new Music_output_def_identifier ($1, MUSIC_OUTPUT_DEF_IDENTIFIER))->self_scm();
408 | translator_spec_block {
412 $$ = $1->self_scm ();
413 scm_unprotect_object ($$);
416 $$ = $1->self_scm ();
417 scm_unprotect_object ($$);
419 | explicit_duration {
422 | number_expression {
433 translator_spec_block:
434 TRANSLATOR '{' translator_spec_body '}'
440 translator_spec_body:
441 TRANSLATOR_IDENTIFIER {
442 $$ = unsmob_translator_def ($1)->clone_scm ();
443 unsmob_translator_def ($$)-> set_spot (THIS->here_input ());
445 | TYPE STRING semicolon {
446 $$ = Translator_def::make_scm ();
447 Translator_def*td = unsmob_translator_def ($$);
448 td->translator_group_type_ = $2;
449 td->set_spot (THIS->here_input ());
451 | translator_spec_body STRING '=' embedded_scm {
452 unsmob_translator_def ($$)->add_property_assign ($2, $4);
454 | translator_spec_body STRING OVERRIDE embedded_scm '=' embedded_scm {
455 unsmob_translator_def ($$)
456 ->add_push_property (scm_string_to_symbol ($2), $4, $6);
458 | translator_spec_body STRING REVERT embedded_scm {
459 unsmob_translator_def($$)->add_pop_property (
460 scm_string_to_symbol ($2), $4);
462 | translator_spec_body STRING '=' identifier_init semicolon {
463 SCM v = gh_int2scm (0);
464 if (gh_string_p ($4) || gh_number_p ($4) || gh_boolean_p ($4))
467 THIS->parser_error (_("Wrong type for property value"));
470 unsmob_translator_def($$)->add_property_assign ($2, v);
472 | translator_spec_body NAME STRING semicolon {
473 unsmob_translator_def ($$)->type_name_ = $3;
475 | translator_spec_body CONSISTS STRING semicolon {
476 unsmob_translator_def ($$)->add_element ($3);
478 | translator_spec_body ELEMENTDESCRIPTIONS embedded_scm {
479 for (SCM p = $3; gh_pair_p (p); p = gh_cdr (p))
480 unsmob_translator_def ($$)
481 ->add_property_assign (scm_symbol_to_string (gh_caar (p)), gh_cdar (p));
484 | translator_spec_body CONSISTSEND STRING semicolon {
485 unsmob_translator_def ($$)->add_last_element ( $3);
487 | translator_spec_body ACCEPTS STRING semicolon {
488 unsmob_translator_def ($$)->set_acceptor ($3,true);
490 | translator_spec_body DENIES STRING semicolon {
491 unsmob_translator_def ($$)->set_acceptor ($3,false);
493 | translator_spec_body REMOVE STRING semicolon {
494 unsmob_translator_def ($$)->remove_element ($3);
503 THIS->remember_spot ();
505 /*cont*/ '{' score_body '}' {
508 if (!$$->def_p_arr_.size ())
511 unsmob_identifier (THIS->lexer_p_->lookup_identifier ("$defaultpaper"));
512 $$->add_output (id ? id->access_content_Music_output_def (true) : new Paper_def );
516 | SCORE '{' score_body error {
518 $$->set_spot (THIS->here_input ());
519 // THIS->here_input ().error ("SCORE INVALID");
520 $$->error ("SCORE INVALID");
521 THIS->parser_error (_f ("SCORE ERROR"));
530 $$->set_spot (THIS->here_input ());
531 SCM m = $1->self_scm ();
532 scm_unprotect_object (m);
536 $$ = $1->access_content_Score (true);
538 | score_body lilypond_header {
541 | score_body output_def {
554 music_output_def_body '}' {
556 THIS-> lexer_p_-> scope_l_arr_.pop();
560 music_output_def_body:
562 Identifier *id = unsmob_identifier (THIS->lexer_p_->lookup_identifier ("$defaultmidi"));
567 p = dynamic_cast<Midi_def*> (id->access_content_Music_output_def (true));
572 THIS->lexer_p_->scope_l_arr_.push (p->scope_p_);
575 Identifier *id = unsmob_identifier (THIS->lexer_p_->lookup_identifier ("$defaultpaper"));
578 p = dynamic_cast<Paper_def*> (id->access_content_Music_output_def (true));
581 THIS-> lexer_p_-> scope_l_arr_.push (p->scope_p_);
584 | PAPER '{' MUSIC_OUTPUT_DEF_IDENTIFIER {
585 Music_output_def *p = $3->access_content_Music_output_def (true);
586 THIS->lexer_p_->scope_l_arr_.push (p->scope_p_);
589 | MIDI '{' MUSIC_OUTPUT_DEF_IDENTIFIER {
590 Music_output_def *p = $3->access_content_Music_output_def (true);
591 THIS->lexer_p_->scope_l_arr_.push (p->scope_p_);
594 | music_output_def_body assignment semicolon {
597 | music_output_def_body translator_spec_block {
598 $$->assign_translator ($2);
600 | music_output_def_body STYLESHEET embedded_scm {
601 dynamic_cast<Paper_def*> ($$)-> style_sheet_ = $3;
603 | music_output_def_body tempo_request semicolon {
605 junk this ? there already is tempo stuff in
608 int m = gh_scm2int ( $2->get_mus_property ("metronome-count"));
609 Duration *d = unsmob_duration ($2->get_mus_property ("duration"));
610 dynamic_cast<Midi_def*> ($$)->set_tempo (d->length_mom (), m);
612 | music_output_def_body error {
618 TEMPO steno_duration '=' bare_unsigned {
620 $$->set_mus_property ("duration", $2);
621 $$->set_mus_property ("metronome-count", gh_int2scm ( $4));
625 Music_list: /* empty */ {
626 $$ = gh_cons (SCM_EOL, SCM_EOL);
630 SCM c = gh_cons ($2->self_scm (), SCM_EOL);
631 scm_unprotect_object ($2->self_scm ()); /* UGH */
634 if (gh_pair_p (gh_cdr (s)))
635 gh_set_cdr_x (gh_cdr (s), c); /* append */
637 gh_set_car_x (s, c); /* set first cons */
638 gh_set_cdr_x (s, c) ; /* remember last cell */
654 | ALTERNATIVE Music_sequence {
656 $2->set_spot (THIS->here_input ());
664 REPEAT STRING bare_unsigned Music Alternative_music
666 Music_sequence* m = dynamic_cast <Music_sequence*> ($5);
667 if (m && $3 < m->length_i ())
668 $5->origin ()->warning (_ ("More alternatives than repeats. Junking excess alternatives."));
670 SCM func = scm_eval2 (ly_symbol2scm ("repeat-name-to-ctor"), SCM_EOL);
671 SCM result = gh_call1 (func, $2);
672 Repeated_music * r = new Repeated_music ($4, $3 >? 1, m);
673 set_music_properties (r, result);
675 r->set_spot (*$4->origin ());
680 Music_sequence: '{' Music_list '}' {
681 $$ = new Music_sequence (gh_car ($2));
686 SEQUENTIAL '{' Music_list '}' {
687 $$ = new Sequential_music (gh_car ($3));
689 | '{' Music_list '}' {
690 $$ = new Sequential_music (gh_car ($2));
695 SIMULTANEOUS '{' Music_list '}'{
696 $$ = new Simultaneous_music (gh_car ($3));
698 | '<' Music_list '>' {
699 $$ = new Simultaneous_music (gh_car ($2));
704 request_chord { $$ = $1; }
705 | OUTPUTPROPERTY embedded_scm embedded_scm '=' embedded_scm {
707 if (!gh_symbol_p ($3))
709 THIS->parser_error (_("Second argument must be a symbol"));
711 /*hould check # args */
712 if (!gh_procedure_p (pred))
714 THIS->parser_error (_("First argument must be a procedure taking 1 argument"));
717 Music *m = new Music;
718 m->set_mus_property ("predicate", pred);
719 m->set_mus_property ("symbol", $3);
720 m->set_mus_property ("value", $5);
721 m->set_mus_property ("iterator-ctor",
722 Output_property_music_iterator::constructor_cxx_function);
727 $$ = unsmob_music ($1)->clone ();
731 | Simple_music '*' bare_unsigned '/' bare_unsigned {
733 $$->compress (Moment($3, $5 ));
735 | Simple_music '*' bare_unsigned {
737 $$->compress (Moment ($3, 1));
743 CONTEXT STRING Music {
744 Context_specced_music *csm = new Context_specced_music ($3);
746 csm->set_mus_property ("context-type",$2);
747 csm->set_mus_property ("context-id", ly_str02scm (""));
751 | AUTOCHANGE STRING Music {
752 Auto_change_music * chm = new Auto_change_music ($3);
753 chm->set_mus_property ("what", $2);
756 chm->set_spot (*$3->origin ());
759 $$ = new Grace_music ($2);
761 | CONTEXT STRING '=' STRING Music {
762 Context_specced_music *csm = new Context_specced_music ($5);
764 csm->set_mus_property ("context-type", $2);
765 csm->set_mus_property ("context-id", $4);
770 THIS->remember_spot ();
773 bare_unsigned '/' bare_unsigned Music
776 $$ = new Time_scaled_music ($3, $5, $6);
777 $$->set_spot (THIS->pop_spot ());
779 | Repeated_music { $$ = $1; }
780 | Simultaneous_music { $$ = $1; }
781 | Sequential_music { $$ = $1; }
782 | TRANSPOSE musical_pitch Music {
783 $$ = new Transposed_music ($3, *unsmob_pitch ($2));
785 | TRANSPOSE steno_tonic_pitch Music {
786 $$ = new Transposed_music ($3, *unsmob_pitch ($2));
788 | APPLY embedded_scm Music {
789 SCM ret = gh_call1 ($2, $3->self_scm ());
790 Music *m = unsmob_music (ret);
792 THIS->parser_error ("\\apply must return a Music");
798 { THIS->lexer_p_->push_note_state (); }
801 THIS->lexer_p_->pop_state ();
804 { THIS->lexer_p_->push_chord_state (); }
808 THIS->lexer_p_->pop_state ();
811 { THIS->lexer_p_->push_lyric_state (); }
815 THIS->lexer_p_->pop_state ();
817 | relative_music { $$ = $1; }
818 | re_rhythmed_music { $$ = $1; }
819 | part_combined_music { $$ = $1; }
823 RELATIVE absolute_musical_pitch Music {
824 $$ = new Relative_octave_music ($3, *unsmob_pitch ($2));
829 ADDLYRICS Music Music {
830 Lyric_combine_music * l = new Lyric_combine_music ($2, $3);
836 PARTCOMBINE STRING Music Music {
837 Part_combine_music * p = new Part_combine_music ($2, $3, $4);
843 TRANSLATOR STRING '=' STRING {
844 Music * t = new Music;
845 t->set_mus_property ("iterator-ctor",
846 Change_iterator::constructor_cxx_function);
847 t-> set_mus_property ("change-to-type", $2);
848 t-> set_mus_property ("change-to-id", $4);
851 $$->set_spot (THIS->here_input ());
856 PROPERTY STRING '.' STRING '=' scalar {
857 Music *t = new Music;
859 t->set_mus_property ("iterator-ctor",
860 Property_iterator::constructor_cxx_function);
861 t->set_mus_property ("symbol", scm_string_to_symbol ($4));
862 t->set_mus_property ("value", $6);
864 Context_specced_music *csm = new Context_specced_music (t);
866 $$->set_spot (THIS->here_input ());
868 csm-> set_mus_property ("context-type", $2);
870 | PROPERTY STRING '.' STRING SET embedded_scm '=' embedded_scm {
871 Music *t = new Music;
872 t->set_mus_property ("iterator-ctor",
873 Push_property_iterator::constructor_cxx_function);
874 t->set_mus_property ("symbols", scm_string_to_symbol ($4));
875 t->set_mus_property ("pop-first", SCM_BOOL_T);
876 t->set_mus_property ("grob-property", $6);
877 t->set_mus_property ("grob-value", $8);
878 Context_specced_music *csm = new Context_specced_music (t);
880 $$->set_spot (THIS->here_input ());
882 csm-> set_mus_property ("context-type", $2);
884 | PROPERTY STRING '.' STRING OVERRIDE embedded_scm '=' embedded_scm {
885 Music *t = new Music;
886 t->set_mus_property ("iterator-ctor",
887 Push_property_iterator::constructor_cxx_function);
888 t->set_mus_property ("symbols", scm_string_to_symbol ($4));
889 t->set_mus_property ("grob-property", $6);
890 t->set_mus_property ("grob-value", $8);
891 Context_specced_music *csm = new Context_specced_music (t);
893 $$->set_spot (THIS->here_input ());
895 csm-> set_mus_property ("context-type", $2);
897 | PROPERTY STRING '.' STRING REVERT embedded_scm {
898 Music *t = new Music;
899 t->set_mus_property ("iterator-ctor",
900 Pop_property_iterator::constructor_cxx_function);
901 t->set_mus_property ("symbols", scm_string_to_symbol ($4));
902 t->set_mus_property ("grob-property", $6);
904 Context_specced_music *csm = new Context_specced_music (t);
906 $$->set_spot (THIS->here_input ());
908 csm-> set_mus_property ("context-type", $2);
914 | bare_int { $$ = gh_int2scm ($1); }
915 | embedded_scm { $$ = $1; }
920 pre_requests simple_element post_requests {
921 Music_sequence *l = dynamic_cast<Music_sequence*>($2);
923 for (int i=0; i < $1->size(); i++)
924 l->append_music ($1->elem(i));
925 for (int i=0; i < $3->size(); i++)
926 l->append_music ($3->elem(i));
929 programming_error ("Need Sequence to add music to");
938 $$ = new Request_chord (gh_cons ($1->self_scm (), SCM_EOL));
939 $$-> set_spot (THIS->here_input ());
940 $1-> set_spot (THIS->here_input ());
943 Music *t = new Music;
945 t->set_mus_property ("iterator-ctor",
946 Property_iterator::constructor_cxx_function);
947 t->set_mus_property ("symbol", ly_symbol2scm ("whichBar"));
948 t->set_mus_property ("value", $2);
950 Context_specced_music *csm = new Context_specced_music (t);
952 $$->set_spot (THIS->here_input ());
954 csm->set_mus_property ("context-type", ly_str02scm ("Score"));
956 | PARTIAL duration_length ';' {
957 Music * p = new Music;
958 p->set_mus_property ("symbol", ly_symbol2scm ( "measurePosition"));
959 p->set_mus_property ("iterator-ctor",
960 Property_iterator::constructor_cxx_function);
962 Moment m = - unsmob_duration($2)->length_mom ();
963 p->set_mus_property ("value", m.smobbed_copy ());
965 Context_specced_music * sp = new Context_specced_music (p);
967 sp-> set_mus_property ("context-type", ly_str02scm ( "Score"));
970 SCM func = scm_eval2 (ly_symbol2scm ("clef-name-to-properties"), SCM_EOL);
971 SCM result = gh_call1 (func, $2);
974 for (SCM s = result ; gh_pair_p (s); s = gh_cdr (s)) {
975 Music * p = new Music;
976 set_music_properties(p, gh_car (s));
977 l = gh_cons (p->self_scm (), l);
978 scm_unprotect_object (p->self_scm ());
980 Sequential_music * seq = new Sequential_music (l);
982 Context_specced_music * sp = new Context_specced_music (seq);
984 sp-> set_mus_property("context-type", ly_str02scm("Staff"));
986 | TIME_T bare_unsigned '/' bare_unsigned ';' {
987 Music * p = new Music;
988 p->set_mus_property ("symbol",
989 ly_symbol2scm ( "timeSignatureFraction"));
990 p->set_mus_property ("iterator-ctor",
991 Property_iterator::constructor_cxx_function);
993 p->set_mus_property ("value", gh_cons (gh_int2scm ($2),
996 Context_specced_music * sp = new Context_specced_music (p);
998 sp-> set_mus_property ("context-type", ly_str02scm ( "Score"));
1003 shorthand_command_req { $$ = $1; }
1004 | verbose_command_req semicolon { $$ = $1; }
1007 shorthand_command_req:
1015 $$ = new Barcheck_req;
1021 Span_req*b= new Span_req;
1022 b->set_span_dir(START);
1023 b->set_mus_property ("span-type", ly_str02scm ("beam"));
1027 Span_req*b= new Span_req;
1028 b->set_span_dir( STOP);
1029 b->set_mus_property ("span-type", ly_str02scm ("beam"));
1033 $$ = new Breathing_sign_req;
1038 verbose_command_req:
1039 COMMANDSPANREQUEST bare_int STRING {
1040 Span_req * sp_p = new Span_req;
1041 sp_p-> set_span_dir ( Direction($2));
1042 sp_p->set_mus_property ("span-type",$3);
1043 sp_p->set_spot (THIS->here_input ());
1047 Mark_req * m = new Mark_req;
1051 Mark_req *m = new Mark_req;
1052 m->set_mus_property ("label", $2);
1056 | MARK bare_unsigned {
1057 Mark_req *m = new Mark_req;
1058 m->set_mus_property ("label", gh_int2scm ($2));
1061 | PENALTY bare_int {
1062 Break_req * b = new Break_req;
1063 b->set_mus_property ("penalty", gh_double2scm ( $2 / 100.0));
1064 b->set_spot (THIS->here_input ());
1067 | SKIP duration_length {
1068 Skip_req * skip_p = new Skip_req;
1069 skip_p->set_mus_property ("duration", $2);
1077 Key_change_req *key_p= new Key_change_req;
1080 | KEY NOTENAME_PITCH SCM_IDENTIFIER {
1081 Key_change_req *key_p= new Key_change_req;
1083 key_p->set_mus_property ("pitch-alist", $3);
1084 ((Music* )key_p)->transpose (* unsmob_pitch ($2));
1091 $$ = new Link_array<Request>;
1093 | post_requests post_request {
1094 $2->set_spot (THIS->here_input ());
1106 request_that_take_dir:
1109 | script_abbreviation {
1110 SCM s = THIS->lexer_p_->lookup_identifier ("dash-" + ly_scm2string ($1));
1111 Articulation_req *a = new Articulation_req;
1112 if (gh_string_p (s))
1113 a->set_mus_property ("articulation-type", s);
1114 else THIS->parser_error (_ ("Expecting string as script definition"));
1120 script_dir request_that_take_dir {
1121 if (Script_req * gs = dynamic_cast<Script_req*> ($2))
1122 gs->set_direction (Direction ($1));
1124 $2->origin ()->warning (_ ("Can't specify direction for this request"));
1130 REQUEST_IDENTIFIER {
1131 $$ = dynamic_cast<Request*> (unsmob_music ($1)->clone ());
1132 $$->set_spot (THIS->here_input ());
1134 | DYNAMICSCRIPT embedded_scm {
1136 TODO: junkme, use text-type == dynamic
1138 Text_script_req *d = new Text_script_req;
1139 d->set_mus_property ("text-type" , ly_symbol2scm ("dynamic"));
1140 d->set_mus_property ("text", $2);
1141 d->set_spot (THIS->here_input ());
1144 | TEXTSCRIPT embedded_scm {
1145 Text_script_req *t = new Text_script_req;
1146 t->set_mus_property ("text", $2);
1147 t->set_spot (THIS->here_input ());
1150 | SPANREQUEST bare_int STRING {
1151 Span_req * sp_p = new Span_req;
1152 sp_p->set_span_dir( Direction($2));
1153 sp_p->set_mus_property ("span-type", $3);
1154 sp_p->set_spot (THIS->here_input ());
1158 Tremolo_req* a = new Tremolo_req;
1159 a->set_spot (THIS->here_input ());
1160 a->set_mus_property ("tremolo-type", gh_int2scm ($1));
1164 Articulation_req * a = new Articulation_req;
1165 a->set_mus_property ("articulation-type", $2);
1166 a->set_spot (THIS->here_input ());
1170 Arpeggio_req *a = new Arpeggio_req;
1171 a->set_spot (THIS->here_input ());
1175 Glissando_req *g = new Glissando_req;
1176 g->set_spot /* No pun intended */ (THIS->here_input ());
1199 steno_musical_pitch:
1203 | NOTENAME_PITCH sup_quotes {
1204 Pitch p = *unsmob_pitch ($1);
1206 $$ = p.smobbed_copy ();
1208 | NOTENAME_PITCH sub_quotes {
1209 Pitch p =* unsmob_pitch ($1);
1212 $$ = p.smobbed_copy ();
1225 | TONICNAME_PITCH sup_quotes {
1226 Pitch p = *unsmob_pitch ($1);
1228 $$ = p.smobbed_copy ();
1230 | TONICNAME_PITCH sub_quotes {
1231 Pitch p =* unsmob_pitch ($1);
1234 $$ = p.smobbed_copy ();
1240 steno_musical_pitch {
1243 | MUSICAL_PITCH embedded_scm {
1244 if (!unsmob_pitch ($2))
1245 THIS->parser_error (_f ("Expecting musical-pitch value", 3));
1247 $$ = m.smobbed_copy ();
1252 DURATION embedded_scm {
1254 if (!unsmob_duration ($2))
1256 THIS->parser_error (_("Must have duration object"));
1257 $$ = Duration ().smobbed_copy ();
1264 if (!THIS->lexer_p_->lyric_state_b ())
1265 THIS->parser_error (_ ("Have to be in Lyric mode for lyrics"));
1266 $$ = new Extender_req;
1272 if (!THIS->lexer_p_->lyric_state_b ())
1273 THIS->parser_error (_ ("Have to be in Lyric mode for lyrics"));
1274 $$ = new Hyphen_req;
1279 close_request_parens {
1281 dynamic_cast<Span_req*> ($$)->set_span_dir ( START);
1284 close_request_parens:
1286 Span_req* s= new Span_req;
1288 s->set_mus_property ("span-type", ly_str02scm( "slur"));
1291 Span_req*s =new Span_req;
1293 s->set_mus_property ("span-type", ly_str02scm ( "crescendo"));
1296 Span_req*s =new Span_req;
1298 s->set_mus_property ("span-type", ly_str02scm ("decrescendo"));
1304 open_request_parens {
1306 dynamic_cast<Span_req*> ($$)->set_span_dir (STOP);
1310 open_request_parens:
1312 Span_req *s = new Span_req;
1313 s->set_mus_property ("span-type", ly_str02scm ( "crescendo"));
1318 Span_req* s= new Span_req;
1320 s->set_mus_property ("span-type", ly_str02scm( "slur"));
1326 Text_script_req *t = new Text_script_req;
1327 t->set_mus_property ("text", $1);
1328 t->set_spot (THIS->here_input ());
1332 Text_script_req *t = new Text_script_req;
1333 t->set_mus_property ("text", $1);
1334 t->set_spot (THIS->here_input ());
1338 String ds = to_str ($1);
1339 Text_script_req* t = new Text_script_req;
1341 t->set_mus_property ("text", ly_str02scm (ds.ch_C()));
1342 t->set_mus_property ("text-type" , ly_symbol2scm ("finger"));
1343 t->set_spot (THIS->here_input ());
1348 script_abbreviation:
1350 $$ = gh_str02scm ("hat");
1353 $$ = gh_str02scm("plus");
1356 $$ = gh_str02scm ("dash");
1359 $$ = gh_str02scm ("bar");
1362 $$ = gh_str02scm ("larger");
1365 $$ = gh_str02scm ("dot");
1373 | '-' { $$ = CENTER; }
1378 $$ = new Link_array<Request>;
1380 | pre_requests open_request {
1385 absolute_musical_pitch:
1386 steno_musical_pitch {
1395 | duration_length '*' bare_unsigned {
1396 $$ = unsmob_duration ($$)->compressed ( $3) .smobbed_copy ();
1398 | duration_length '/' bare_unsigned {
1399 $$ = unsmob_duration ($$)->compressed (Moment (1,$3)).smobbed_copy ();
1403 entered_notemode_duration:
1405 THIS->set_last_duration (unsmob_duration ($1));
1409 optional_notemode_duration:
1411 $$ = THIS->default_duration_.smobbed_copy ();
1413 | entered_notemode_duration {
1419 bare_unsigned dots {
1421 if (!is_duration_b ($1))
1422 THIS->parser_error (_f ("not a duration: %d", $1));
1426 $$ = Duration (l, $2).smobbed_copy ();
1428 | DURATION_IDENTIFIER dots {
1429 Duration *d =unsmob_duration ($1);
1430 Duration k (d->duration_log (),d->dot_count () + $2);
1431 $$ = k.smobbed_copy ();
1449 | ':' bare_unsigned {
1450 if (!is_duration_b ($2))
1451 THIS->parser_error (_f ("not a duration: %d", $2));
1458 musical_pitch exclamations questions optional_notemode_duration {
1459 if (!THIS->lexer_p_->note_state_b ())
1460 THIS->parser_error (_ ("Have to be in Note mode for notes"));
1462 Note_req *n = new Note_req;
1464 n->set_mus_property ("pitch", $1);
1465 n->set_mus_property ("duration", $4);
1468 n->set_mus_property ("cautionary", SCM_BOOL_T);
1469 if ($2 % 2 || $3 % 2)
1470 n->set_mus_property ("force-accidental", SCM_BOOL_T);
1472 Simultaneous_music*v = new Request_chord (gh_list (n->self_scm (), SCM_UNDEFINED));
1477 v->set_spot (THIS->here_input ());
1478 n->set_spot (THIS->here_input ());
1482 | RESTNAME optional_notemode_duration {
1484 SCM e = SCM_UNDEFINED;
1485 if (ly_scm2string ($1) =="s")
1487 Skip_req * skip_p = new Skip_req;
1488 skip_p->set_mus_property ("duration" ,$2);
1490 skip_p->set_spot (THIS->here_input());
1491 e = skip_p->self_scm ();
1495 Rest_req * rest_req_p = new Rest_req;
1496 rest_req_p->set_mus_property ("duration", $2);
1497 rest_req_p->set_spot (THIS->here_input());
1498 e = rest_req_p->self_scm ();
1500 Simultaneous_music* velt_p = new Request_chord (gh_list (e,SCM_UNDEFINED));
1501 velt_p->set_spot (THIS->here_input());
1506 | MEASURES optional_notemode_duration {
1507 Skip_req * sk = new Skip_req;
1508 sk->set_mus_property ("duration", $2);
1509 Span_req *sp1 = new Span_req;
1510 Span_req *sp2 = new Span_req;
1511 sp1-> set_span_dir ( START);
1512 sp2-> set_span_dir ( STOP);
1513 SCM r = ly_str02scm ("rest");
1514 sp1->set_mus_property ("span-type", r);
1515 sp2->set_mus_property ("span-type", r);
1517 Request_chord * rqc1 = new Request_chord (gh_list (sp1->self_scm (), SCM_UNDEFINED));
1518 Request_chord * rqc2 = new Request_chord (gh_list (sk->self_scm (), SCM_UNDEFINED));;
1519 Request_chord * rqc3 = new Request_chord(gh_list (sp2->self_scm (), SCM_UNDEFINED));;
1521 SCM ms = gh_list (rqc1->self_scm (), rqc2->self_scm (), rqc3->self_scm (), SCM_UNDEFINED);
1523 $$ = new Sequential_music (ms);
1526 THIS->remember_spot ();
1529 optional_notemode_duration {
1530 if (!THIS->lexer_p_->lyric_state_b ()) {
1531 THIS->pop_spot ().error (_ ("Have to be in Lyric mode for lyrics"));
1532 THIS->error_level_i_ = 1;
1533 THIS->parser_error (_ ("Giving up"));
1537 Lyric_req* lreq_p = new Lyric_req;
1538 lreq_p->set_mus_property ("text", $1);
1539 lreq_p->set_mus_property ("duration",$3);
1540 lreq_p->set_spot (THIS->here_input());
1541 Simultaneous_music* velt_p = new Request_chord (gh_list (lreq_p->self_scm (), SCM_UNDEFINED));
1548 if (!THIS->lexer_p_->chord_state_b ())
1549 THIS->parser_error (_ ("Have to be in Chord mode for chords"));
1556 steno_tonic_pitch optional_notemode_duration chord_additions chord_subtractions chord_inversion chord_bass {
1557 $$ = Chord::get_chord ($1, $3, $4, $5, $6, $2);
1558 $$->set_spot (THIS->here_input ());
1565 | CHORD_COLON chord_notes {
1574 | chord_notes '.' chord_step {
1575 $$ = gh_append2 ($$, $3);
1583 | CHORD_CARET chord_notes {
1593 | '/' steno_tonic_pitch {
1602 | CHORD_BASS steno_tonic_pitch {
1609 $$ = gh_cons ($1, SCM_EOL);
1611 | CHORDMODIFIER_PITCH {
1612 $$ = gh_cons ($1, SCM_EOL);
1614 | CHORDMODIFIER_PITCH chord_note { /* Ugh. */
1615 $$ = gh_list ($1, $2, SCM_UNDEFINED);
1622 m.notename_i_ = ($1 - 1) % 7;
1623 m.octave_i_ = $1 > 7 ? 1 : 0;
1624 m.alteration_i_ = 0;
1626 $$ = m.smobbed_copy ();
1628 | bare_unsigned '+' {
1630 m.notename_i_ = ($1 - 1) % 7;
1631 m.octave_i_ = $1 > 7 ? 1 : 0;
1632 m.alteration_i_ = 1;
1635 $$ = m.smobbed_copy ();
1637 | bare_unsigned CHORD_MINUS {
1639 m.notename_i_ = ($1 - 1) % 7;
1640 m.octave_i_ = $1 > 7 ? 1 : 0;
1641 m.alteration_i_ = -1;
1643 $$ = m.smobbed_copy ();
1654 | '-' number_expression %prec UNARY_MINUS {
1655 $$ = scm_difference ($2, SCM_UNDEFINED);
1657 | number_expression '*' number_expression {
1658 $$ = scm_product ($1, $3);
1660 | number_expression '/' number_expression {
1661 $$ = scm_divide ($1, $3);
1663 | number_expression '+' number_expression {
1664 $$ = scm_sum ($1, $3);
1666 | number_expression '-' number_expression {
1667 $$ = scm_difference ($1, $3);
1669 | '(' number_expression ')' {
1676 $$ = gh_int2scm ($1);
1679 $$ = gh_int2scm ($1);
1682 $$ = gh_double2scm ($1);
1684 | NUMBER_IDENTIFIER {
1688 $$ = gh_double2scm ($1 CM);
1691 $$ = gh_double2scm ($1 PT);
1694 $$ = gh_double2scm ($1 INCH);
1697 $$ = gh_double2scm ($1 MM);
1700 $$ = gh_double2scm ($1 CHAR);
1707 if (scm_integer_p ($1) == SCM_BOOL_T) {
1708 $$ = gh_scm2int ($1);
1711 THIS->parser_error (_("need integer number arg"));
1715 THIS->parser_error (_("Must be positive integer"));
1723 if (scm_integer_p ($1) == SCM_BOOL_T)
1725 int k = gh_scm2int ($1);
1729 THIS->parser_error (_("need integer number arg"));
1743 | STRING_IDENTIFIER {
1746 | string '+' string {
1747 $$ = scm_string_append (scm_listify ($1, $3, SCM_UNDEFINED));
1754 | exclamations '!' { $$ ++; }
1759 | questions '?' { $$ ++; }
1770 My_lily_parser::set_yydebug (bool b)
1777 extern My_lily_parser * current_parser;
1780 My_lily_parser::do_yyparse ()
1783 current_parser = this;;
1784 yyparse ((void*)this);