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