]> git.donarmstrong.com Git - lilypond.git/blob - lily/parser.yy
73ad657154eb22d02f72af93544190a8a4a38db1
[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                 bool autobeam
1069                   = gh_equal_p ($4, scm_makfrom0str ("autoBeamSettings"));
1070                 bool itc = internal_type_checking_global_b;
1071                 Music *t = new Music (SCM_EOL);
1072                 t->set_mus_property ("iterator-ctor",
1073                         Push_property_iterator::constructor_cxx_function);
1074                 t->set_mus_property ("symbol", scm_string_to_symbol ($4));
1075                 t->set_mus_property ("pop-first", SCM_BOOL_T);
1076                 if (autobeam)
1077                         internal_type_checking_global_b = false;
1078                 t->set_mus_property ("grob-property", $6);
1079                 if (autobeam)
1080                         internal_type_checking_global_b = itc;
1081                 t->set_mus_property ("grob-value", $8);
1082                 Context_specced_music *csm = new Context_specced_music (SCM_EOL);
1083                 csm->set_mus_property ("element", t->self_scm ());
1084                 scm_gc_unprotect_object (t->self_scm ());
1085                 $$ = csm;
1086                 $$->set_spot (THIS->here_input ());
1087
1088                 csm-> set_mus_property ("context-type", $2);
1089         }
1090         | PROPERTY STRING '.' STRING OVERRIDE embedded_scm '=' embedded_scm {
1091                 /*
1092                         UGH UGH UGH UGH.
1093                 */
1094                 bool autobeam
1095                   = gh_equal_p ($4, scm_makfrom0str ("autoBeamSettings"));
1096                 bool itc = internal_type_checking_global_b;
1097
1098                 Music *t = new Music (SCM_EOL);
1099                 t->set_mus_property ("iterator-ctor",
1100                         Push_property_iterator::constructor_cxx_function);
1101                 t->set_mus_property ("symbol", scm_string_to_symbol ($4));
1102
1103                 if (autobeam)
1104                         internal_type_checking_global_b = false;
1105                 t->set_mus_property ("grob-property", $6);
1106                 t->set_mus_property ("grob-value", $8);
1107                 if (autobeam)
1108                         internal_type_checking_global_b = itc;
1109
1110                 Context_specced_music *csm = new Context_specced_music (SCM_EOL);
1111                 csm->set_mus_property ("element", t->self_scm ());
1112                 scm_gc_unprotect_object (t->self_scm ());
1113
1114                 $$ = csm;
1115                 $$->set_spot (THIS->here_input ());
1116
1117                 csm-> set_mus_property ("context-type", $2);
1118         }
1119         | PROPERTY STRING '.' STRING REVERT embedded_scm {
1120                 Music *t = new Music (SCM_EOL);
1121                 bool autobeam
1122                   = gh_equal_p ($4, scm_makfrom0str ("autoBeamSettings"));
1123                 bool itc = internal_type_checking_global_b;
1124
1125                 t->set_mus_property ("iterator-ctor",
1126                         Pop_property_iterator::constructor_cxx_function);
1127                 t->set_mus_property ("symbol", scm_string_to_symbol ($4));
1128                 if (autobeam)
1129                         internal_type_checking_global_b = false;
1130                 t->set_mus_property ("grob-property", $6);
1131                 if (autobeam)
1132                         internal_type_checking_global_b = itc;
1133         
1134                 Context_specced_music *csm = new Context_specced_music (SCM_EOL);
1135                 csm->set_mus_property ("element", t->self_scm ());
1136                 scm_gc_unprotect_object (t->self_scm ());
1137
1138                 $$ = csm;
1139                 $$->set_spot (THIS->here_input ());
1140
1141                 csm-> set_mus_property ("context-type", $2);
1142         }
1143         ;
1144
1145
1146 scalar:
1147         string          { $$ = $1; }
1148         | bare_int      { $$ = gh_int2scm ($1); }
1149         | embedded_scm  { $$ = $1; }
1150         ;
1151
1152
1153 request_chord:
1154         pre_requests {
1155                 THIS->push_spot ();
1156         } /*cont */ simple_element post_requests        {
1157                 Music_sequence *l = dynamic_cast<Music_sequence*> ($3);
1158                 
1159                 $1->concat (*$4);
1160                 for (int i=0; i < $1->size (); i++) {
1161                   Music * m = $1->elem (i);
1162                   l->append_music (m);
1163                 }
1164                 $$ = $3;
1165
1166                 delete $1;
1167                 delete $4;
1168         }
1169         | command_element
1170         ;
1171
1172 command_element:
1173         command_req {
1174                 $$ = new Request_chord (SCM_EOL);
1175                 $$->set_mus_property ("elements", gh_cons ($1->self_scm (), SCM_EOL));
1176           scm_gc_unprotect_object ($1->self_scm());
1177
1178                 $$-> set_spot (THIS->here_input ());
1179                 $1-> set_spot (THIS->here_input ());
1180         }
1181         | E_LEFTSQUARE {
1182                 Span_req *l = new Span_req;
1183                 l->set_span_dir (START);
1184                 l->set_mus_property ("span-type", scm_makfrom0str ("ligature"));
1185                 l->set_spot (THIS->here_input ());
1186
1187                 $$ = new Request_chord (SCM_EOL);
1188                 $$->set_mus_property ("elements", gh_cons (l->self_scm (), SCM_EOL));
1189           scm_gc_unprotect_object (l->self_scm());
1190                 $$->set_spot (THIS->here_input ());
1191         }
1192         | E_RIGHTSQUARE {
1193                 Span_req *l = new Span_req;
1194                 l->set_span_dir (STOP);
1195                 l->set_mus_property ("span-type", scm_makfrom0str ("ligature"));
1196                 l->set_spot (THIS->here_input ());
1197
1198                 $$ = new Request_chord (SCM_EOL);
1199                 $$->set_mus_property ("elements", gh_cons (l->self_scm (), SCM_EOL));
1200                 $$->set_spot (THIS->here_input ());
1201           scm_gc_unprotect_object (l->self_scm());
1202
1203         }
1204         | E_BACKSLASH {
1205                 $$ = new Music (gh_list (gh_cons (ly_symbol2scm ("name"), ly_symbol2scm ("separator")), SCM_UNDEFINED));
1206                 $$->set_spot (THIS->here_input ());
1207         }
1208         | '|'      {
1209
1210                 extern Music * get_barcheck();
1211                 $$ = get_barcheck ();
1212                 $$->set_spot (THIS->here_input ());
1213         }
1214         | BAR STRING                    {
1215                 Music *t = set_property_music (ly_symbol2scm ("whichBar"), $2);
1216
1217                 Context_specced_music *csm = new Context_specced_music (SCM_EOL);
1218                 csm->set_mus_property ("element", t->self_scm ());
1219                 scm_gc_unprotect_object (t->self_scm ());
1220
1221                 $$ = csm;
1222                 $$->set_spot (THIS->here_input ());
1223
1224                 csm->set_mus_property ("context-type", scm_makfrom0str ("Score"));
1225         }
1226         | PARTIAL duration_length       {
1227                 Moment m = - unsmob_duration ($2)->length_mom ();
1228                 Music * p = set_property_music (ly_symbol2scm ( "measurePosition"),m.smobbed_copy ());
1229
1230                 Context_specced_music * sp = new Context_specced_music (SCM_EOL);
1231                 sp->set_mus_property ("element", p->self_scm ());
1232                 scm_gc_unprotect_object (p->self_scm ());
1233
1234                 $$ =sp ;
1235                 sp-> set_mus_property ("context-type", scm_makfrom0str ( "Score"));
1236         }
1237         | CLEF STRING  {
1238                 SCM func = scm_primitive_eval (ly_symbol2scm ("clef-name-to-properties"));
1239                 SCM result = gh_call1 (func, $2);
1240
1241                 SCM l = SCM_EOL;
1242                 for (SCM s = result ; gh_pair_p (s); s = ly_cdr (s)) {
1243                         Music * p = new Music (SCM_EOL);
1244                         set_music_properties (p, ly_car (s));
1245                         l = gh_cons (p->self_scm (), l);
1246                         scm_gc_unprotect_object (p->self_scm ());
1247                 }
1248                 Sequential_music * seq = new Sequential_music (SCM_EOL);
1249                 seq->set_mus_property ("elements", l);
1250
1251                 Context_specced_music * sp = new Context_specced_music (SCM_EOL);
1252                 sp->set_mus_property ("element", seq->self_scm ());
1253                 scm_gc_unprotect_object (seq->self_scm ());
1254
1255                 $$ =sp ;
1256                 sp-> set_mus_property ("context-type", scm_makfrom0str ("Staff"));
1257         }
1258         | TIME_T fraction  {
1259                 Music * p1 = set_property_music (ly_symbol2scm ( "timeSignatureFraction"), $2);
1260
1261                 int l = gh_scm2int (ly_car ($2));
1262                 int o = gh_scm2int (ly_cdr ($2));
1263
1264                 Moment one_beat = Moment (1)/Moment (o);
1265                 Moment len = Moment (l) * one_beat;
1266
1267
1268                 Music *p2 = set_property_music (ly_symbol2scm ("measureLength"), len.smobbed_copy ());
1269                 Music *p3 = set_property_music (ly_symbol2scm ("beatLength"), one_beat.smobbed_copy ());
1270
1271                 SCM list = scm_list_n (p1->self_scm (), p2->self_scm (), p3->self_scm(), SCM_UNDEFINED);
1272                 Sequential_music *seq = new Sequential_music (SCM_EOL);
1273                 seq->set_mus_property ("elements", list);
1274                 
1275
1276                 Context_specced_music * sp = new Context_specced_music (SCM_EOL);
1277                 sp->set_mus_property ("element", seq->self_scm ());
1278
1279                 
1280
1281                 scm_gc_unprotect_object (p3->self_scm ());
1282                 scm_gc_unprotect_object (p2->self_scm ());
1283                 scm_gc_unprotect_object (p1->self_scm ());
1284                 scm_gc_unprotect_object (seq->self_scm ());
1285
1286                 $$ = sp;
1287
1288 /*
1289  TODO: should make alias TimingContext for Score
1290 */
1291
1292                 sp-> set_mus_property ("context-type", scm_makfrom0str ( "Score"));
1293         }
1294         ;
1295
1296 command_req:
1297         shorthand_command_req   { $$ = $1; }
1298         | verbose_command_req   { $$ = $1; }
1299         ;
1300
1301 shorthand_command_req:
1302         extender_req {
1303                 $$ = $1;
1304         }
1305         | hyphen_req {
1306                 $$ = $1;
1307         }
1308         | '~'   {
1309                 $$ = new Tie_req;
1310         }
1311         | '['           {
1312                 Span_req*b= new Span_req;
1313                 b->set_span_dir (START);
1314                 b->set_mus_property ("span-type", scm_makfrom0str ("beam"));
1315                 $$ =b;
1316
1317
1318                 THIS->last_beam_start_ = b->self_scm ();
1319         }
1320         | ']'           {
1321                 Span_req*b= new Span_req;
1322                 b->set_span_dir ( STOP);
1323                 b->set_mus_property ("span-type", scm_makfrom0str ("beam"));
1324                 $$ = b;
1325         }
1326         | BREATHE {
1327                 $$ = new Breathing_sign_req;
1328         }
1329         | E_TILDE {
1330                 $$ = new Porrectus_req;
1331         }
1332         ;
1333
1334 verbose_command_req:
1335         COMMANDSPANREQUEST bare_int STRING { /*TODO: junkme */
1336                 Span_req * sp = new Span_req;
1337                 sp-> set_span_dir ( Direction ($2));
1338                 sp->set_mus_property ("span-type",$3);
1339                 sp->set_spot (THIS->here_input ());
1340                 $$ = sp;
1341         }
1342         | MARK DEFAULT  {
1343                 Mark_req * m = new Mark_req;
1344                 $$ = m;
1345         }
1346         | MARK scalar {
1347                 Mark_req *m = new Mark_req;
1348                 m->set_mus_property ("label", $2);
1349                 $$ = m;
1350         }
1351         | PENALTY SCM_T         {
1352                 Break_req * b = new Break_req;
1353                 SCM s = $2;
1354                 if (!gh_number_p (s))
1355                         s  =gh_int2scm (0);
1356
1357                 b->set_mus_property ("penalty", s);
1358                 b->set_spot (THIS->here_input ());
1359                 $$ = b;
1360         }
1361         | SKIP duration_length {
1362                 Skip_req * skip = new Skip_req;
1363                 skip->set_mus_property ("duration", $2);
1364
1365                 $$ = skip;
1366         }
1367         | tempo_request {
1368                 $$ = $1;
1369         }
1370         | KEY DEFAULT {
1371                 Key_change_req *key= new Key_change_req;
1372                 $$ = key;
1373         }
1374         | KEY NOTENAME_PITCH SCM_IDENTIFIER     {
1375                 Key_change_req *key= new Key_change_req;
1376                 
1377                 key->set_mus_property ("pitch-alist", $3);
1378                 ((Music*)key)->transpose (* unsmob_pitch ($2));
1379                 $$ = key; 
1380         }
1381         ;
1382
1383 post_requests:
1384         {
1385                 $$ = new Link_array<Request>;
1386         }
1387         | post_requests post_request {
1388                 $2->set_spot (THIS->here_input ());
1389                 $$->push ($2);
1390         }
1391         ;
1392
1393 post_request:
1394         verbose_request
1395         | request_with_dir
1396         | close_request
1397         ;
1398
1399
1400 request_that_take_dir:
1401         gen_text_def
1402         | verbose_request
1403         | script_abbreviation {
1404                 SCM s = THIS->lexer_->lookup_identifier ("dash" + ly_scm2string ($1));
1405                 Articulation_req *a = new Articulation_req;
1406                 if (gh_string_p (s))
1407                         a->set_mus_property ("articulation-type", s);
1408                 else THIS->parser_error (_ ("Expecting string as script definition"));
1409                 $$ = a;
1410         }
1411         ;
1412
1413 request_with_dir:
1414         script_dir request_that_take_dir        {
1415                 if (Script_req * gs = dynamic_cast<Script_req*> ($2))
1416                         gs->set_direction (Direction ($1));
1417                 else if ($1)
1418                         $2->origin ()->warning (_ ("Can't specify direction for this request"));
1419                 $$ = $2;
1420         }
1421         ;
1422         
1423 verbose_request:
1424         REQUEST_IDENTIFIER      {
1425                 $$ = dynamic_cast<Request*> (unsmob_music ($1)->clone ());
1426                 $$->set_spot (THIS->here_input ());
1427         }
1428         | DYNAMICSCRIPT embedded_scm {
1429                 /*
1430                         TODO: junkme, use text-type == dynamic
1431                 */
1432                 Text_script_req *d = new Text_script_req;
1433                 SCM dyn = ly_symbol2scm ("dynamic");
1434                 d->set_mus_property ("text-type" , dyn);
1435                 d->set_mus_property ("text", $2);
1436                 d->set_spot (THIS->here_input ());
1437                 $$ = d;
1438         }
1439         | SPANREQUEST bare_int STRING {
1440                 Span_req * sp = new Span_req;
1441                 sp->set_span_dir ( Direction ($2));
1442                 sp->set_mus_property ("span-type", $3);
1443                 sp->set_spot (THIS->here_input ());
1444                 $$ = sp;
1445         }
1446         | tremolo_type  {
1447                Tremolo_req* a = new Tremolo_req;
1448                a->set_spot (THIS->here_input ());
1449                a->set_mus_property ("tremolo-type", gh_int2scm ($1));
1450                $$ = a;
1451         }
1452         | SCRIPT STRING         { 
1453                 Articulation_req * a = new Articulation_req;
1454                 a->set_mus_property ("articulation-type", $2);
1455                 a->set_spot (THIS->here_input ());
1456                 $$ = a;
1457         }
1458         /*
1459 duh, junk this syntax from the parser, if possible. 
1460         */
1461         | ARPEGGIO {
1462                 Arpeggio_req *a = new Arpeggio_req;
1463                 a->set_spot (THIS->here_input ());
1464                 $$ = a;
1465         }
1466         | GLISSANDO {
1467                 Glissando_req *g = new Glissando_req;
1468                 g->set_spot /* No pun intended */ (THIS->here_input ());
1469                 $$ = g;
1470         }       
1471         ;
1472
1473 sup_quotes:
1474         '\'' {
1475                 $$ = 1;
1476         }
1477         | sup_quotes '\'' {
1478                 $$ ++;
1479         }
1480         ;
1481
1482 sub_quotes:
1483         ',' {
1484                 $$ = 1;
1485         }
1486         | sub_quotes ',' {
1487                 $$ ++ ;
1488         }
1489         ;
1490
1491 steno_pitch:
1492         NOTENAME_PITCH  {
1493                 $$ = $1;
1494         }
1495         | NOTENAME_PITCH sup_quotes     {
1496                 Pitch p = *unsmob_pitch ($1);
1497                 p.octave_ +=  $2;
1498                 $$ = p.smobbed_copy ();
1499         }
1500         | NOTENAME_PITCH sub_quotes      {
1501                 Pitch p =* unsmob_pitch ($1);
1502
1503                 p.octave_ +=  -$2;
1504                 $$ = p.smobbed_copy ();
1505
1506         }
1507         ;
1508
1509 /*
1510 ugh. duplication
1511 */
1512
1513 steno_tonic_pitch:
1514         TONICNAME_PITCH {
1515                 $$ = $1;
1516         }
1517         | TONICNAME_PITCH sup_quotes    {
1518                 Pitch p = *unsmob_pitch ($1);
1519                 p.octave_ +=  $2;
1520                 $$ = p.smobbed_copy ();
1521         }
1522         | TONICNAME_PITCH sub_quotes     {
1523                 Pitch p =* unsmob_pitch ($1);
1524
1525                 p.octave_ +=  -$2;
1526                 $$ = p.smobbed_copy ();
1527
1528         }
1529         ;
1530
1531 pitch:
1532         steno_pitch {
1533                 $$ = $1;
1534         }
1535         | explicit_pitch {
1536                 $$ = $1;
1537         }
1538         ;
1539
1540 explicit_pitch:
1541         PITCH embedded_scm {
1542                 $$ = $2;
1543                 if (!unsmob_pitch ($2)) {
1544                         THIS->parser_error (_f ("Expecting musical-pitch value", 3));
1545                          $$ = Pitch ().smobbed_copy ();
1546                 }
1547         }
1548         ;
1549
1550 verbose_duration:
1551         DURATION embedded_scm   {
1552                 $$ = $2;
1553                 if (!unsmob_duration ($2))
1554                 {
1555                         THIS->parser_error (_ ("Must have duration object"));
1556                         $$ = Duration ().smobbed_copy ();
1557                 }
1558         }
1559         ;
1560
1561 extender_req:
1562         EXTENDER {
1563                 if (!THIS->lexer_->lyric_state_b ())
1564                         THIS->parser_error (_ ("Have to be in Lyric mode for lyrics"));
1565                 $$ = new Extender_req;
1566         }
1567         ;
1568
1569 hyphen_req:
1570         HYPHEN {
1571                 if (!THIS->lexer_->lyric_state_b ())
1572                         THIS->parser_error (_ ("Have to be in Lyric mode for lyrics"));
1573                 $$ = new Hyphen_req;
1574         }
1575         ;
1576
1577 close_request:
1578         close_request_parens {
1579                 $$ = $1;
1580                 dynamic_cast<Span_req*> ($$)->set_span_dir ( START);
1581         }
1582         ;
1583  
1584 close_request_parens:
1585         '('     {
1586                 Span_req* s= new Span_req;
1587                 $$ = s;
1588                 s->set_mus_property ("span-type", scm_makfrom0str ( "slur"));
1589                 s->set_spot (THIS->here_input());
1590         }
1591         | E_OPEN        {
1592                 Span_req* s= new Span_req;
1593                 $$ = s;
1594                 s->set_mus_property ("span-type", scm_makfrom0str ( "phrasing-slur"));
1595                 s->set_spot (THIS->here_input());
1596         }
1597         | E_SMALLER {
1598                 Span_req*s =new Span_req;
1599                 $$ = s;
1600                 s->set_mus_property ("span-type", scm_makfrom0str ( "crescendo"));
1601                 s->set_spot (THIS->here_input());
1602         }
1603         | E_BIGGER {
1604                 Span_req*s =new Span_req;
1605                 $$ = s;
1606                 s->set_mus_property ("span-type", scm_makfrom0str ("decrescendo"));
1607                 s->set_spot (THIS->here_input());
1608         }
1609         ;
1610
1611
1612 open_request:
1613         open_request_parens {
1614                 $$ = $1;
1615                 dynamic_cast<Span_req*> ($$)->set_span_dir (STOP);
1616         }
1617         ;
1618
1619 open_request_parens:
1620         E_EXCLAMATION   {
1621                 Span_req *s =  new Span_req;
1622                 s->set_mus_property ("span-type", scm_makfrom0str ( "crescendo"));
1623                 s->set_spot (THIS->here_input());
1624
1625                 $$ = s;
1626         }
1627         | ')'   {
1628                 Span_req* s= new Span_req;
1629                 $$ = s;
1630                 s->set_mus_property ("span-type", scm_makfrom0str ( "slur"));
1631                 s->set_spot (THIS->here_input());
1632
1633         }
1634         | E_CLOSE       {
1635                 Span_req* s= new Span_req;
1636                 $$ = s;
1637                 s->set_mus_property ("span-type", scm_makfrom0str ( "phrasing-slur"));
1638                 s->set_spot (THIS->here_input());
1639         }
1640         ;
1641
1642 gen_text_def:
1643         embedded_scm {
1644                 Text_script_req *t = new Text_script_req;
1645                 t->set_mus_property ("text", $1);
1646                 t->set_spot (THIS->here_input ());
1647                 $$ = t;
1648         }
1649         | string {
1650                 Text_script_req *t = new Text_script_req;
1651                 t->set_mus_property ("text", $1);
1652                 t->set_spot (THIS->here_input ());
1653                 $$ = t;
1654         }
1655         | DIGIT {
1656                 String ds = to_string ($1);
1657                 Text_script_req* t = new Text_script_req;
1658                 SCM finger = ly_symbol2scm ("finger");
1659                 t->set_mus_property ("text",  scm_makfrom0str (ds.to_str0 ()));
1660                 t->set_mus_property ("text-type" , finger);
1661                 t->set_spot (THIS->here_input ());
1662                 $$ = t;
1663         }
1664         ;
1665
1666 script_abbreviation:
1667         '^'             {
1668                 $$ = scm_makfrom0str ("Hat");
1669         }
1670         | '+'           {
1671                 $$ = scm_makfrom0str ("Plus");
1672         }
1673         | '-'           {
1674                 $$ = scm_makfrom0str ("Dash");
1675         }
1676         | '|'           {
1677                 $$ = scm_makfrom0str ("Bar");
1678         }
1679         | '>'           {
1680                 $$ = scm_makfrom0str ("Larger");
1681         }
1682         | '.'           {
1683                 $$ = scm_makfrom0str ("Dot");
1684         }
1685         | '_' {
1686                 $$ = scm_makfrom0str ("Underscore");
1687         }
1688         ;
1689
1690 script_dir:
1691         '_'     { $$ = DOWN; }
1692         | '^'   { $$ = UP; }
1693         | '-'   { $$ = CENTER; }
1694         ;
1695
1696 pre_requests:
1697         {
1698                 $$ = new Link_array<Request>;
1699         }
1700         | pre_requests open_request {
1701                 $$->push ($2);
1702         }
1703         ;
1704
1705 absolute_pitch:
1706         steno_pitch     {
1707                 $$ = $1;
1708         }
1709         ;
1710
1711 duration_length:
1712         multiplied_duration {
1713                 $$ = $1;
1714         }
1715         | verbose_duration {
1716                 $$ = $1;
1717         }       
1718         ;
1719
1720 optional_notemode_duration:
1721         {
1722                 Duration dd = THIS->default_duration_;
1723                 $$ = dd.smobbed_copy ();
1724
1725                 THIS->beam_check ($$);
1726         }
1727         | multiplied_duration   {
1728                 $$ = $1;
1729                 THIS->default_duration_ = *unsmob_duration ($$);
1730
1731                 THIS->beam_check ($$);
1732         }
1733         | verbose_duration {
1734                 $$ = $1;
1735                 THIS->default_duration_ = *unsmob_duration ($$);
1736         }       
1737         ;
1738
1739 steno_duration:
1740         bare_unsigned dots              {
1741                 int l = 0;
1742                 if (!is_duration_b ($1))
1743                         THIS->parser_error (_f ("not a duration: %d", $1));
1744                 else
1745                         l =  intlog2 ($1);
1746
1747                 $$ = Duration (l, $2).smobbed_copy ();
1748         }
1749         | DURATION_IDENTIFIER dots      {
1750                 Duration *d =unsmob_duration ($1);
1751                 Duration k (d->duration_log (),d->dot_count () + $2);
1752                 $$ = k.smobbed_copy ();
1753         }
1754         ;
1755
1756
1757
1758
1759 multiplied_duration:
1760         steno_duration {
1761                 $$ = $1;
1762         }
1763         | multiplied_duration '*' bare_unsigned {
1764                 $$ = unsmob_duration ($$)->compressed ( $3) .smobbed_copy ();
1765         }
1766         | multiplied_duration '*' FRACTION {
1767                 Rational  m (gh_scm2int (ly_car ($3)), gh_scm2int (ly_cdr ($3)));
1768
1769                 $$ = unsmob_duration ($$)->compressed (m).smobbed_copy ();
1770         }
1771         ;
1772
1773 fraction:
1774         FRACTION { $$ = $1; }
1775         | UNSIGNED '/' UNSIGNED {
1776                 $$ = gh_cons (gh_int2scm ($1), gh_int2scm ($3));
1777         }
1778         ;
1779
1780 dots:
1781         /* empty */     {
1782                 $$ = 0;
1783         }
1784         | dots '.' {
1785                 $$ ++;
1786         }
1787         ;
1788
1789
1790 tremolo_type: 
1791         ':'     {
1792                 $$ =0;
1793         }
1794         | ':' bare_unsigned {
1795                 if (!is_duration_b ($2))
1796                         THIS->parser_error (_f ("not a duration: %d", $2));
1797                 $$ = $2;
1798         }
1799         ;
1800
1801
1802 bass_number:
1803         DIGIT
1804         | UNSIGNED 
1805         ;
1806
1807 bass_mod:
1808         '-'     { $$ = -1; }
1809         | '+'   { $$ = 1; } 
1810         | '!'   { $$ = 0; }
1811         ;
1812
1813 bass_figure:
1814         FIGURE_SPACE {
1815                 Bass_figure_req *bfr = new Bass_figure_req;
1816                 $$ = bfr->self_scm();
1817                 scm_gc_unprotect_object ($$);
1818         }
1819         | bass_number  {
1820                 Bass_figure_req *bfr = new Bass_figure_req;
1821                 $$ = bfr->self_scm();
1822
1823                 bfr->set_mus_property ("figure", gh_int2scm ($1));
1824
1825                 scm_gc_unprotect_object ($$);
1826         }
1827         | bass_figure bass_mod {
1828                 Music *m = unsmob_music ($1);
1829                 if ($2) {
1830                         SCM salter =m->get_mus_property ("alteration");
1831                         int alter = gh_number_p ( salter) ? gh_scm2int (salter) : 0;
1832                         m->set_mus_property ("alteration",
1833                                 gh_int2scm (alter + $2));
1834                 } else {
1835                         m->set_mus_property ("alteration", gh_int2scm (0));
1836                 }
1837         }
1838         ;
1839
1840 br_bass_figure:
1841         '[' bass_figure {
1842                 $$ = $2;
1843                 unsmob_music ($$)->set_mus_property ("bracket-start", SCM_BOOL_T);
1844         }
1845         | bass_figure   {
1846                 $$ = $1;
1847         }
1848         | br_bass_figure ']' {
1849                 $$ = $1;
1850                 unsmob_music ($1)->set_mus_property ("bracket-stop", SCM_BOOL_T);
1851         }
1852         ;
1853
1854 figure_list:
1855         /**/            {
1856                 $$ = SCM_EOL;
1857         }
1858         | figure_list br_bass_figure {
1859                 $$ = gh_cons ($2, $1); 
1860         }
1861         ;
1862
1863 figure_spec:
1864         FIGURE_OPEN figure_list FIGURE_CLOSE {
1865                 Music * m = new Request_chord (SCM_EOL);
1866                 $2 = scm_reverse_x ($2, SCM_EOL);
1867                 m->set_mus_property ("elements",  $2);
1868                 $$ = m->self_scm ();
1869         }
1870         ;
1871
1872
1873 optional_rest:
1874         /**/   { $$ = 0; }
1875         | REST { $$ = 1; }
1876         ;
1877
1878 simple_element:
1879         pitch exclamations questions optional_notemode_duration optional_rest {
1880
1881                 Input i = THIS->pop_spot ();
1882                 if (!THIS->lexer_->note_state_b ())
1883                         THIS->parser_error (_ ("Have to be in Note mode for notes"));
1884
1885                 Music *n = 0;
1886                 if ($5)
1887                         n =  new Rest_req ;
1888                 else
1889                         n =  new Note_req;
1890                 
1891                 n->set_mus_property ("pitch", $1);
1892                 n->set_mus_property ("duration", $4);
1893
1894
1895                 if ($3 % 2)
1896                         n->set_mus_property ("cautionary", SCM_BOOL_T);
1897                 if ($2 % 2 || $3 % 2)
1898                         n->set_mus_property ("force-accidental", SCM_BOOL_T);
1899
1900                 Simultaneous_music*v = new Request_chord (SCM_EOL);
1901                 v->set_mus_property ("elements", scm_list_n (n->self_scm (), SCM_UNDEFINED));
1902                 scm_gc_unprotect_object (n->self_scm());
1903
1904                 v->set_spot (i);
1905                 n->set_spot (i);
1906                 $$ = v;
1907         }
1908         | figure_spec optional_notemode_duration {
1909                 Music * m = unsmob_music ($1);
1910                 Input i = THIS->pop_spot (); 
1911                 m->set_spot (i);
1912                 for (SCM s = m->get_mus_property ("elements"); gh_pair_p (s); s = ly_cdr (s))
1913                         {
1914                                 unsmob_music (ly_car (s))->set_mus_property ("duration", $2);
1915                         }
1916                 $$ = m;
1917         }       
1918         | RESTNAME optional_notemode_duration           {
1919
1920                 Input i = THIS->pop_spot ();
1921                 SCM e = SCM_UNDEFINED;
1922                 if (ly_scm2string ($1) =="s") {
1923                         /* Space */
1924                         Skip_req * skip = new Skip_req;
1925                         skip->set_mus_property ("duration" ,$2);
1926                         skip->set_spot (i);
1927                         e = skip->self_scm ();
1928                   }
1929                   else {
1930                         Rest_req * rest_req = new Rest_req;
1931                         rest_req->set_mus_property ("duration", $2);
1932                         rest_req->set_spot (i);
1933                         e = rest_req->self_scm ();
1934                     }
1935                 Simultaneous_music* velt = new Request_chord (SCM_EOL);
1936                 velt-> set_mus_property ("elements", scm_list_n (e,SCM_UNDEFINED));
1937                 velt->set_spot (i);
1938
1939                 $$ = velt;
1940         }
1941         | MULTI_MEASURE_REST optional_notemode_duration         {
1942                 Input i = THIS->pop_spot ();
1943
1944                 Skip_req * sk = new Skip_req;
1945                 sk->set_mus_property ("duration", $2);
1946                 Span_req *sp1 = new Span_req;
1947                 Span_req *sp2 = new Span_req;
1948                 sp1-> set_span_dir ( START);
1949                 sp2-> set_span_dir ( STOP);
1950                 SCM r = scm_makfrom0str ("rest");
1951                 sp1->set_mus_property ("span-type", r);
1952                 sp2->set_mus_property ("span-type", r);
1953
1954                 Request_chord * rqc1 = new Request_chord (SCM_EOL);
1955                 rqc1->set_mus_property ("elements", scm_list_n (sp1->self_scm (), SCM_UNDEFINED));
1956                 Request_chord * rqc2 = new Request_chord (SCM_EOL);
1957                 rqc2->set_mus_property ("elements", scm_list_n (sk->self_scm (), SCM_UNDEFINED));;
1958                 Request_chord * rqc3 = new Request_chord (SCM_EOL);
1959                 rqc3->set_mus_property ("elements", scm_list_n (sp2->self_scm (), SCM_UNDEFINED));;
1960
1961                 SCM ms = scm_list_n (rqc1->self_scm (), rqc2->self_scm (), rqc3->self_scm (), SCM_UNDEFINED);
1962
1963                 $$ = new Sequential_music (SCM_EOL);
1964                 $$->set_mus_property ("elements", ms);
1965         }
1966         | STRING optional_notemode_duration     {
1967                 Input i = THIS->pop_spot ();
1968
1969                 Lyric_req* lreq = new Lyric_req;
1970                 lreq->set_mus_property ("text", $1);
1971                 lreq->set_mus_property ("duration",$2);
1972                 lreq->set_spot (i);
1973                 Simultaneous_music* velt = new Request_chord (SCM_EOL);
1974                 velt->set_mus_property ("elements", scm_list_n (lreq->self_scm (), SCM_UNDEFINED));
1975
1976                 $$= velt;
1977         }
1978         | chord {
1979                 Input i = THIS->pop_spot ();
1980
1981                 if (!THIS->lexer_->chord_state_b ())
1982                         THIS->parser_error (_ ("Have to be in Chord mode for chords"));
1983                 $$ = $1;
1984         }
1985         ;
1986
1987
1988 chord:
1989         steno_tonic_pitch optional_notemode_duration chord_additions chord_subtractions chord_inversion chord_bass {
1990                 $$ = Chord::get_chord ($1, $3, $4, $5, $6, $2);
1991                 $$->set_spot (THIS->here_input ());
1992         };
1993
1994 chord_additions: 
1995         {
1996                 $$ = SCM_EOL;
1997         } 
1998         | CHORD_COLON chord_notes {
1999                 $$ = $2;
2000         }
2001         ;
2002
2003 chord_notes:
2004         chord_step {
2005                 $$ = $1;
2006         }
2007         | chord_notes '.' chord_step {
2008                 $$ = gh_append2 ($$, $3);
2009         }
2010         ;
2011
2012 chord_subtractions: 
2013         {
2014                 $$ = SCM_EOL;
2015         } 
2016         | CHORD_CARET chord_notes {
2017                 $$ = $2;
2018         }
2019         ;
2020
2021
2022 chord_inversion:
2023         {
2024                 $$ = SCM_EOL;
2025         }
2026         | '/' steno_tonic_pitch {
2027                 $$ = $2;
2028         }
2029         ;
2030
2031 chord_bass:
2032         {
2033                 $$ = SCM_EOL;
2034         }
2035         | CHORD_BASS steno_tonic_pitch {
2036                 $$ = $2;
2037         }
2038         ;
2039
2040 chord_step:
2041         chord_note {
2042                 $$ = gh_cons ($1, SCM_EOL);
2043         }
2044         | CHORDMODIFIER_PITCH {
2045                 $$ = gh_cons (unsmob_pitch ($1)->smobbed_copy (), SCM_EOL);
2046         }
2047         | CHORDMODIFIER_PITCH chord_note { /* Ugh. */
2048                 $$ = scm_list_n (unsmob_pitch ($1)->smobbed_copy (),
2049                         $2, SCM_UNDEFINED);
2050         }
2051         ;
2052
2053 chord_note:
2054         bare_unsigned {
2055                  Pitch m;
2056                 m.notename_ = ($1 - 1) % 7;
2057                 m.octave_ = $1 > 7 ? 1 : 0;
2058                 m.alteration_ = 0;
2059
2060                 $$ = m.smobbed_copy ();
2061         } 
2062         | bare_unsigned '+' {
2063                 Pitch m;
2064                 m.notename_ = ($1 - 1) % 7;
2065                 m.octave_ = $1 > 7 ? 1 : 0;
2066                 m.alteration_ = 1;
2067
2068
2069                 $$ = m.smobbed_copy ();
2070         }
2071         | bare_unsigned CHORD_MINUS {
2072                 Pitch m;
2073                 m.notename_ = ($1 - 1) % 7;
2074                 m.octave_ = $1 > 7 ? 1 : 0;
2075                 m.alteration_ = -1;
2076
2077                 $$ = m.smobbed_copy ();
2078         }
2079         ;
2080
2081 /*
2082         UTILITIES
2083  */
2084 number_expression:
2085         number_expression '+' number_term {
2086                 $$ = scm_sum ($1, $3);
2087         }
2088         | number_expression '-' number_term {
2089                 $$ = scm_difference ($1, $3);
2090         }
2091         | number_term 
2092         ;
2093
2094 number_term:
2095         number_factor {
2096                 $$ = $1;
2097         }
2098         | number_factor '*' number_factor {
2099                 $$ = scm_product ($1, $3);
2100         }
2101         | number_factor '/' number_factor {
2102                 $$ = scm_divide ($1, $3);
2103         }
2104         ;
2105
2106 number_factor:
2107         '(' number_expression ')'       {
2108                 $$ = $2;
2109         }
2110         | '-'  number_factor { /* %prec UNARY_MINUS */
2111                 $$ = scm_difference ($2, SCM_UNDEFINED);
2112         }
2113         | bare_number
2114         ;
2115
2116
2117 bare_number:
2118         UNSIGNED        {
2119                 $$ = gh_int2scm ($1);
2120         }
2121         | REAL          {
2122                 $$ = $1;
2123         }
2124         | NUMBER_IDENTIFIER             {
2125                 $$ = $1;
2126         }
2127         | REAL CM_T     {
2128                 $$ = gh_double2scm (gh_scm2double ($1) CM );
2129         }
2130         | REAL PT_T     {
2131                 $$ = gh_double2scm (gh_scm2double ($1) PT);
2132         }
2133         | REAL IN_T     {
2134                 $$ = gh_double2scm (gh_scm2double ($1) INCH);
2135         }
2136         | REAL MM_T     {
2137                 $$ = gh_double2scm (gh_scm2double ($1) MM);
2138         }
2139         | REAL CHAR_T   {
2140                 $$ = gh_double2scm (gh_scm2double ($1) CHAR);
2141         }
2142         ;
2143
2144
2145 bare_unsigned:
2146         UNSIGNED {
2147                         $$ = $1;
2148         }
2149         | DIGIT {
2150                 $$ = $1;
2151         }
2152         ;
2153
2154 bare_int:
2155         bare_number {
2156                 if (scm_integer_p ($1) == SCM_BOOL_T)
2157                 {
2158                         int k = gh_scm2int ($1);
2159                         $$ = k;
2160                 } else
2161                 {
2162                         THIS->parser_error (_ ("need integer number arg"));
2163                         $$ = 0;
2164                 }
2165         }
2166         | '-' bare_int {
2167                 $$ = -$2;
2168         }
2169         ;
2170
2171
2172 string:
2173         STRING          {
2174                 $$ = $1;
2175         }
2176         | STRING_IDENTIFIER     {
2177                 $$ = $1;
2178         }
2179         | string '+' string {
2180                 $$ = scm_string_append (scm_list_n ($1, $3, SCM_UNDEFINED));
2181         }
2182         ;
2183
2184
2185 exclamations:
2186                 { $$ = 0; }
2187         | exclamations '!'      { $$ ++; }
2188         ;
2189
2190 questions:
2191                 { $$ = 0; }
2192         | questions '?' { $$ ++; }
2193         ;
2194
2195
2196 %%
2197
2198 void
2199 My_lily_parser::set_yydebug (bool )
2200 {
2201 #if 0
2202         yydebug = b;
2203 #endif
2204 }
2205
2206 extern My_lily_parser * current_parser;
2207
2208 void
2209 My_lily_parser::do_yyparse ()
2210 {
2211
2212         current_parser = this;;
2213         yyparse ((void*)this);
2214 }
2215
2216
2217 /*
2218 Should make this optional?    It will also complain when you do
2219
2220         [s4]
2221
2222 which is entirely legitimate.
2223
2224 Or we can scrap it. Barchecks should detect wrong durations, and
2225 skipTypesetting speeds it up a lot.
2226 */
2227 void
2228 My_lily_parser::beam_check (SCM dur)
2229 {
2230   Duration *d = unsmob_duration (dur);
2231   if (unsmob_music (last_beam_start_) && d->duration_log () <= 2)
2232     {
2233       Music * m = unsmob_music (last_beam_start_);
2234       m->origin ()->warning (_("Suspect duration found following this beam"));
2235     }
2236   last_beam_start_ = SCM_EOL;
2237 }