1 %{ // -*-Fundamental-*-
4 parser.yy -- Bison/C++ parser for lilypond
6 source file of the GNU LilyPond music typesetter
8 (c) 1997--2001 Han-Wen Nienhuys <hanwen@cs.uu.nl>
9 Jan Nieuwenhuizen <janneke@gnu.org>
13 Two shift/reduce problems:
20 the rules for who is protecting what are very shady. TODO: uniformise
29 #include "translator-def.hh"
30 #include "lily-guile.hh"
31 #include "change-iterator.hh"
33 #include "my-lily-lexer.hh"
34 #include "paper-def.hh"
35 #include "midi-def.hh"
37 #include "file-path.hh"
39 #include "dimensions.hh"
40 #include "command-request.hh"
41 #include "musical-request.hh"
42 #include "my-lily-parser.hh"
43 #include "context-specced-music.hh"
45 #include "music-list.hh"
46 #include "output-property-music-iterator.hh"
47 #include "property-iterator.hh"
48 #include "input-file-results.hh"
50 #include "relative-music.hh"
51 #include "lyric-combine-music.hh"
52 #include "transposed-music.hh"
53 #include "time-scaled-music.hh"
54 #include "repeated-music.hh"
55 #include "untransposable-music.hh"
56 #include "lilypond-input-version.hh"
57 #include "grace-music.hh"
58 #include "part-combine-music.hh"
59 #include "scm-hash.hh"
60 #include "auto-change-iterator.hh"
61 #include "un-relativable-music.hh"
63 #include "ly-modules.hh"
66 regular_identifier_b (SCM id)
68 String str = ly_scm2string (id);
69 char const *s = str.to_str0 () ;
74 v = v && isalpha (*s);
84 return t && t == 1 << intlog2 (t);
88 set_music_properties (Music *p, SCM a)
90 for (SCM k = a; gh_pair_p (k); k = ly_cdr (k))
92 p->internal_set_mus_property (ly_caar (k), ly_cdar (k));
100 parser_make_music (SCM sym)
102 if (!make_music_proc)
103 make_music_proc = scm_primitive_eval (ly_symbol2scm ("make-music-by-name"));
105 SCM rv = scm_call_1 (make_music_proc, sym);
110 scm_gc_protect_object (rv);
111 return unsmob_music (rv);
114 #define MY_MAKE_MUSIC(x) parser_make_music (ly_symbol2scm (x))
116 #define TYPED_MAKE_MUSIC(x,v,y) x *v = dynamic_cast<x*> (parser_make_music (ly_symbol2scm (y)));
121 set_property_music (SCM sym, SCM value)
123 Music * p = MY_MAKE_MUSIC("PropertySet");
124 p->set_mus_property ("symbol", sym);
125 p->set_mus_property ("value", value);
130 // needed for bison.simple's malloc () and free ()
132 // #include <malloc.h>
137 #define YYERROR_VERBOSE 1
139 #define YYPARSE_PARAM my_lily_parser
140 #define YYLEX_PARAM my_lily_parser
142 ((My_lily_parser *) my_lily_parser)
144 #define yyerror THIS->parser_error
148 /* We use SCMs to do strings, because it saves us the trouble of
149 deleting them. Let's hope that a stack overflow doesnt trigger a move
150 of the parse stack onto the heap. */
155 Link_array<Music> *reqvec;
157 String *string; // needed by the lexer as temporary scratch area.
160 Scheme_hash_table *scmhash;
161 Music_output_def * outputdef;
169 yylex (YYSTYPE *s, void * v)
171 My_lily_parser *pars = (My_lily_parser*) v;
172 My_lily_lexer * lex = pars->lexer_;
174 lex->lexval = (void*) s;
175 return lex->yylex ();
183 /* tokens which are not keywords */
193 %token CHORDMODIFIERS
201 %token GROBDESCRIPTIONS
207 %token FIGURES FIGURE_OPEN FIGURE_CLOSE
208 %token FIGURE_BRACKET_CLOSE FIGURE_BRACKET_OPEN
218 %token MULTI_MEASURE_REST
231 %token OVERRIDE SET REVERT
244 %token COMMANDSPANREQUEST
246 %token OUTPUTPROPERTY
257 %token E_CHAR E_EXCLAMATION E_SMALLER E_BIGGER E_OPEN E_CLOSE
258 %token E_LEFTSQUARE E_RIGHTSQUARE E_TILDE
260 %token <i> E_UNSIGNED
261 %token CHORD_BASS CHORD_COLON CHORD_MINUS CHORD_CARET CHORD_SLASH
264 %type <i> exclamations questions dots optional_rest
265 %type <i> bass_number bass_mod
266 %type <scm> br_bass_figure bass_figure figure_list figure_spec
268 %token <scm> NOTENAME_PITCH
269 %token <scm> TONICNAME_PITCH
270 %token <scm> CHORDMODIFIER_PITCH
271 %token <scm> DURATION_IDENTIFIER
272 %token <scm> FRACTION
273 %token <id> IDENTIFIER
276 %token <scm> SCORE_IDENTIFIER
277 %token <scm> MUSIC_OUTPUT_DEF_IDENTIFIER
279 %token <scm> NUMBER_IDENTIFIER
280 %token <scm> REQUEST_IDENTIFIER
281 %token <scm> MUSIC_IDENTIFIER TRANSLATOR_IDENTIFIER
282 %token <scm> STRING_IDENTIFIER SCM_IDENTIFIER
283 %token <scm> RESTNAME
289 %type <outputdef> output_def
290 %type <scm> lilypond_header lilypond_header_body
291 %type <music> open_request_parens close_request_parens open_request close_request
292 %type <music> request_with_dir request_that_take_dir verbose_request
293 %type <i> sub_quotes sup_quotes
294 %type <music> simple_element request_chord command_element Simple_music Composite_music
295 %type <music> Repeated_music
296 %type <scm> Alternative_music
297 %type <i> tremolo_type
298 %type <i> bare_int bare_unsigned
300 %type <scm> identifier_init
302 %type <scm> steno_duration optional_notemode_duration multiplied_duration
303 %type <scm> verbose_duration
305 %type <reqvec> pre_requests post_requests
306 %type <music> gen_text_def
307 %type <scm> steno_pitch pitch absolute_pitch
308 %type <scm> explicit_pitch steno_tonic_pitch
310 %type <scm> chord_additions chord_subtractions chord_notes chord_step
312 %type <scm> chord_note chord_inversion chord_bass
313 %type <scm> duration_length fraction
315 %type <scm> embedded_scm scalar
316 %type <music> Music Sequential_music Simultaneous_music
317 %type <music> relative_music re_rhythmed_music part_combined_music
318 %type <music> property_def translator_change simple_property_def
319 %type <scm> Music_list
320 %type <outputdef> music_output_def_body
321 %type <music> shorthand_command_req
322 %type <music> post_request
323 %type <music> command_req verbose_command_req
324 %type <music> extender_req
325 %type <music> hyphen_req
326 %type <music> string_request
327 %type <scm> string bare_number number_expression number_term number_factor
329 %type <score> score_block score_body
331 %type <scm> translator_spec_block translator_spec_body
332 %type <tempo> tempo_request
333 %type <scm> notenames_body notenames_block chordmodifiers_block
334 %type <scm> script_abbreviation
340 /* We don't assign precedence to / and *, because we might need varied
341 prec levels in different prods */
347 lilypond: /* empty */
348 | lilypond toplevel_expression {}
349 | lilypond assignment { }
351 THIS->error_level_ = 1;
354 THIS->error_level_ = 1;
360 THIS->lexer_->pitchname_tab_ = $1;
362 | chordmodifiers_block {
363 THIS->lexer_->chordmodifier_tab_ = $1;
366 THIS->input_file_->header_ = $1;
369 THIS->input_file_->scores_.push ($1);
372 if (dynamic_cast<Paper_def*> ($1))
373 THIS->lexer_->set_identifier (scm_makfrom0str ("$defaultpaper"), $1->self_scm ());
374 else if (dynamic_cast<Midi_def*> ($1))
375 THIS->lexer_->set_identifier (scm_makfrom0str ("$defaultmidi"), $1->self_scm ());
388 chordmodifiers_block:
389 CHORDMODIFIERS notenames_body { $$ = $2; }
393 PITCHNAMES notenames_body { $$ = $2; }
398 int i = scm_ilength ($1);
400 SCM tab = scm_make_vector (gh_int2scm (i), SCM_EOL);
401 for (SCM s = $1; gh_pair_p (s); s = ly_cdr (s)) {
402 SCM pt = ly_cdar (s);
403 if (!unsmob_pitch (pt))
404 THIS->parser_error ("Need pitch object.");
406 scm_hashq_set_x (tab, ly_caar (s), pt);
413 lilypond_header_body:
415 $$ = ly_make_anonymous_module ();
416 THIS->lexer_->add_scope ($$);
418 | lilypond_header_body assignment {
424 HEADER '{' lilypond_header_body '}' {
425 $$ = THIS->lexer_-> remove_scope();
437 /* cont */ '=' identifier_init {
440 Should find generic way of associating input with objects.
442 Input ip = THIS->pop_spot ();
444 if (! regular_identifier_b ($1))
446 ip.warning (_ ("Identifier should have alphabetic characters only"));
449 THIS->lexer_->set_identifier ($1, $4);
452 TODO: devise standard for protection in parser.
454 The parser stack lives on the C-stack, which means that
455 all objects can be unprotected as soon as they're here.
465 $$ = $1->self_scm ();
466 scm_gc_unprotect_object ($$);
469 $$ = $1->self_scm ();
470 scm_gc_unprotect_object ($$);
472 | translator_spec_block {
476 $$ = $1->self_scm ();
477 scm_gc_unprotect_object ($$);
480 $$ = $1->self_scm ();
481 scm_gc_unprotect_object ($$);
486 | number_expression {
497 translator_spec_block:
498 TRANSLATOR '{' translator_spec_body '}'
504 translator_spec_body:
505 TRANSLATOR_IDENTIFIER {
506 $$ = unsmob_translator_def ($1)->clone_scm ();
507 unsmob_translator_def ($$)-> set_spot (THIS->here_input ());
510 $$ = Translator_def::make_scm ();
511 Translator_def*td = unsmob_translator_def ($$);
512 td->translator_group_type_ = $2;
513 td->set_spot (THIS->here_input ());
515 | translator_spec_body STRING '=' embedded_scm {
516 unsmob_translator_def ($$)->add_property_assign ($2, $4);
518 | translator_spec_body STRING OVERRIDE embedded_scm '=' embedded_scm {
519 unsmob_translator_def ($$)
520 ->add_push_property (scm_string_to_symbol ($2), $4, $6);
522 | translator_spec_body STRING SET embedded_scm '=' embedded_scm {
523 unsmob_translator_def ($$)
524 ->add_push_property (scm_string_to_symbol ($2), $4, $6);
526 | translator_spec_body STRING REVERT embedded_scm {
527 unsmob_translator_def ($$)->add_pop_property (
528 scm_string_to_symbol ($2), $4);
530 | translator_spec_body NAME STRING {
531 unsmob_translator_def ($$)->type_name_ = $3;
533 | translator_spec_body CONSISTS STRING {
534 unsmob_translator_def ($$)->add_element ($3);
536 | translator_spec_body ALIAS STRING {
537 Translator_def*td = unsmob_translator_def ($$);
538 td->type_aliases_ = scm_cons ($3, td->type_aliases_);
540 | translator_spec_body GROBDESCRIPTIONS embedded_scm {
541 Translator_def*td = unsmob_translator_def($$);
542 // td->add_property_assign (ly_symbol2scm ("allGrobDescriptions"), $3);
543 for (SCM p = $3; gh_pair_p (p); p = ly_cdr (p))
544 td->add_property_assign (scm_symbol_to_string (ly_caar (p)), ly_cdar (p));
546 | translator_spec_body CONSISTSEND STRING {
547 unsmob_translator_def ($$)->add_last_element ( $3);
549 | translator_spec_body ACCEPTS STRING {
550 unsmob_translator_def ($$)->set_acceptor ($3,true);
552 | translator_spec_body DENIES STRING {
553 unsmob_translator_def ($$)->set_acceptor ($3,false);
555 | translator_spec_body REMOVE STRING {
556 unsmob_translator_def ($$)->remove_element ($3);
567 /*cont*/ '{' score_body '}' {
570 if (!$$->defs_.size ())
572 Music_output_def *id =
573 unsmob_music_output_def (THIS->lexer_->lookup_identifier ("$defaultpaper"));
574 $$->add_output (id ? id->clone () : new Paper_def );
583 $$->set_spot (THIS->here_input ());
584 SCM m = $1->self_scm ();
585 scm_gc_unprotect_object (m);
590 SCM check_funcs = scm_c_eval_string ("toplevel-music-functions");
591 for (; gh_pair_p (check_funcs); check_funcs = gh_cdr (check_funcs))
592 m = gh_call1 (gh_car (check_funcs), m);
597 $$ = new Score (*unsmob_score ($1));
598 $$->set_spot (THIS->here_input ());
600 | score_body lilypond_header {
603 | score_body output_def {
616 music_output_def_body '}' {
618 THIS-> lexer_-> remove_scope ();
622 music_output_def_body:
624 Music_output_def *id = unsmob_music_output_def (THIS->lexer_->lookup_identifier ("$defaultmidi"));
629 p = dynamic_cast<Midi_def*> (id->clone ());
634 THIS->lexer_->add_scope (p->scope_);
637 Music_output_def *id = unsmob_music_output_def (THIS->lexer_->lookup_identifier ("$defaultpaper"));
640 p = dynamic_cast<Paper_def*> (id->clone ());
643 THIS-> lexer_->add_scope (p->scope_);
646 | PAPER '{' MUSIC_OUTPUT_DEF_IDENTIFIER {
647 Music_output_def *p = unsmob_music_output_def ($3);
649 THIS->lexer_->add_scope (p->scope_);
652 | MIDI '{' MUSIC_OUTPUT_DEF_IDENTIFIER {
653 Music_output_def *p = unsmob_music_output_def ($3);
656 THIS->lexer_->add_scope (p->scope_);
659 | music_output_def_body assignment {
662 | music_output_def_body translator_spec_block {
663 $$->assign_translator ($2);
665 | music_output_def_body STYLESHEET embedded_scm {
666 dynamic_cast<Paper_def*> ($$)-> style_sheet_ = $3;
668 | music_output_def_body tempo_request {
670 junk this ? there already is tempo stuff in
673 int m = gh_scm2int ( $2->get_mus_property ("metronome-count"));
674 Duration *d = unsmob_duration ($2->get_mus_property ("duration"));
675 Midi_def * md = dynamic_cast<Midi_def*> ($$);
677 md->set_tempo (d->length_mom (), m);
679 | music_output_def_body error {
685 TEMPO steno_duration '=' bare_unsigned {
686 TYPED_MAKE_MUSIC(Tempo_req,t,"TempoEvent");
688 $$->set_mus_property ("duration", $2);
689 $$->set_mus_property ("metronome-count", gh_int2scm ( $4));
694 The representation of a list is the
698 to have efficient append.
700 Music_list: /* empty */ {
701 $$ = scm_cons (SCM_EOL, SCM_EOL);
705 SCM c = scm_cons ($2->self_scm (), SCM_EOL);
706 scm_gc_unprotect_object ($2->self_scm ()); /* UGH */
707 if (gh_pair_p (ly_cdr (s)))
708 gh_set_cdr_x (ly_cdr (s), c); /* append */
710 gh_set_car_x (s, c); /* set first cons */
711 gh_set_cdr_x (s, c) ; /* remember last cell */
727 | ALTERNATIVE '{' Music_list '}' {
733 REPEAT string bare_unsigned Music Alternative_music
737 SCM alts = gh_pair_p ($5) ? gh_car ($5) : SCM_EOL;
738 if (times < scm_ilength (alts)) {
739 unsmob_music (gh_car (alts))
740 ->origin ()->warning (
741 _("More alternatives than repeats. Junking excess alternatives."));
742 alts = ly_truncate_list (times, alts);
745 TYPED_MAKE_MUSIC(Repeated_music,r,"RepeatedMusic");
748 r-> set_mus_property ("element", beg->self_scm ());
749 scm_gc_unprotect_object (beg->self_scm ());
751 r->set_mus_property ("repeat-count", gh_int2scm (times >? 1));
753 r-> set_mus_property ("elements",alts);
754 SCM func = scm_primitive_eval (ly_symbol2scm ("repeat-name-to-ctor"));
755 SCM result = gh_call1 (func, $2);
757 if (gh_equal_p ($2, scm_makfrom0str ("tremolo")))
760 we can not get durations and other stuff correct down the line, so we have to
761 add to the duration log here.
763 SCM func = scm_primitive_eval (ly_symbol2scm ("shift-duration-log"));
765 gh_call3 (func, r->self_scm (), gh_int2scm(-intlog2 ($3*2/3)),gh_int2scm(1));
767 gh_call3 (func, r->self_scm (), gh_int2scm(-intlog2 ($3)), gh_int2scm(0));
770 set_music_properties (r, result);
772 r->set_spot (*$4->origin ());
779 SEQUENTIAL '{' Music_list '}' {
780 $$ = MY_MAKE_MUSIC("SequentialMusic");
781 $$->set_mus_property ("elements", ly_car ($3));
782 $$->set_spot(THIS->here_input());
784 | '{' Music_list '}' {
785 $$ = MY_MAKE_MUSIC("SequentialMusic");
786 $$->set_mus_property ("elements", ly_car ($2));
787 $$->set_spot(THIS->here_input());
792 SIMULTANEOUS '{' Music_list '}'{
793 $$ = MY_MAKE_MUSIC("SimultaneousMusic");
794 $$->set_mus_property ("elements", ly_car ($3));
795 $$->set_spot(THIS->here_input());
798 | '<' Music_list '>' {
799 $$ = MY_MAKE_MUSIC("SimultaneousMusic");
800 $$->set_mus_property ("elements", ly_car ($2));
801 $$->set_spot(THIS->here_input());
806 request_chord { $$ = $1; }
807 | OUTPUTPROPERTY embedded_scm embedded_scm '=' embedded_scm {
809 if (!gh_symbol_p ($3))
811 THIS->parser_error (_ ("Second argument must be a symbol"));
813 /* Should check # args */
814 if (!gh_procedure_p (pred))
816 THIS->parser_error (_ ("First argument must be a procedure taking one argument"));
819 TYPED_MAKE_MUSIC(Music,m,"OutputPropertySetMusic");
820 m->set_mus_property ("predicate", pred);
821 m->set_mus_property ("grob-property", $3);
822 m->set_mus_property ("grob-value", $5);
827 $$ = unsmob_music ($1)->clone ();
829 $$->set_spot (THIS->here_input());
837 CONTEXT STRING Music {
838 TYPED_MAKE_MUSIC(Music,csm, "ContextSpeccedMusic");
840 csm->set_mus_property ("element", $3->self_scm ());
841 scm_gc_unprotect_object ($3->self_scm ());
843 csm->set_mus_property ("context-type",$2);
844 csm->set_mus_property ("context-id", scm_makfrom0str (""));
848 | AUTOCHANGE STRING Music {
849 TYPED_MAKE_MUSIC(Music,chm,"AutoChangeMusic");
850 chm->set_mus_property ("element", $3->self_scm ());
852 scm_gc_unprotect_object ($3->self_scm ());
853 chm->set_mus_property ("what", $2);
856 chm->set_spot (*$3->origin ());
861 The other version is for easier debugging of
862 Sequential_music_iterator in combination with grace notes.
865 SCM start = THIS->lexer_->lookup_identifier ("startGraceMusic");
866 SCM stop = THIS->lexer_->lookup_identifier ("stopGraceMusic");
867 Music *startm = unsmob_music (start);
868 Music *stopm = unsmob_music (stop);
872 stopm = stopm->clone ();
873 ms = scm_cons (stopm->self_scm (), ms);
874 scm_gc_unprotect_object (stopm->self_scm ());
876 ms = scm_cons ($2->self_scm (), ms);
877 scm_gc_unprotect_object ($2->self_scm());
879 startm = startm->clone ();
880 ms = scm_cons (startm->self_scm () , ms);
881 scm_gc_unprotect_object (startm->self_scm ());
885 Music* seq = MY_MAKE_MUSIC("SequentialMusic");
886 seq->set_mus_property ("elements", ms);
889 $$ = MY_MAKE_MUSIC("GraceMusic");
890 $$->set_mus_property ("element", seq->self_scm ());
891 scm_gc_unprotect_object (seq->self_scm ());
893 $$ = MY_MAKE_MUSIC("GraceMusic");
894 $$->set_mus_property ("element", $2->self_scm ());
895 scm_gc_unprotect_object ($2->self_scm ());
898 | CONTEXT string '=' string Music {
899 Music * csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
901 csm->set_mus_property ("element", $5->self_scm ());
902 scm_gc_unprotect_object ($5->self_scm ());
904 csm->set_mus_property ("context-type", $2);
905 csm->set_mus_property ("context-id", $4);
916 int n = gh_scm2int (ly_car ($3)); int d = gh_scm2int (ly_cdr ($3));
918 $$= MY_MAKE_MUSIC("TimeScaledMusic");
919 $$->set_spot (THIS->pop_spot ());
922 $$->set_mus_property ("element", mp->self_scm ());
923 scm_gc_unprotect_object (mp->self_scm ());
924 $$->set_mus_property ("numerator", gh_int2scm (n));
925 $$->set_mus_property ("denominator", gh_int2scm (d));
926 $$->compress (Moment (Rational (n,d)));
929 | Repeated_music { $$ = $1; }
930 | Simultaneous_music { $$ = $1; }
931 | Sequential_music { $$ = $1; }
932 | TRANSPOSE pitch Music {
933 $$ = MY_MAKE_MUSIC("TransposedMusic");
935 Pitch pit = *unsmob_pitch ($2);
938 $$->set_mus_property ("element", p->self_scm ());
939 scm_gc_unprotect_object (p->self_scm ());
941 | TRANSPOSE steno_tonic_pitch Music {
942 $$ = MY_MAKE_MUSIC("TransposedMusic");
944 Pitch pit = *unsmob_pitch ($2);
947 $$->set_mus_property ("element", p->self_scm ());
948 scm_gc_unprotect_object (p->self_scm ());
951 | APPLY embedded_scm Music {
952 SCM ret = gh_call1 ($2, $3->self_scm ());
953 Music *m = unsmob_music (ret);
955 THIS->parser_error ("\\apply must return a Music");
956 m = MY_MAKE_MUSIC("Music");
961 { THIS->lexer_->push_note_state (); }
964 THIS->lexer_->pop_state ();
967 { THIS->lexer_->push_figuredbass_state (); }
970 Music * chm = MY_MAKE_MUSIC("UntransposableMusic");
971 chm->set_mus_property ("element", $3->self_scm ());
973 scm_gc_unprotect_object ($3->self_scm());
975 THIS->lexer_->pop_state ();
978 { THIS->lexer_->push_chord_state (); }
981 Music * chm = MY_MAKE_MUSIC("UnrelativableMusic");
982 chm->set_mus_property ("element", $3->self_scm ());
983 scm_gc_unprotect_object ($3->self_scm());
986 THIS->lexer_->pop_state ();
989 { THIS->lexer_->push_lyric_state (); }
993 THIS->lexer_->pop_state ();
995 | relative_music { $$ = $1; }
996 | re_rhythmed_music { $$ = $1; }
997 | part_combined_music { $$ = $1; }
1001 RELATIVE absolute_pitch Music {
1003 Pitch pit = *unsmob_pitch ($2);
1004 $$ = MY_MAKE_MUSIC("RelativeOctaveMusic");
1006 $$->set_mus_property ("element", p->self_scm ());
1007 scm_gc_unprotect_object (p->self_scm ());
1009 $$->set_mus_property ("last-pitch", p->to_relative_octave (pit).smobbed_copy ());
1015 ADDLYRICS Music Music {
1016 TYPED_MAKE_MUSIC(Lyric_combine_music, l,"LyricCombineMusic");
1017 l->set_mus_property ("elements", gh_list ($2->self_scm (), $3->self_scm (), SCM_UNDEFINED));
1018 scm_gc_unprotect_object ($3->self_scm ());
1019 scm_gc_unprotect_object ($2->self_scm ());
1024 part_combined_music:
1025 PARTCOMBINE STRING Music Music {
1026 TYPED_MAKE_MUSIC(Part_combine_music,p, "PartCombineMusic");
1027 p->set_mus_property ("what", $2);
1028 p->set_mus_property ("elements", gh_list ($3->self_scm (),$4->self_scm (), SCM_UNDEFINED));
1030 scm_gc_unprotect_object ($3->self_scm ());
1031 scm_gc_unprotect_object ($4->self_scm ());
1038 TRANSLATOR STRING '=' STRING {
1039 TYPED_MAKE_MUSIC(Music,t,"TranslatorChange");
1040 t-> set_mus_property ("change-to-type", $2);
1041 t-> set_mus_property ("change-to-id", $4);
1044 $$->set_spot (THIS->here_input ());
1050 | ONCE simple_property_def {
1052 SCM e = $2->get_mus_property ("element");
1053 unsmob_music (e)->set_mus_property ("once", SCM_BOOL_T);
1057 simple_property_def:
1058 PROPERTY STRING '.' STRING '=' scalar {
1059 Music *t = set_property_music (scm_string_to_symbol ($4), $6);
1060 Music *csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
1062 csm->set_mus_property ("element", t->self_scm ());
1063 scm_gc_unprotect_object (t->self_scm ());
1066 $$->set_spot (THIS->here_input ());
1068 csm-> set_mus_property ("context-type", $2);
1070 | PROPERTY STRING '.' STRING UNSET {
1072 Music *t = MY_MAKE_MUSIC("PropertyUnset");
1073 t->set_mus_property ("symbol", scm_string_to_symbol ($4));
1075 Music *csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
1076 csm->set_mus_property ("element", t->self_scm ());
1077 scm_gc_unprotect_object (t->self_scm ());
1080 $$->set_spot (THIS->here_input ());
1082 csm-> set_mus_property ("context-type", $2);
1084 | PROPERTY STRING '.' STRING SET embedded_scm '=' embedded_scm {
1086 = gh_equal_p ($4, scm_makfrom0str ("autoBeamSettings"));
1087 bool itc = internal_type_checking_global_b;
1088 Music *t = MY_MAKE_MUSIC("OverrideProperty");
1090 t->set_mus_property ("symbol", scm_string_to_symbol ($4));
1091 t->set_mus_property ("pop-first", SCM_BOOL_T);
1093 internal_type_checking_global_b = false;
1094 t->set_mus_property ("grob-property", $6);
1096 internal_type_checking_global_b = itc;
1097 t->set_mus_property ("grob-value", $8);
1099 Music *csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
1100 csm->set_mus_property ("element", t->self_scm ());
1101 scm_gc_unprotect_object (t->self_scm ());
1103 $$->set_spot (THIS->here_input ());
1105 csm-> set_mus_property ("context-type", $2);
1107 | PROPERTY STRING '.' STRING OVERRIDE
1108 embedded_scm '=' embedded_scm
1114 = gh_equal_p ($4, scm_makfrom0str ("autoBeamSettings"));
1115 bool itc = internal_type_checking_global_b;
1117 Music *t = MY_MAKE_MUSIC("OverrideProperty");
1118 t->set_mus_property ("symbol", scm_string_to_symbol ($4));
1120 internal_type_checking_global_b = false;
1121 t->set_mus_property ("grob-property", $6);
1122 t->set_mus_property ("grob-value", $8);
1124 internal_type_checking_global_b = itc;
1126 Music *csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
1127 csm->set_mus_property ("element", t->self_scm ());
1128 scm_gc_unprotect_object (t->self_scm ());
1131 $$->set_spot (THIS->here_input ());
1133 csm-> set_mus_property ("context-type", $2);
1136 | PROPERTY STRING '.' STRING REVERT embedded_scm {
1137 Music *t = MY_MAKE_MUSIC("RevertProperty");
1139 = gh_equal_p ($4, scm_makfrom0str ("autoBeamSettings"));
1140 bool itc = internal_type_checking_global_b;
1142 t->set_mus_property ("symbol", scm_string_to_symbol ($4));
1144 internal_type_checking_global_b = false;
1145 t->set_mus_property ("grob-property", $6);
1147 internal_type_checking_global_b = itc;
1149 Music *csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
1150 csm->set_mus_property ("element", t->self_scm ());
1151 scm_gc_unprotect_object (t->self_scm ());
1154 $$->set_spot (THIS->here_input ());
1156 csm-> set_mus_property ("context-type", $2);
1163 | bare_int { $$ = gh_int2scm ($1); }
1164 | embedded_scm { $$ = $1; }
1171 } /*cont */ simple_element post_requests {
1172 Music_sequence *l = dynamic_cast<Music_sequence*> ($3);
1175 for (int i=0; i < $1->size (); i++) {
1176 Music * m = $1->elem (i);
1177 l->append_music (m);
1189 $$ = MY_MAKE_MUSIC("RequestChord");
1190 $$->set_mus_property ("elements", scm_cons ($1->self_scm (), SCM_EOL));
1191 scm_gc_unprotect_object ($1->self_scm());
1193 $$-> set_spot (THIS->here_input ());
1194 $1-> set_spot (THIS->here_input ());
1197 Music *l = MY_MAKE_MUSIC("SpanEvent");
1198 l->set_mus_property ("span-direction", gh_int2scm (START));
1199 l->set_mus_property ("span-type", scm_makfrom0str ("ligature"));
1200 l->set_spot (THIS->here_input ());
1202 $$ = MY_MAKE_MUSIC("RequestChord");
1203 $$->set_mus_property ("elements", scm_cons (l->self_scm (), SCM_EOL));
1204 scm_gc_unprotect_object (l->self_scm());
1205 $$->set_spot (THIS->here_input ());
1208 Music *l = MY_MAKE_MUSIC("SpanEvent");
1209 l->set_mus_property ("span-direction", gh_int2scm (STOP));
1210 l->set_mus_property ("span-type", scm_makfrom0str ("ligature"));
1211 l->set_spot (THIS->here_input ());
1213 $$ = MY_MAKE_MUSIC("RequestChord");
1214 $$->set_mus_property ("elements", scm_cons (l->self_scm (), SCM_EOL));
1215 $$->set_spot (THIS->here_input ());
1216 scm_gc_unprotect_object (l->self_scm());
1220 $$ = MY_MAKE_MUSIC("VoiceSeparator");
1221 $$->set_spot (THIS->here_input ());
1225 $$ = MY_MAKE_MUSIC("BarCheck");
1226 $$->set_spot (THIS->here_input ());
1229 Music *t = set_property_music (ly_symbol2scm ("whichBar"), $2);
1231 Music *csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
1232 csm->set_mus_property ("element", t->self_scm ());
1233 scm_gc_unprotect_object (t->self_scm ());
1236 $$->set_spot (THIS->here_input ());
1238 csm->set_mus_property ("context-type", scm_makfrom0str ("Timing"));
1240 | PARTIAL duration_length {
1241 Moment m = - unsmob_duration ($2)->length_mom ();
1242 Music * p = set_property_music (ly_symbol2scm ( "measurePosition"),m.smobbed_copy ());
1244 Music * sp = MY_MAKE_MUSIC("ContextSpeccedMusic");
1245 sp->set_mus_property ("element", p->self_scm ());
1246 scm_gc_unprotect_object (p->self_scm ());
1249 sp-> set_mus_property ("context-type", scm_makfrom0str ("Timing"));
1252 SCM func = scm_primitive_eval (ly_symbol2scm ("clef-name-to-properties"));
1253 SCM result = gh_call1 (func, $2);
1256 for (SCM s = result ; gh_pair_p (s); s = ly_cdr (s)) {
1257 Music * p = MY_MAKE_MUSIC("Music");
1258 set_music_properties (p, ly_car (s));
1259 l = scm_cons (p->self_scm (), l);
1260 scm_gc_unprotect_object (p->self_scm ());
1262 Music * seq = MY_MAKE_MUSIC("SequentialMusic");
1263 seq->set_mus_property ("elements", l);
1265 Music * sp = MY_MAKE_MUSIC("ContextSpeccedMusic");
1266 sp->set_mus_property ("element", seq->self_scm ());
1267 scm_gc_unprotect_object (seq->self_scm ());
1270 sp-> set_mus_property ("context-type", scm_makfrom0str ("Staff"));
1273 Music * p1 = set_property_music (ly_symbol2scm ( "timeSignatureFraction"), $2);
1275 int l = gh_scm2int (ly_car ($2));
1276 int o = gh_scm2int (ly_cdr ($2));
1278 Moment one_beat = Moment (1)/Moment (o);
1279 Moment len = Moment (l) * one_beat;
1282 Music *p2 = set_property_music (ly_symbol2scm ("measureLength"), len.smobbed_copy ());
1283 Music *p3 = set_property_music (ly_symbol2scm ("beatLength"), one_beat.smobbed_copy ());
1285 SCM list = scm_list_n (p1->self_scm (), p2->self_scm (), p3->self_scm(), SCM_UNDEFINED);
1286 Music *seq = MY_MAKE_MUSIC("SequentialMusic");
1287 seq->set_mus_property ("elements", list);
1290 Music * sp = MY_MAKE_MUSIC("ContextSpeccedMusic");
1291 sp->set_mus_property ("element", seq->self_scm ());
1293 scm_gc_unprotect_object (p3->self_scm ());
1294 scm_gc_unprotect_object (p2->self_scm ());
1295 scm_gc_unprotect_object (p1->self_scm ());
1296 scm_gc_unprotect_object (seq->self_scm ());
1300 sp-> set_mus_property ("context-type", scm_makfrom0str ( "Timing"));
1305 shorthand_command_req { $$ = $1; }
1306 | verbose_command_req { $$ = $1; }
1309 shorthand_command_req:
1317 $$ = MY_MAKE_MUSIC("TieEvent");
1320 Music *b= MY_MAKE_MUSIC("SpanEvent");
1321 b->set_mus_property ("span-direction", gh_int2scm (START))
1323 b->set_mus_property ("span-type", scm_makfrom0str ("beam"));
1327 THIS->last_beam_start_ = b->self_scm ();
1330 Music *b= MY_MAKE_MUSIC("SpanEvent");
1331 b->set_mus_property ("span-direction", gh_int2scm (STOP))
1333 b->set_mus_property ("span-type", scm_makfrom0str ("beam"));
1337 $$ = MY_MAKE_MUSIC("BreathingSignEvent");
1340 $$ = MY_MAKE_MUSIC("PorrectusEvent");
1344 verbose_command_req:
1345 COMMANDSPANREQUEST bare_int STRING { /*TODO: junkme */
1346 Music * sp = MY_MAKE_MUSIC("SpanEvent");
1347 sp->set_mus_property ("span-direction", gh_int2scm (Direction ($2)));
1348 sp->set_mus_property ("span-type",$3);
1349 sp->set_spot (THIS->here_input ());
1353 Music * m = MY_MAKE_MUSIC("MarkEvent");
1357 Music *m = MY_MAKE_MUSIC("MarkEvent");
1358 m->set_mus_property ("label", $2);
1362 Music * b = MY_MAKE_MUSIC("BreakEvent");
1364 if (!gh_number_p (s))
1367 b->set_mus_property ("penalty", s);
1368 b->set_spot (THIS->here_input ());
1371 | SKIP duration_length {
1372 Music * skip = MY_MAKE_MUSIC("SkipEvent");
1373 skip->set_mus_property ("duration", $2);
1381 Music *key= MY_MAKE_MUSIC("KeyChangeEvent");
1384 | KEY NOTENAME_PITCH SCM_IDENTIFIER {
1385 Music *key= MY_MAKE_MUSIC("KeyChangeEvent");
1387 key->set_mus_property ("pitch-alist", $3);
1388 ((Music*)key)->transpose (* unsmob_pitch ($2));
1395 $$ = new Link_array<Music>;
1397 | post_requests post_request {
1398 $2->set_spot (THIS->here_input ());
1413 Music * s = MY_MAKE_MUSIC("StringNumberEvent");
1414 s->set_mus_property ("string-number", gh_int2scm($1));
1415 s->set_spot (THIS->here_input ());
1421 request_that_take_dir:
1424 | script_abbreviation {
1425 SCM s = THIS->lexer_->lookup_identifier ("dash" + ly_scm2string ($1));
1426 Music *a = MY_MAKE_MUSIC("ArticulationEvent");
1427 if (gh_string_p (s))
1428 a->set_mus_property ("articulation-type", s);
1429 else THIS->parser_error (_ ("Expecting string as script definition"));
1435 script_dir request_that_take_dir {
1436 $2->set_mus_property ("direction", gh_int2scm ($1));
1442 REQUEST_IDENTIFIER {
1443 $$ = unsmob_music ($1)->clone ();
1444 $$->set_spot (THIS->here_input ());
1446 | DYNAMICSCRIPT embedded_scm {
1448 TODO: junkme, use text-type == dynamic
1450 Music *d = MY_MAKE_MUSIC("TextScriptEvent");
1451 SCM dyn = ly_symbol2scm ("dynamic");
1452 d->set_mus_property ("text-type" , dyn);
1453 d->set_mus_property ("text", $2);
1454 d->set_spot (THIS->here_input ());
1457 | SPANREQUEST bare_int STRING {
1458 Music * sp = MY_MAKE_MUSIC("SpanEvent");
1459 sp->set_mus_property ("span-direction", gh_int2scm ( $2));
1460 sp->set_mus_property ("span-type", $3);
1461 sp->set_spot (THIS->here_input ());
1465 Music * a = MY_MAKE_MUSIC("TremoloEvent");
1466 a->set_spot (THIS->here_input ());
1467 a->set_mus_property ("tremolo-type", gh_int2scm ($1));
1471 Music * a = MY_MAKE_MUSIC("ArticulationEvent");
1472 a->set_mus_property ("articulation-type", $2);
1473 a->set_spot (THIS->here_input ());
1478 duh, junk this syntax from the parser, if possible.
1481 Music *a = MY_MAKE_MUSIC("ArpeggioEvent");
1482 a->set_spot (THIS->here_input ());
1486 Music *g = MY_MAKE_MUSIC("GlissandoEvent");
1487 g->set_spot /* No pun intended */ (THIS->here_input ());
1514 | NOTENAME_PITCH sup_quotes {
1515 Pitch p = *unsmob_pitch ($1);
1517 $$ = p.smobbed_copy ();
1519 | NOTENAME_PITCH sub_quotes {
1520 Pitch p =* unsmob_pitch ($1);
1523 $$ = p.smobbed_copy ();
1536 | TONICNAME_PITCH sup_quotes {
1537 Pitch p = *unsmob_pitch ($1);
1539 $$ = p.smobbed_copy ();
1541 | TONICNAME_PITCH sub_quotes {
1542 Pitch p =* unsmob_pitch ($1);
1545 $$ = p.smobbed_copy ();
1560 PITCH embedded_scm {
1562 if (!unsmob_pitch ($2)) {
1563 THIS->parser_error (_f ("Expecting musical-pitch value", 3));
1564 $$ = Pitch ().smobbed_copy ();
1570 DURATION embedded_scm {
1572 if (!unsmob_duration ($2))
1574 THIS->parser_error (_ ("Must have duration object"));
1575 $$ = Duration ().smobbed_copy ();
1582 if (!THIS->lexer_->lyric_state_b ())
1583 THIS->parser_error (_ ("Have to be in Lyric mode for lyrics"));
1584 $$ = MY_MAKE_MUSIC("ExtenderEvent");
1590 if (!THIS->lexer_->lyric_state_b ())
1591 THIS->parser_error (_ ("Have to be in Lyric mode for lyrics"));
1592 $$ = MY_MAKE_MUSIC("HyphenEvent");
1597 close_request_parens {
1599 dynamic_cast<Music *> ($$)->set_mus_property ("span-direction", gh_int2scm (START))
1604 close_request_parens:
1606 Music * s= MY_MAKE_MUSIC("SpanEvent");
1608 s->set_mus_property ("span-type", scm_makfrom0str ( "slur"));
1609 s->set_spot (THIS->here_input());
1612 Music * s= MY_MAKE_MUSIC("SpanEvent");
1614 s->set_mus_property ("span-type", scm_makfrom0str ( "phrasing-slur"));
1615 s->set_spot (THIS->here_input());
1618 Music *s =MY_MAKE_MUSIC("SpanEvent");
1620 s->set_mus_property ("span-type", scm_makfrom0str ( "crescendo"));
1621 s->set_spot (THIS->here_input());
1624 Music *s =MY_MAKE_MUSIC("SpanEvent");
1626 s->set_mus_property ("span-type", scm_makfrom0str ("decrescendo"));
1627 s->set_spot (THIS->here_input());
1633 open_request_parens {
1635 dynamic_cast<Music *> ($$)->set_mus_property ("span-direction", gh_int2scm (STOP))
1640 open_request_parens:
1642 Music *s = MY_MAKE_MUSIC("SpanEvent");
1643 s->set_mus_property ("span-type", scm_makfrom0str ( "crescendo"));
1644 s->set_spot (THIS->here_input());
1649 Music * s= MY_MAKE_MUSIC("SpanEvent");
1651 s->set_mus_property ("span-type", scm_makfrom0str ( "slur"));
1652 s->set_spot (THIS->here_input());
1656 Music * s= MY_MAKE_MUSIC("SpanEvent");
1658 s->set_mus_property ("span-type", scm_makfrom0str ( "phrasing-slur"));
1659 s->set_spot (THIS->here_input());
1665 Music *t = MY_MAKE_MUSIC("TextScriptEvent");
1666 t->set_mus_property ("text", $1);
1667 t->set_spot (THIS->here_input ());
1671 Music *t = MY_MAKE_MUSIC("TextScriptEvent");
1672 t->set_mus_property ("text", $1);
1673 t->set_spot (THIS->here_input ());
1677 String ds = to_string ($1);
1678 Music * t = MY_MAKE_MUSIC("TextScriptEvent");
1679 SCM finger = ly_symbol2scm ("finger");
1680 t->set_mus_property ("text", scm_makfrom0str (ds.to_str0 ()));
1681 t->set_mus_property ("text-type" , finger);
1682 t->set_spot (THIS->here_input ());
1687 script_abbreviation:
1689 $$ = scm_makfrom0str ("Hat");
1692 $$ = scm_makfrom0str ("Plus");
1695 $$ = scm_makfrom0str ("Dash");
1698 $$ = scm_makfrom0str ("Bar");
1701 $$ = scm_makfrom0str ("Larger");
1704 $$ = scm_makfrom0str ("Dot");
1707 $$ = scm_makfrom0str ("Underscore");
1714 | '-' { $$ = CENTER; }
1719 $$ = new Link_array<Music>;
1721 | pre_requests open_request {
1733 multiplied_duration {
1736 | verbose_duration {
1741 optional_notemode_duration:
1743 Duration dd = THIS->default_duration_;
1744 $$ = dd.smobbed_copy ();
1746 THIS->beam_check ($$);
1748 | multiplied_duration {
1750 THIS->default_duration_ = *unsmob_duration ($$);
1752 THIS->beam_check ($$);
1754 | verbose_duration {
1756 THIS->default_duration_ = *unsmob_duration ($$);
1761 bare_unsigned dots {
1763 if (!is_duration_b ($1))
1764 THIS->parser_error (_f ("not a duration: %d", $1));
1768 $$ = Duration (l, $2).smobbed_copy ();
1770 | DURATION_IDENTIFIER dots {
1771 Duration *d =unsmob_duration ($1);
1772 Duration k (d->duration_log (),d->dot_count () + $2);
1773 $$ = k.smobbed_copy ();
1780 multiplied_duration:
1784 | multiplied_duration '*' bare_unsigned {
1785 $$ = unsmob_duration ($$)->compressed ( $3) .smobbed_copy ();
1787 | multiplied_duration '*' FRACTION {
1788 Rational m (gh_scm2int (ly_car ($3)), gh_scm2int (ly_cdr ($3)));
1790 $$ = unsmob_duration ($$)->compressed (m).smobbed_copy ();
1795 FRACTION { $$ = $1; }
1796 | UNSIGNED '/' UNSIGNED {
1797 $$ = scm_cons (gh_int2scm ($1), gh_int2scm ($3));
1815 | ':' bare_unsigned {
1816 if (!is_duration_b ($2))
1817 THIS->parser_error (_f ("not a duration: %d", $2));
1836 Music *bfr = MY_MAKE_MUSIC("BassFigureEvent");
1837 $$ = bfr->self_scm();
1838 scm_gc_unprotect_object ($$);
1841 Music *bfr = MY_MAKE_MUSIC("BassFigureEvent");
1842 $$ = bfr->self_scm();
1844 bfr->set_mus_property ("figure", gh_int2scm ($1));
1846 scm_gc_unprotect_object ($$);
1848 | bass_figure bass_mod {
1849 Music *m = unsmob_music ($1);
1851 SCM salter =m->get_mus_property ("alteration");
1852 int alter = gh_number_p ( salter) ? gh_scm2int (salter) : 0;
1853 m->set_mus_property ("alteration",
1854 gh_int2scm (alter + $2));
1856 m->set_mus_property ("alteration", gh_int2scm (0));
1864 unsmob_music ($$)->set_mus_property ("bracket-start", SCM_BOOL_T);
1869 | br_bass_figure ']' {
1871 unsmob_music ($1)->set_mus_property ("bracket-stop", SCM_BOOL_T);
1879 | figure_list br_bass_figure {
1880 $$ = scm_cons ($2, $1);
1885 FIGURE_OPEN figure_list FIGURE_CLOSE {
1886 Music * m = MY_MAKE_MUSIC("RequestChord");
1887 $2 = scm_reverse_x ($2, SCM_EOL);
1888 m->set_mus_property ("elements", $2);
1889 $$ = m->self_scm ();
1900 pitch exclamations questions optional_notemode_duration optional_rest {
1902 Input i = THIS->pop_spot ();
1903 if (!THIS->lexer_->note_state_b ())
1904 THIS->parser_error (_ ("Have to be in Note mode for notes"));
1908 n = MY_MAKE_MUSIC("RestEvent");
1910 n = MY_MAKE_MUSIC("NoteEvent");
1912 n->set_mus_property ("pitch", $1);
1913 n->set_mus_property ("duration", $4);
1917 n->set_mus_property ("cautionary", SCM_BOOL_T);
1918 if ($2 % 2 || $3 % 2)
1919 n->set_mus_property ("force-accidental", SCM_BOOL_T);
1921 Music *v = MY_MAKE_MUSIC("RequestChord");
1922 v->set_mus_property ("elements", scm_list_n (n->self_scm (), SCM_UNDEFINED));
1923 scm_gc_unprotect_object (n->self_scm());
1929 | figure_spec optional_notemode_duration {
1930 Music * m = unsmob_music ($1);
1931 Input i = THIS->pop_spot ();
1933 for (SCM s = m->get_mus_property ("elements"); gh_pair_p (s); s = ly_cdr (s))
1935 unsmob_music (ly_car (s))->set_mus_property ("duration", $2);
1939 | RESTNAME optional_notemode_duration {
1941 Input i = THIS->pop_spot ();
1942 SCM e = SCM_UNDEFINED;
1943 if (ly_scm2string ($1) =="s") {
1945 Music * skip = MY_MAKE_MUSIC("SkipEvent");
1946 skip->set_mus_property ("duration" ,$2);
1948 e = skip->self_scm ();
1951 Music * rest_req = MY_MAKE_MUSIC("RestEvent");
1952 rest_req->set_mus_property ("duration", $2);
1953 rest_req->set_spot (i);
1954 e = rest_req->self_scm ();
1956 Music * velt = MY_MAKE_MUSIC("RequestChord");
1957 velt-> set_mus_property ("elements", scm_list_n (e,SCM_UNDEFINED));
1962 | MULTI_MEASURE_REST optional_notemode_duration {
1965 Music * sk = MY_MAKE_MUSIC("SkipEvent");
1966 sk->set_mus_property ("duration", $2);
1967 Music *sp1 = MY_MAKE_MUSIC("SpanEvent");
1968 Music *sp2 = MY_MAKE_MUSIC("SpanEvent");
1969 sp1-> set_mus_property ("span-direction", gh_int2scm (START))
1971 sp2-> set_mus_property ("span-direction", gh_int2scm (STOP))
1973 SCM r = scm_makfrom0str ("rest");
1974 sp1->set_mus_property ("span-type", r);
1975 sp2->set_mus_property ("span-type", r);
1977 Music *rqc1 = MY_MAKE_MUSIC("RequestChord");
1978 rqc1->set_mus_property ("elements", scm_list_n (sp1->self_scm (), SCM_UNDEFINED));
1979 Music *rqc2 = MY_MAKE_MUSIC("RequestChord");
1980 rqc2->set_mus_property ("elements", scm_list_n (sk->self_scm (), SCM_UNDEFINED));;
1981 Music *rqc3 = MY_MAKE_MUSIC("RequestChord");
1982 rqc3->set_mus_property ("elements", scm_list_n (sp2->self_scm (), SCM_UNDEFINED));;
1984 SCM ms = scm_list_n (rqc1->self_scm (), rqc2->self_scm (), rqc3->self_scm (), SCM_UNDEFINED);
1986 $$ = MY_MAKE_MUSIC("SequentialMusic");
1987 $$->set_mus_property ("elements", ms);
1989 | STRING optional_notemode_duration {
1990 Input i = THIS->pop_spot ();
1992 Music * lreq = MY_MAKE_MUSIC("LyricEvent");
1993 lreq->set_mus_property ("text", $1);
1994 lreq->set_mus_property ("duration",$2);
1996 Music * velt = MY_MAKE_MUSIC("RequestChord");
1997 velt->set_mus_property ("elements", scm_list_n (lreq->self_scm (), SCM_UNDEFINED));
2002 Input i = THIS->pop_spot ();
2004 if (!THIS->lexer_->chord_state_b ())
2005 THIS->parser_error (_ ("Have to be in Chord mode for chords"));
2012 steno_tonic_pitch optional_notemode_duration chord_additions chord_subtractions chord_inversion chord_bass {
2013 $$ = Chord::get_chord ($1, $3, $4, $5, $6, $2);
2014 $$->set_spot (THIS->here_input ());
2021 | CHORD_COLON chord_notes {
2030 | chord_notes '.' chord_step {
2031 $$ = gh_append2 ($$, $3);
2039 | CHORD_CARET chord_notes {
2049 | CHORD_SLASH steno_tonic_pitch {
2058 | CHORD_BASS steno_tonic_pitch {
2065 $$ = scm_cons ($1, SCM_EOL);
2067 | CHORDMODIFIER_PITCH {
2068 $$ = scm_cons (unsmob_pitch ($1)->smobbed_copy (), SCM_EOL);
2070 | CHORDMODIFIER_PITCH chord_note { /* Ugh. */
2071 $$ = scm_list_n (unsmob_pitch ($1)->smobbed_copy (),
2079 m.notename_ = ($1 - 1) % 7;
2080 m.octave_ = $1 > 7 ? 1 : 0;
2083 $$ = m.smobbed_copy ();
2085 | bare_unsigned '+' {
2087 m.notename_ = ($1 - 1) % 7;
2088 m.octave_ = $1 > 7 ? 1 : 0;
2092 $$ = m.smobbed_copy ();
2094 | bare_unsigned CHORD_MINUS {
2096 m.notename_ = ($1 - 1) % 7;
2097 m.octave_ = $1 > 7 ? 1 : 0;
2100 $$ = m.smobbed_copy ();
2108 number_expression '+' number_term {
2109 $$ = scm_sum ($1, $3);
2111 | number_expression '-' number_term {
2112 $$ = scm_difference ($1, $3);
2121 | number_factor '*' number_factor {
2122 $$ = scm_product ($1, $3);
2124 | number_factor '/' number_factor {
2125 $$ = scm_divide ($1, $3);
2130 '(' number_expression ')' {
2133 | '-' number_factor { /* %prec UNARY_MINUS */
2134 $$ = scm_difference ($2, SCM_UNDEFINED);
2142 $$ = gh_int2scm ($1);
2147 | NUMBER_IDENTIFIER {
2151 $$ = gh_double2scm (gh_scm2double ($1) CM );
2154 $$ = gh_double2scm (gh_scm2double ($1) PT);
2157 $$ = gh_double2scm (gh_scm2double ($1) INCH);
2160 $$ = gh_double2scm (gh_scm2double ($1) MM);
2163 $$ = gh_double2scm (gh_scm2double ($1) CHAR);
2179 if (scm_integer_p ($1) == SCM_BOOL_T)
2181 int k = gh_scm2int ($1);
2185 THIS->parser_error (_ ("need integer number arg"));
2199 | STRING_IDENTIFIER {
2202 | string '+' string {
2203 $$ = scm_string_append (scm_list_n ($1, $3, SCM_UNDEFINED));
2210 | exclamations '!' { $$ ++; }
2215 | questions '?' { $$ ++; }
2222 My_lily_parser::set_yydebug (bool )
2229 extern My_lily_parser * current_parser;
2232 My_lily_parser::do_yyparse ()
2235 current_parser = this;;
2236 yyparse ((void*)this);
2241 Should make this optional? It will also complain when you do
2245 which is entirely legitimate.
2247 Or we can scrap it. Barchecks should detect wrong durations, and
2248 skipTypesetting speeds it up a lot.
2251 My_lily_parser::beam_check (SCM dur)
2253 Duration *d = unsmob_duration (dur);
2254 if (unsmob_music (last_beam_start_) && d->duration_log () <= 2)
2256 Music * m = unsmob_music (last_beam_start_);
2257 m->origin ()->warning (_("Suspect duration found following this beam"));
2259 last_beam_start_ = SCM_EOL;