]> git.donarmstrong.com Git - lilypond.git/blob - lily/parser.yy
* lily/source-file.cc (get_line): oops. All line numbers were off
[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         | close_event
1380         | open_event
1381         | script_abbreviation {
1382                 SCM s = THIS->lexer_->lookup_identifier ("dash" + ly_scm2string ($1));
1383                 Music *a = MY_MAKE_MUSIC("ArticulationEvent");
1384                 if (gh_string_p (s))
1385                         a->set_mus_property ("articulation-type", s);
1386                 else THIS->parser_error (_ ("Expecting string as script definition"));
1387                 $$ = a;
1388         }
1389         ;
1390
1391 event_with_dir:
1392         script_dir event_that_take_dir  {
1393                 $2->set_mus_property ("direction", gh_int2scm ($1));
1394                 $$ = $2;
1395         }
1396         ;
1397         
1398 verbose_event:
1399         EVENT_IDENTIFIER        {
1400                 $$ = unsmob_music ($1)->clone ();
1401                 $$->set_spot (THIS->here_input ());
1402         }
1403         | SPANREQUEST bare_int STRING {
1404
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 }