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