]> git.donarmstrong.com Git - lilypond.git/blob - lily/parser.yy
patch::: 1.3.32.jcn1
[lilypond.git] / lily / parser.yy
1 %{ // -*-Fundamental-*-
2
3 /*
4   parser.yy -- Bison/C++ parser for mudela
5
6   source file of the GNU LilyPond music typesetter
7
8   (c)  1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
9            Jan Nieuwenhuizen <janneke@gnu.org>
10 */
11
12 #include <iostream.h>
13 #include "lily-guile.hh"
14 #include "notename-table.hh"
15 #include "translation-property.hh"
16 #include "lookup.hh"
17 #include "misc.hh"
18 #include "my-lily-lexer.hh"
19 #include "paper-def.hh"
20 #include "midi-def.hh"
21 #include "main.hh"
22 #include "file-path.hh"
23 #include "debug.hh"
24 #include "dimensions.hh"
25 #include "identifier.hh"
26 #include "command-request.hh"
27 #include "musical-request.hh"
28 #include "my-lily-parser.hh"
29 #include "context-specced-music.hh"
30 #include "translator-group.hh"
31 #include "score.hh"
32 #include "music-list.hh"
33 #include "change-translator.hh"
34 #include "file-results.hh"
35 #include "scope.hh"
36 #include "relative-music.hh"
37 #include "lyric-combine-music.hh"
38 #include "transposed-music.hh"
39 #include "time-scaled-music.hh"
40 #include "repeated-music.hh"
41 #include "mudela-version.hh"
42 #include "grace-music.hh"
43 #include "auto-change-music.hh"
44 #include "output-property.hh"
45
46 // mmm
47 Mudela_version oldest_version ("1.3.4");
48
49 bool
50 is_duration_b (int t)
51 {
52   return t == 1 << intlog2(t);
53 }
54
55
56
57
58 void
59 print_mudela_versions (ostream &os)
60 {
61   os << _f ("Oldest supported input version: %s", oldest_version.str ()) 
62     << endl;
63 }
64 // needed for bison.simple's malloc() and free()
65 #include <malloc.h>
66
67 #ifndef NDEBUG
68 #define YYDEBUG 1
69 #endif
70
71 #define YYERROR_VERBOSE 1
72
73 #define YYPARSE_PARAM my_lily_parser_l
74 #define YYLEX_PARAM my_lily_parser_l
75 #define THIS ((My_lily_parser *) my_lily_parser_l)
76
77 #define yyerror THIS->parser_error
78 #define ARRAY_SIZE(a,s)   if (a.size () != s) THIS->parser_error (_f ("Expecting %d arguments", s))
79
80 %}
81
82
83 %union {
84     Array<Musical_pitch> *pitch_arr;
85     Link_array<Request> *reqvec;
86     Array<int> *intvec;
87     Notename_table *chordmodifiertab;
88     Duration *duration;
89     Identifier *id;
90     String * string;
91     Music *music;
92     Music_list *music_list;
93     Score *score;
94     Scope *scope;
95     Interval *interval;
96     Musical_req* musreq;
97     Music_output_def * outputdef;
98     Musical_pitch * pitch;
99     Midi_def* midi;
100     Moment *moment;
101     Notename_table *notenametab;
102     Paper_def *paper;
103     Real real;
104     Request * request;
105
106  /* We use SCMs to do strings, because it saves us the trouble of
107 deleting them.  Let's hope that a stack overflow doesnt trigger a move
108 of the parse stack onto the heap. */
109     SCM scm;
110
111     Tempo_req *tempo;
112     Translator_group* trans;
113     char c;
114     int i;
115 }
116 %{
117
118 int
119 yylex (YYSTYPE *s,  void * v_l)
120 {
121         My_lily_parser   *pars_l = (My_lily_parser*) v_l;
122         My_lily_lexer * lex_l = pars_l->lexer_p_;
123
124         lex_l->lexval_l = (void*) s;
125         return lex_l->yylex ();
126 }
127
128
129 %}
130
131 %pure_parser
132
133 /* tokens which are not keywords */
134 %token AUTOCHANGE
135 %token TEXTSCRIPT
136 %token ACCEPTS
137 %token ALTERNATIVE
138 %token BAR
139 %token BREATHE
140 %token CHORDMODIFIERS
141 %token CHORDS
142 %token CHAR_T
143 %token CLEF
144 %token CM_T
145 %token CONSISTS
146 %token SEQUENTIAL
147 %token SIMULTANEOUS
148 %token CONSISTSEND
149 %token DURATION
150 %token EXTENDER
151 %token FONT
152 %token GRACE
153 %token HEADER
154 %token HYPHEN
155 %token IN_T
156 %token INVALID
157 %token KEY
158 %token KEYSIGNATURE
159 %token LYRICS
160 %token MARK
161 %token MEASURES
162 %token MIDI
163 %token MM_T
164 %token MUSICAL_PITCH
165 %token NAME
166 %token NOTENAMES
167 %token NOTES
168 %token PAPER
169 %token PARTIAL
170 %token PENALTY
171 %token PROPERTY
172 %token PT_T
173 %token RELATIVE
174 %token REMOVE
175 %token REPEAT
176 %token REPETITIONS
177 %token ADDLYRICS
178 %token SCM_T
179 %token SCORE
180 %token SCRIPT
181 %token SKIP
182 %token SPANREQUEST
183 %token COMMANDSPANREQUEST
184 %token TEMPO
185 %token OUTPUTPROPERTY
186 %token TIME_T
187 %token TIMES
188 %token TRANSLATOR
189 %token TRANSPOSE
190 %token TYPE
191 %token CONTEXT
192
193 /* escaped */
194 %token E_CHAR E_EXCLAMATION E_SMALLER E_BIGGER 
195 %token CHORD_BASS CHORD_COLON CHORD_MINUS CHORD_CARET 
196
197 %type <i>       exclamations questions
198 %token <i>      DIGIT
199 %token <pitch>  NOTENAME_PITCH
200 %token <pitch>  TONICNAME_PITCH
201 %token <pitch>  CHORDMODIFIER_PITCH
202 %token <id>     DURATION_IDENTIFIER
203 %token <id>     IDENTIFIER
204 %token <id>     NOTENAME_TABLE_IDENTIFIER
205 %token <id>     MUSIC_IDENTIFIER
206 %token <id>     REQUEST_IDENTIFIER
207 %token <id>     REAL_IDENTIFIER
208 %token <id>     STRING_IDENTIFIER
209 %token <id>     TRANS_IDENTIFIER
210 %token <id>     INT_IDENTIFIER
211 %token <id>     SCORE_IDENTIFIER
212 %token <id>     MIDI_IDENTIFIER
213 %token <id>     PAPER_IDENTIFIER
214 %token <real>   REAL
215 %token <scm>    DURATION RESTNAME
216 %token <scm>    STRING
217 %token <scm>    SCM_T
218 %token <i>      UNSIGNED
219
220
221 %type <outputdef> output_def
222 %type <scope>   mudela_header mudela_header_body
223 %type <request> open_request_parens close_request_parens open_request close_request
224 %type <request> request_with_dir request_that_take_dir verbose_request
225 %type <i>       sub_quotes sup_quotes
226 %type <music>   simple_element  request_chord command_element Simple_music  Composite_music 
227 %type <music>   Alternative_music Repeated_music
228 %type <i>       tremolo_type
229 %type <i>       int unsigned
230 %type <i>       script_dir
231 %type <i>       optional_modality 
232 %type <id>      identifier_init  
233 %type <duration> steno_duration optional_notemode_duration
234 %type <duration> entered_notemode_duration explicit_duration
235 %type <intvec>   int_list
236 %type <reqvec>  pre_requests post_requests
237 %type <request> gen_text_def
238 %type <pitch>   explicit_musical_pitch steno_musical_pitch musical_pitch absolute_musical_pitch
239 %type <pitch>   steno_tonic_pitch
240
241 %type <pitch_arr>       pitch_list
242 %type <music>   chord
243 %type <pitch_arr>       chord_additions chord_subtractions chord_notes chord_step
244 %type <pitch>   chord_note chord_inversion chord_bass
245 %type <midi>    midi_block midi_body
246 %type <duration>        duration_length
247
248 %type <scm>  embedded_scm scalar
249 %type <music>   Music Sequential_music Simultaneous_music Music_sequence
250 %type <music>   relative_music re_rhythmed_music
251 %type <music>   property_def translator_change
252 %type <music_list> Music_list
253 %type <paper>   paper_block paper_def_body
254 %type <real>    real real_with_dimension
255 %type <request> shorthand_command_req
256 %type <request> post_request 
257 %type <request> command_req verbose_command_req
258 %type <request> extender_req
259 %type <request> hyphen_req
260 %type <scm>     string
261 %type <score>   score_block score_body
262
263 %type <scm>     script_abbreviation
264 %type <trans>   translator_spec_block translator_spec_body
265 %type <tempo>   tempo_request
266 %type <notenametab> notenames_body notenames_block chordmodifiers_block
267
268
269
270 %left '-' '+'
271 %left '*' '/'
272 %left UNARY_MINUS
273
274 %%
275
276 mudela: /* empty */
277         | mudela toplevel_expression {}
278         | mudela assignment  { }
279         | mudela error
280         | mudela INVALID        {
281                 THIS->error_level_i_  =1;
282         }
283         ;
284
285 toplevel_expression:
286         notenames_block                 {
287                 THIS->lexer_p_->set_notename_table ($1);
288         }
289         | chordmodifiers_block                  {
290                 THIS->lexer_p_->set_chordmodifier_table ($1);
291         }
292         | mudela_header {
293                 delete header_global_p;
294                 header_global_p = $1;
295         }
296         | score_block {
297                 score_global_array.push ($1);
298         }
299         | paper_block {
300                 Identifier * id = new
301                         Paper_def_identifier ($1, PAPER_IDENTIFIER);
302                 THIS->lexer_p_->set_identifier ("$defaultpaper", id)
303         }
304         | midi_block {
305                 Identifier * id = new
306                         Midi_def_identifier ($1, MIDI_IDENTIFIER);
307                 THIS->lexer_p_->set_identifier ("$defaultmidi", id)
308         }
309         | embedded_scm {
310                 // junk value
311         }       
312         ;
313
314 embedded_scm:
315         SCM_T
316         ;
317
318
319 chordmodifiers_block:
320         CHORDMODIFIERS '{' notenames_body '}'  {  $$ = $3; }
321         ;
322
323
324 notenames_block:
325         NOTENAMES '{' notenames_body '}'  {  $$ = $3; }
326         ;
327
328
329
330 notenames_body:
331         /**/    {
332                 $$ = new Notename_table;
333         }
334         | NOTENAME_TABLE_IDENTIFIER     {
335                 $$ = $1-> access_content_Notename_table(true);
336         }
337         | notenames_body STRING '=' explicit_musical_pitch {
338                 $$->add_note_name (ly_scm2string ($2), $4);
339                 delete $4;
340         }
341         ;
342
343 mudela_header_body:
344         {
345                 $$ = new Scope;
346                 THIS->lexer_p_-> scope_l_arr_.push ($$);
347         }
348         | mudela_header_body assignment semicolon { 
349
350         }
351         ;
352
353 mudela_header:
354         HEADER '{' mudela_header_body '}'       {
355                 $$ = $3;
356                 THIS->lexer_p_-> scope_l_arr_.pop ();           
357         }
358         ;
359
360
361 /*
362         DECLARATIONS
363 */
364 assignment:
365         STRING {
366                 THIS->remember_spot ();
367         }
368         /* cont */ '=' identifier_init  {
369             THIS->lexer_p_->set_identifier (ly_scm2string ($1), $4);
370             $4->init_b_ = THIS->init_parse_b_;
371             $4->set_spot (THIS->pop_spot ());
372         }
373         ;
374
375
376
377 identifier_init:
378         score_block {
379                 $$ = new Score_identifier ($1, SCORE_IDENTIFIER);
380
381         }
382         | chordmodifiers_block {
383                 $$ = new Notename_table_identifier ($1, NOTENAME_TABLE_IDENTIFIER);
384         }
385         | notenames_block {
386                 $$ = new Notename_table_identifier ($1, NOTENAME_TABLE_IDENTIFIER);
387         }
388         | paper_block {
389                 $$ = new Paper_def_identifier ($1, PAPER_IDENTIFIER);
390         }
391         | midi_block {
392                 $$ = new Midi_def_identifier ($1, MIDI_IDENTIFIER);
393
394         }
395         | translator_spec_block {
396                 $$ = new Translator_group_identifier ($1, TRANS_IDENTIFIER);
397         }
398         | Music  {
399                 $$ = new Music_identifier ($1, MUSIC_IDENTIFIER);
400         }
401
402         | post_request {
403                 $$ = new Request_identifier ($1, REQUEST_IDENTIFIER);
404         }
405         | explicit_duration {
406                 $$ = new Duration_identifier ($1, DURATION_IDENTIFIER);
407         }
408         | real {
409                 $$ = new Real_identifier (new Real ($1), REAL_IDENTIFIER);
410         }
411         | string {
412                 $$ = new String_identifier (new String (ly_scm2string ($1)), STRING_IDENTIFIER);
413         }
414         | int   {
415                 $$ = new int_identifier (new int ($1), INT_IDENTIFIER);
416         }
417         ;
418
419 translator_spec_block:
420         TRANSLATOR '{' translator_spec_body '}'
421                 {
422                 $$ = $3;
423         }
424         ;
425
426 translator_spec_body:
427         TRANS_IDENTIFIER        {
428                 $$ = $1->access_content_Translator_group (true);
429                 $$-> set_spot (THIS->here_input ());
430         }
431         | TYPE STRING semicolon {
432                 Translator* t = get_translator_l (ly_scm2string ($2));
433                 Translator_group * tg = dynamic_cast<Translator_group*> (t);
434
435                 if (!tg)
436                         THIS->parser_error (_("Need a translator group for a context"));
437                 
438                 tg = dynamic_cast<Translator_group*> (t->clone ());
439                 tg->set_spot (THIS->here_input ());
440                 $$ = tg;
441         }
442         | translator_spec_body STRING '=' embedded_scm                  {
443                 Translator_group* tg = dynamic_cast<Translator_group*> ($$);
444                 tg->set_property (ly_scm2string ($2), $4);
445         }
446         | translator_spec_body STRING '=' identifier_init semicolon     { 
447                 Identifier* id = $4;
448                 String_identifier *s = dynamic_cast<String_identifier*> (id);
449                 Real_identifier *r= dynamic_cast<Real_identifier*>(id);
450                 int_identifier *i = dynamic_cast<int_identifier*> (id);
451         
452                 SCM v;
453                 if (s) v = ly_str02scm (s->access_content_String (false)->ch_C());
454                 if (i) v = gh_int2scm (*i->access_content_int (false));
455                 if (r) v = gh_double2scm (*r->access_content_Real (false));
456                 if (!s && !i && !r)
457                         THIS->parser_error (_("Wrong type for property value"));
458
459                 delete $4;
460                 /* ugh*/
461                 Translator_group* tg = dynamic_cast<Translator_group*> ($$);
462                 
463                 tg->set_property (ly_scm2string ($2), v);
464         }
465         | translator_spec_body NAME STRING semicolon {
466                 $$->type_str_ = ly_scm2string ($3);
467         }
468         | translator_spec_body CONSISTS STRING semicolon {
469                 dynamic_cast<Translator_group*> ($$)-> set_element (ly_scm2string ($3), true);
470         }
471         | translator_spec_body CONSISTSEND STRING semicolon {
472                 dynamic_cast<Translator_group*> ($$)-> set_element (ly_scm2string ($3), true);
473         }
474         | translator_spec_body ACCEPTS STRING semicolon {
475                 dynamic_cast<Translator_group*> ($$)-> set_acceptor (ly_scm2string ($3), true);
476         }
477         | translator_spec_body REMOVE STRING semicolon {
478                 dynamic_cast<Translator_group*> ($$)-> set_element (ly_scm2string ($3), false);
479         }
480         ;
481
482 /*
483         SCORE
484 */
485 score_block:
486         SCORE { 
487         }
488         /*cont*/ '{' score_body '}'     {
489                 $$ = $4;
490                 if (!$$->def_p_arr_.size ())
491                         $$->add_output (THIS->default_paper_p ());
492         }
493         ;
494
495 score_body:             {
496                 $$ = new Score;
497                 $$->set_spot (THIS->here_input ());
498         }
499         | SCORE_IDENTIFIER {
500                 $$ = $1->access_content_Score (true);
501         }
502         | score_body mudela_header      {
503                 $$->header_p_ = $2;
504         }
505         | score_body Music      {
506                 if ($$->music_p_)
507                         $2->warning (_ ("More than one music block"));  
508                 $$->music_p_ = $2;
509         }
510         | score_body output_def {
511                 $$->add_output ($2);
512         }
513         | score_body error {
514
515         }
516         ;
517
518 output_def:
519         paper_block {
520                 $$ = $1;
521         }
522         |  midi_block           {
523                 $$= $1;
524         }
525         ;
526
527
528 /*
529         PAPER
530 */
531 paper_block:
532         PAPER '{' paper_def_body '}'    { 
533                 $$ = $3;
534                 THIS-> lexer_p_->scope_l_arr_.pop ();
535         }
536         ;
537
538
539 paper_def_body:
540         /* empty */                     {
541                 Paper_def *p = THIS->default_paper_p ();
542                 THIS-> lexer_p_-> scope_l_arr_.push (p->scope_p_);
543                 $$ = p;
544         }
545         | PAPER_IDENTIFIER      {
546                 Paper_def *p = $1->access_content_Paper_def (true);
547                 THIS->lexer_p_->scope_l_arr_.push (p->scope_p_);
548                 $$ = p;
549         }
550         | paper_def_body int '=' FONT STRING            { // ugh, what a syntax
551                 Lookup * l = new Lookup;
552                 l->font_name_ = ly_scm2string ($5);
553                 $$->set_lookup ($2, l);
554         }
555         | paper_def_body assignment semicolon {
556                 
557         }
558         | paper_def_body SCM_T '=' SCM_T {
559                 if (!gh_symbol_p ($2))
560                         THIS->parser_error ("expect a symbol as lvalue");
561                 else
562                         $$->default_properties_.set ($2, $4);
563         }
564         | paper_def_body SCM_T '=' real semicolon {
565                 if (!gh_symbol_p ($2))
566                         THIS->parser_error ("expect a symbol as lvalue");
567                 else
568                         $$->default_properties_.set ($2, gh_double2scm ($4));
569         }
570         | paper_def_body translator_spec_block {
571                 $$->assign_translator ($2);
572         }
573         | paper_def_body error {
574
575         }
576         ;
577
578
579
580 real_with_dimension:
581         REAL CM_T       {
582                 $$ = $1 CM;
583         }
584         | REAL PT_T     {
585                 $$ = $1 PT;
586         }
587         | REAL IN_T     {
588                 $$ = $1 INCH;
589         }
590         | REAL MM_T     {
591                 $$ = $1 MM;
592         }
593         | REAL CHAR_T   {
594                 $$ = $1 CHAR;
595         }
596         ;
597
598 real:
599         REAL            {
600                 $$ = $1;
601         }
602         | real_with_dimension
603         | REAL_IDENTIFIER               {
604                 $$= *$1->access_content_Real (false);
605         }
606         | '-'  real %prec UNARY_MINUS {
607                 $$ = -$2;
608         }
609         | real '*' real {
610                 $$ = $1 * $3;
611         }
612         | real '/' real {
613                 $$ = $1 / $3;
614         }
615         | real '+' real {
616                 $$ = $1  + $3;
617         }
618         | real '-' real {
619                 $$ = $1 - $3;
620         }
621         | '(' real ')'  {
622                 $$ = $2;
623         }
624         ;
625                 
626 /*
627         MIDI
628 */
629 midi_block:
630         MIDI
631         '{' midi_body '}'       {
632                 $$ = $3;
633                 THIS-> lexer_p_-> scope_l_arr_.pop();
634         }
635         ;
636
637 midi_body: /* empty */          {
638                 Midi_def * p =THIS->default_midi_p ();
639                 $$ = p;
640                 THIS->lexer_p_->scope_l_arr_.push (p->scope_p_);
641         }
642         | MIDI_IDENTIFIER       {
643                 Midi_def * p =$1-> access_content_Midi_def (true);
644                 $$ = p;
645                 THIS->lexer_p_->scope_l_arr_.push (p->scope_p_);
646         }
647         | midi_body assignment semicolon {
648
649         }
650         | midi_body translator_spec_block       {
651                 $$-> assign_translator ($2);
652         }
653         | midi_body tempo_request semicolon {
654                 $$->set_tempo ($2->dur_.length_mom (), $2->metronome_i_);
655                 delete $2;
656         }
657         | midi_body error {
658
659         }
660         ;
661
662 tempo_request:
663         TEMPO steno_duration '=' unsigned       {
664                 $$ = new Tempo_req;
665                 $$->dur_ = *$2;
666                 delete $2;
667                 $$-> metronome_i_ = $4;
668         }
669         ;
670
671 Music_list: /* empty */ {
672                 $$ = new Music_list;
673                 $$->set_spot (THIS->here_input ());
674         }
675         | Music_list Music {
676                 $$->add_music ($2);
677         }
678         | Music_list error {
679         }
680         ;
681
682
683 Music:
684         Simple_music
685         | Composite_music
686         ;
687
688 Alternative_music:
689         /* empty */ {
690                 $$ = 0;
691         }
692         | ALTERNATIVE Music_sequence {
693                 $$ = $2;
694                 $2->set_spot (THIS->here_input ());
695         }
696         ;
697
698
699
700
701 Repeated_music:
702         REPEAT STRING unsigned Music Alternative_music
703         {
704                 Music_sequence* m = dynamic_cast <Music_sequence*> ($5);
705                 if (m && $3 < m->length_i ())
706                         $5->warning (_ ("More alternatives than repeats.  Junking excess alternatives."));
707
708                 Repeated_music * r = new Repeated_music ($4, $3 >? 1, m);
709                 $$ = r;
710                 r->fold_b_ = (ly_scm2string ($2) == "fold");
711                 r->volta_fold_b_ =  (ly_scm2string ($2) == "volta");
712                 r->set_spot ($4->spot  ());
713         }
714         ;
715
716 Music_sequence: '{' Music_list '}'      {
717                 $$ = new Music_sequence ($2);
718                 $$->set_spot ($2->spot ());
719         }
720         ;
721
722 Sequential_music:
723         SEQUENTIAL '{' Music_list '}'           {
724                 $$ = new Sequential_music ($3);
725                 $$->set_spot ($3->spot ());
726         }
727         | '{' Music_list '}'            {
728                 $$ = new Sequential_music ($2);
729                 $$->set_spot ($2->spot ());
730         }
731         ;
732
733 Simultaneous_music:
734         SIMULTANEOUS '{' Music_list '}'{
735                 $$ = new Simultaneous_music ($3);
736                 $$->set_spot ($3->spot ());
737         }
738         | '<' Music_list '>'    {
739                 $$ = new Simultaneous_music ($2);
740                 $$->set_spot ($2->spot ());
741         }
742         ;
743
744 Simple_music:
745         request_chord           { $$ = $1; }
746         | OUTPUTPROPERTY embedded_scm embedded_scm '=' embedded_scm     {
747                 SCM pred = $2;
748                 if (!gh_symbol_p ($3))
749                 {
750                         THIS->parser_error (_("Second argument must be a symbol")); 
751                 }
752                 /*hould check # args */
753                 if (!gh_procedure_p (pred))
754                 {
755                         THIS->parser_error (_("First argument must be a procedure taking 1 argument"));
756                 }
757         
758                 $$ = new Output_property (pred,$3, $5);
759         }
760         | MUSIC_IDENTIFIER { $$ = $1->access_content_Music (true); }
761         | property_def
762         | translator_change
763         | Simple_music '*' unsigned '/' unsigned        {
764                 $$ = $1;
765                 $$->compress (Moment($3, $5 ));
766         }
767         | Simple_music '*' unsigned              {
768                 $$ = $1;
769                 $$->compress (Moment ($3, 1));
770         }
771         ;
772
773
774 Composite_music:
775         CONTEXT STRING Music    {
776                 Context_specced_music *csm =  new Context_specced_music ($3);
777
778                 csm->translator_type_str_ = ly_scm2string ($2);
779                 csm->translator_id_str_ = "";
780
781
782                 $$ = csm;
783         }
784         | AUTOCHANGE STRING Music       {
785                 Auto_change_music * chm = new Auto_change_music (ly_scm2string ($2), $3);
786
787                 $$ = chm;
788                 chm->set_spot ($3->spot ());
789         }
790         | GRACE Music {
791                 $$ = new Grace_music ($2);
792         }
793         | CONTEXT STRING '=' STRING Music {
794                 Context_specced_music *csm =  new Context_specced_music ($5);
795
796                 csm->translator_type_str_ = ly_scm2string ($2);
797                 csm->translator_id_str_ = ly_scm2string ($4);
798
799                 $$ = csm;
800         }
801         | TIMES {
802                 THIS->remember_spot ();
803         }
804         /* CONTINUED */ 
805                 unsigned '/' unsigned Music     
806
807         {
808                 $$ = new Time_scaled_music ($3, $5, $6);
809                 $$->set_spot (THIS->pop_spot ());
810         }
811         | Repeated_music                { $$ = $1; }
812         | Simultaneous_music            { $$ = $1; }
813         | Sequential_music              { $$ = $1; }
814         | TRANSPOSE musical_pitch Music {
815                 $$ = new Transposed_music ($3, *$2);
816                 delete $2;
817         }
818         | TRANSPOSE steno_tonic_pitch Music {
819                 $$ = new Transposed_music ($3, *$2);
820                 delete $2;
821         }
822         | NOTES
823                 { THIS->lexer_p_->push_note_state (); }
824         Music
825                 { $$ = $3;
826                   THIS->lexer_p_->pop_state ();
827                 }
828         | CHORDS
829                 { THIS->lexer_p_->push_chord_state (); }
830         Music
831                 {
832                   $$ = $3;
833                   THIS->lexer_p_->pop_state ();
834         }
835         | LYRICS
836                 { THIS->lexer_p_->push_lyric_state (); }
837         Music
838                 {
839                   $$ = $3;
840                   THIS->lexer_p_->pop_state ();
841         }
842         | relative_music        { $$ = $1; }
843         | re_rhythmed_music     { $$ = $1; } 
844         ;
845
846 relative_music:
847         RELATIVE absolute_musical_pitch Music {
848                 $$ = new Relative_octave_music ($3, *$2);
849                 delete $2;
850         }
851         ;
852
853 re_rhythmed_music:
854         ADDLYRICS Music Music {
855                 Lyric_combine_music * l = new Lyric_combine_music ($2, $3);
856                 $$ = l;
857         }
858         ;
859
860 translator_change:
861         TRANSLATOR STRING '=' STRING  {
862                 Change_translator * t = new Change_translator;
863                 t-> change_to_type_str_ = ly_scm2string ($2);
864                 t-> change_to_id_str_ = ly_scm2string ($4);
865
866                 $$ = t;
867                 $$->set_spot (THIS->here_input ());
868         }
869         ;
870
871 property_def:
872         PROPERTY STRING '.' STRING '='  scalar {
873                 Translation_property *t = new Translation_property;
874
875                 t->var_str_ = ly_scm2string ($4);
876                 t->value_ = $6;
877
878                 Context_specced_music *csm = new Context_specced_music (t);
879                 $$ = csm;
880                 $$->set_spot (THIS->here_input ());
881
882                 csm-> translator_type_str_ = ly_scm2string ($2);
883         }
884         ;
885
886 scalar:
887         string          { $$ = $1; }
888         | int           { $$ = gh_int2scm ($1); }
889         | embedded_scm  { $$ = $1; }
890         ;
891
892
893 request_chord:
894         pre_requests simple_element post_requests       {
895                 Music_sequence *l = dynamic_cast<Music_sequence*>($2);
896                 if (l) {
897                         for (int i=0; i < $1->size(); i++)
898                                 l->add_music ($1->elem(i));
899                         for (int i=0; i < $3->size(); i++)
900                                 l->add_music ($3->elem(i));
901                         }
902                 else
903                         programming_error ("Need Sequence to add music to");
904                 $$ = $2;
905                 
906         }
907         | command_element
908         ;
909
910 command_element:
911         command_req {
912                 $$ = new Request_chord;
913                 $$-> set_spot (THIS->here_input ());
914                 $1-> set_spot (THIS->here_input ());
915                 ((Simultaneous_music*)$$) ->add_music ($1);//ugh
916         }
917         | PARTIAL duration_length ';'   {
918                 Translation_property * p = new Translation_property;
919                 p->var_str_ = "measurePosition";
920                 p->value_ =  (new Moment (-$2->length_mom ()))->smobify_self ();
921                 delete $2;
922                 Context_specced_music * sp = new Context_specced_music (p);
923                 $$ =sp ;
924                 sp-> translator_type_str_ = "Score";
925         }
926         ;
927
928 command_req:
929         shorthand_command_req
930         | verbose_command_req semicolon { $$ = $1; }
931         ;
932
933 shorthand_command_req:
934         extender_req {
935                 $$ = $1;
936         }
937         | hyphen_req {
938                 $$ = $1;
939         }
940         | '|'                           {
941                 $$ = new Barcheck_req;
942         }
943         | '~'   {
944                 $$ = new Tie_req;
945         }
946         | '['           {
947                 Span_req*b= new Span_req;
948                 b->span_dir_ = START;
949                 b->span_type_str_ = "beam";
950                 $$ =b;
951         }
952         | '[' ':' unsigned {
953                 if (!is_duration_b ($3))
954                   THIS->parser_error (_f ("not a duration: %d", $3));
955                 else
956                   THIS->set_chord_tremolo ($3);
957
958                 Chord_tremolo_req* a = new Chord_tremolo_req;
959                 a->span_dir_ = START;
960                 // urg
961                 a->type_i_ = THIS->chord_tremolo_type_i_;
962                 $$=a;
963         }
964         | ']'           {
965                 /* URG
966                  */
967                 if (!THIS->chord_tremolo_type_i_)
968                   {
969                      Span_req*b= new Span_req;
970                      b->span_dir_ = STOP;
971                      b->span_type_str_ = "beam";
972                      $$ = b;
973                    }
974                 else
975                   {
976                     Chord_tremolo_req* a = new Chord_tremolo_req;
977                     a->span_dir_ = STOP;
978                     a->type_i_ = THIS->chord_tremolo_type_i_;
979                     THIS->set_chord_tremolo (0);
980                     $$ = a;
981                   }
982         }
983         | BREATHE {
984                 $$ = new Breathing_sign_req;
985         }
986         ;
987
988
989 verbose_command_req:
990         
991         BAR STRING                      {
992                 $$ = new Bar_req (ly_scm2string ($2));
993         }
994         | COMMANDSPANREQUEST int STRING {
995                 Span_req * sp_p = new Span_req;
996                 sp_p-> span_dir_  = Direction($2);
997                 sp_p->span_type_str_ = ly_scm2string ($3);
998                 sp_p->set_spot (THIS->here_input ());
999                 $$ = sp_p;
1000         }
1001         | MARK  {
1002                 Mark_req * m = new Mark_req;
1003                 $$ = m;
1004         }
1005         | MARK STRING {
1006                 Mark_req *m = new Mark_req;
1007                 m->mark_label_ = $2;
1008                 $$ = m;
1009
1010         }
1011         | MARK unsigned {
1012                 Mark_req *m = new Mark_req;
1013                 m->mark_label_ =  gh_int2scm ($2);
1014                 $$ = m;
1015         }
1016
1017         | TIME_T unsigned '/' unsigned  {
1018                 Time_signature_change_req *m = new Time_signature_change_req;
1019                 m->beats_i_ = $2;
1020                 m->one_beat_i_=$4;
1021                 $$ = m;
1022         }
1023         | PENALTY int   {
1024                 Break_req * b = new Break_req;
1025                 b->penalty_f_ = $2 / 100.0;
1026                 b->set_spot (THIS->here_input ());
1027                 $$ = b;
1028         }
1029         | SKIP duration_length {
1030                 Skip_req * skip_p = new Skip_req;
1031                 skip_p->duration_ = *$2;
1032                 delete $2;
1033                 $$ = skip_p;
1034         }
1035         | tempo_request {
1036                 $$ = $1;
1037         }
1038         | CLEF STRING {
1039                 $$ = new Clef_change_req (ly_scm2string ($2));
1040
1041         }
1042 /* UGH. optional.  */
1043         | KEY NOTENAME_PITCH optional_modality  {
1044                 Key_change_req *key_p= new Key_change_req;
1045                 key_p->key_.pitch_arr_.push (*$2);
1046                 key_p->key_.ordinary_key_b_ = true;
1047                 key_p->key_.modality_i_ = $3;
1048                 $$ = key_p;
1049                 delete $2;
1050         }
1051         | KEYSIGNATURE pitch_list {
1052                 Key_change_req *key_p= new Key_change_req;
1053                 key_p->key_.pitch_arr_ = *$2;
1054                 key_p->key_.ordinary_key_b_ = false;
1055                 $$ = key_p;
1056                 delete $2;
1057         }
1058         ;
1059
1060 post_requests:
1061         {
1062                 $$ = new Link_array<Request>;
1063         }
1064         | post_requests post_request {
1065                 $2->set_spot (THIS->here_input ());
1066                 $$->push ($2);
1067         }
1068         ;
1069
1070 post_request:
1071         verbose_request
1072         | request_with_dir
1073         | close_request
1074         ;
1075
1076
1077 request_that_take_dir:
1078         gen_text_def
1079         | verbose_request
1080         | script_abbreviation {
1081                 Identifier*i = THIS->lexer_p_->lookup_identifier ("dash-" + ly_scm2string ($1));
1082                 Articulation_req *a = new Articulation_req;
1083                 a->articulation_str_ = *i->access_content_String (false);
1084                 $$ = a;
1085         }
1086         ;
1087
1088 request_with_dir:
1089         script_dir request_that_take_dir        {
1090                 if (Script_req * gs = dynamic_cast<Script_req*> ($2))
1091                         gs->dir_ = Direction ($1);
1092                 else if ($1)
1093                         $2->warning (_ ("Can't specify direction for this request"));
1094                 $$ = $2;
1095         }
1096         ;
1097         
1098 verbose_request:
1099         REQUEST_IDENTIFIER      {
1100                 $$ = (Request*)$1->access_content_Request (true);
1101                 $$->set_spot (THIS->here_input ());
1102         }
1103         | TEXTSCRIPT STRING STRING      {
1104                 Text_script_req *ts_p = new Text_script_req;
1105                 ts_p-> text_str_ = ly_scm2string ($2);
1106                 ts_p-> style_str_ = ly_scm2string ($3);
1107                 ts_p->set_spot (THIS->here_input ());
1108
1109                 $$ = ts_p;
1110         }
1111         | SPANREQUEST int STRING {
1112                 Span_req * sp_p = new Span_req;
1113                 sp_p-> span_dir_  = Direction($2);
1114                 sp_p->span_type_str_ = ly_scm2string ($3);
1115                 sp_p->set_spot (THIS->here_input ());
1116                 $$ = sp_p;
1117         }
1118         | tremolo_type  {
1119                 Tremolo_req* a = new Tremolo_req;
1120                 a->set_spot (THIS->here_input ());
1121                 a->type_i_ = $1;
1122                 $$ = a;
1123         }
1124         | SCRIPT STRING         { 
1125                 Articulation_req * a = new Articulation_req;
1126                 a->articulation_str_ = ly_scm2string ($2);
1127                 a->set_spot (THIS->here_input ());
1128                 $$ = a;
1129
1130         }
1131         ;
1132
1133 optional_modality:
1134         /* empty */     {
1135                 $$ = 0;
1136         }
1137         | int   {
1138                 $$ = $1;
1139         }
1140         ;
1141
1142 sup_quotes:
1143         '\'' {
1144                 $$ = 1;
1145         }
1146         | sup_quotes '\'' {
1147                 $$ ++;
1148         }
1149         ;
1150
1151 sub_quotes:
1152         ',' {
1153                 $$ = 1;
1154         }
1155         | sub_quotes ',' {
1156                 $$ ++ ;
1157         }
1158         ;
1159
1160 steno_musical_pitch:
1161         NOTENAME_PITCH  {
1162                 $$ = $1;
1163         }
1164         | NOTENAME_PITCH sup_quotes     {
1165                 $$ = $1;
1166                 $$->octave_i_ +=  $2;
1167         }
1168         | NOTENAME_PITCH sub_quotes      {
1169                 $$ = $1;
1170                 $$->octave_i_ += - $2;
1171         }
1172         ;
1173
1174 steno_tonic_pitch:
1175         TONICNAME_PITCH {
1176                 $$ = $1;
1177         }
1178         | TONICNAME_PITCH sup_quotes    {
1179                 $$ = $1;
1180                 $$->octave_i_ +=  $2;
1181         }
1182         | TONICNAME_PITCH sub_quotes     {
1183                 $$ = $1;
1184                 $$->octave_i_ += - $2;
1185         }
1186         ;
1187
1188 explicit_musical_pitch:
1189         MUSICAL_PITCH '{' int_list '}'  {/* ugh */
1190                 Array<int> &a = *$3;
1191                 ARRAY_SIZE(a,3);
1192                 $$ = new Musical_pitch;
1193                 $$->octave_i_ = a[0];
1194                 $$->notename_i_ = a[1];
1195                 $$->accidental_i_ = a[2];
1196                 delete &a;
1197         }
1198         ;
1199
1200 musical_pitch:
1201         steno_musical_pitch {
1202                 $$ = $1;
1203         }
1204         | explicit_musical_pitch {
1205                 $$ = $1;
1206         }
1207         ;
1208
1209 explicit_duration:
1210         DURATION '{' int_list '}'       {
1211                 $$ = new Duration;
1212                 Array<int> &a = *$3;
1213                 ARRAY_SIZE(a,2);
1214                         
1215                 $$-> durlog_i_ = a[0];
1216                 $$-> dots_i_ = a[1];
1217
1218                 delete &a;              
1219         }
1220         ;
1221
1222 extender_req:
1223         EXTENDER {
1224                 if (!THIS->lexer_p_->lyric_state_b ())
1225                         THIS->parser_error (_ ("Have to be in Lyric mode for lyrics"));
1226                 $$ = new Extender_req;
1227         }
1228         ;
1229
1230 hyphen_req:
1231         HYPHEN {
1232                 if (!THIS->lexer_p_->lyric_state_b ())
1233                         THIS->parser_error (_ ("Have to be in Lyric mode for lyrics"));
1234                 $$ = new Hyphen_req;
1235         }
1236         ;
1237
1238 close_request:
1239         close_request_parens {
1240                 $$ = $1;
1241                 dynamic_cast<Span_req*> ($$)->span_dir_ = START;
1242         }
1243         
1244 close_request_parens:
1245         '('     {
1246                 Span_req* s= new Span_req;
1247                 $$ = s;
1248                 s->span_type_str_ = "slur";
1249         }
1250         | E_SMALLER {
1251                 Span_req*s =new Span_req;
1252                 $$ = s;
1253                 s->span_type_str_ = "crescendo";
1254         }
1255         | E_BIGGER {
1256                 Span_req*s =new Span_req;
1257                 $$ = s;
1258                 s->span_type_str_ = "decrescendo";
1259         }
1260         ;
1261
1262
1263 open_request:
1264         open_request_parens {
1265                 $$ = $1;
1266                 dynamic_cast<Span_req*> ($$)->span_dir_ = STOP;
1267         }
1268         ;
1269
1270 open_request_parens:
1271         E_EXCLAMATION   {
1272                 Span_req *s =  new Span_req;
1273                 s->span_type_str_ = "crescendo";
1274                 $$ = s;
1275         }
1276         | ')'   {
1277                 Span_req* s= new Span_req;
1278                 $$ = s;
1279                 s->span_type_str_ = "slur";
1280         }
1281         ;
1282
1283 gen_text_def:
1284         string {
1285                 Text_script_req *t  = new Text_script_req;
1286                 $$ = t;
1287                 t->text_str_ = ly_scm2string ($1);
1288
1289                 $$->set_spot (THIS->here_input ());
1290         }
1291         | DIGIT {
1292                 Text_script_req* t  = new Text_script_req;
1293                 $$ = t;
1294                 t->text_str_ = to_str ($1);
1295                 t->style_str_ = "finger";
1296                 $$->set_spot (THIS->here_input ());
1297         }
1298         ;
1299
1300 script_abbreviation:
1301         '^'             {
1302                 $$ = gh_str02scm  ("hat");
1303         }
1304         | '+'           {
1305                 $$ = gh_str02scm("plus");
1306         }
1307         | '-'           {
1308                 $$ = gh_str02scm ("dash");
1309         }
1310         | '|'           {
1311                 $$ = gh_str02scm ("bar");
1312         }
1313         | '>'           {
1314                 $$ = gh_str02scm ("larger");
1315         }
1316         | '.'           {
1317                 $$ = gh_str02scm ("dot");
1318         }
1319         ;
1320
1321
1322 script_dir:
1323         '_'     { $$ = DOWN; }
1324         | '^'   { $$ = UP; }
1325         | '-'   { $$ = CENTER; }
1326         ;
1327
1328 pre_requests:
1329         {
1330                 $$ = new Link_array<Request>;
1331         }
1332         | pre_requests open_request {
1333                 $$->push ($2);
1334         }
1335         ;
1336
1337 absolute_musical_pitch:
1338         steno_musical_pitch     {
1339                 $$ = $1;
1340         }
1341         ;
1342
1343 duration_length:
1344         steno_duration {
1345                 $$ = $1;
1346         }
1347         | duration_length '*' unsigned {
1348                 $$->tuplet_iso_i_ *= $3;
1349         }
1350         | duration_length '/' unsigned {
1351                 $$->tuplet_type_i_ *= $3;
1352         }
1353         ;
1354
1355 entered_notemode_duration:
1356         steno_duration  {
1357                 THIS->set_last_duration ($1);
1358         }
1359         ;
1360
1361 optional_notemode_duration:
1362         {
1363                 $$ = new Duration (THIS->default_duration_);
1364         }
1365         | entered_notemode_duration {
1366                 $$ = $1;
1367         }
1368         ;
1369
1370 steno_duration:
1371         unsigned                {
1372                 $$ = new Duration;
1373                 if (!is_duration_b ($1))
1374                         THIS->parser_error (_f ("not a duration: %d", $1));
1375                 else {
1376                         $$->durlog_i_ = intlog2 ($1);
1377                      }
1378         }
1379         | DURATION_IDENTIFIER   {
1380                 $$ = $1->access_content_Duration (true);
1381         }
1382         | steno_duration '.'    {
1383                 $$->dots_i_ ++;
1384         }
1385         ;
1386
1387
1388 tremolo_type: 
1389         ':'     {
1390                 $$ =0;
1391         }
1392         | ':' unsigned {
1393                 if (!is_duration_b ($2))
1394                         THIS->parser_error (_f ("not a duration: %d", $2));
1395                 $$ = $2;
1396         }
1397         ;
1398
1399
1400 simple_element:
1401         musical_pitch exclamations questions optional_notemode_duration {
1402                 if (!THIS->lexer_p_->note_state_b ())
1403                         THIS->parser_error (_ ("Have to be in Note mode for notes"));
1404
1405
1406                 Note_req *n = new Note_req;
1407                 
1408                 n->pitch_ = *$1;
1409                 n->duration_ = *$4;
1410                 /*
1411                   URG
1412                  */
1413                 if (THIS->chord_tremolo_type_i_)
1414                   {
1415                     if (n->duration_.plet_b ())
1416                       // urg, burp.  what nonsense / silly implementation
1417                       THIS->parser_error (_ ("can't put stem tremolo on tuplet"));
1418                     else
1419                       n->duration_.set_plet (1, 2);
1420                   }
1421                 n->cautionary_b_ = $3 % 2;
1422                 n->forceacc_b_ = $2 % 2 || n->cautionary_b_;
1423
1424                 Simultaneous_music*v = new Request_chord;
1425                 v->set_spot ($1->spot ());
1426                 n->set_spot ($1->spot ());
1427
1428                 v->add_music (n);
1429
1430                 $$ = v;
1431
1432                 delete $1;
1433                 delete $4;
1434
1435         }
1436         | RESTNAME optional_notemode_duration           {
1437                   Simultaneous_music* velt_p = new Request_chord;
1438                   velt_p->set_spot (THIS->here_input());
1439
1440                   if (ly_scm2string ($1) =="s")
1441                     { /* Space */
1442                       Skip_req * skip_p = new Skip_req;
1443                       skip_p->duration_ = *$2;
1444
1445                       skip_p->set_spot (THIS->here_input());
1446                       velt_p->add_music (skip_p);
1447                     }
1448                   else
1449                     {
1450                       Rest_req * rest_req_p = new Rest_req;
1451                       rest_req_p->duration_ = *$2;
1452                       rest_req_p->set_spot (THIS->here_input());
1453
1454                       velt_p->add_music (rest_req_p);
1455                     }
1456
1457                   delete $2;
1458                   $$ = velt_p;
1459         }
1460         | MEASURES optional_notemode_duration   {
1461                 Skip_req * sk = new Skip_req;
1462                 sk->duration_ = *$2;
1463                 Music_list * ms = new Music_list;
1464                 Request_chord * rqc1 = new Request_chord;
1465                 Request_chord * rqc2 = new Request_chord;
1466                 Request_chord * rqc3 = new Request_chord;
1467
1468                 Span_req *sp1 = new Span_req;
1469                 Span_req *sp2 = new Span_req;
1470                 sp1-> span_dir_ = START;
1471                 sp2-> span_dir_ = STOP;
1472                 sp1->span_type_str_ = sp2->span_type_str_ = "rest";
1473                 rqc1->add_music (sp1);
1474                 rqc2->add_music (sk);
1475                 rqc3->add_music (sp2);
1476                 
1477                 ms->add_music (rqc1);
1478                 ms->add_music (rqc2);
1479                 ms->add_music (rqc3);
1480
1481                 $$ = new Sequential_music (ms);
1482         }
1483         | STRING optional_notemode_duration     {
1484                 if (!THIS->lexer_p_->lyric_state_b ())
1485                         THIS->parser_error (_ ("Have to be in Lyric mode for lyrics"));
1486                   Simultaneous_music* velt_p = new Request_chord;
1487
1488                   Lyric_req* lreq_p = new Lyric_req;
1489                   lreq_p ->text_str_ = ly_scm2string ($1);
1490                   lreq_p->duration_ = *$2;
1491                   lreq_p->set_spot (THIS->here_input());
1492
1493                   velt_p->add_music (lreq_p);
1494
1495                   delete  $2;
1496                 $$= velt_p;
1497
1498         }
1499         | chord {
1500                 if (!THIS->lexer_p_->chord_state_b ())
1501                         THIS->parser_error (_ ("Have to be in Chord mode for chords"));
1502                 $$ = $1;
1503         }
1504         ;
1505
1506 chord:
1507         steno_tonic_pitch optional_notemode_duration chord_additions chord_subtractions chord_inversion chord_bass {
1508                 $$ = THIS->get_chord (*$1, $3, $4, $5, $6, *$2);
1509         };
1510
1511 chord_additions: 
1512         {
1513                 $$ = new Array<Musical_pitch>;
1514         } 
1515         | CHORD_COLON chord_notes {
1516                 $$ = $2;
1517         }
1518         ;
1519
1520 chord_notes:
1521         chord_step {
1522                 $$ = $1
1523         }
1524         | chord_notes '.' chord_step {
1525                 $$ = $1;
1526                 $$->concat (*$3);
1527         }
1528         ;
1529
1530 chord_subtractions: 
1531         {
1532                 $$ = new Array<Musical_pitch>;
1533         } 
1534         | CHORD_CARET chord_notes {
1535                 $$ = $2;
1536         }
1537         ;
1538
1539
1540 chord_inversion:
1541         {
1542                 $$ = 0;
1543         }
1544         | '/' steno_tonic_pitch {
1545                 $$ = $2;
1546                 $$->set_spot (THIS->here_input ());
1547         }
1548         ;
1549
1550 chord_bass:
1551         {
1552                 $$ = 0;
1553         }
1554         | CHORD_BASS steno_tonic_pitch {
1555                 $$ = $2;
1556                 $$->set_spot (THIS->here_input ());
1557         }
1558         ;
1559
1560 chord_step:
1561         chord_note {
1562                 $$ = new Array<Musical_pitch>;
1563                 $$->push (*$1);
1564         }
1565         | CHORDMODIFIER_PITCH {
1566                 $$ = new Array<Musical_pitch>;
1567                 $$->push (*$1);
1568         }
1569         | CHORDMODIFIER_PITCH chord_note { /* Ugh. */
1570                 $$ = new Array<Musical_pitch>;
1571                 $$->push (*$1);
1572                 $$->push (*$2);
1573         }
1574         ;
1575
1576 chord_note:
1577         unsigned {
1578                 $$ = new Musical_pitch;
1579                 $$->notename_i_ = ($1 - 1) % 7;
1580                 $$->octave_i_ = $1 > 7 ? 1 : 0;
1581                 $$->accidental_i_ = 0;
1582         } 
1583         | unsigned '+' {
1584                 $$ = new Musical_pitch;
1585                 $$->notename_i_ = ($1 - 1) % 7;
1586                 $$->octave_i_ = $1 > 7 ? 1 : 0;
1587                 $$->accidental_i_ = 1;
1588         }
1589         | unsigned CHORD_MINUS {
1590                 $$ = new Musical_pitch;
1591                 $$->notename_i_ = ($1 - 1) % 7;
1592                 $$->octave_i_ = $1 > 7 ? 1 : 0;
1593                 $$->accidental_i_ = -1;
1594         }
1595         ;
1596
1597 /*
1598         UTILITIES
1599  */
1600 pitch_list:                     {
1601                 $$ = new Array<Musical_pitch>;
1602         }
1603         | pitch_list musical_pitch      {
1604                 $$->push (*$2);
1605                 delete $2;
1606         }
1607         ;
1608
1609
1610 int_list:
1611         /**/                    {
1612                 $$ = new Array<int>
1613         }
1614         | int_list int          {
1615                 $$->push ($2);          
1616         }
1617         ;
1618
1619 unsigned:
1620         UNSIGNED        {
1621                 $$ = $1;
1622         }
1623         | DIGIT         {
1624                 $$ = $1;
1625         }
1626         ;
1627
1628 int:
1629         unsigned {
1630                 $$ = $1;
1631         }
1632         | '-' unsigned {
1633                 $$ = -$2;
1634         }
1635         | INT_IDENTIFIER        {
1636                 $$ = *$1->access_content_int (false);
1637         }
1638         ;
1639
1640
1641 string:
1642         STRING          {
1643                 $$ = $1;
1644         }
1645         | STRING_IDENTIFIER     {
1646                 $$ = ly_str02scm ($1->access_content_String (true)->ch_C ());
1647         }
1648         | string '+' string {
1649                 $$ = scm_string_append (scm_listify ($1, $3, SCM_UNDEFINED));
1650         }
1651         ;
1652
1653
1654 exclamations:
1655                 { $$ = 0; }
1656         | exclamations '!'      { $$ ++; }
1657         ;
1658
1659 questions:
1660                 { $$ = 0; }
1661         | questions '?' { $$ ++; }
1662         ;
1663
1664
1665 semicolon:
1666         ';'
1667         ;
1668 %%
1669
1670 void
1671 My_lily_parser::set_yydebug (bool b)
1672 {
1673 #ifdef YYDEBUG
1674         yydebug = b;
1675 #endif
1676 }
1677 void
1678 My_lily_parser::do_yyparse ()
1679 {
1680         yyparse ((void*)this);
1681 }
1682
1683