]> git.donarmstrong.com Git - lilypond.git/blob - lily/parser.yy
* lily/include/midi-stream.hh: use stdio.h iso. iostream.h
[lilypond.git] / lily / parser.yy
1 %{ // -*-Fundamental-*-
2
3 /*
4   parser.yy -- Bison/C++ parser for lilypond
5
6   source file of the GNU LilyPond music typesetter
7
8   (c)  1997--2001 Han-Wen Nienhuys <hanwen@cs.uu.nl>
9            Jan Nieuwenhuizen <janneke@gnu.org>
10 */
11
12 /*
13   Two shift/reduce problems:
14     -
15     -
16  */
17
18 /*
19
20 the rules for who is protecting what are very shady. TODO: uniformise
21 this.
22
23
24 */
25
26 #include <ctype.h>
27
28 #include "translator-def.hh"
29 #include "lily-guile.hh"
30 #include "misc.hh"
31 #include "my-lily-lexer.hh"
32 #include "paper-def.hh"
33 #include "midi-def.hh"
34 #include "main.hh"
35 #include "file-path.hh"
36 #include "warn.hh"
37 #include "dimensions.hh"
38 #include "my-lily-parser.hh"
39 #include "score.hh"
40 #include "input-file-results.hh"
41 #include "input.hh"
42 #include "lilypond-input-version.hh"
43 #include "scm-hash.hh"
44 #include "auto-change-iterator.hh"
45 #include "chord.hh"
46 #include "ly-modules.hh"
47 #include "music-sequence.hh"
48
49 bool
50 regular_identifier_b (SCM id)
51 {
52   String str = ly_scm2string (id);
53   char const *s = str.to_str0 () ;
54
55   bool v = true;
56   while (*s && v)
57    {
58         v = v && isalpha (*s);
59         s++;
60    }
61   return v;
62 }
63
64
65
66 bool
67 is_duration_b (int t)
68 {
69   return t && t == 1 << intlog2 (t);
70 }
71
72 void
73 set_music_properties (Music *p, SCM a)
74 {
75   for (SCM k = a; gh_pair_p (k); k = ly_cdr (k))
76         {
77         p->internal_set_mus_property (ly_caar (k), ly_cdar (k));
78         }
79 }
80
81
82
83 #define MY_MAKE_MUSIC(x)  make_music_by_name (ly_symbol2scm (x))
84
85 Music* 
86 set_property_music (SCM sym, SCM value)
87 {
88         Music * p = MY_MAKE_MUSIC("PropertySet");
89         p->set_mus_property ("symbol", sym);
90         p->set_mus_property ("value", value);
91         return p;
92 }
93
94 Music*
95 make_span_req (SCM name)
96 {
97   static SCM proc;
98   if (!proc)
99     proc = scm_c_eval_string ("old-span-event->event");
100   SCM m = scm_call_1 (proc, name);
101   scm_gc_protect_object (m);
102   return unsmob_music (m);
103 }
104
105 // needed for bison.simple's malloc () and free ()
106
107 // #include <malloc.h>
108 #include <stdlib.h>
109
110
111
112 #define YYERROR_VERBOSE 1
113
114 #define YYPARSE_PARAM my_lily_parser
115 #define YYLEX_PARAM my_lily_parser
116 #define THIS\
117         ((My_lily_parser *) my_lily_parser)
118
119 #define yyerror THIS->parser_error
120
121 %}
122
123 /* We use SCMs to do strings, because it saves us the trouble of
124 deleting them.  Let's hope that a stack overflow doesnt trigger a move
125 of the parse stack onto the heap. */
126
127
128 %union {
129
130     Link_array<Music> *reqvec;
131
132     String *string; // needed by the lexer as temporary scratch area.
133     Music *music;
134     Score *score;
135     Scheme_hash_table *scmhash;
136     Music_output_def * outputdef;
137     SCM scm;
138     int i;
139 }
140 %{
141
142 int
143 yylex (YYSTYPE *s,  void * v)
144 {
145         My_lily_parser   *pars = (My_lily_parser*) v;
146         My_lily_lexer * lex = pars->lexer_;
147
148         lex->lexval = (void*) s;
149         return lex->yylex ();
150 }
151
152
153 %}
154
155 %pure_parser
156
157 /* tokens which are not keywords */
158 %token AUTOCHANGE
159 %token ALIAS
160 %token APPLY
161 %token ARPEGGIO
162 %token ACCEPTS
163 %token ALTERNATIVE
164 %token BAR
165 %token BREATHE
166 %token CHORDMODIFIERS
167 %token CHORDS
168 %token CHAR_T
169 %token CLEF
170 %token CM_T
171 %token CONSISTS
172 %token DURATION
173 %token SEQUENTIAL
174 %token GROBDESCRIPTIONS
175 %token SIMULTANEOUS
176 %token CONSISTSEND
177 %token DENIES
178 %token DURATION
179 %token EXTENDER
180 %token FIGURES FIGURE_OPEN FIGURE_CLOSE
181 %token FIGURE_BRACKET_CLOSE FIGURE_BRACKET_OPEN
182 %token GLISSANDO
183 %token GRACE 
184 %token HEADER
185 %token HYPHEN
186 %token IN_T
187 %token INVALID
188 %token KEY
189 %token LYRICS
190 %token MARK
191 %token MULTI_MEASURE_REST
192 %token MIDI
193 %token MM_T
194 %token PITCH
195 %token DEFAULT
196 %token NAME
197 %token PITCHNAMES
198 %token NOTES
199 %token ONCE
200 %token PAPER
201 %token PARTIAL
202 %token PENALTY
203 %token PROPERTY
204 %token OVERRIDE SET REVERT 
205 %token PT_T
206 %token RELATIVE
207 %token REMOVE
208 %token REPEAT
209 %token ADDLYRICS
210 %token PARTCOMBINE
211 %token SCM_T
212 %token SCORE
213 %token SCRIPT
214 %token SKIP
215 %token SPANREQUEST
216 %token STYLESHEET
217 %token COMMANDSPANREQUEST
218 %token TEMPO
219 %token OUTPUTPROPERTY
220 %token TIME_T
221 %token TIMES
222 %token TRANSLATOR
223 %token TRANSPOSE
224 %token TYPE
225 %token UNSET
226 %token CONTEXT
227 %token REST
228
229 /* escaped */
230 %token E_CHAR E_EXCLAMATION E_SMALLER E_BIGGER E_OPEN E_CLOSE
231 %token E_LEFTSQUARE E_RIGHTSQUARE E_TILDE
232 %token E_BACKSLASH
233 %token <i> E_UNSIGNED
234 %token CHORD_BASS CHORD_COLON CHORD_MINUS CHORD_CARET  CHORD_SLASH
235 %token FIGURE_SPACE
236
237 %type <i>       exclamations questions dots optional_rest
238 %type <i>       bass_number bass_mod
239 %type <scm>     br_bass_figure bass_figure figure_list figure_spec
240 %token <i>      DIGIT
241 %token <scm>    NOTENAME_PITCH
242 %token <scm>    TONICNAME_PITCH
243 %token <scm>    CHORDMODIFIER_PITCH
244 %token <scm>    DURATION_IDENTIFIER
245 %token <scm>    FRACTION
246 %token <id>     IDENTIFIER
247
248
249 %token <scm>    SCORE_IDENTIFIER
250 %token <scm>    MUSIC_OUTPUT_DEF_IDENTIFIER
251
252 %token <scm>    NUMBER_IDENTIFIER
253 %token <scm>    EVENT_IDENTIFIER
254 %token <scm>    MUSIC_IDENTIFIER TRANSLATOR_IDENTIFIER
255 %token <scm>    STRING_IDENTIFIER SCM_IDENTIFIER 
256 %token <scm>    RESTNAME
257 %token <scm>    STRING   
258 %token <scm>    SCM_T
259 %token <i>      UNSIGNED
260 %token <scm>   REAL
261
262 %type <outputdef> output_def
263 %type <scm>     lilypond_header lilypond_header_body
264 %type <music>   open_event_parens close_event_parens open_event close_event
265 %type <music> event_with_dir event_that_take_dir verbose_event
266 %type <i>       sub_quotes sup_quotes
267 %type <music>   simple_element  event_chord command_element Simple_music  Composite_music 
268 %type <music>   Repeated_music
269 %type <scm>     Alternative_music
270 %type <i>       tremolo_type
271 %type <i>       bare_int  bare_unsigned
272 %type <i>       script_dir
273 %type <scm>     identifier_init 
274
275 %type <scm> steno_duration optional_notemode_duration multiplied_duration
276 %type <scm>  verbose_duration
277         
278 %type <reqvec>  pre_events post_events
279 %type <music> gen_text_def
280 %type <scm>   steno_pitch pitch absolute_pitch
281 %type <scm>   explicit_pitch steno_tonic_pitch
282
283 %type <scm>     chord_additions chord_subtractions chord_notes chord_step
284 %type <music>   chord
285 %type <scm>     chord_note chord_inversion chord_bass
286 %type <scm>     duration_length fraction
287
288 %type <scm>  embedded_scm scalar
289 %type <music>   Music Sequential_music Simultaneous_music 
290 %type <music>   relative_music re_rhythmed_music part_combined_music
291 %type <music>   property_def translator_change  simple_property_def
292 %type <scm> Music_list
293 %type <outputdef>  music_output_def_body
294 %type <music> shorthand_command_req
295 %type <music>   post_event 
296 %type <music> command_req verbose_command_req
297 %type <music>   extender_req
298 %type <music> hyphen_req
299 %type <music> string_event
300 %type <scm>     string bare_number number_expression number_term number_factor 
301
302 %type <score>   score_block score_body
303
304 %type <scm>     translator_spec_block translator_spec_body
305 %type <music>   tempo_event
306 %type <scm> notenames_body notenames_block chordmodifiers_block
307 %type <scm>     script_abbreviation
308
309
310
311 %left '-' '+'
312
313 /* We don't assign precedence to / and *, because we might need varied
314 prec levels in different prods */
315
316 %left UNARY_MINUS
317
318 %%
319
320 lilypond:       /* empty */
321         | lilypond toplevel_expression {}
322         | lilypond assignment  { }
323         | lilypond error {
324                 THIS->error_level_  = 1;
325         }
326         | lilypond INVALID      {
327                 THIS->error_level_  = 1;
328         }
329         ;
330
331 toplevel_expression:
332         notenames_block                 {
333                 THIS->lexer_->pitchname_tab_ =  $1;
334         }
335         | chordmodifiers_block                  {
336                 THIS->lexer_->chordmodifier_tab_  = $1;
337         }
338         | lilypond_header {
339                 THIS->input_file_->header_ = $1;
340         }
341         | score_block {
342                 THIS->input_file_->scores_.push ($1);
343         }
344         | output_def {
345                 if (dynamic_cast<Paper_def*> ($1))
346                         THIS->lexer_->set_identifier (scm_makfrom0str ("$defaultpaper"), $1->self_scm ());
347                 else if (dynamic_cast<Midi_def*> ($1))
348                         THIS->lexer_->set_identifier (scm_makfrom0str ("$defaultmidi"), $1->self_scm ());
349         }
350         | embedded_scm {
351                 // junk value
352         }       
353         ;
354
355 embedded_scm:
356         SCM_T
357         | SCM_IDENTIFIER 
358         ;
359
360
361 chordmodifiers_block:
362         CHORDMODIFIERS notenames_body   {  $$ = $2; }
363         ;
364
365 notenames_block:
366         PITCHNAMES notenames_body   {  $$ = $2; }
367         ;
368
369 notenames_body:
370         embedded_scm    {
371           int i = scm_ilength ($1);
372
373           SCM tab = scm_make_vector (gh_int2scm (i), SCM_EOL);
374           for (SCM s = $1; gh_pair_p (s); s = ly_cdr (s)) {
375                 SCM pt = ly_cdar (s);
376                 if (!unsmob_pitch (pt))
377                         THIS->parser_error ("Need pitch object.");
378                 else
379                         scm_hashq_set_x (tab, ly_caar (s), pt);
380           }
381
382           $$ = tab;
383         }
384         ;
385
386 lilypond_header_body:
387         {
388                 $$ = ly_make_anonymous_module (); 
389                 THIS->lexer_->add_scope ($$);
390         }
391         | lilypond_header_body assignment  { 
392                 
393         }
394         ;
395
396 lilypond_header:
397         HEADER '{' lilypond_header_body '}'     {
398                 $$ = THIS->lexer_-> remove_scope();
399         }
400         ;
401
402
403 /*
404         DECLARATIONS
405 */
406 assignment:
407         STRING {
408                 THIS->push_spot ();
409         }
410         /* cont */ '=' identifier_init  {
411
412         /*
413                 Should find generic way of associating input with objects.
414         */
415                 Input ip = THIS->pop_spot ();
416
417                 if (! regular_identifier_b ($1))
418                 {
419                         ip.warning (_ ("Identifier should have alphabetic characters only"));
420                 }
421
422                 THIS->lexer_->set_identifier ($1, $4);
423
424 /*
425  TODO: devise standard for protection in parser.
426
427   The parser stack lives on the C-stack, which means that
428 all objects can be unprotected as soon as they're here.
429
430 */
431         }
432         ;
433
434
435
436 identifier_init:
437         score_block {
438                 $$ = $1->self_scm ();
439                 scm_gc_unprotect_object ($$);
440         }
441         | output_def {
442                 $$ = $1->self_scm ();
443                 scm_gc_unprotect_object ($$);
444         }
445         | translator_spec_block {
446                 $$ = $1;
447         }
448         | Music  {
449                 $$ = $1->self_scm ();
450                 scm_gc_unprotect_object ($$);
451         }
452         | post_event {
453                 $$ = $1->self_scm ();
454                 scm_gc_unprotect_object ($$);
455         }
456         | verbose_duration {
457                 $$ = $1;
458         }
459         | number_expression {
460                 $$ = $1;
461         }
462         | string {
463                 $$ = $1;
464         }
465         | embedded_scm  {
466                 $$ = $1;
467         }
468         ;
469
470 translator_spec_block:
471         TRANSLATOR '{' translator_spec_body '}'
472                 {
473                 $$ = $3;
474         }
475         ;
476
477 translator_spec_body:
478         TRANSLATOR_IDENTIFIER   {
479                 $$ = unsmob_translator_def ($1)->clone_scm ();
480                 unsmob_translator_def ($$)-> set_spot (THIS->here_input ());
481         }
482         | TYPE STRING   {
483                 $$ = Translator_def::make_scm ();
484                 Translator_def*td =  unsmob_translator_def ($$);
485                 td->translator_group_type_ = $2;
486                 td->set_spot (THIS->here_input ());
487         }
488         | translator_spec_body STRING '=' embedded_scm                  {
489                 unsmob_translator_def ($$)->add_property_assign ($2, $4);
490         }
491         | translator_spec_body STRING OVERRIDE embedded_scm '=' embedded_scm {
492                 unsmob_translator_def ($$)
493                         ->add_push_property (scm_string_to_symbol ($2), $4, $6);
494         }
495         | translator_spec_body STRING SET embedded_scm '=' embedded_scm {
496                 unsmob_translator_def ($$)
497                         ->add_push_property (scm_string_to_symbol ($2), $4, $6);
498         }
499         | translator_spec_body STRING REVERT embedded_scm  {
500           unsmob_translator_def ($$)->add_pop_property (
501                 scm_string_to_symbol ($2), $4);
502         }
503         | translator_spec_body NAME STRING  {
504                 unsmob_translator_def ($$)->type_name_ = $3;
505         }
506         | translator_spec_body CONSISTS STRING  {
507                 unsmob_translator_def ($$)->add_element ($3);
508         }
509         | translator_spec_body ALIAS STRING  {
510                 Translator_def*td = unsmob_translator_def ($$);
511                 td->type_aliases_ = scm_cons ($3, td->type_aliases_);
512         }
513         | translator_spec_body GROBDESCRIPTIONS embedded_scm {
514                 Translator_def*td = unsmob_translator_def($$);
515                 // td->add_property_assign (ly_symbol2scm ("allGrobDescriptions"), $3);
516                 for (SCM p = $3; gh_pair_p (p); p = ly_cdr (p))
517                         td->add_property_assign (scm_symbol_to_string (ly_caar (p)), ly_cdar (p));
518         }
519         | translator_spec_body CONSISTSEND STRING  {
520                 unsmob_translator_def ($$)->add_last_element ( $3);
521         }
522         | translator_spec_body ACCEPTS STRING  {
523                 unsmob_translator_def ($$)->set_acceptor ($3,true);
524         }
525         | translator_spec_body DENIES STRING  {
526                 unsmob_translator_def ($$)->set_acceptor ($3,false);
527         }
528         | translator_spec_body REMOVE STRING  {
529                 unsmob_translator_def ($$)->remove_element ($3);
530         }
531         ;
532
533 /*
534         SCORE
535 */
536 score_block:
537         SCORE { 
538                 THIS->push_spot ();
539         }
540         /*cont*/ '{' score_body '}'     {
541                 THIS->pop_spot ();
542                 $$ = $4;
543                 if (!$$->defs_.size ())
544                 {
545                   Music_output_def *id =
546                         unsmob_music_output_def (THIS->lexer_->lookup_identifier ("$defaultpaper"));
547                   $$->add_output (id ? id->clone () :  new Paper_def );
548                 }
549         }
550         ;
551
552 score_body:
553         Music   {
554                 $$ = new Score;
555         
556                 $$->set_spot (THIS->here_input ());
557                 SCM m = $1->self_scm ();
558                 scm_gc_unprotect_object (m);
559
560                 /*
561                         guh.
562                 */
563                 SCM check_funcs = scm_c_eval_string ("toplevel-music-functions");
564                 for (; gh_pair_p (check_funcs); check_funcs = gh_cdr (check_funcs))
565                         m = gh_call1 (gh_car (check_funcs), m);
566                 $$->music_ = m;
567
568         }
569         | SCORE_IDENTIFIER {
570                 $$ = new Score (*unsmob_score ($1));
571                 $$->set_spot (THIS->here_input ());
572         }
573         | score_body lilypond_header    {
574                 $$->header_ = $2;
575         }
576         | score_body output_def {
577                 $$->add_output ($2);
578         }
579         | score_body error {
580
581         }
582         ;
583
584
585 /*
586         MIDI
587 */
588 output_def:
589         music_output_def_body '}' {
590                 $$ = $1;
591                 THIS-> lexer_-> remove_scope ();
592         }
593         ;
594
595 music_output_def_body:
596         MIDI '{'    {
597                 Music_output_def *id = unsmob_music_output_def (THIS->lexer_->lookup_identifier ("$defaultmidi"));
598
599
600                 Midi_def* p =0;
601                 if (id)
602                         p = dynamic_cast<Midi_def*> (id->clone ());
603                 else
604                         p = new Midi_def;
605
606                 $$ = p;
607                 THIS->lexer_->add_scope (p->scope_);
608         }
609         | PAPER '{'     {
610                 Music_output_def *id = unsmob_music_output_def (THIS->lexer_->lookup_identifier ("$defaultpaper"));
611                   Paper_def *p = 0;
612                 if (id)
613                         p = dynamic_cast<Paper_def*> (id->clone ());
614                 else
615                         p = new Paper_def;
616                 THIS-> lexer_->add_scope (p->scope_);
617                 $$ = p;
618         }
619         | PAPER '{' MUSIC_OUTPUT_DEF_IDENTIFIER         {
620                 Music_output_def *p = unsmob_music_output_def ($3);
621                 p = p->clone ();
622                 THIS->lexer_->add_scope (p->scope_);
623                 $$ = p;
624         }
625         | MIDI '{' MUSIC_OUTPUT_DEF_IDENTIFIER  {
626                 Music_output_def *p = unsmob_music_output_def ($3);
627                 p = p->clone ();
628
629                 THIS->lexer_->add_scope (p->scope_);
630                 $$ = p;
631         }
632         | music_output_def_body assignment  {
633
634         }
635         | music_output_def_body translator_spec_block   {
636                 $$->assign_translator ($2);
637         }
638         | music_output_def_body STYLESHEET embedded_scm {
639                 dynamic_cast<Paper_def*> ($$)-> style_sheet_ = $3;
640         }
641         | music_output_def_body tempo_event  {
642                 /*
643                         junk this ? there already is tempo stuff in
644                         music.
645                 */
646                 int m = gh_scm2int ( $2->get_mus_property ("metronome-count"));
647                 Duration *d = unsmob_duration ($2->get_mus_property ("duration"));
648                 Midi_def * md = dynamic_cast<Midi_def*> ($$);
649                 if (md)
650                         md->set_tempo (d->get_length (), m);
651         }
652         | music_output_def_body error {
653
654         }
655         ;
656
657 tempo_event:
658         TEMPO steno_duration '=' bare_unsigned  {
659                 $$ = MY_MAKE_MUSIC("TempoEvent");
660                 $$->set_mus_property ("duration", $2);
661                 $$->set_mus_property ("metronome-count", gh_int2scm ( $4));
662         }
663         ;
664
665 /*
666 The representation of a  list is the
667
668   (LIST . LAST-CONS)
669
670  to have  efficient append.
671 */
672 Music_list: /* empty */ {
673                 $$ = scm_cons (SCM_EOL, SCM_EOL);
674         }
675         | Music_list Music {
676                 SCM s = $$;
677                 SCM c = scm_cons ($2->self_scm (), SCM_EOL);
678                 scm_gc_unprotect_object ($2->self_scm ()); /* UGH */
679                 if (gh_pair_p (ly_cdr (s)))
680                         gh_set_cdr_x (ly_cdr (s), c); /* append */
681                 else
682                         gh_set_car_x (s, c); /* set first cons */
683                 gh_set_cdr_x (s, c) ;  /* remember last cell */ 
684         }
685         | Music_list error {
686         }
687         ;
688
689
690 Music:
691         Simple_music
692         | Composite_music
693         ;
694
695 Alternative_music:
696         /* empty */ {
697                 $$ = SCM_EOL;
698         }
699         | ALTERNATIVE '{' Music_list '}' {
700                 $$ = $3;
701         }
702         ;
703
704 Repeated_music:
705         REPEAT string bare_unsigned Music Alternative_music
706         {
707                 Music *beg = $4;
708                 int times = $3;
709                 SCM alts = gh_pair_p ($5) ? gh_car ($5) : SCM_EOL;
710                 if (times < scm_ilength (alts)) {
711                   unsmob_music (gh_car (alts))
712                     ->origin ()->warning (
713                     _("More alternatives than repeats.  Junking excess alternatives."));
714                   alts = ly_truncate_list (times, alts);
715                 }
716
717
718                 static SCM proc;
719                 if (!proc)
720                         proc = scm_c_eval_string ("make-repeated-music");
721
722                 SCM mus = scm_call_1 (proc, $2);
723                 scm_gc_protect_object (mus); // UGH. 
724                 Music *r =unsmob_music (mus);
725                 if (beg)
726                         {
727                         r-> set_mus_property ("element", beg->self_scm ());
728                         scm_gc_unprotect_object (beg->self_scm ());
729                         }
730                 r->set_mus_property ("repeat-count", gh_int2scm (times >? 1));
731
732                 r-> set_mus_property ("elements",alts);
733                 if (gh_equal_p ($2, scm_makfrom0str ("tremolo")))
734                 {
735                 /*
736                 we can not get durations and other stuff correct down the line, so we have to
737                 add to the duration log here.
738                 */
739                         SCM func = scm_primitive_eval (ly_symbol2scm ("shift-duration-log"));
740                         if (($3 % 3) == 0)
741                           gh_call3 (func, r->self_scm (), gh_int2scm(-intlog2 ($3*2/3)),gh_int2scm(1));
742                         else
743                           gh_call3 (func, r->self_scm (), gh_int2scm(-intlog2 ($3)), gh_int2scm(0));
744                 }
745                 r->set_spot (*$4->origin ());
746
747                 $$ = r;
748         }
749         ;
750
751 Sequential_music:
752         SEQUENTIAL '{' Music_list '}'           {
753                 $$ = MY_MAKE_MUSIC("SequentialMusic");
754                 $$->set_mus_property ("elements", ly_car ($3));
755                 $$->set_spot(THIS->here_input());
756         }
757         | '{' Music_list '}'            {
758                 $$ = MY_MAKE_MUSIC("SequentialMusic");
759                 $$->set_mus_property ("elements", ly_car ($2));
760                 $$->set_spot(THIS->here_input());
761         }
762         ;
763
764 Simultaneous_music:
765         SIMULTANEOUS '{' Music_list '}'{
766                 $$ = MY_MAKE_MUSIC("SimultaneousMusic");
767                 $$->set_mus_property ("elements", ly_car ($3));
768                 $$->set_spot(THIS->here_input());
769
770         }
771         | '<' Music_list '>'    {
772                 $$ = MY_MAKE_MUSIC("SimultaneousMusic");
773                 $$->set_mus_property ("elements", ly_car ($2));
774                 $$->set_spot(THIS->here_input());
775         }
776         ;
777
778 Simple_music:
779         event_chord             { $$ = $1; }
780         | OUTPUTPROPERTY embedded_scm embedded_scm '=' embedded_scm     {
781                 SCM pred = $2;
782                 if (!gh_symbol_p ($3))
783                 {
784                         THIS->parser_error (_ ("Second argument must be a symbol")); 
785                 }
786                 /* Should check # args */
787                 if (!gh_procedure_p (pred))
788                 {
789                         THIS->parser_error (_ ("First argument must be a procedure taking one argument"));
790                 }
791
792                 Music*m = MY_MAKE_MUSIC("OutputPropertySetMusic");
793                 m->set_mus_property ("predicate", pred);
794                 m->set_mus_property ("grob-property", $3);
795                 m->set_mus_property ("grob-value",  $5);
796
797                 $$ = m;
798         }
799         | MUSIC_IDENTIFIER {
800                 $$ = unsmob_music ($1)->clone ();
801
802                 $$->set_spot (THIS->here_input());
803         }
804         | property_def
805         | translator_change
806         ;
807
808
809 Composite_music:
810         CONTEXT STRING Music    {
811                 Music*csm =MY_MAKE_MUSIC("ContextSpeccedMusic");
812
813                 csm->set_mus_property ("element", $3->self_scm ());
814                 scm_gc_unprotect_object ($3->self_scm ());
815
816                 csm->set_mus_property ("context-type",$2);
817                 csm->set_mus_property ("context-id", scm_makfrom0str (""));
818
819                 $$ = csm;
820         }
821         | AUTOCHANGE STRING Music       {
822         Music*chm = MY_MAKE_MUSIC("AutoChangeMusic");
823                 chm->set_mus_property ("element", $3->self_scm ());
824                 chm->set_mus_property ("iterator-ctor", Auto_change_iterator::constructor_proc);
825
826                 scm_gc_unprotect_object ($3->self_scm ());
827                 chm->set_mus_property ("what", $2); 
828
829                 $$ = chm;
830                 chm->set_spot (*$3->origin ());
831         }
832         | GRACE Music {
833 #if 1
834         /*
835                 The other version is for easier debugging  of
836                 Sequential_music_iterator in combination with grace notes.
837         */
838
839                 SCM start = THIS->lexer_->lookup_identifier ("startGraceMusic");
840                 SCM stop = THIS->lexer_->lookup_identifier ("stopGraceMusic");
841                 Music *startm = unsmob_music (start);
842                 Music *stopm = unsmob_music (stop);
843
844                 SCM ms = SCM_EOL;
845                 if (stopm) {
846                         stopm = stopm->clone ();
847                         ms = scm_cons (stopm->self_scm (), ms);
848                         scm_gc_unprotect_object (stopm->self_scm ());
849                 }
850                 ms = scm_cons ($2->self_scm (), ms);
851                 scm_gc_unprotect_object ($2->self_scm());
852                 if (startm) {
853                         startm = startm->clone ();
854                         ms = scm_cons (startm->self_scm () , ms);
855                         scm_gc_unprotect_object (startm->self_scm ());
856                 }
857
858         
859                 Music* seq = MY_MAKE_MUSIC("SequentialMusic");
860                 seq->set_mus_property ("elements", ms);
861
862                 
863                 $$ = MY_MAKE_MUSIC("GraceMusic");
864                 $$->set_mus_property ("element", seq->self_scm ());
865                 scm_gc_unprotect_object (seq->self_scm ());
866 #else
867                 $$ = MY_MAKE_MUSIC("GraceMusic");
868                 $$->set_mus_property ("element", $2->self_scm ());
869                 scm_gc_unprotect_object ($2->self_scm ());
870 #endif
871         }
872         | CONTEXT string '=' string Music {
873                 Music * csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
874
875                 csm->set_mus_property ("element", $5->self_scm ());
876                 scm_gc_unprotect_object ($5->self_scm ());
877
878                 csm->set_mus_property ("context-type", $2);
879                 csm->set_mus_property ("context-id", $4);
880
881                 $$ = csm;
882         }
883         | TIMES {
884                 THIS->push_spot ();
885         }
886         /* CONTINUED */ 
887                 fraction Music  
888
889         {
890                 int n = gh_scm2int (ly_car ($3)); int d = gh_scm2int (ly_cdr ($3));
891                 Music *mp = $4;
892         $$= MY_MAKE_MUSIC("TimeScaledMusic");
893                 $$->set_spot (THIS->pop_spot ());
894
895
896                 $$->set_mus_property ("element", mp->self_scm ());
897                 scm_gc_unprotect_object (mp->self_scm ());
898                 $$->set_mus_property ("numerator", gh_int2scm (n));
899                 $$->set_mus_property ("denominator", gh_int2scm (d));
900                 $$->compress (Moment (Rational (n,d)));
901
902         }
903         | Repeated_music                { $$ = $1; }
904         | Simultaneous_music            { $$ = $1; }
905         | Sequential_music              { $$ = $1; }
906         | TRANSPOSE pitch Music {
907                 $$ = MY_MAKE_MUSIC("TransposedMusic");
908                 Music *p = $3;
909                 Pitch pit = *unsmob_pitch ($2);
910
911                 p->transpose (pit);
912                 $$->set_mus_property ("element", p->self_scm ());
913                 scm_gc_unprotect_object (p->self_scm ());
914         }
915         | TRANSPOSE steno_tonic_pitch Music {
916                 $$ = MY_MAKE_MUSIC("TransposedMusic");
917                 Music *p = $3;
918                 Pitch pit = *unsmob_pitch ($2);
919
920                 p->transpose (pit);
921                 $$->set_mus_property ("element", p->self_scm ());
922                 scm_gc_unprotect_object (p->self_scm ());
923         
924         }
925         | APPLY embedded_scm Music  {
926                 SCM ret = gh_call1 ($2, $3->self_scm ());
927                 Music *m = unsmob_music (ret);
928                 if (!m) {
929                         THIS->parser_error ("\\apply must return a Music");
930                         m = MY_MAKE_MUSIC("Music");
931                         }
932                 $$ = m;
933         }
934         | NOTES
935                 { THIS->lexer_->push_note_state (); }
936         Music
937                 { $$ = $3;
938                   THIS->lexer_->pop_state ();
939                 }
940         | FIGURES
941                 { THIS->lexer_->push_figuredbass_state (); }
942         Music
943                 {
944                   Music * chm = MY_MAKE_MUSIC("UntransposableMusic");
945                   chm->set_mus_property ("element", $3->self_scm ());
946                   $$ = chm;
947                   scm_gc_unprotect_object ($3->self_scm());
948
949                   THIS->lexer_->pop_state ();
950         }
951         | CHORDS
952                 { THIS->lexer_->push_chord_state (); }
953         Music
954                 {
955                   Music * chm = MY_MAKE_MUSIC("UnrelativableMusic");
956                   chm->set_mus_property ("element", $3->self_scm ());
957                   scm_gc_unprotect_object ($3->self_scm());
958                   $$ = chm;
959
960                   THIS->lexer_->pop_state ();
961         }
962         | LYRICS
963                 { THIS->lexer_->push_lyric_state (); }
964         Music
965                 {
966                   $$ = $3;
967                   THIS->lexer_->pop_state ();
968         }
969         | relative_music        { $$ = $1; }
970         | re_rhythmed_music     { $$ = $1; } 
971         | part_combined_music   { $$ = $1; } 
972         ;
973
974 relative_music:
975         RELATIVE absolute_pitch Music {
976                 Music * p = $3;
977                 Pitch pit = *unsmob_pitch ($2);
978                 $$ = MY_MAKE_MUSIC("RelativeOctaveMusic");
979
980                 $$->set_mus_property ("element", p->self_scm ());
981                 scm_gc_unprotect_object (p->self_scm ());
982
983                 $$->set_mus_property ("last-pitch", p->to_relative_octave (pit).smobbed_copy ());
984
985         }
986         ;
987
988 re_rhythmed_music:
989         ADDLYRICS Music Music {
990         Music*l =MY_MAKE_MUSIC("LyricCombineMusic");
991           l->set_mus_property ("elements", gh_list ($2->self_scm (), $3->self_scm (), SCM_UNDEFINED));
992           scm_gc_unprotect_object ($3->self_scm ());
993           scm_gc_unprotect_object ($2->self_scm ());
994           $$ = l;
995         }
996         ;
997
998 part_combined_music:
999         PARTCOMBINE STRING Music Music {
1000         Music * p= MY_MAKE_MUSIC("PartCombineMusic");
1001                 p->set_mus_property ("what", $2);
1002                 p->set_mus_property ("elements", gh_list ($3->self_scm (),$4->self_scm (), SCM_UNDEFINED));  
1003
1004                 scm_gc_unprotect_object ($3->self_scm ());
1005                 scm_gc_unprotect_object ($4->self_scm ());  
1006
1007                 $$ = p;
1008         }
1009         ;
1010
1011 translator_change:
1012         TRANSLATOR STRING '=' STRING  {
1013                 Music*t= MY_MAKE_MUSIC("TranslatorChange");
1014                 t-> set_mus_property ("change-to-type", $2);
1015                 t-> set_mus_property ("change-to-id", $4);
1016
1017                 $$ = t;
1018                 $$->set_spot (THIS->here_input ());
1019         }
1020         ;
1021
1022 property_def:
1023         simple_property_def
1024         | ONCE simple_property_def {
1025                 $$ = $2;
1026                 SCM e = $2->get_mus_property ("element");
1027                 unsmob_music (e)->set_mus_property ("once", SCM_BOOL_T);
1028         }
1029         ;
1030
1031 simple_property_def:
1032         PROPERTY STRING '.' STRING '='  scalar {
1033                 Music *t = set_property_music (scm_string_to_symbol ($4), $6);
1034                 Music *csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
1035
1036                 csm->set_mus_property ("element", t->self_scm ());
1037                 scm_gc_unprotect_object (t->self_scm ());
1038
1039                 $$ = csm;
1040                 $$->set_spot (THIS->here_input ());
1041
1042                 csm-> set_mus_property ("context-type", $2);
1043         }
1044         | PROPERTY STRING '.' STRING UNSET {
1045                 
1046                 Music *t = MY_MAKE_MUSIC("PropertyUnset");
1047                 t->set_mus_property ("symbol", scm_string_to_symbol ($4));
1048
1049                 Music *csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
1050                 csm->set_mus_property ("element", t->self_scm ());
1051                 scm_gc_unprotect_object (t->self_scm ());
1052
1053                 $$ = csm;
1054                 $$->set_spot (THIS->here_input ());
1055
1056                 csm-> set_mus_property ("context-type", $2);
1057         }
1058         | PROPERTY STRING '.' STRING SET embedded_scm '=' embedded_scm {
1059                 bool autobeam
1060                   = gh_equal_p ($4, scm_makfrom0str ("autoBeamSettings"));
1061                 bool itc = internal_type_checking_global_b;
1062                 Music *t = MY_MAKE_MUSIC("OverrideProperty");
1063                 t->set_mus_property ("symbol", scm_string_to_symbol ($4));
1064                 t->set_mus_property ("pop-first", SCM_BOOL_T);
1065                 if (autobeam)
1066                         internal_type_checking_global_b = false;
1067                 t->set_mus_property ("grob-property", $6);
1068                 if (autobeam)
1069                         internal_type_checking_global_b = itc;
1070                 t->set_mus_property ("grob-value", $8);
1071
1072                 Music *csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
1073                 csm->set_mus_property ("element", t->self_scm ());
1074                 scm_gc_unprotect_object (t->self_scm ());
1075                 $$ = csm;
1076                 $$->set_spot (THIS->here_input ());
1077
1078                 csm-> set_mus_property ("context-type", $2);
1079         }
1080         | PROPERTY STRING '.' STRING OVERRIDE
1081                 embedded_scm '=' embedded_scm
1082         {
1083                 /*
1084                         UGH UGH UGH UGH.
1085                 */
1086                 bool autobeam
1087                   = gh_equal_p ($4, scm_makfrom0str ("autoBeamSettings"));
1088                 bool itc = internal_type_checking_global_b;
1089
1090                 Music *t = MY_MAKE_MUSIC("OverrideProperty");
1091                 t->set_mus_property ("symbol", scm_string_to_symbol ($4));
1092                 if (autobeam)
1093                         internal_type_checking_global_b = false;
1094                 t->set_mus_property ("grob-property", $6);
1095                 t->set_mus_property ("grob-value", $8);
1096                 if (autobeam)
1097                         internal_type_checking_global_b = itc;
1098
1099                 Music *csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
1100                 csm->set_mus_property ("element", t->self_scm ());
1101                 scm_gc_unprotect_object (t->self_scm ());
1102
1103                 $$ = csm;
1104                 $$->set_spot (THIS->here_input ());
1105
1106                 csm-> set_mus_property ("context-type", $2);
1107
1108         }
1109         | PROPERTY STRING '.' STRING REVERT embedded_scm {
1110                 Music *t = MY_MAKE_MUSIC("RevertProperty");
1111                 bool autobeam
1112                   = gh_equal_p ($4, scm_makfrom0str ("autoBeamSettings"));
1113                 bool itc = internal_type_checking_global_b;
1114
1115                 t->set_mus_property ("symbol", scm_string_to_symbol ($4));
1116                 if (autobeam)
1117                         internal_type_checking_global_b = false;
1118                 t->set_mus_property ("grob-property", $6);
1119                 if (autobeam)
1120                         internal_type_checking_global_b = itc;
1121         
1122                 Music *csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
1123                 csm->set_mus_property ("element", t->self_scm ());
1124                 scm_gc_unprotect_object (t->self_scm ());
1125
1126                 $$ = csm;
1127                 $$->set_spot (THIS->here_input ());
1128
1129                 csm-> set_mus_property ("context-type", $2);
1130         }
1131         ;
1132
1133
1134 scalar:
1135         string          { $$ = $1; }
1136         | bare_int      { $$ = gh_int2scm ($1); }
1137         | embedded_scm  { $$ = $1; }
1138         ;
1139
1140
1141 event_chord:
1142         pre_events {
1143                 THIS->push_spot ();
1144         } /*cont */ simple_element post_events  {
1145                 Music_sequence *l = dynamic_cast<Music_sequence*> ($3);
1146                 
1147                 $1->concat (*$4);
1148                 for (int i=0; i < $1->size (); i++) {
1149                   Music * m = $1->elem (i);
1150                   l->append_music (m);
1151                 }
1152                 $$ = $3;
1153
1154                 delete $1;
1155                 delete $4;
1156         }
1157         | command_element
1158         ;
1159
1160 command_element:
1161         command_req {
1162                 $$ = MY_MAKE_MUSIC("EventChord");
1163                 $$->set_mus_property ("elements", scm_cons ($1->self_scm (), SCM_EOL));
1164           scm_gc_unprotect_object ($1->self_scm());
1165
1166                 $$-> set_spot (THIS->here_input ());
1167                 $1-> set_spot (THIS->here_input ());
1168         }
1169         | E_LEFTSQUARE {
1170                 Music *l = MY_MAKE_MUSIC("LigatureEvent");
1171                 l->set_mus_property ("span-direction", gh_int2scm (START));
1172                 l->set_spot (THIS->here_input ());
1173
1174                 $$ = MY_MAKE_MUSIC("EventChord");
1175                 $$->set_mus_property ("elements", scm_cons (l->self_scm (), SCM_EOL));
1176           scm_gc_unprotect_object (l->self_scm());
1177                 $$->set_spot (THIS->here_input ());
1178         }
1179         | E_RIGHTSQUARE {
1180                 Music *l = MY_MAKE_MUSIC("LigatureEvent");
1181                 l->set_mus_property ("span-direction", gh_int2scm (STOP));
1182                 l->set_spot (THIS->here_input ());
1183
1184                 $$ = MY_MAKE_MUSIC("EventChord");
1185                 $$->set_mus_property ("elements", scm_cons (l->self_scm (), SCM_EOL));
1186                 $$->set_spot (THIS->here_input ());
1187           scm_gc_unprotect_object (l->self_scm());
1188
1189         }
1190         | E_BACKSLASH {
1191                 $$ = MY_MAKE_MUSIC("VoiceSeparator");
1192                 $$->set_spot (THIS->here_input ());
1193         }
1194         | '|'      {
1195
1196                 $$ = MY_MAKE_MUSIC("BarCheck");
1197                 $$->set_spot (THIS->here_input ());
1198         }
1199         | BAR STRING                    {
1200                 Music *t = set_property_music (ly_symbol2scm ("whichBar"), $2);
1201
1202                 Music *csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
1203                 csm->set_mus_property ("element", t->self_scm ());
1204                 scm_gc_unprotect_object (t->self_scm ());
1205
1206                 $$ = csm;
1207                 $$->set_spot (THIS->here_input ());
1208
1209                 csm->set_mus_property ("context-type", scm_makfrom0str ("Timing"));
1210         }
1211         | PARTIAL duration_length       {
1212                 Moment m = - unsmob_duration ($2)->get_length ();
1213                 Music * p = set_property_music (ly_symbol2scm ( "measurePosition"),m.smobbed_copy ());
1214
1215                 Music * sp = MY_MAKE_MUSIC("ContextSpeccedMusic");
1216                 sp->set_mus_property ("element", p->self_scm ());
1217                 scm_gc_unprotect_object (p->self_scm ());
1218
1219                 $$ =sp ;
1220                 sp-> set_mus_property ("context-type", scm_makfrom0str ("Timing"));
1221         }
1222         | CLEF STRING  {
1223                 static SCM proc ;
1224                 if (!proc)
1225                         proc = scm_c_eval_string ("make-clef-set");
1226
1227                 SCM result = scm_call_1 (proc, $2);
1228                 scm_gc_protect_object (result);
1229                 $$ = unsmob_music (result);
1230         }
1231         | TIME_T fraction  {
1232                 Music * p1 = set_property_music (ly_symbol2scm ( "timeSignatureFraction"), $2);
1233
1234                 int l = gh_scm2int (ly_car ($2));
1235                 int o = gh_scm2int (ly_cdr ($2));
1236
1237                 Moment one_beat = Moment (1)/Moment (o);
1238                 Moment len = Moment (l) * one_beat;
1239
1240
1241                 Music *p2 = set_property_music (ly_symbol2scm ("measureLength"), len.smobbed_copy ());
1242                 Music *p3 = set_property_music (ly_symbol2scm ("beatLength"), one_beat.smobbed_copy ());
1243
1244                 SCM list = scm_list_n (p1->self_scm (), p2->self_scm (), p3->self_scm(), SCM_UNDEFINED);
1245                 Music *seq = MY_MAKE_MUSIC("SequentialMusic");
1246                 seq->set_mus_property ("elements", list);
1247                 
1248
1249                 Music * sp = MY_MAKE_MUSIC("ContextSpeccedMusic");
1250                 sp->set_mus_property ("element", seq->self_scm ());
1251
1252                 scm_gc_unprotect_object (p3->self_scm ());
1253                 scm_gc_unprotect_object (p2->self_scm ());
1254                 scm_gc_unprotect_object (p1->self_scm ());
1255                 scm_gc_unprotect_object (seq->self_scm ());
1256
1257                 $$ = sp;
1258
1259                 sp-> set_mus_property ("context-type", scm_makfrom0str ( "Timing"));
1260         }
1261         ;
1262
1263 command_req:
1264         shorthand_command_req   { $$ = $1; }
1265         | verbose_command_req   { $$ = $1; }
1266         ;
1267
1268 shorthand_command_req:
1269         extender_req {
1270                 $$ = $1;
1271         }
1272         | hyphen_req {
1273                 $$ = $1;
1274         }
1275         | '~'   {
1276                 $$ = MY_MAKE_MUSIC("TieEvent");
1277         }
1278         | '['           {
1279                 Music *b= MY_MAKE_MUSIC("BeamEvent");
1280                 b->set_mus_property ("span-direction", gh_int2scm (START))
1281 ;
1282                 $$ =b;
1283
1284
1285                 THIS->last_beam_start_ = b->self_scm ();
1286         }
1287         | ']'           {
1288                 Music *b= MY_MAKE_MUSIC("BeamEvent");
1289                 b->set_mus_property ("span-direction", gh_int2scm (STOP));
1290                 $$ = b;
1291         }
1292         | BREATHE {
1293                 $$ = MY_MAKE_MUSIC("BreathingSignEvent");
1294         }
1295         | E_TILDE {
1296                 $$ = MY_MAKE_MUSIC("PorrectusEvent");
1297         }
1298         ;
1299
1300 verbose_command_req:
1301         COMMANDSPANREQUEST bare_int STRING {
1302                 Music *sp = make_span_req ($3);
1303                 sp->set_mus_property ("span-direction", gh_int2scm (Direction ($2)));
1304                 sp->set_spot (THIS->here_input ());
1305                 $$ = sp;
1306         }
1307         | MARK DEFAULT  {
1308                 Music * m = MY_MAKE_MUSIC("MarkEvent");
1309                 $$ = m;
1310         }
1311         | MARK scalar {
1312                 Music *m = MY_MAKE_MUSIC("MarkEvent");
1313                 m->set_mus_property ("label", $2);
1314                 $$ = m;
1315         }
1316         | PENALTY SCM_T         {
1317                 Music * b = MY_MAKE_MUSIC("BreakEvent");
1318                 SCM s = $2;
1319                 if (!gh_number_p (s))
1320                         s = gh_int2scm (0);
1321
1322                 b->set_mus_property ("penalty", s);
1323                 b->set_spot (THIS->here_input ());
1324                 $$ = b;
1325         }
1326         | SKIP duration_length {
1327                 Music * skip = MY_MAKE_MUSIC("SkipEvent");
1328                 skip->set_mus_property ("duration", $2);
1329
1330                 $$ = skip;
1331         }
1332         | tempo_event {
1333                 $$ = $1;
1334         }
1335         | KEY DEFAULT {
1336                 Music *key= MY_MAKE_MUSIC("KeyChangeEvent");
1337                 $$ = key;
1338         }
1339         | KEY NOTENAME_PITCH SCM_IDENTIFIER     {
1340                 Music *key= MY_MAKE_MUSIC("KeyChangeEvent");
1341                 
1342                 key->set_mus_property ("pitch-alist", $3);
1343                 ((Music*)key)->transpose (* unsmob_pitch ($2));
1344                 $$ = key; 
1345         }
1346         ;
1347
1348 post_events:
1349         {
1350                 $$ = new Link_array<Music>;
1351         }
1352         | post_events post_event {
1353                 $2->set_spot (THIS->here_input ());
1354                 $$->push ($2);
1355         }
1356         ;
1357
1358 post_event:
1359         verbose_event
1360         | event_with_dir
1361         | close_event
1362         | string_event
1363         ;
1364
1365
1366 string_event:
1367         E_UNSIGNED {
1368                 Music * s = MY_MAKE_MUSIC("StringNumberEvent");
1369                 s->set_mus_property ("string-number",  gh_int2scm($1));
1370                 s->set_spot (THIS->here_input ());
1371                 $$ = s;
1372         }
1373         ;
1374
1375
1376 event_that_take_dir:
1377         gen_text_def
1378         | verbose_event
1379         | script_abbreviation {
1380                 SCM s = THIS->lexer_->lookup_identifier ("dash" + ly_scm2string ($1));
1381                 Music *a = MY_MAKE_MUSIC("ArticulationEvent");
1382                 if (gh_string_p (s))
1383                         a->set_mus_property ("articulation-type", s);
1384                 else THIS->parser_error (_ ("Expecting string as script definition"));
1385                 $$ = a;
1386         }
1387         ;
1388
1389 event_with_dir:
1390         script_dir event_that_take_dir  {
1391                 $2->set_mus_property ("direction", gh_int2scm ($1));
1392                 $$ = $2;
1393         }
1394         ;
1395         
1396 verbose_event:
1397         EVENT_IDENTIFIER        {
1398                 $$ = unsmob_music ($1)->clone ();
1399                 $$->set_spot (THIS->here_input ());
1400         }
1401         | SPANREQUEST bare_int STRING {
1402
1403                 Music * sp = make_span_req ($3);
1404                 sp->set_mus_property ("span-direction", gh_int2scm ( $2));
1405                 sp->set_spot (THIS->here_input ());
1406                 $$ = sp;
1407         }
1408         | tremolo_type  {
1409                Music * a = MY_MAKE_MUSIC("TremoloEvent");
1410                a->set_spot (THIS->here_input ());
1411                a->set_mus_property ("tremolo-type", gh_int2scm ($1));
1412                $$ = a;
1413         }
1414         | SCRIPT STRING         { 
1415                 Music * a = MY_MAKE_MUSIC("ArticulationEvent");
1416                 a->set_mus_property ("articulation-type", $2);
1417                 a->set_spot (THIS->here_input ());
1418                 $$ = a;
1419         }
1420
1421         /*
1422                 duh, junk this syntax from the parser, if possible. 
1423         */
1424         | ARPEGGIO {
1425                 Music *a = MY_MAKE_MUSIC("ArpeggioEvent");
1426                 a->set_spot (THIS->here_input ());
1427                 $$ = a;
1428         }
1429         | GLISSANDO {
1430                 Music *g = MY_MAKE_MUSIC("GlissandoEvent");
1431                 g->set_spot /* No pun intended */ (THIS->here_input ());
1432                 $$ = g;
1433         }       
1434         ;
1435
1436 sup_quotes:
1437         '\'' {
1438                 $$ = 1;
1439         }
1440         | sup_quotes '\'' {
1441                 $$ ++;
1442         }
1443         ;
1444
1445 sub_quotes:
1446         ',' {
1447                 $$ = 1;
1448         }
1449         | sub_quotes ',' {
1450                 $$ ++ ;
1451         }
1452         ;
1453
1454 steno_pitch:
1455         NOTENAME_PITCH  {
1456                 $$ = $1;
1457         }
1458         | NOTENAME_PITCH sup_quotes     {
1459                 Pitch p = *unsmob_pitch ($1);
1460                 p.octave_ +=  $2;
1461                 $$ = p.smobbed_copy ();
1462         }
1463         | NOTENAME_PITCH sub_quotes      {
1464                 Pitch p =* unsmob_pitch ($1);
1465
1466                 p.octave_ +=  -$2;
1467                 $$ = p.smobbed_copy ();
1468
1469         }
1470         ;
1471
1472 /*
1473 ugh. duplication
1474 */
1475
1476 steno_tonic_pitch:
1477         TONICNAME_PITCH {
1478                 $$ = $1;
1479         }
1480         | TONICNAME_PITCH sup_quotes    {
1481                 Pitch p = *unsmob_pitch ($1);
1482                 p.octave_ +=  $2;
1483                 $$ = p.smobbed_copy ();
1484         }
1485         | TONICNAME_PITCH sub_quotes     {
1486                 Pitch p =* unsmob_pitch ($1);
1487
1488                 p.octave_ +=  -$2;
1489                 $$ = p.smobbed_copy ();
1490
1491         }
1492         ;
1493
1494 pitch:
1495         steno_pitch {
1496                 $$ = $1;
1497         }
1498         | explicit_pitch {
1499                 $$ = $1;
1500         }
1501         ;
1502
1503 explicit_pitch:
1504         PITCH embedded_scm {
1505                 $$ = $2;
1506                 if (!unsmob_pitch ($2)) {
1507                         THIS->parser_error (_f ("Expecting musical-pitch value", 3));
1508                          $$ = Pitch ().smobbed_copy ();
1509                 }
1510         }
1511         ;
1512
1513 verbose_duration:
1514         DURATION embedded_scm   {
1515                 $$ = $2;
1516                 if (!unsmob_duration ($2))
1517                 {
1518                         THIS->parser_error (_ ("Must have duration object"));
1519                         $$ = Duration ().smobbed_copy ();
1520                 }
1521         }
1522         ;
1523
1524 extender_req:
1525         EXTENDER {
1526                 if (!THIS->lexer_->lyric_state_b ())
1527                         THIS->parser_error (_ ("Have to be in Lyric mode for lyrics"));
1528                 $$ = MY_MAKE_MUSIC("ExtenderEvent");
1529         }
1530         ;
1531
1532 hyphen_req:
1533         HYPHEN {
1534                 if (!THIS->lexer_->lyric_state_b ())
1535                         THIS->parser_error (_ ("Have to be in Lyric mode for lyrics"));
1536                 $$ = MY_MAKE_MUSIC("HyphenEvent");
1537         }
1538         ;
1539
1540 close_event:
1541         close_event_parens {
1542                 $$ = $1;
1543                 dynamic_cast<Music *> ($$)->set_mus_property ("span-direction", gh_int2scm (START))
1544 ;
1545         }
1546         ;
1547  
1548 close_event_parens:
1549         '('     {
1550                 Music * s= MY_MAKE_MUSIC("SlurEvent");
1551                 $$ = s;
1552                 s->set_spot (THIS->here_input());
1553         }
1554         | E_OPEN        {
1555                 Music * s= MY_MAKE_MUSIC("PhrasingSlurEvent");
1556                 $$ = s;
1557                 s->set_spot (THIS->here_input());
1558         }
1559         | E_SMALLER {
1560                 Music *s =MY_MAKE_MUSIC("CrescendoEvent");
1561                 $$ = s;
1562                 s->set_spot (THIS->here_input());
1563         }
1564         | E_BIGGER {
1565                 Music *s =MY_MAKE_MUSIC("DecrescendoEvent");
1566                 $$ = s;
1567                 s->set_spot (THIS->here_input());
1568         }
1569         ;
1570
1571
1572 open_event:
1573         open_event_parens {
1574                 $$ = $1;
1575                 dynamic_cast<Music *> ($$)->set_mus_property ("span-direction", gh_int2scm (STOP))
1576 ;
1577         }
1578         ;
1579
1580 open_event_parens:
1581         E_EXCLAMATION   {
1582                 Music *s =  MY_MAKE_MUSIC("CrescendoEvent");
1583                 s->set_spot (THIS->here_input());
1584
1585                 $$ = s;
1586         }
1587         | ')'   {
1588                 Music * s= MY_MAKE_MUSIC("SlurEvent");
1589                 $$ = s;
1590                 s->set_spot (THIS->here_input());
1591
1592         }
1593         | E_CLOSE       {
1594                 Music * s= MY_MAKE_MUSIC("PhrasingSlurEvent");
1595                 $$ = s;
1596                 s->set_mus_property ("span-type", scm_makfrom0str ( "phrasing-slur"));
1597                 s->set_spot (THIS->here_input());
1598         }
1599         ;
1600
1601 gen_text_def:
1602         embedded_scm {
1603                 Music *t = MY_MAKE_MUSIC("TextScriptEvent");
1604                 t->set_mus_property ("text", $1);
1605                 t->set_spot (THIS->here_input ());
1606                 $$ = t;
1607         }
1608         | string {
1609                 Music *t = MY_MAKE_MUSIC("TextScriptEvent");
1610                 t->set_mus_property ("text", $1);
1611                 t->set_spot (THIS->here_input ());
1612                 $$ = t;
1613         }
1614         | DIGIT {
1615                 String ds = to_string ($1);
1616                 Music * t = MY_MAKE_MUSIC("TextScriptEvent");
1617                 SCM finger = ly_symbol2scm ("finger");
1618                 t->set_mus_property ("text",  scm_makfrom0str (ds.to_str0 ()));
1619                 t->set_mus_property ("text-type" , finger);
1620                 t->set_spot (THIS->here_input ());
1621                 $$ = t;
1622         }
1623         ;
1624
1625 script_abbreviation:
1626         '^'             {
1627                 $$ = scm_makfrom0str ("Hat");
1628         }
1629         | '+'           {
1630                 $$ = scm_makfrom0str ("Plus");
1631         }
1632         | '-'           {
1633                 $$ = scm_makfrom0str ("Dash");
1634         }
1635         | '|'           {
1636                 $$ = scm_makfrom0str ("Bar");
1637         }
1638         | '>'           {
1639                 $$ = scm_makfrom0str ("Larger");
1640         }
1641         | '.'           {
1642                 $$ = scm_makfrom0str ("Dot");
1643         }
1644         | '_' {
1645                 $$ = scm_makfrom0str ("Underscore");
1646         }
1647         ;
1648
1649 script_dir:
1650         '_'     { $$ = DOWN; }
1651         | '^'   { $$ = UP; }
1652         | '-'   { $$ = CENTER; }
1653         ;
1654
1655 pre_events:
1656         {
1657                 $$ = new Link_array<Music>;
1658         }
1659         | pre_events open_event {
1660                 $$->push ($2);
1661         }
1662         ;
1663
1664 absolute_pitch:
1665         steno_pitch     {
1666                 $$ = $1;
1667         }
1668         ;
1669
1670 duration_length:
1671         multiplied_duration {
1672                 $$ = $1;
1673         }
1674         | verbose_duration {
1675                 $$ = $1;
1676         }       
1677         ;
1678
1679 optional_notemode_duration:
1680         {
1681                 Duration dd = THIS->default_duration_;
1682                 $$ = dd.smobbed_copy ();
1683
1684                 THIS->beam_check ($$);
1685         }
1686         | multiplied_duration   {
1687                 $$ = $1;
1688                 THIS->default_duration_ = *unsmob_duration ($$);
1689
1690                 THIS->beam_check ($$);
1691         }
1692         | verbose_duration {
1693                 $$ = $1;
1694                 THIS->default_duration_ = *unsmob_duration ($$);
1695         }       
1696         ;
1697
1698 steno_duration:
1699         bare_unsigned dots              {
1700                 int l = 0;
1701                 if (!is_duration_b ($1))
1702                         THIS->parser_error (_f ("not a duration: %d", $1));
1703                 else
1704                         l =  intlog2 ($1);
1705
1706                 $$ = Duration (l, $2).smobbed_copy ();
1707         }
1708         | DURATION_IDENTIFIER dots      {
1709                 Duration *d =unsmob_duration ($1);
1710                 Duration k (d->duration_log (),d->dot_count () + $2);
1711                 $$ = k.smobbed_copy ();
1712         }
1713         ;
1714
1715
1716
1717
1718 multiplied_duration:
1719         steno_duration {
1720                 $$ = $1;
1721         }
1722         | multiplied_duration '*' bare_unsigned {
1723                 $$ = unsmob_duration ($$)->compressed ( $3) .smobbed_copy ();
1724         }
1725         | multiplied_duration '*' FRACTION {
1726                 Rational  m (gh_scm2int (ly_car ($3)), gh_scm2int (ly_cdr ($3)));
1727
1728                 $$ = unsmob_duration ($$)->compressed (m).smobbed_copy ();
1729         }
1730         ;
1731
1732 fraction:
1733         FRACTION { $$ = $1; }
1734         | UNSIGNED '/' UNSIGNED {
1735                 $$ = scm_cons (gh_int2scm ($1), gh_int2scm ($3));
1736         }
1737         ;
1738
1739 dots:
1740         /* empty */     {
1741                 $$ = 0;
1742         }
1743         | dots '.' {
1744                 $$ ++;
1745         }
1746         ;
1747
1748
1749 tremolo_type: 
1750         ':'     {
1751                 $$ =0;
1752         }
1753         | ':' bare_unsigned {
1754                 if (!is_duration_b ($2))
1755                         THIS->parser_error (_f ("not a duration: %d", $2));
1756                 $$ = $2;
1757         }
1758         ;
1759
1760
1761 bass_number:
1762         DIGIT
1763         | UNSIGNED 
1764         ;
1765
1766 bass_mod:
1767         '-'     { $$ = -1; }
1768         | '+'   { $$ = 1; } 
1769         | '!'   { $$ = 0; }
1770         ;
1771
1772 bass_figure:
1773         FIGURE_SPACE {
1774                 Music *bfr = MY_MAKE_MUSIC("BassFigureEvent");
1775                 $$ = bfr->self_scm();
1776                 scm_gc_unprotect_object ($$);
1777         }
1778         | bass_number  {
1779                 Music *bfr = MY_MAKE_MUSIC("BassFigureEvent");
1780                 $$ = bfr->self_scm();
1781
1782                 bfr->set_mus_property ("figure", gh_int2scm ($1));
1783
1784                 scm_gc_unprotect_object ($$);
1785         }
1786         | bass_figure bass_mod {
1787                 Music *m = unsmob_music ($1);
1788                 if ($2) {
1789                         SCM salter =m->get_mus_property ("alteration");
1790                         int alter = gh_number_p ( salter) ? gh_scm2int (salter) : 0;
1791                         m->set_mus_property ("alteration",
1792                                 gh_int2scm (alter + $2));
1793                 } else {
1794                         m->set_mus_property ("alteration", gh_int2scm (0));
1795                 }
1796         }
1797         ;
1798
1799 br_bass_figure:
1800         '[' bass_figure {
1801                 $$ = $2;
1802                 unsmob_music ($$)->set_mus_property ("bracket-start", SCM_BOOL_T);
1803         }
1804         | bass_figure   {
1805                 $$ = $1;
1806         }
1807         | br_bass_figure ']' {
1808                 $$ = $1;
1809                 unsmob_music ($1)->set_mus_property ("bracket-stop", SCM_BOOL_T);
1810         }
1811         ;
1812
1813 figure_list:
1814         /**/            {
1815                 $$ = SCM_EOL;
1816         }
1817         | figure_list br_bass_figure {
1818                 $$ = scm_cons ($2, $1); 
1819         }
1820         ;
1821
1822 figure_spec:
1823         FIGURE_OPEN figure_list FIGURE_CLOSE {
1824                 Music * m = MY_MAKE_MUSIC("EventChord");
1825                 $2 = scm_reverse_x ($2, SCM_EOL);
1826                 m->set_mus_property ("elements",  $2);
1827                 $$ = m->self_scm ();
1828         }
1829         ;
1830
1831
1832 optional_rest:
1833         /**/   { $$ = 0; }
1834         | REST { $$ = 1; }
1835         ;
1836
1837 simple_element:
1838         pitch exclamations questions optional_notemode_duration optional_rest {
1839
1840                 Input i = THIS->pop_spot ();
1841                 if (!THIS->lexer_->note_state_b ())
1842                         THIS->parser_error (_ ("Have to be in Note mode for notes"));
1843
1844                 Music *n = 0;
1845                 if ($5)
1846                         n =  MY_MAKE_MUSIC("RestEvent");
1847                 else
1848                         n =  MY_MAKE_MUSIC("NoteEvent");
1849                 
1850                 n->set_mus_property ("pitch", $1);
1851                 n->set_mus_property ("duration", $4);
1852
1853
1854                 if ($3 % 2)
1855                         n->set_mus_property ("cautionary", SCM_BOOL_T);
1856                 if ($2 % 2 || $3 % 2)
1857                         n->set_mus_property ("force-accidental", SCM_BOOL_T);
1858
1859                 Music *v = MY_MAKE_MUSIC("EventChord");
1860                 v->set_mus_property ("elements", scm_list_n (n->self_scm (), SCM_UNDEFINED));
1861                 scm_gc_unprotect_object (n->self_scm());
1862
1863                 v->set_spot (i);
1864                 n->set_spot (i);
1865                 $$ = v;
1866         }
1867         | figure_spec optional_notemode_duration {
1868                 Music * m = unsmob_music ($1);
1869                 Input i = THIS->pop_spot (); 
1870                 m->set_spot (i);
1871                 for (SCM s = m->get_mus_property ("elements"); gh_pair_p (s); s = ly_cdr (s))
1872                         {
1873                                 unsmob_music (ly_car (s))->set_mus_property ("duration", $2);
1874                         }
1875                 $$ = m;
1876         }       
1877         | RESTNAME optional_notemode_duration           {
1878
1879                 Input i = THIS->pop_spot ();
1880                 SCM e = SCM_UNDEFINED;
1881                 if (ly_scm2string ($1) =="s") {
1882                         /* Space */
1883                         Music * skip = MY_MAKE_MUSIC("SkipEvent");
1884                         skip->set_mus_property ("duration" ,$2);
1885                         skip->set_spot (i);
1886                         e = skip->self_scm ();
1887                   }
1888                   else {
1889                         Music * rest_req = MY_MAKE_MUSIC("RestEvent");
1890                         rest_req->set_mus_property ("duration", $2);
1891                         rest_req->set_spot (i);
1892                         e = rest_req->self_scm ();
1893                     }
1894                 Music * velt = MY_MAKE_MUSIC("EventChord");
1895                 velt-> set_mus_property ("elements", scm_list_n (e,SCM_UNDEFINED));
1896                 velt->set_spot (i);
1897
1898                 $$ = velt;
1899         }
1900         | MULTI_MEASURE_REST optional_notemode_duration         {
1901                 THIS->pop_spot ();
1902
1903                 Music * sk = MY_MAKE_MUSIC("SkipEvent");
1904                 sk->set_mus_property ("duration", $2);
1905                 Music *sp1 = MY_MAKE_MUSIC("MultiMeasureRestEvent");
1906                 Music *sp2 = MY_MAKE_MUSIC("MultiMeasureRestEvent");
1907                 sp1-> set_mus_property ("span-direction", gh_int2scm (START))
1908 ;
1909                 sp2-> set_mus_property ("span-direction", gh_int2scm (STOP))
1910 ;
1911                 Music *rqc1 = MY_MAKE_MUSIC("EventChord");
1912                 rqc1->set_mus_property ("elements", scm_list_n (sp1->self_scm (), SCM_UNDEFINED));
1913                 Music *rqc2 = MY_MAKE_MUSIC("EventChord");
1914                 rqc2->set_mus_property ("elements", scm_list_n (sk->self_scm (), SCM_UNDEFINED));;
1915                 Music *rqc3 = MY_MAKE_MUSIC("EventChord");
1916                 rqc3->set_mus_property ("elements", scm_list_n (sp2->self_scm (), SCM_UNDEFINED));;
1917
1918                 SCM ms = scm_list_n (rqc1->self_scm (), rqc2->self_scm (), rqc3->self_scm (), SCM_UNDEFINED);
1919
1920                 $$ = MY_MAKE_MUSIC("SequentialMusic");
1921                 $$->set_mus_property ("elements", ms);
1922         }
1923         | STRING optional_notemode_duration     {
1924                 Input i = THIS->pop_spot ();
1925
1926                 Music * lreq = MY_MAKE_MUSIC("LyricEvent");
1927                 lreq->set_mus_property ("text", $1);
1928                 lreq->set_mus_property ("duration",$2);
1929                 lreq->set_spot (i);
1930                 Music * velt = MY_MAKE_MUSIC("EventChord");
1931                 velt->set_mus_property ("elements", scm_list_n (lreq->self_scm (), SCM_UNDEFINED));
1932
1933                 $$= velt;
1934         }
1935         | chord {
1936                 THIS->pop_spot ();
1937
1938                 if (!THIS->lexer_->chord_state_b ())
1939                         THIS->parser_error (_ ("Have to be in Chord mode for chords"));
1940                 $$ = $1;
1941         }
1942         ;
1943
1944
1945 chord:
1946         steno_tonic_pitch optional_notemode_duration chord_additions chord_subtractions chord_inversion chord_bass {
1947                 $$ = Chord::get_chord ($1, $3, $4, $5, $6, $2);
1948                 $$->set_spot (THIS->here_input ());
1949         };
1950
1951 chord_additions: 
1952         {
1953                 $$ = SCM_EOL;
1954         } 
1955         | CHORD_COLON chord_notes {
1956                 $$ = $2;
1957         }
1958         ;
1959
1960 chord_notes:
1961         chord_step {
1962                 $$ = $1;
1963         }
1964         | chord_notes '.' chord_step {
1965                 $$ = gh_append2 ($$, $3);
1966         }
1967         ;
1968
1969 chord_subtractions: 
1970         {
1971                 $$ = SCM_EOL;
1972         } 
1973         | CHORD_CARET chord_notes {
1974                 $$ = $2;
1975         }
1976         ;
1977
1978
1979 chord_inversion:
1980         {
1981                 $$ = SCM_EOL;
1982         }
1983         | CHORD_SLASH steno_tonic_pitch {
1984                 $$ = $2;
1985         }
1986         ;
1987
1988 chord_bass:
1989         {
1990                 $$ = SCM_EOL;
1991         }
1992         | CHORD_BASS steno_tonic_pitch {
1993                 $$ = $2;
1994         }
1995         ;
1996
1997 chord_step:
1998         chord_note {
1999                 $$ = scm_cons ($1, SCM_EOL);
2000         }
2001         | CHORDMODIFIER_PITCH {
2002                 $$ = scm_cons (unsmob_pitch ($1)->smobbed_copy (), SCM_EOL);
2003         }
2004         | CHORDMODIFIER_PITCH chord_note { /* Ugh. */
2005                 $$ = scm_list_n (unsmob_pitch ($1)->smobbed_copy (),
2006                         $2, SCM_UNDEFINED);
2007         }
2008         ;
2009
2010 chord_note:
2011         bare_unsigned {
2012                  Pitch m;
2013                 m.notename_ = ($1 - 1) % 7;
2014                 m.octave_ = $1 > 7 ? 1 : 0;
2015                 m.alteration_ = 0;
2016
2017                 $$ = m.smobbed_copy ();
2018         } 
2019         | bare_unsigned '+' {
2020                 Pitch m;
2021                 m.notename_ = ($1 - 1) % 7;
2022                 m.octave_ = $1 > 7 ? 1 : 0;
2023                 m.alteration_ = 1;
2024
2025
2026                 $$ = m.smobbed_copy ();
2027         }
2028         | bare_unsigned CHORD_MINUS {
2029                 Pitch m;
2030                 m.notename_ = ($1 - 1) % 7;
2031                 m.octave_ = $1 > 7 ? 1 : 0;
2032                 m.alteration_ = -1;
2033
2034                 $$ = m.smobbed_copy ();
2035         }
2036         ;
2037
2038 /*
2039         UTILITIES
2040  */
2041 number_expression:
2042         number_expression '+' number_term {
2043                 $$ = scm_sum ($1, $3);
2044         }
2045         | number_expression '-' number_term {
2046                 $$ = scm_difference ($1, $3);
2047         }
2048         | number_term 
2049         ;
2050
2051 number_term:
2052         number_factor {
2053                 $$ = $1;
2054         }
2055         | number_factor '*' number_factor {
2056                 $$ = scm_product ($1, $3);
2057         }
2058         | number_factor '/' number_factor {
2059                 $$ = scm_divide ($1, $3);
2060         }
2061         ;
2062
2063 number_factor:
2064         '(' number_expression ')'       {
2065                 $$ = $2;
2066         }
2067         | '-'  number_factor { /* %prec UNARY_MINUS */
2068                 $$ = scm_difference ($2, SCM_UNDEFINED);
2069         }
2070         | bare_number
2071         ;
2072
2073
2074 bare_number:
2075         UNSIGNED        {
2076                 $$ = gh_int2scm ($1);
2077         }
2078         | REAL          {
2079                 $$ = $1;
2080         }
2081         | NUMBER_IDENTIFIER             {
2082                 $$ = $1;
2083         }
2084         | REAL CM_T     {
2085                 $$ = gh_double2scm (gh_scm2double ($1) CM );
2086         }
2087         | REAL PT_T     {
2088                 $$ = gh_double2scm (gh_scm2double ($1) PT);
2089         }
2090         | REAL IN_T     {
2091                 $$ = gh_double2scm (gh_scm2double ($1) INCH);
2092         }
2093         | REAL MM_T     {
2094                 $$ = gh_double2scm (gh_scm2double ($1) MM);
2095         }
2096         | REAL CHAR_T   {
2097                 $$ = gh_double2scm (gh_scm2double ($1) CHAR);
2098         }
2099         ;
2100
2101
2102 bare_unsigned:
2103         UNSIGNED {
2104                         $$ = $1;
2105         }
2106         | DIGIT {
2107                 $$ = $1;
2108         }
2109         ;
2110
2111 bare_int:
2112         bare_number {
2113                 if (scm_integer_p ($1) == SCM_BOOL_T)
2114                 {
2115                         int k = gh_scm2int ($1);
2116                         $$ = k;
2117                 } else
2118                 {
2119                         THIS->parser_error (_ ("need integer number arg"));
2120                         $$ = 0;
2121                 }
2122         }
2123         | '-' bare_int {
2124                 $$ = -$2;
2125         }
2126         ;
2127
2128
2129 string:
2130         STRING          {
2131                 $$ = $1;
2132         }
2133         | STRING_IDENTIFIER     {
2134                 $$ = $1;
2135         }
2136         | string '+' string {
2137                 $$ = scm_string_append (scm_list_n ($1, $3, SCM_UNDEFINED));
2138         }
2139         ;
2140
2141
2142 exclamations:
2143                 { $$ = 0; }
2144         | exclamations '!'      { $$ ++; }
2145         ;
2146
2147 questions:
2148                 { $$ = 0; }
2149         | questions '?' { $$ ++; }
2150         ;
2151
2152
2153 %%
2154
2155 void
2156 My_lily_parser::set_yydebug (bool )
2157 {
2158 #if 0
2159         yydebug = b;
2160 #endif
2161 }
2162
2163 extern My_lily_parser * current_parser;
2164
2165 void
2166 My_lily_parser::do_yyparse ()
2167 {
2168
2169         current_parser = this;;
2170         yyparse ((void*)this);
2171 }
2172
2173
2174 /*
2175 Should make this optional?    It will also complain when you do
2176
2177         [s4]
2178
2179 which is entirely legitimate.
2180
2181 Or we can scrap it. Barchecks should detect wrong durations, and
2182 skipTypesetting speeds it up a lot.
2183 */
2184 void
2185 My_lily_parser::beam_check (SCM dur)
2186 {
2187   Duration *d = unsmob_duration (dur);
2188   if (unsmob_music (last_beam_start_) && d->duration_log () <= 2)
2189     {
2190       Music * m = unsmob_music (last_beam_start_);
2191       m->origin ()->warning (_("Suspect duration found following this beam"));
2192     }
2193   last_beam_start_ = SCM_EOL;
2194 }