]> git.donarmstrong.com Git - lilypond.git/blob - lily/parser.yy
release: 1.3.34
[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--2000 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         | KEY {
1043                 Key_change_req *key_p= new Key_change_req;
1044                 key_p->key_ = 0;
1045                 $$ = key_p;
1046         }
1047 /* UGH. optional.  */
1048
1049         | KEY NOTENAME_PITCH optional_modality  {
1050                 Key_change_req *key_p= new Key_change_req;
1051                 Key_def d;
1052                 d.pitch_arr_.push (*$2);
1053                 d.ordinary_key_b_ = true;
1054                 d.modality_i_ = $3;
1055
1056                 key_p->key_ = new Key_def (d);
1057                 $$ = key_p;
1058                 delete $2;
1059         }
1060         | KEYSIGNATURE pitch_list {
1061                 Key_change_req *key_p= new Key_change_req;
1062                 Key_def d;
1063                 d.pitch_arr_ = *$2;
1064                 d.ordinary_key_b_ = false;
1065
1066                 key_p->key_ = new Key_def(d);
1067                 $$ = key_p;
1068                 delete $2;
1069         }
1070         ;
1071
1072 post_requests:
1073         {
1074                 $$ = new Link_array<Request>;
1075         }
1076         | post_requests post_request {
1077                 $2->set_spot (THIS->here_input ());
1078                 $$->push ($2);
1079         }
1080         ;
1081
1082 post_request:
1083         verbose_request
1084         | request_with_dir
1085         | close_request
1086         ;
1087
1088
1089 request_that_take_dir:
1090         gen_text_def
1091         | verbose_request
1092         | script_abbreviation {
1093                 Identifier*i = THIS->lexer_p_->lookup_identifier ("dash-" + ly_scm2string ($1));
1094                 Articulation_req *a = new Articulation_req;
1095                 a->articulation_str_ = *i->access_content_String (false);
1096                 $$ = a;
1097         }
1098         ;
1099
1100 request_with_dir:
1101         script_dir request_that_take_dir        {
1102                 if (Script_req * gs = dynamic_cast<Script_req*> ($2))
1103                         gs->dir_ = Direction ($1);
1104                 else if ($1)
1105                         $2->warning (_ ("Can't specify direction for this request"));
1106                 $$ = $2;
1107         }
1108         ;
1109         
1110 verbose_request:
1111         REQUEST_IDENTIFIER      {
1112                 $$ = (Request*)$1->access_content_Request (true);
1113                 $$->set_spot (THIS->here_input ());
1114         }
1115         | TEXTSCRIPT STRING STRING      {
1116                 Text_script_req *ts_p = new Text_script_req;
1117                 ts_p-> text_str_ = ly_scm2string ($2);
1118                 ts_p-> style_str_ = ly_scm2string ($3);
1119                 ts_p->set_spot (THIS->here_input ());
1120
1121                 $$ = ts_p;
1122         }
1123         | SPANREQUEST int STRING {
1124                 Span_req * sp_p = new Span_req;
1125                 sp_p-> span_dir_  = Direction($2);
1126                 sp_p->span_type_str_ = ly_scm2string ($3);
1127                 sp_p->set_spot (THIS->here_input ());
1128                 $$ = sp_p;
1129         }
1130         | tremolo_type  {
1131                 Tremolo_req* a = new Tremolo_req;
1132                 a->set_spot (THIS->here_input ());
1133                 a->type_i_ = $1;
1134                 $$ = a;
1135         }
1136         | SCRIPT STRING         { 
1137                 Articulation_req * a = new Articulation_req;
1138                 a->articulation_str_ = ly_scm2string ($2);
1139                 a->set_spot (THIS->here_input ());
1140                 $$ = a;
1141
1142         }
1143         ;
1144
1145 optional_modality:
1146         /* empty */     {
1147                 $$ = 0;
1148         }
1149         | int   {
1150                 $$ = $1;
1151         }
1152         ;
1153
1154 sup_quotes:
1155         '\'' {
1156                 $$ = 1;
1157         }
1158         | sup_quotes '\'' {
1159                 $$ ++;
1160         }
1161         ;
1162
1163 sub_quotes:
1164         ',' {
1165                 $$ = 1;
1166         }
1167         | sub_quotes ',' {
1168                 $$ ++ ;
1169         }
1170         ;
1171
1172 steno_musical_pitch:
1173         NOTENAME_PITCH  {
1174                 $$ = $1;
1175         }
1176         | NOTENAME_PITCH sup_quotes     {
1177                 $$ = $1;
1178                 $$->octave_i_ +=  $2;
1179         }
1180         | NOTENAME_PITCH sub_quotes      {
1181                 $$ = $1;
1182                 $$->octave_i_ += - $2;
1183         }
1184         ;
1185
1186 steno_tonic_pitch:
1187         TONICNAME_PITCH {
1188                 $$ = $1;
1189         }
1190         | TONICNAME_PITCH sup_quotes    {
1191                 $$ = $1;
1192                 $$->octave_i_ +=  $2;
1193         }
1194         | TONICNAME_PITCH sub_quotes     {
1195                 $$ = $1;
1196                 $$->octave_i_ += - $2;
1197         }
1198         ;
1199
1200 explicit_musical_pitch:
1201         MUSICAL_PITCH '{' int_list '}'  {/* ugh */
1202                 Array<int> &a = *$3;
1203                 ARRAY_SIZE(a,3);
1204                 $$ = new Musical_pitch;
1205                 $$->octave_i_ = a[0];
1206                 $$->notename_i_ = a[1];
1207                 $$->accidental_i_ = a[2];
1208                 delete &a;
1209         }
1210         ;
1211
1212 musical_pitch:
1213         steno_musical_pitch {
1214                 $$ = $1;
1215         }
1216         | explicit_musical_pitch {
1217                 $$ = $1;
1218         }
1219         ;
1220
1221 explicit_duration:
1222         DURATION '{' int_list '}'       {
1223                 $$ = new Duration;
1224                 Array<int> &a = *$3;
1225                 ARRAY_SIZE(a,2);
1226                         
1227                 $$-> durlog_i_ = a[0];
1228                 $$-> dots_i_ = a[1];
1229
1230                 delete &a;              
1231         }
1232         ;
1233
1234 extender_req:
1235         EXTENDER {
1236                 if (!THIS->lexer_p_->lyric_state_b ())
1237                         THIS->parser_error (_ ("Have to be in Lyric mode for lyrics"));
1238                 $$ = new Extender_req;
1239         }
1240         ;
1241
1242 hyphen_req:
1243         HYPHEN {
1244                 if (!THIS->lexer_p_->lyric_state_b ())
1245                         THIS->parser_error (_ ("Have to be in Lyric mode for lyrics"));
1246                 $$ = new Hyphen_req;
1247         }
1248         ;
1249
1250 close_request:
1251         close_request_parens {
1252                 $$ = $1;
1253                 dynamic_cast<Span_req*> ($$)->span_dir_ = START;
1254         }
1255         
1256 close_request_parens:
1257         '('     {
1258                 Span_req* s= new Span_req;
1259                 $$ = s;
1260                 s->span_type_str_ = "slur";
1261         }
1262         | E_SMALLER {
1263                 Span_req*s =new Span_req;
1264                 $$ = s;
1265                 s->span_type_str_ = "crescendo";
1266         }
1267         | E_BIGGER {
1268                 Span_req*s =new Span_req;
1269                 $$ = s;
1270                 s->span_type_str_ = "decrescendo";
1271         }
1272         ;
1273
1274
1275 open_request:
1276         open_request_parens {
1277                 $$ = $1;
1278                 dynamic_cast<Span_req*> ($$)->span_dir_ = STOP;
1279         }
1280         ;
1281
1282 open_request_parens:
1283         E_EXCLAMATION   {
1284                 Span_req *s =  new Span_req;
1285                 s->span_type_str_ = "crescendo";
1286                 $$ = s;
1287         }
1288         | ')'   {
1289                 Span_req* s= new Span_req;
1290                 $$ = s;
1291                 s->span_type_str_ = "slur";
1292         }
1293         ;
1294
1295 gen_text_def:
1296         string {
1297                 Text_script_req *t  = new Text_script_req;
1298                 $$ = t;
1299                 t->text_str_ = ly_scm2string ($1);
1300
1301                 $$->set_spot (THIS->here_input ());
1302         }
1303         | DIGIT {
1304                 Text_script_req* t  = new Text_script_req;
1305                 $$ = t;
1306                 t->text_str_ = to_str ($1);
1307                 t->style_str_ = "finger";
1308                 $$->set_spot (THIS->here_input ());
1309         }
1310         ;
1311
1312 script_abbreviation:
1313         '^'             {
1314                 $$ = gh_str02scm  ("hat");
1315         }
1316         | '+'           {
1317                 $$ = gh_str02scm("plus");
1318         }
1319         | '-'           {
1320                 $$ = gh_str02scm ("dash");
1321         }
1322         | '|'           {
1323                 $$ = gh_str02scm ("bar");
1324         }
1325         | '>'           {
1326                 $$ = gh_str02scm ("larger");
1327         }
1328         | '.'           {
1329                 $$ = gh_str02scm ("dot");
1330         }
1331         ;
1332
1333
1334 script_dir:
1335         '_'     { $$ = DOWN; }
1336         | '^'   { $$ = UP; }
1337         | '-'   { $$ = CENTER; }
1338         ;
1339
1340 pre_requests:
1341         {
1342                 $$ = new Link_array<Request>;
1343         }
1344         | pre_requests open_request {
1345                 $$->push ($2);
1346         }
1347         ;
1348
1349 absolute_musical_pitch:
1350         steno_musical_pitch     {
1351                 $$ = $1;
1352         }
1353         ;
1354
1355 duration_length:
1356         steno_duration {
1357                 $$ = $1;
1358         }
1359         | duration_length '*' unsigned {
1360                 $$->tuplet_iso_i_ *= $3;
1361         }
1362         | duration_length '/' unsigned {
1363                 $$->tuplet_type_i_ *= $3;
1364         }
1365         ;
1366
1367 entered_notemode_duration:
1368         steno_duration  {
1369                 THIS->set_last_duration ($1);
1370         }
1371         ;
1372
1373 optional_notemode_duration:
1374         {
1375                 $$ = new Duration (THIS->default_duration_);
1376         }
1377         | entered_notemode_duration {
1378                 $$ = $1;
1379         }
1380         ;
1381
1382 steno_duration:
1383         unsigned                {
1384                 $$ = new Duration;
1385                 if (!is_duration_b ($1))
1386                         THIS->parser_error (_f ("not a duration: %d", $1));
1387                 else {
1388                         $$->durlog_i_ = intlog2 ($1);
1389                      }
1390         }
1391         | DURATION_IDENTIFIER   {
1392                 $$ = $1->access_content_Duration (true);
1393         }
1394         | steno_duration '.'    {
1395                 $$->dots_i_ ++;
1396         }
1397         ;
1398
1399
1400 tremolo_type: 
1401         ':'     {
1402                 $$ =0;
1403         }
1404         | ':' unsigned {
1405                 if (!is_duration_b ($2))
1406                         THIS->parser_error (_f ("not a duration: %d", $2));
1407                 $$ = $2;
1408         }
1409         ;
1410
1411
1412 simple_element:
1413         musical_pitch exclamations questions optional_notemode_duration {
1414                 if (!THIS->lexer_p_->note_state_b ())
1415                         THIS->parser_error (_ ("Have to be in Note mode for notes"));
1416
1417
1418                 Note_req *n = new Note_req;
1419                 
1420                 n->pitch_ = *$1;
1421                 n->duration_ = *$4;
1422                 /*
1423                   URG
1424                  */
1425                 if (THIS->chord_tremolo_type_i_)
1426                   {
1427                     if (n->duration_.plet_b ())
1428                       // urg, burp.  what nonsense / silly implementation
1429                       THIS->parser_error (_ ("can't put stem tremolo on tuplet"));
1430                     else
1431                       n->duration_.set_plet (1, 2);
1432                   }
1433                 n->cautionary_b_ = $3 % 2;
1434                 n->forceacc_b_ = $2 % 2 || n->cautionary_b_;
1435
1436                 Simultaneous_music*v = new Request_chord;
1437                 v->set_spot ($1->spot ());
1438                 n->set_spot ($1->spot ());
1439
1440                 v->add_music (n);
1441
1442                 $$ = v;
1443
1444                 delete $1;
1445                 delete $4;
1446
1447         }
1448         | RESTNAME optional_notemode_duration           {
1449                   Simultaneous_music* velt_p = new Request_chord;
1450                   velt_p->set_spot (THIS->here_input());
1451
1452                   if (ly_scm2string ($1) =="s")
1453                     { /* Space */
1454                       Skip_req * skip_p = new Skip_req;
1455                       skip_p->duration_ = *$2;
1456
1457                       skip_p->set_spot (THIS->here_input());
1458                       velt_p->add_music (skip_p);
1459                     }
1460                   else
1461                     {
1462                       Rest_req * rest_req_p = new Rest_req;
1463                       rest_req_p->duration_ = *$2;
1464                       rest_req_p->set_spot (THIS->here_input());
1465
1466                       velt_p->add_music (rest_req_p);
1467                     }
1468
1469                   delete $2;
1470                   $$ = velt_p;
1471         }
1472         | MEASURES optional_notemode_duration   {
1473                 Skip_req * sk = new Skip_req;
1474                 sk->duration_ = *$2;
1475                 Music_list * ms = new Music_list;
1476                 Request_chord * rqc1 = new Request_chord;
1477                 Request_chord * rqc2 = new Request_chord;
1478                 Request_chord * rqc3 = new Request_chord;
1479
1480                 Span_req *sp1 = new Span_req;
1481                 Span_req *sp2 = new Span_req;
1482                 sp1-> span_dir_ = START;
1483                 sp2-> span_dir_ = STOP;
1484                 sp1->span_type_str_ = sp2->span_type_str_ = "rest";
1485                 rqc1->add_music (sp1);
1486                 rqc2->add_music (sk);
1487                 rqc3->add_music (sp2);
1488                 
1489                 ms->add_music (rqc1);
1490                 ms->add_music (rqc2);
1491                 ms->add_music (rqc3);
1492
1493                 $$ = new Sequential_music (ms);
1494         }
1495         | STRING optional_notemode_duration     {
1496                 if (!THIS->lexer_p_->lyric_state_b ())
1497                         THIS->parser_error (_ ("Have to be in Lyric mode for lyrics"));
1498                   Simultaneous_music* velt_p = new Request_chord;
1499
1500                   Lyric_req* lreq_p = new Lyric_req;
1501                   lreq_p ->text_str_ = ly_scm2string ($1);
1502                   lreq_p->duration_ = *$2;
1503                   lreq_p->set_spot (THIS->here_input());
1504
1505                   velt_p->add_music (lreq_p);
1506
1507                   delete  $2;
1508                 $$= velt_p;
1509
1510         }
1511         | chord {
1512                 if (!THIS->lexer_p_->chord_state_b ())
1513                         THIS->parser_error (_ ("Have to be in Chord mode for chords"));
1514                 $$ = $1;
1515         }
1516         ;
1517
1518 chord:
1519         steno_tonic_pitch optional_notemode_duration chord_additions chord_subtractions chord_inversion chord_bass {
1520                 $$ = THIS->get_chord (*$1, $3, $4, $5, $6, *$2);
1521         };
1522
1523 chord_additions: 
1524         {
1525                 $$ = new Array<Musical_pitch>;
1526         } 
1527         | CHORD_COLON chord_notes {
1528                 $$ = $2;
1529         }
1530         ;
1531
1532 chord_notes:
1533         chord_step {
1534                 $$ = $1
1535         }
1536         | chord_notes '.' chord_step {
1537                 $$ = $1;
1538                 $$->concat (*$3);
1539         }
1540         ;
1541
1542 chord_subtractions: 
1543         {
1544                 $$ = new Array<Musical_pitch>;
1545         } 
1546         | CHORD_CARET chord_notes {
1547                 $$ = $2;
1548         }
1549         ;
1550
1551
1552 chord_inversion:
1553         {
1554                 $$ = 0;
1555         }
1556         | '/' steno_tonic_pitch {
1557                 $$ = $2;
1558                 $$->set_spot (THIS->here_input ());
1559         }
1560         ;
1561
1562 chord_bass:
1563         {
1564                 $$ = 0;
1565         }
1566         | CHORD_BASS steno_tonic_pitch {
1567                 $$ = $2;
1568                 $$->set_spot (THIS->here_input ());
1569         }
1570         ;
1571
1572 chord_step:
1573         chord_note {
1574                 $$ = new Array<Musical_pitch>;
1575                 $$->push (*$1);
1576         }
1577         | CHORDMODIFIER_PITCH {
1578                 $$ = new Array<Musical_pitch>;
1579                 $$->push (*$1);
1580         }
1581         | CHORDMODIFIER_PITCH chord_note { /* Ugh. */
1582                 $$ = new Array<Musical_pitch>;
1583                 $$->push (*$1);
1584                 $$->push (*$2);
1585         }
1586         ;
1587
1588 chord_note:
1589         unsigned {
1590                 $$ = new Musical_pitch;
1591                 $$->notename_i_ = ($1 - 1) % 7;
1592                 $$->octave_i_ = $1 > 7 ? 1 : 0;
1593                 $$->accidental_i_ = 0;
1594         } 
1595         | unsigned '+' {
1596                 $$ = new Musical_pitch;
1597                 $$->notename_i_ = ($1 - 1) % 7;
1598                 $$->octave_i_ = $1 > 7 ? 1 : 0;
1599                 $$->accidental_i_ = 1;
1600         }
1601         | unsigned CHORD_MINUS {
1602                 $$ = new Musical_pitch;
1603                 $$->notename_i_ = ($1 - 1) % 7;
1604                 $$->octave_i_ = $1 > 7 ? 1 : 0;
1605                 $$->accidental_i_ = -1;
1606         }
1607         ;
1608
1609 /*
1610         UTILITIES
1611  */
1612 pitch_list:                     {
1613                 $$ = new Array<Musical_pitch>;
1614         }
1615         | pitch_list musical_pitch      {
1616                 $$->push (*$2);
1617                 delete $2;
1618         }
1619         ;
1620
1621
1622 int_list:
1623         /**/                    {
1624                 $$ = new Array<int>
1625         }
1626         | int_list int          {
1627                 $$->push ($2);          
1628         }
1629         ;
1630
1631 unsigned:
1632         UNSIGNED        {
1633                 $$ = $1;
1634         }
1635         | DIGIT         {
1636                 $$ = $1;
1637         }
1638         ;
1639
1640 int:
1641         unsigned {
1642                 $$ = $1;
1643         }
1644         | '-' unsigned {
1645                 $$ = -$2;
1646         }
1647         | INT_IDENTIFIER        {
1648                 $$ = *$1->access_content_int (false);
1649         }
1650         ;
1651
1652
1653 string:
1654         STRING          {
1655                 $$ = $1;
1656         }
1657         | STRING_IDENTIFIER     {
1658                 $$ = ly_str02scm ($1->access_content_String (true)->ch_C ());
1659         }
1660         | string '+' string {
1661                 $$ = scm_string_append (scm_listify ($1, $3, SCM_UNDEFINED));
1662         }
1663         ;
1664
1665
1666 exclamations:
1667                 { $$ = 0; }
1668         | exclamations '!'      { $$ ++; }
1669         ;
1670
1671 questions:
1672                 { $$ = 0; }
1673         | questions '?' { $$ ++; }
1674         ;
1675
1676
1677 semicolon:
1678         ';'
1679         ;
1680 %%
1681
1682 void
1683 My_lily_parser::set_yydebug (bool b)
1684 {
1685 #ifdef YYDEBUG
1686         yydebug = b;
1687 #endif
1688 }
1689 void
1690 My_lily_parser::do_yyparse ()
1691 {
1692         yyparse ((void*)this);
1693 }
1694
1695