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