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