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