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