]> git.donarmstrong.com Git - lilypond.git/blob - lily/parser.yy
03ad89173278691038daa74b8a5001fcb7f58178
[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                 Music *r = MY_MAKE_MUSIC("RepeatedMusic");
734                 if (beg)
735                         {
736                         r-> set_mus_property ("element", beg->self_scm ());
737                         scm_gc_unprotect_object (beg->self_scm ());
738                         }
739                 r->set_mus_property ("repeat-count", gh_int2scm (times >? 1));
740
741                 r-> set_mus_property ("elements",alts);
742                 SCM func = scm_primitive_eval (ly_symbol2scm ("repeat-name-to-ctor"));
743                 SCM result = gh_call1 (func, $2);
744
745                 if (gh_equal_p ($2, scm_makfrom0str ("tremolo")))
746                 {
747                 /*
748                 we can not get durations and other stuff correct down the line, so we have to
749                 add to the duration log here.
750                 */
751                         SCM func = scm_primitive_eval (ly_symbol2scm ("shift-duration-log"));
752                         if (($3 % 3) == 0)
753                           gh_call3 (func, r->self_scm (), gh_int2scm(-intlog2 ($3*2/3)),gh_int2scm(1));
754                         else
755                           gh_call3 (func, r->self_scm (), gh_int2scm(-intlog2 ($3)), gh_int2scm(0));
756                 }
757
758                 set_music_properties (r, result);
759
760                 r->set_spot (*$4->origin ());
761
762                 $$ = r;
763         }
764         ;
765
766 Sequential_music:
767         SEQUENTIAL '{' Music_list '}'           {
768                 $$ = MY_MAKE_MUSIC("SequentialMusic");
769                 $$->set_mus_property ("elements", ly_car ($3));
770                 $$->set_spot(THIS->here_input());
771         }
772         | '{' Music_list '}'            {
773                 $$ = MY_MAKE_MUSIC("SequentialMusic");
774                 $$->set_mus_property ("elements", ly_car ($2));
775                 $$->set_spot(THIS->here_input());
776         }
777         ;
778
779 Simultaneous_music:
780         SIMULTANEOUS '{' Music_list '}'{
781                 $$ = MY_MAKE_MUSIC("SimultaneousMusic");
782                 $$->set_mus_property ("elements", ly_car ($3));
783                 $$->set_spot(THIS->here_input());
784
785         }
786         | '<' Music_list '>'    {
787                 $$ = MY_MAKE_MUSIC("SimultaneousMusic");
788                 $$->set_mus_property ("elements", ly_car ($2));
789                 $$->set_spot(THIS->here_input());
790         }
791         ;
792
793 Simple_music:
794         request_chord           { $$ = $1; }
795         | OUTPUTPROPERTY embedded_scm embedded_scm '=' embedded_scm     {
796                 SCM pred = $2;
797                 if (!gh_symbol_p ($3))
798                 {
799                         THIS->parser_error (_ ("Second argument must be a symbol")); 
800                 }
801                 /* Should check # args */
802                 if (!gh_procedure_p (pred))
803                 {
804                         THIS->parser_error (_ ("First argument must be a procedure taking one argument"));
805                 }
806
807         Music*m = MY_MAKE_MUSIC("OutputPropertySetMusic");
808                 m->set_mus_property ("predicate", pred);
809                 m->set_mus_property ("grob-property", $3);
810                 m->set_mus_property ("grob-value",  $5);
811
812                 $$ = m;
813         }
814         | MUSIC_IDENTIFIER {
815                 $$ = unsmob_music ($1)->clone ();
816
817                 $$->set_spot (THIS->here_input());
818         }
819         | property_def
820         | translator_change
821         ;
822
823
824 Composite_music:
825         CONTEXT STRING Music    {
826                 Music*csm =MY_MAKE_MUSIC("ContextSpeccedMusic");
827
828                 csm->set_mus_property ("element", $3->self_scm ());
829                 scm_gc_unprotect_object ($3->self_scm ());
830
831                 csm->set_mus_property ("context-type",$2);
832                 csm->set_mus_property ("context-id", scm_makfrom0str (""));
833
834                 $$ = csm;
835         }
836         | AUTOCHANGE STRING Music       {
837         Music*chm = MY_MAKE_MUSIC("AutoChangeMusic");
838                 chm->set_mus_property ("element", $3->self_scm ());
839
840                 scm_gc_unprotect_object ($3->self_scm ());
841                 chm->set_mus_property ("what", $2); 
842
843                 $$ = chm;
844                 chm->set_spot (*$3->origin ());
845         }
846         | GRACE Music {
847 #if 1
848         /*
849                 The other version is for easier debugging  of
850                 Sequential_music_iterator in combination with grace notes.
851         */
852
853                 SCM start = THIS->lexer_->lookup_identifier ("startGraceMusic");
854                 SCM stop = THIS->lexer_->lookup_identifier ("stopGraceMusic");
855                 Music *startm = unsmob_music (start);
856                 Music *stopm = unsmob_music (stop);
857
858                 SCM ms = SCM_EOL;
859                 if (stopm) {
860                         stopm = stopm->clone ();
861                         ms = scm_cons (stopm->self_scm (), ms);
862                         scm_gc_unprotect_object (stopm->self_scm ());
863                 }
864                 ms = scm_cons ($2->self_scm (), ms);
865                 scm_gc_unprotect_object ($2->self_scm());
866                 if (startm) {
867                         startm = startm->clone ();
868                         ms = scm_cons (startm->self_scm () , ms);
869                         scm_gc_unprotect_object (startm->self_scm ());
870                 }
871
872         
873                 Music* seq = MY_MAKE_MUSIC("SequentialMusic");
874                 seq->set_mus_property ("elements", ms);
875
876                 
877                 $$ = MY_MAKE_MUSIC("GraceMusic");
878                 $$->set_mus_property ("element", seq->self_scm ());
879                 scm_gc_unprotect_object (seq->self_scm ());
880 #else
881                 $$ = MY_MAKE_MUSIC("GraceMusic");
882                 $$->set_mus_property ("element", $2->self_scm ());
883                 scm_gc_unprotect_object ($2->self_scm ());
884 #endif
885         }
886         | CONTEXT string '=' string Music {
887                 Music * csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
888
889                 csm->set_mus_property ("element", $5->self_scm ());
890                 scm_gc_unprotect_object ($5->self_scm ());
891
892                 csm->set_mus_property ("context-type", $2);
893                 csm->set_mus_property ("context-id", $4);
894
895                 $$ = csm;
896         }
897         | TIMES {
898                 THIS->push_spot ();
899         }
900         /* CONTINUED */ 
901                 fraction Music  
902
903         {
904                 int n = gh_scm2int (ly_car ($3)); int d = gh_scm2int (ly_cdr ($3));
905                 Music *mp = $4;
906         $$= MY_MAKE_MUSIC("TimeScaledMusic");
907                 $$->set_spot (THIS->pop_spot ());
908
909
910                 $$->set_mus_property ("element", mp->self_scm ());
911                 scm_gc_unprotect_object (mp->self_scm ());
912                 $$->set_mus_property ("numerator", gh_int2scm (n));
913                 $$->set_mus_property ("denominator", gh_int2scm (d));
914                 $$->compress (Moment (Rational (n,d)));
915
916         }
917         | Repeated_music                { $$ = $1; }
918         | Simultaneous_music            { $$ = $1; }
919         | Sequential_music              { $$ = $1; }
920         | TRANSPOSE pitch Music {
921                 $$ = MY_MAKE_MUSIC("TransposedMusic");
922                 Music *p = $3;
923                 Pitch pit = *unsmob_pitch ($2);
924
925                 p->transpose (pit);
926                 $$->set_mus_property ("element", p->self_scm ());
927                 scm_gc_unprotect_object (p->self_scm ());
928         }
929         | TRANSPOSE steno_tonic_pitch Music {
930                 $$ = MY_MAKE_MUSIC("TransposedMusic");
931                 Music *p = $3;
932                 Pitch pit = *unsmob_pitch ($2);
933
934                 p->transpose (pit);
935                 $$->set_mus_property ("element", p->self_scm ());
936                 scm_gc_unprotect_object (p->self_scm ());
937         
938         }
939         | APPLY embedded_scm Music  {
940                 SCM ret = gh_call1 ($2, $3->self_scm ());
941                 Music *m = unsmob_music (ret);
942                 if (!m) {
943                         THIS->parser_error ("\\apply must return a Music");
944                         m = MY_MAKE_MUSIC("Music");
945                         }
946                 $$ = m;
947         }
948         | NOTES
949                 { THIS->lexer_->push_note_state (); }
950         Music
951                 { $$ = $3;
952                   THIS->lexer_->pop_state ();
953                 }
954         | FIGURES
955                 { THIS->lexer_->push_figuredbass_state (); }
956         Music
957                 {
958                   Music * chm = MY_MAKE_MUSIC("UntransposableMusic");
959                   chm->set_mus_property ("element", $3->self_scm ());
960                   $$ = chm;
961                   scm_gc_unprotect_object ($3->self_scm());
962
963                   THIS->lexer_->pop_state ();
964         }
965         | CHORDS
966                 { THIS->lexer_->push_chord_state (); }
967         Music
968                 {
969                   Music * chm = MY_MAKE_MUSIC("UnrelativableMusic");
970                   chm->set_mus_property ("element", $3->self_scm ());
971                   scm_gc_unprotect_object ($3->self_scm());
972                   $$ = chm;
973
974                   THIS->lexer_->pop_state ();
975         }
976         | LYRICS
977                 { THIS->lexer_->push_lyric_state (); }
978         Music
979                 {
980                   $$ = $3;
981                   THIS->lexer_->pop_state ();
982         }
983         | relative_music        { $$ = $1; }
984         | re_rhythmed_music     { $$ = $1; } 
985         | part_combined_music   { $$ = $1; } 
986         ;
987
988 relative_music:
989         RELATIVE absolute_pitch Music {
990                 Music * p = $3;
991                 Pitch pit = *unsmob_pitch ($2);
992                 $$ = MY_MAKE_MUSIC("RelativeOctaveMusic");
993
994                 $$->set_mus_property ("element", p->self_scm ());
995                 scm_gc_unprotect_object (p->self_scm ());
996
997                 $$->set_mus_property ("last-pitch", p->to_relative_octave (pit).smobbed_copy ());
998
999         }
1000         ;
1001
1002 re_rhythmed_music:
1003         ADDLYRICS Music Music {
1004         Music*l =MY_MAKE_MUSIC("LyricCombineMusic");
1005           l->set_mus_property ("elements", gh_list ($2->self_scm (), $3->self_scm (), SCM_UNDEFINED));
1006           scm_gc_unprotect_object ($3->self_scm ());
1007           scm_gc_unprotect_object ($2->self_scm ());
1008           $$ = l;
1009         }
1010         ;
1011
1012 part_combined_music:
1013         PARTCOMBINE STRING Music Music {
1014         Music * p= MY_MAKE_MUSIC("PartCombineMusic");
1015                 p->set_mus_property ("what", $2);
1016                 p->set_mus_property ("elements", gh_list ($3->self_scm (),$4->self_scm (), SCM_UNDEFINED));  
1017
1018                 scm_gc_unprotect_object ($3->self_scm ());
1019                 scm_gc_unprotect_object ($4->self_scm ());  
1020
1021                 $$ = p;
1022         }
1023         ;
1024
1025 translator_change:
1026         TRANSLATOR STRING '=' STRING  {
1027                 Music*t= MY_MAKE_MUSIC("TranslatorChange");
1028                 t-> set_mus_property ("change-to-type", $2);
1029                 t-> set_mus_property ("change-to-id", $4);
1030
1031                 $$ = t;
1032                 $$->set_spot (THIS->here_input ());
1033         }
1034         ;
1035
1036 property_def:
1037         simple_property_def
1038         | ONCE simple_property_def {
1039                 $$ = $2;
1040                 SCM e = $2->get_mus_property ("element");
1041                 unsmob_music (e)->set_mus_property ("once", SCM_BOOL_T);
1042         }
1043         ;
1044
1045 simple_property_def:
1046         PROPERTY STRING '.' STRING '='  scalar {
1047                 Music *t = set_property_music (scm_string_to_symbol ($4), $6);
1048                 Music *csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
1049
1050                 csm->set_mus_property ("element", t->self_scm ());
1051                 scm_gc_unprotect_object (t->self_scm ());
1052
1053                 $$ = csm;
1054                 $$->set_spot (THIS->here_input ());
1055
1056                 csm-> set_mus_property ("context-type", $2);
1057         }
1058         | PROPERTY STRING '.' STRING UNSET {
1059                 
1060                 Music *t = MY_MAKE_MUSIC("PropertyUnset");
1061                 t->set_mus_property ("symbol", scm_string_to_symbol ($4));
1062
1063                 Music *csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
1064                 csm->set_mus_property ("element", t->self_scm ());
1065                 scm_gc_unprotect_object (t->self_scm ());
1066
1067                 $$ = csm;
1068                 $$->set_spot (THIS->here_input ());
1069
1070                 csm-> set_mus_property ("context-type", $2);
1071         }
1072         | PROPERTY STRING '.' STRING SET embedded_scm '=' embedded_scm {
1073                 bool autobeam
1074                   = gh_equal_p ($4, scm_makfrom0str ("autoBeamSettings"));
1075                 bool itc = internal_type_checking_global_b;
1076                 Music *t = MY_MAKE_MUSIC("OverrideProperty");
1077
1078                 t->set_mus_property ("symbol", scm_string_to_symbol ($4));
1079                 t->set_mus_property ("pop-first", SCM_BOOL_T);
1080                 if (autobeam)
1081                         internal_type_checking_global_b = false;
1082                 t->set_mus_property ("grob-property", $6);
1083                 if (autobeam)
1084                         internal_type_checking_global_b = itc;
1085                 t->set_mus_property ("grob-value", $8);
1086
1087                 Music *csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
1088                 csm->set_mus_property ("element", t->self_scm ());
1089                 scm_gc_unprotect_object (t->self_scm ());
1090                 $$ = csm;
1091                 $$->set_spot (THIS->here_input ());
1092
1093                 csm-> set_mus_property ("context-type", $2);
1094         }
1095         | PROPERTY STRING '.' STRING OVERRIDE
1096                 embedded_scm '=' embedded_scm
1097         {
1098                 /*
1099                         UGH UGH UGH UGH.
1100                 */
1101                 bool autobeam
1102                   = gh_equal_p ($4, scm_makfrom0str ("autoBeamSettings"));
1103                 bool itc = internal_type_checking_global_b;
1104
1105                 Music *t = MY_MAKE_MUSIC("OverrideProperty");
1106                 t->set_mus_property ("symbol", scm_string_to_symbol ($4));
1107                 if (autobeam)
1108                         internal_type_checking_global_b = false;
1109                 t->set_mus_property ("grob-property", $6);
1110                 t->set_mus_property ("grob-value", $8);
1111                 if (autobeam)
1112                         internal_type_checking_global_b = itc;
1113
1114                 Music *csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
1115                 csm->set_mus_property ("element", t->self_scm ());
1116                 scm_gc_unprotect_object (t->self_scm ());
1117
1118                 $$ = csm;
1119                 $$->set_spot (THIS->here_input ());
1120
1121                 csm-> set_mus_property ("context-type", $2);
1122
1123         }
1124         | PROPERTY STRING '.' STRING REVERT embedded_scm {
1125                 Music *t = MY_MAKE_MUSIC("RevertProperty");
1126                 bool autobeam
1127                   = gh_equal_p ($4, scm_makfrom0str ("autoBeamSettings"));
1128                 bool itc = internal_type_checking_global_b;
1129
1130                 t->set_mus_property ("symbol", scm_string_to_symbol ($4));
1131                 if (autobeam)
1132                         internal_type_checking_global_b = false;
1133                 t->set_mus_property ("grob-property", $6);
1134                 if (autobeam)
1135                         internal_type_checking_global_b = itc;
1136         
1137                 Music *csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
1138                 csm->set_mus_property ("element", t->self_scm ());
1139                 scm_gc_unprotect_object (t->self_scm ());
1140
1141                 $$ = csm;
1142                 $$->set_spot (THIS->here_input ());
1143
1144                 csm-> set_mus_property ("context-type", $2);
1145         }
1146         ;
1147
1148
1149 scalar:
1150         string          { $$ = $1; }
1151         | bare_int      { $$ = gh_int2scm ($1); }
1152         | embedded_scm  { $$ = $1; }
1153         ;
1154
1155
1156 request_chord:
1157         pre_requests {
1158                 THIS->push_spot ();
1159         } /*cont */ simple_element post_requests        {
1160                 Music_sequence *l = dynamic_cast<Music_sequence*> ($3);
1161                 
1162                 $1->concat (*$4);
1163                 for (int i=0; i < $1->size (); i++) {
1164                   Music * m = $1->elem (i);
1165                   l->append_music (m);
1166                 }
1167                 $$ = $3;
1168
1169                 delete $1;
1170                 delete $4;
1171         }
1172         | command_element
1173         ;
1174
1175 command_element:
1176         command_req {
1177                 $$ = MY_MAKE_MUSIC("RequestChord");
1178                 $$->set_mus_property ("elements", scm_cons ($1->self_scm (), SCM_EOL));
1179           scm_gc_unprotect_object ($1->self_scm());
1180
1181                 $$-> set_spot (THIS->here_input ());
1182                 $1-> set_spot (THIS->here_input ());
1183         }
1184         | E_LEFTSQUARE {
1185                 Music *l = MY_MAKE_MUSIC("LigatureEvent");
1186                 l->set_mus_property ("span-direction", gh_int2scm (START));
1187                 l->set_spot (THIS->here_input ());
1188
1189                 $$ = MY_MAKE_MUSIC("RequestChord");
1190                 $$->set_mus_property ("elements", scm_cons (l->self_scm (), SCM_EOL));
1191           scm_gc_unprotect_object (l->self_scm());
1192                 $$->set_spot (THIS->here_input ());
1193         }
1194         | E_RIGHTSQUARE {
1195                 Music *l = MY_MAKE_MUSIC("LigatureEvent");
1196                 l->set_mus_property ("span-direction", gh_int2scm (STOP));
1197                 l->set_spot (THIS->here_input ());
1198
1199                 $$ = MY_MAKE_MUSIC("RequestChord");
1200                 $$->set_mus_property ("elements", scm_cons (l->self_scm (), SCM_EOL));
1201                 $$->set_spot (THIS->here_input ());
1202           scm_gc_unprotect_object (l->self_scm());
1203
1204         }
1205         | E_BACKSLASH {
1206                 $$ = MY_MAKE_MUSIC("VoiceSeparator");
1207                 $$->set_spot (THIS->here_input ());
1208         }
1209         | '|'      {
1210
1211                 $$ = MY_MAKE_MUSIC("BarCheck");
1212                 $$->set_spot (THIS->here_input ());
1213         }
1214         | BAR STRING                    {
1215                 Music *t = set_property_music (ly_symbol2scm ("whichBar"), $2);
1216
1217                 Music *csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
1218                 csm->set_mus_property ("element", t->self_scm ());
1219                 scm_gc_unprotect_object (t->self_scm ());
1220
1221                 $$ = csm;
1222                 $$->set_spot (THIS->here_input ());
1223
1224                 csm->set_mus_property ("context-type", scm_makfrom0str ("Timing"));
1225         }
1226         | PARTIAL duration_length       {
1227                 Moment m = - unsmob_duration ($2)->length_mom ();
1228                 Music * p = set_property_music (ly_symbol2scm ( "measurePosition"),m.smobbed_copy ());
1229
1230                 Music * sp = MY_MAKE_MUSIC("ContextSpeccedMusic");
1231                 sp->set_mus_property ("element", p->self_scm ());
1232                 scm_gc_unprotect_object (p->self_scm ());
1233
1234                 $$ =sp ;
1235                 sp-> set_mus_property ("context-type", scm_makfrom0str ("Timing"));
1236         }
1237         | CLEF STRING  {
1238                 SCM func = scm_primitive_eval (ly_symbol2scm ("clef-name-to-properties"));
1239                 SCM result = gh_call1 (func, $2);
1240
1241                 SCM l = SCM_EOL;
1242                 for (SCM s = result ; gh_pair_p (s); s = ly_cdr (s)) {
1243                         Music * p = MY_MAKE_MUSIC("Music");
1244                         set_music_properties (p, ly_car (s));
1245                         l = scm_cons (p->self_scm (), l);
1246                         scm_gc_unprotect_object (p->self_scm ());
1247                 }
1248                 Music * seq = MY_MAKE_MUSIC("SequentialMusic");
1249                 seq->set_mus_property ("elements", l);
1250
1251                 Music * sp = MY_MAKE_MUSIC("ContextSpeccedMusic");
1252                 sp->set_mus_property ("element", seq->self_scm ());
1253                 scm_gc_unprotect_object (seq->self_scm ());
1254
1255                 $$ =sp ;
1256                 sp-> set_mus_property ("context-type", scm_makfrom0str ("Staff"));
1257         }
1258         | TIME_T fraction  {
1259                 Music * p1 = set_property_music (ly_symbol2scm ( "timeSignatureFraction"), $2);
1260
1261                 int l = gh_scm2int (ly_car ($2));
1262                 int o = gh_scm2int (ly_cdr ($2));
1263
1264                 Moment one_beat = Moment (1)/Moment (o);
1265                 Moment len = Moment (l) * one_beat;
1266
1267
1268                 Music *p2 = set_property_music (ly_symbol2scm ("measureLength"), len.smobbed_copy ());
1269                 Music *p3 = set_property_music (ly_symbol2scm ("beatLength"), one_beat.smobbed_copy ());
1270
1271                 SCM list = scm_list_n (p1->self_scm (), p2->self_scm (), p3->self_scm(), SCM_UNDEFINED);
1272                 Music *seq = MY_MAKE_MUSIC("SequentialMusic");
1273                 seq->set_mus_property ("elements", list);
1274                 
1275
1276                 Music * sp = MY_MAKE_MUSIC("ContextSpeccedMusic");
1277                 sp->set_mus_property ("element", seq->self_scm ());
1278
1279                 scm_gc_unprotect_object (p3->self_scm ());
1280                 scm_gc_unprotect_object (p2->self_scm ());
1281                 scm_gc_unprotect_object (p1->self_scm ());
1282                 scm_gc_unprotect_object (seq->self_scm ());
1283
1284                 $$ = sp;
1285
1286                 sp-> set_mus_property ("context-type", scm_makfrom0str ( "Timing"));
1287         }
1288         ;
1289
1290 command_req:
1291         shorthand_command_req   { $$ = $1; }
1292         | verbose_command_req   { $$ = $1; }
1293         ;
1294
1295 shorthand_command_req:
1296         extender_req {
1297                 $$ = $1;
1298         }
1299         | hyphen_req {
1300                 $$ = $1;
1301         }
1302         | '~'   {
1303                 $$ = MY_MAKE_MUSIC("TieEvent");
1304         }
1305         | '['           {
1306                 Music *b= MY_MAKE_MUSIC("BeamEvent");
1307                 b->set_mus_property ("span-direction", gh_int2scm (START))
1308 ;
1309                 $$ =b;
1310
1311
1312                 THIS->last_beam_start_ = b->self_scm ();
1313         }
1314         | ']'           {
1315                 Music *b= MY_MAKE_MUSIC("BeamEvent");
1316                 b->set_mus_property ("span-direction", gh_int2scm (STOP));
1317                 $$ = b;
1318         }
1319         | BREATHE {
1320                 $$ = MY_MAKE_MUSIC("BreathingSignEvent");
1321         }
1322         | E_TILDE {
1323                 $$ = MY_MAKE_MUSIC("PorrectusEvent");
1324         }
1325         ;
1326
1327 verbose_command_req:
1328         COMMANDSPANREQUEST bare_int STRING {
1329                 Music *sp = make_span_req ($3);
1330                 sp->set_mus_property ("span-direction", gh_int2scm (Direction ($2)));
1331                 sp->set_spot (THIS->here_input ());
1332                 $$ = sp;
1333         }
1334         | MARK DEFAULT  {
1335                 Music * m = MY_MAKE_MUSIC("MarkEvent");
1336                 $$ = m;
1337         }
1338         | MARK scalar {
1339                 Music *m = MY_MAKE_MUSIC("MarkEvent");
1340                 m->set_mus_property ("label", $2);
1341                 $$ = m;
1342         }
1343         | PENALTY SCM_T         {
1344                 Music * b = MY_MAKE_MUSIC("BreakEvent");
1345                 SCM s = $2;
1346                 if (!gh_number_p (s))
1347                         s = gh_int2scm (0);
1348
1349                 b->set_mus_property ("penalty", s);
1350                 b->set_spot (THIS->here_input ());
1351                 $$ = b;
1352         }
1353         | SKIP duration_length {
1354                 Music * skip = MY_MAKE_MUSIC("SkipEvent");
1355                 skip->set_mus_property ("duration", $2);
1356
1357                 $$ = skip;
1358         }
1359         | tempo_request {
1360                 $$ = $1;
1361         }
1362         | KEY DEFAULT {
1363                 Music *key= MY_MAKE_MUSIC("KeyChangeEvent");
1364                 $$ = key;
1365         }
1366         | KEY NOTENAME_PITCH SCM_IDENTIFIER     {
1367                 Music *key= MY_MAKE_MUSIC("KeyChangeEvent");
1368                 
1369                 key->set_mus_property ("pitch-alist", $3);
1370                 ((Music*)key)->transpose (* unsmob_pitch ($2));
1371                 $$ = key; 
1372         }
1373         ;
1374
1375 post_requests:
1376         {
1377                 $$ = new Link_array<Music>;
1378         }
1379         | post_requests post_request {
1380                 $2->set_spot (THIS->here_input ());
1381                 $$->push ($2);
1382         }
1383         ;
1384
1385 post_request:
1386         verbose_request
1387         | request_with_dir
1388         | close_request
1389         | string_request
1390         ;
1391
1392
1393 string_request:
1394         E_UNSIGNED {
1395                 Music * s = MY_MAKE_MUSIC("StringNumberEvent");
1396                 s->set_mus_property ("string-number",  gh_int2scm($1));
1397                 s->set_spot (THIS->here_input ());
1398                 $$ = s;
1399         }
1400         ;
1401
1402
1403 request_that_take_dir:
1404         gen_text_def
1405         | verbose_request
1406         | script_abbreviation {
1407                 SCM s = THIS->lexer_->lookup_identifier ("dash" + ly_scm2string ($1));
1408                 Music *a = MY_MAKE_MUSIC("ArticulationEvent");
1409                 if (gh_string_p (s))
1410                         a->set_mus_property ("articulation-type", s);
1411                 else THIS->parser_error (_ ("Expecting string as script definition"));
1412                 $$ = a;
1413         }
1414         ;
1415
1416 request_with_dir:
1417         script_dir request_that_take_dir        {
1418                 $2->set_mus_property ("direction", gh_int2scm ($1));
1419                 $$ = $2;
1420         }
1421         ;
1422         
1423 verbose_request:
1424         REQUEST_IDENTIFIER      {
1425                 $$ = unsmob_music ($1)->clone ();
1426                 $$->set_spot (THIS->here_input ());
1427         }
1428         | DYNAMICSCRIPT embedded_scm {
1429                 /*
1430                         TODO: junkme, use text-type == dynamic
1431                 */
1432                 Music *d = MY_MAKE_MUSIC("TextScriptEvent");
1433                 SCM dyn = ly_symbol2scm ("dynamic");
1434                 d->set_mus_property ("text-type" , dyn);
1435                 d->set_mus_property ("text", $2);
1436                 d->set_spot (THIS->here_input ());
1437                 $$ = d;
1438         }
1439         | SPANREQUEST bare_int STRING {
1440
1441                 Music * sp = make_span_req ($3);
1442                 sp->set_mus_property ("span-direction", gh_int2scm ( $2));
1443                 sp->set_spot (THIS->here_input ());
1444                 $$ = sp;
1445         }
1446         | tremolo_type  {
1447                Music * a = MY_MAKE_MUSIC("TremoloEvent");
1448                a->set_spot (THIS->here_input ());
1449                a->set_mus_property ("tremolo-type", gh_int2scm ($1));
1450                $$ = a;
1451         }
1452         | SCRIPT STRING         { 
1453                 Music * a = MY_MAKE_MUSIC("ArticulationEvent");
1454                 a->set_mus_property ("articulation-type", $2);
1455                 a->set_spot (THIS->here_input ());
1456                 $$ = a;
1457         }
1458
1459         /*
1460                 duh, junk this syntax from the parser, if possible. 
1461         */
1462         | ARPEGGIO {
1463                 Music *a = MY_MAKE_MUSIC("ArpeggioEvent");
1464                 a->set_spot (THIS->here_input ());
1465                 $$ = a;
1466         }
1467         | GLISSANDO {
1468                 Music *g = MY_MAKE_MUSIC("GlissandoEvent");
1469                 g->set_spot /* No pun intended */ (THIS->here_input ());
1470                 $$ = g;
1471         }       
1472         ;
1473
1474 sup_quotes:
1475         '\'' {
1476                 $$ = 1;
1477         }
1478         | sup_quotes '\'' {
1479                 $$ ++;
1480         }
1481         ;
1482
1483 sub_quotes:
1484         ',' {
1485                 $$ = 1;
1486         }
1487         | sub_quotes ',' {
1488                 $$ ++ ;
1489         }
1490         ;
1491
1492 steno_pitch:
1493         NOTENAME_PITCH  {
1494                 $$ = $1;
1495         }
1496         | NOTENAME_PITCH sup_quotes     {
1497                 Pitch p = *unsmob_pitch ($1);
1498                 p.octave_ +=  $2;
1499                 $$ = p.smobbed_copy ();
1500         }
1501         | NOTENAME_PITCH sub_quotes      {
1502                 Pitch p =* unsmob_pitch ($1);
1503
1504                 p.octave_ +=  -$2;
1505                 $$ = p.smobbed_copy ();
1506
1507         }
1508         ;
1509
1510 /*
1511 ugh. duplication
1512 */
1513
1514 steno_tonic_pitch:
1515         TONICNAME_PITCH {
1516                 $$ = $1;
1517         }
1518         | TONICNAME_PITCH sup_quotes    {
1519                 Pitch p = *unsmob_pitch ($1);
1520                 p.octave_ +=  $2;
1521                 $$ = p.smobbed_copy ();
1522         }
1523         | TONICNAME_PITCH sub_quotes     {
1524                 Pitch p =* unsmob_pitch ($1);
1525
1526                 p.octave_ +=  -$2;
1527                 $$ = p.smobbed_copy ();
1528
1529         }
1530         ;
1531
1532 pitch:
1533         steno_pitch {
1534                 $$ = $1;
1535         }
1536         | explicit_pitch {
1537                 $$ = $1;
1538         }
1539         ;
1540
1541 explicit_pitch:
1542         PITCH embedded_scm {
1543                 $$ = $2;
1544                 if (!unsmob_pitch ($2)) {
1545                         THIS->parser_error (_f ("Expecting musical-pitch value", 3));
1546                          $$ = Pitch ().smobbed_copy ();
1547                 }
1548         }
1549         ;
1550
1551 verbose_duration:
1552         DURATION embedded_scm   {
1553                 $$ = $2;
1554                 if (!unsmob_duration ($2))
1555                 {
1556                         THIS->parser_error (_ ("Must have duration object"));
1557                         $$ = Duration ().smobbed_copy ();
1558                 }
1559         }
1560         ;
1561
1562 extender_req:
1563         EXTENDER {
1564                 if (!THIS->lexer_->lyric_state_b ())
1565                         THIS->parser_error (_ ("Have to be in Lyric mode for lyrics"));
1566                 $$ = MY_MAKE_MUSIC("ExtenderEvent");
1567         }
1568         ;
1569
1570 hyphen_req:
1571         HYPHEN {
1572                 if (!THIS->lexer_->lyric_state_b ())
1573                         THIS->parser_error (_ ("Have to be in Lyric mode for lyrics"));
1574                 $$ = MY_MAKE_MUSIC("HyphenEvent");
1575         }
1576         ;
1577
1578 close_request:
1579         close_request_parens {
1580                 $$ = $1;
1581                 dynamic_cast<Music *> ($$)->set_mus_property ("span-direction", gh_int2scm (START))
1582 ;
1583         }
1584         ;
1585  
1586 close_request_parens:
1587         '('     {
1588                 Music * s= MY_MAKE_MUSIC("SlurEvent");
1589                 $$ = s;
1590                 s->set_spot (THIS->here_input());
1591         }
1592         | E_OPEN        {
1593                 Music * s= MY_MAKE_MUSIC("PhrasingSlurEvent");
1594                 $$ = s;
1595                 s->set_spot (THIS->here_input());
1596         }
1597         | E_SMALLER {
1598                 Music *s =MY_MAKE_MUSIC("CrescendoEvent");
1599                 $$ = s;
1600                 s->set_spot (THIS->here_input());
1601         }
1602         | E_BIGGER {
1603                 Music *s =MY_MAKE_MUSIC("DecrescendoEvent");
1604                 $$ = s;
1605                 s->set_spot (THIS->here_input());
1606         }
1607         ;
1608
1609
1610 open_request:
1611         open_request_parens {
1612                 $$ = $1;
1613                 dynamic_cast<Music *> ($$)->set_mus_property ("span-direction", gh_int2scm (STOP))
1614 ;
1615         }
1616         ;
1617
1618 open_request_parens:
1619         E_EXCLAMATION   {
1620                 Music *s =  MY_MAKE_MUSIC("CrescendoEvent");
1621                 s->set_spot (THIS->here_input());
1622
1623                 $$ = s;
1624         }
1625         | ')'   {
1626                 Music * s= MY_MAKE_MUSIC("SlurEvent");
1627                 $$ = s;
1628                 s->set_spot (THIS->here_input());
1629
1630         }
1631         | E_CLOSE       {
1632                 Music * s= MY_MAKE_MUSIC("PhrasingSlurEvent");
1633                 $$ = s;
1634                 s->set_mus_property ("span-type", scm_makfrom0str ( "phrasing-slur"));
1635                 s->set_spot (THIS->here_input());
1636         }
1637         ;
1638
1639 gen_text_def:
1640         embedded_scm {
1641                 Music *t = MY_MAKE_MUSIC("TextScriptEvent");
1642                 t->set_mus_property ("text", $1);
1643                 t->set_spot (THIS->here_input ());
1644                 $$ = t;
1645         }
1646         | string {
1647                 Music *t = MY_MAKE_MUSIC("TextScriptEvent");
1648                 t->set_mus_property ("text", $1);
1649                 t->set_spot (THIS->here_input ());
1650                 $$ = t;
1651         }
1652         | DIGIT {
1653                 String ds = to_string ($1);
1654                 Music * t = MY_MAKE_MUSIC("TextScriptEvent");
1655                 SCM finger = ly_symbol2scm ("finger");
1656                 t->set_mus_property ("text",  scm_makfrom0str (ds.to_str0 ()));
1657                 t->set_mus_property ("text-type" , finger);
1658                 t->set_spot (THIS->here_input ());
1659                 $$ = t;
1660         }
1661         ;
1662
1663 script_abbreviation:
1664         '^'             {
1665                 $$ = scm_makfrom0str ("Hat");
1666         }
1667         | '+'           {
1668                 $$ = scm_makfrom0str ("Plus");
1669         }
1670         | '-'           {
1671                 $$ = scm_makfrom0str ("Dash");
1672         }
1673         | '|'           {
1674                 $$ = scm_makfrom0str ("Bar");
1675         }
1676         | '>'           {
1677                 $$ = scm_makfrom0str ("Larger");
1678         }
1679         | '.'           {
1680                 $$ = scm_makfrom0str ("Dot");
1681         }
1682         | '_' {
1683                 $$ = scm_makfrom0str ("Underscore");
1684         }
1685         ;
1686
1687 script_dir:
1688         '_'     { $$ = DOWN; }
1689         | '^'   { $$ = UP; }
1690         | '-'   { $$ = CENTER; }
1691         ;
1692
1693 pre_requests:
1694         {
1695                 $$ = new Link_array<Music>;
1696         }
1697         | pre_requests open_request {
1698                 $$->push ($2);
1699         }
1700         ;
1701
1702 absolute_pitch:
1703         steno_pitch     {
1704                 $$ = $1;
1705         }
1706         ;
1707
1708 duration_length:
1709         multiplied_duration {
1710                 $$ = $1;
1711         }
1712         | verbose_duration {
1713                 $$ = $1;
1714         }       
1715         ;
1716
1717 optional_notemode_duration:
1718         {
1719                 Duration dd = THIS->default_duration_;
1720                 $$ = dd.smobbed_copy ();
1721
1722                 THIS->beam_check ($$);
1723         }
1724         | multiplied_duration   {
1725                 $$ = $1;
1726                 THIS->default_duration_ = *unsmob_duration ($$);
1727
1728                 THIS->beam_check ($$);
1729         }
1730         | verbose_duration {
1731                 $$ = $1;
1732                 THIS->default_duration_ = *unsmob_duration ($$);
1733         }       
1734         ;
1735
1736 steno_duration:
1737         bare_unsigned dots              {
1738                 int l = 0;
1739                 if (!is_duration_b ($1))
1740                         THIS->parser_error (_f ("not a duration: %d", $1));
1741                 else
1742                         l =  intlog2 ($1);
1743
1744                 $$ = Duration (l, $2).smobbed_copy ();
1745         }
1746         | DURATION_IDENTIFIER dots      {
1747                 Duration *d =unsmob_duration ($1);
1748                 Duration k (d->duration_log (),d->dot_count () + $2);
1749                 $$ = k.smobbed_copy ();
1750         }
1751         ;
1752
1753
1754
1755
1756 multiplied_duration:
1757         steno_duration {
1758                 $$ = $1;
1759         }
1760         | multiplied_duration '*' bare_unsigned {
1761                 $$ = unsmob_duration ($$)->compressed ( $3) .smobbed_copy ();
1762         }
1763         | multiplied_duration '*' FRACTION {
1764                 Rational  m (gh_scm2int (ly_car ($3)), gh_scm2int (ly_cdr ($3)));
1765
1766                 $$ = unsmob_duration ($$)->compressed (m).smobbed_copy ();
1767         }
1768         ;
1769
1770 fraction:
1771         FRACTION { $$ = $1; }
1772         | UNSIGNED '/' UNSIGNED {
1773                 $$ = scm_cons (gh_int2scm ($1), gh_int2scm ($3));
1774         }
1775         ;
1776
1777 dots:
1778         /* empty */     {
1779                 $$ = 0;
1780         }
1781         | dots '.' {
1782                 $$ ++;
1783         }
1784         ;
1785
1786
1787 tremolo_type: 
1788         ':'     {
1789                 $$ =0;
1790         }
1791         | ':' bare_unsigned {
1792                 if (!is_duration_b ($2))
1793                         THIS->parser_error (_f ("not a duration: %d", $2));
1794                 $$ = $2;
1795         }
1796         ;
1797
1798
1799 bass_number:
1800         DIGIT
1801         | UNSIGNED 
1802         ;
1803
1804 bass_mod:
1805         '-'     { $$ = -1; }
1806         | '+'   { $$ = 1; } 
1807         | '!'   { $$ = 0; }
1808         ;
1809
1810 bass_figure:
1811         FIGURE_SPACE {
1812                 Music *bfr = MY_MAKE_MUSIC("BassFigureEvent");
1813                 $$ = bfr->self_scm();
1814                 scm_gc_unprotect_object ($$);
1815         }
1816         | bass_number  {
1817                 Music *bfr = MY_MAKE_MUSIC("BassFigureEvent");
1818                 $$ = bfr->self_scm();
1819
1820                 bfr->set_mus_property ("figure", gh_int2scm ($1));
1821
1822                 scm_gc_unprotect_object ($$);
1823         }
1824         | bass_figure bass_mod {
1825                 Music *m = unsmob_music ($1);
1826                 if ($2) {
1827                         SCM salter =m->get_mus_property ("alteration");
1828                         int alter = gh_number_p ( salter) ? gh_scm2int (salter) : 0;
1829                         m->set_mus_property ("alteration",
1830                                 gh_int2scm (alter + $2));
1831                 } else {
1832                         m->set_mus_property ("alteration", gh_int2scm (0));
1833                 }
1834         }
1835         ;
1836
1837 br_bass_figure:
1838         '[' bass_figure {
1839                 $$ = $2;
1840                 unsmob_music ($$)->set_mus_property ("bracket-start", SCM_BOOL_T);
1841         }
1842         | bass_figure   {
1843                 $$ = $1;
1844         }
1845         | br_bass_figure ']' {
1846                 $$ = $1;
1847                 unsmob_music ($1)->set_mus_property ("bracket-stop", SCM_BOOL_T);
1848         }
1849         ;
1850
1851 figure_list:
1852         /**/            {
1853                 $$ = SCM_EOL;
1854         }
1855         | figure_list br_bass_figure {
1856                 $$ = scm_cons ($2, $1); 
1857         }
1858         ;
1859
1860 figure_spec:
1861         FIGURE_OPEN figure_list FIGURE_CLOSE {
1862                 Music * m = MY_MAKE_MUSIC("RequestChord");
1863                 $2 = scm_reverse_x ($2, SCM_EOL);
1864                 m->set_mus_property ("elements",  $2);
1865                 $$ = m->self_scm ();
1866         }
1867         ;
1868
1869
1870 optional_rest:
1871         /**/   { $$ = 0; }
1872         | REST { $$ = 1; }
1873         ;
1874
1875 simple_element:
1876         pitch exclamations questions optional_notemode_duration optional_rest {
1877
1878                 Input i = THIS->pop_spot ();
1879                 if (!THIS->lexer_->note_state_b ())
1880                         THIS->parser_error (_ ("Have to be in Note mode for notes"));
1881
1882                 Music *n = 0;
1883                 if ($5)
1884                         n =  MY_MAKE_MUSIC("RestEvent");
1885                 else
1886                         n =  MY_MAKE_MUSIC("NoteEvent");
1887                 
1888                 n->set_mus_property ("pitch", $1);
1889                 n->set_mus_property ("duration", $4);
1890
1891
1892                 if ($3 % 2)
1893                         n->set_mus_property ("cautionary", SCM_BOOL_T);
1894                 if ($2 % 2 || $3 % 2)
1895                         n->set_mus_property ("force-accidental", SCM_BOOL_T);
1896
1897                 Music *v = MY_MAKE_MUSIC("RequestChord");
1898                 v->set_mus_property ("elements", scm_list_n (n->self_scm (), SCM_UNDEFINED));
1899                 scm_gc_unprotect_object (n->self_scm());
1900
1901                 v->set_spot (i);
1902                 n->set_spot (i);
1903                 $$ = v;
1904         }
1905         | figure_spec optional_notemode_duration {
1906                 Music * m = unsmob_music ($1);
1907                 Input i = THIS->pop_spot (); 
1908                 m->set_spot (i);
1909                 for (SCM s = m->get_mus_property ("elements"); gh_pair_p (s); s = ly_cdr (s))
1910                         {
1911                                 unsmob_music (ly_car (s))->set_mus_property ("duration", $2);
1912                         }
1913                 $$ = m;
1914         }       
1915         | RESTNAME optional_notemode_duration           {
1916
1917                 Input i = THIS->pop_spot ();
1918                 SCM e = SCM_UNDEFINED;
1919                 if (ly_scm2string ($1) =="s") {
1920                         /* Space */
1921                         Music * skip = MY_MAKE_MUSIC("SkipEvent");
1922                         skip->set_mus_property ("duration" ,$2);
1923                         skip->set_spot (i);
1924                         e = skip->self_scm ();
1925                   }
1926                   else {
1927                         Music * rest_req = MY_MAKE_MUSIC("RestEvent");
1928                         rest_req->set_mus_property ("duration", $2);
1929                         rest_req->set_spot (i);
1930                         e = rest_req->self_scm ();
1931                     }
1932                 Music * velt = MY_MAKE_MUSIC("RequestChord");
1933                 velt-> set_mus_property ("elements", scm_list_n (e,SCM_UNDEFINED));
1934                 velt->set_spot (i);
1935
1936                 $$ = velt;
1937         }
1938         | MULTI_MEASURE_REST optional_notemode_duration         {
1939                 THIS->pop_spot ();
1940
1941                 Music * sk = MY_MAKE_MUSIC("SkipEvent");
1942                 sk->set_mus_property ("duration", $2);
1943                 Music *sp1 = MY_MAKE_MUSIC("MultiMeasureRestEvent");
1944                 Music *sp2 = MY_MAKE_MUSIC("MultiMeasureRestEvent");
1945                 sp1-> set_mus_property ("span-direction", gh_int2scm (START))
1946 ;
1947                 sp2-> set_mus_property ("span-direction", gh_int2scm (STOP))
1948 ;
1949                 Music *rqc1 = MY_MAKE_MUSIC("RequestChord");
1950                 rqc1->set_mus_property ("elements", scm_list_n (sp1->self_scm (), SCM_UNDEFINED));
1951                 Music *rqc2 = MY_MAKE_MUSIC("RequestChord");
1952                 rqc2->set_mus_property ("elements", scm_list_n (sk->self_scm (), SCM_UNDEFINED));;
1953                 Music *rqc3 = MY_MAKE_MUSIC("RequestChord");
1954                 rqc3->set_mus_property ("elements", scm_list_n (sp2->self_scm (), SCM_UNDEFINED));;
1955
1956                 SCM ms = scm_list_n (rqc1->self_scm (), rqc2->self_scm (), rqc3->self_scm (), SCM_UNDEFINED);
1957
1958                 $$ = MY_MAKE_MUSIC("SequentialMusic");
1959                 $$->set_mus_property ("elements", ms);
1960         }
1961         | STRING optional_notemode_duration     {
1962                 Input i = THIS->pop_spot ();
1963
1964                 Music * lreq = MY_MAKE_MUSIC("LyricEvent");
1965                 lreq->set_mus_property ("text", $1);
1966                 lreq->set_mus_property ("duration",$2);
1967                 lreq->set_spot (i);
1968                 Music * velt = MY_MAKE_MUSIC("RequestChord");
1969                 velt->set_mus_property ("elements", scm_list_n (lreq->self_scm (), SCM_UNDEFINED));
1970
1971                 $$= velt;
1972         }
1973         | chord {
1974                 THIS->pop_spot ();
1975
1976                 if (!THIS->lexer_->chord_state_b ())
1977                         THIS->parser_error (_ ("Have to be in Chord mode for chords"));
1978                 $$ = $1;
1979         }
1980         ;
1981
1982
1983 chord:
1984         steno_tonic_pitch optional_notemode_duration chord_additions chord_subtractions chord_inversion chord_bass {
1985                 $$ = Chord::get_chord ($1, $3, $4, $5, $6, $2);
1986                 $$->set_spot (THIS->here_input ());
1987         };
1988
1989 chord_additions: 
1990         {
1991                 $$ = SCM_EOL;
1992         } 
1993         | CHORD_COLON chord_notes {
1994                 $$ = $2;
1995         }
1996         ;
1997
1998 chord_notes:
1999         chord_step {
2000                 $$ = $1;
2001         }
2002         | chord_notes '.' chord_step {
2003                 $$ = gh_append2 ($$, $3);
2004         }
2005         ;
2006
2007 chord_subtractions: 
2008         {
2009                 $$ = SCM_EOL;
2010         } 
2011         | CHORD_CARET chord_notes {
2012                 $$ = $2;
2013         }
2014         ;
2015
2016
2017 chord_inversion:
2018         {
2019                 $$ = SCM_EOL;
2020         }
2021         | CHORD_SLASH steno_tonic_pitch {
2022                 $$ = $2;
2023         }
2024         ;
2025
2026 chord_bass:
2027         {
2028                 $$ = SCM_EOL;
2029         }
2030         | CHORD_BASS steno_tonic_pitch {
2031                 $$ = $2;
2032         }
2033         ;
2034
2035 chord_step:
2036         chord_note {
2037                 $$ = scm_cons ($1, SCM_EOL);
2038         }
2039         | CHORDMODIFIER_PITCH {
2040                 $$ = scm_cons (unsmob_pitch ($1)->smobbed_copy (), SCM_EOL);
2041         }
2042         | CHORDMODIFIER_PITCH chord_note { /* Ugh. */
2043                 $$ = scm_list_n (unsmob_pitch ($1)->smobbed_copy (),
2044                         $2, SCM_UNDEFINED);
2045         }
2046         ;
2047
2048 chord_note:
2049         bare_unsigned {
2050                  Pitch m;
2051                 m.notename_ = ($1 - 1) % 7;
2052                 m.octave_ = $1 > 7 ? 1 : 0;
2053                 m.alteration_ = 0;
2054
2055                 $$ = m.smobbed_copy ();
2056         } 
2057         | bare_unsigned '+' {
2058                 Pitch m;
2059                 m.notename_ = ($1 - 1) % 7;
2060                 m.octave_ = $1 > 7 ? 1 : 0;
2061                 m.alteration_ = 1;
2062
2063
2064                 $$ = m.smobbed_copy ();
2065         }
2066         | bare_unsigned CHORD_MINUS {
2067                 Pitch m;
2068                 m.notename_ = ($1 - 1) % 7;
2069                 m.octave_ = $1 > 7 ? 1 : 0;
2070                 m.alteration_ = -1;
2071
2072                 $$ = m.smobbed_copy ();
2073         }
2074         ;
2075
2076 /*
2077         UTILITIES
2078  */
2079 number_expression:
2080         number_expression '+' number_term {
2081                 $$ = scm_sum ($1, $3);
2082         }
2083         | number_expression '-' number_term {
2084                 $$ = scm_difference ($1, $3);
2085         }
2086         | number_term 
2087         ;
2088
2089 number_term:
2090         number_factor {
2091                 $$ = $1;
2092         }
2093         | number_factor '*' number_factor {
2094                 $$ = scm_product ($1, $3);
2095         }
2096         | number_factor '/' number_factor {
2097                 $$ = scm_divide ($1, $3);
2098         }
2099         ;
2100
2101 number_factor:
2102         '(' number_expression ')'       {
2103                 $$ = $2;
2104         }
2105         | '-'  number_factor { /* %prec UNARY_MINUS */
2106                 $$ = scm_difference ($2, SCM_UNDEFINED);
2107         }
2108         | bare_number
2109         ;
2110
2111
2112 bare_number:
2113         UNSIGNED        {
2114                 $$ = gh_int2scm ($1);
2115         }
2116         | REAL          {
2117                 $$ = $1;
2118         }
2119         | NUMBER_IDENTIFIER             {
2120                 $$ = $1;
2121         }
2122         | REAL CM_T     {
2123                 $$ = gh_double2scm (gh_scm2double ($1) CM );
2124         }
2125         | REAL PT_T     {
2126                 $$ = gh_double2scm (gh_scm2double ($1) PT);
2127         }
2128         | REAL IN_T     {
2129                 $$ = gh_double2scm (gh_scm2double ($1) INCH);
2130         }
2131         | REAL MM_T     {
2132                 $$ = gh_double2scm (gh_scm2double ($1) MM);
2133         }
2134         | REAL CHAR_T   {
2135                 $$ = gh_double2scm (gh_scm2double ($1) CHAR);
2136         }
2137         ;
2138
2139
2140 bare_unsigned:
2141         UNSIGNED {
2142                         $$ = $1;
2143         }
2144         | DIGIT {
2145                 $$ = $1;
2146         }
2147         ;
2148
2149 bare_int:
2150         bare_number {
2151                 if (scm_integer_p ($1) == SCM_BOOL_T)
2152                 {
2153                         int k = gh_scm2int ($1);
2154                         $$ = k;
2155                 } else
2156                 {
2157                         THIS->parser_error (_ ("need integer number arg"));
2158                         $$ = 0;
2159                 }
2160         }
2161         | '-' bare_int {
2162                 $$ = -$2;
2163         }
2164         ;
2165
2166
2167 string:
2168         STRING          {
2169                 $$ = $1;
2170         }
2171         | STRING_IDENTIFIER     {
2172                 $$ = $1;
2173         }
2174         | string '+' string {
2175                 $$ = scm_string_append (scm_list_n ($1, $3, SCM_UNDEFINED));
2176         }
2177         ;
2178
2179
2180 exclamations:
2181                 { $$ = 0; }
2182         | exclamations '!'      { $$ ++; }
2183         ;
2184
2185 questions:
2186                 { $$ = 0; }
2187         | questions '?' { $$ ++; }
2188         ;
2189
2190
2191 %%
2192
2193 void
2194 My_lily_parser::set_yydebug (bool )
2195 {
2196 #if 0
2197         yydebug = b;
2198 #endif
2199 }
2200
2201 extern My_lily_parser * current_parser;
2202
2203 void
2204 My_lily_parser::do_yyparse ()
2205 {
2206
2207         current_parser = this;;
2208         yyparse ((void*)this);
2209 }
2210
2211
2212 /*
2213 Should make this optional?    It will also complain when you do
2214
2215         [s4]
2216
2217 which is entirely legitimate.
2218
2219 Or we can scrap it. Barchecks should detect wrong durations, and
2220 skipTypesetting speeds it up a lot.
2221 */
2222 void
2223 My_lily_parser::beam_check (SCM dur)
2224 {
2225   Duration *d = unsmob_duration (dur);
2226   if (unsmob_music (last_beam_start_) && d->duration_log () <= 2)
2227     {
2228       Music * m = unsmob_music (last_beam_start_);
2229       m->origin ()->warning (_("Suspect duration found following this beam"));
2230     }
2231   last_beam_start_ = SCM_EOL;
2232 }