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