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