]> git.donarmstrong.com Git - lilypond.git/blob - lily/parser.yy
e5a7583522e26fb30d825678e32530e25f757cd2
[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         Music   {
492                 $$ = new Score;
493                 $$->set_spot (THIS->here_input ());
494                 $$->music_p_ = $1;
495         }
496         | SCORE_IDENTIFIER {
497                 $$ = $1->access_content_Score (true);
498         }
499         | score_body mudela_header      {
500                 $$->header_p_ = $2;
501         }
502         | score_body output_def {
503                 $$->add_output ($2);
504         }
505         | score_body error {
506
507         }
508         ;
509
510 output_def:
511         paper_block {
512                 $$ = $1;
513         }
514         |  midi_block           {
515                 $$= $1;
516         }
517         ;
518
519
520 /*
521         PAPER
522 */
523 paper_block:
524         PAPER '{' paper_def_body '}'    { 
525                 $$ = $3;
526                 THIS-> lexer_p_->scope_l_arr_.pop ();
527         }
528         ;
529
530
531 paper_def_body:
532         /* empty */                     {
533                   Identifier *id = THIS->lexer_p_->lookup_identifier ("$defaultpaper");
534                   Paper_def *p = id ? id->access_content_Paper_def (true) : new Paper_def;
535                 THIS-> lexer_p_-> scope_l_arr_.push (p->scope_p_);
536                 $$ = p;
537         }
538         | PAPER_IDENTIFIER      {
539                 Paper_def *p = $1->access_content_Paper_def (true);
540                 THIS->lexer_p_->scope_l_arr_.push (p->scope_p_);
541                 $$ = p;
542         }
543         | paper_def_body int '=' FONT STRING            { // ugh, what a syntax
544                 Lookup * l = new Lookup;
545                 l->font_name_ = ly_scm2string ($5);
546                 $$->set_lookup ($2, l);
547         }
548         | paper_def_body assignment semicolon {
549                 
550         }
551         | paper_def_body SCM_T '=' SCM_T {
552                 if (!gh_symbol_p ($2))
553                         THIS->parser_error ("expect a symbol as lvalue");
554                 else
555                         $$->default_properties_.set ($2, $4);
556         }
557         | paper_def_body SCM_T '=' real semicolon {
558                 if (!gh_symbol_p ($2))
559                         THIS->parser_error ("expect a symbol as lvalue");
560                 else
561                         $$->default_properties_.set ($2, gh_double2scm ($4));
562         }
563         | paper_def_body translator_spec_block {
564                 $$->assign_translator ($2);
565         }
566         | paper_def_body error {
567
568         }
569         ;
570
571
572
573 real_with_dimension:
574         REAL CM_T       {
575                 $$ = $1 CM;
576         }
577         | REAL PT_T     {
578                 $$ = $1 PT;
579         }
580         | REAL IN_T     {
581                 $$ = $1 INCH;
582         }
583         | REAL MM_T     {
584                 $$ = $1 MM;
585         }
586         | REAL CHAR_T   {
587                 $$ = $1 CHAR;
588         }
589         ;
590
591 real:
592         REAL            {
593                 $$ = $1;
594         }
595         | real_with_dimension
596         | REAL_IDENTIFIER               {
597                 $$= *$1->access_content_Real (false);
598         }
599         | '-'  real %prec UNARY_MINUS {
600                 $$ = -$2;
601         }
602         | real '*' real {
603                 $$ = $1 * $3;
604         }
605         | real '/' real {
606                 $$ = $1 / $3;
607         }
608         | real '+' real {
609                 $$ = $1  + $3;
610         }
611         | real '-' real {
612                 $$ = $1 - $3;
613         }
614         | '(' real ')'  {
615                 $$ = $2;
616         }
617         ;
618                 
619 /*
620         MIDI
621 */
622 midi_block:
623         MIDI
624         '{' midi_body '}'       {
625                 $$ = $3;
626                 THIS-> lexer_p_-> scope_l_arr_.pop();
627         }
628         ;
629
630 midi_body: /* empty */          {
631          Identifier *id = THIS->lexer_p_->lookup_identifier ("$defaultmidi");
632          Midi_def* p = id
633                 ? id->access_content_Midi_def (true) : new Midi_def ;
634
635          $$ = p;
636          THIS->lexer_p_->scope_l_arr_.push (p->scope_p_);
637         }
638         | MIDI_IDENTIFIER       {
639                 Midi_def * p =$1-> access_content_Midi_def (true);
640                 $$ = p;
641                 THIS->lexer_p_->scope_l_arr_.push (p->scope_p_);
642         }
643         | midi_body assignment semicolon {
644
645         }
646         | midi_body translator_spec_block       {
647                 $$-> assign_translator ($2);
648         }
649         | midi_body tempo_request semicolon {
650                 /*
651                         junk this ? there already is tempo stuff in
652                         music.
653                 */
654                 $$->set_tempo ($2->dur_.length_mom (), $2->metronome_i_);
655                 delete $2;
656         }
657         | midi_body error {
658
659         }
660         ;
661
662 tempo_request:
663         TEMPO steno_duration '=' unsigned       {
664                 $$ = new Tempo_req;
665                 $$->dur_ = *$2;
666                 delete $2;
667                 $$-> metronome_i_ = $4;
668         }
669         ;
670
671 Music_list: /* empty */ {
672                 $$ = new Music_list;
673                 $$->set_spot (THIS->here_input ());
674         }
675         | Music_list Music {
676                 $$->add_music ($2);
677         }
678         | Music_list error {
679         }
680         ;
681
682
683 Music:
684         Simple_music
685         | Composite_music
686         ;
687
688 Alternative_music:
689         /* empty */ {
690                 $$ = 0;
691         }
692         | ALTERNATIVE Music_sequence {
693                 $$ = $2;
694                 $2->set_spot (THIS->here_input ());
695         }
696         ;
697
698
699
700
701 Repeated_music:
702         REPEAT STRING unsigned Music Alternative_music
703         {
704                 Music_sequence* m = dynamic_cast <Music_sequence*> ($5);
705                 if (m && $3 < m->length_i ())
706                         $5->warning (_ ("More alternatives than repeats.  Junking excess alternatives."));
707
708                 Repeated_music * r = new Repeated_music ($4, $3 >? 1, m);
709                 $$ = r;
710                 r->type_ = ly_scm2string ($2);
711                 r->fold_b_ = (r->type_ == "fold");
712                 r->volta_fold_b_ =  (r->type_ == "volta");
713                 r->set_spot ($4->spot  ());
714         }
715         ;
716
717 Music_sequence: '{' Music_list '}'      {
718                 $$ = new Music_sequence ($2);
719                 $$->set_spot ($2->spot ());
720         }
721         ;
722
723 Sequential_music:
724         SEQUENTIAL '{' Music_list '}'           {
725                 $$ = new Sequential_music ($3);
726                 $$->set_spot ($3->spot ());
727         }
728         | '{' Music_list '}'            {
729                 $$ = new Sequential_music ($2);
730                 $$->set_spot ($2->spot ());
731         }
732         ;
733
734 Simultaneous_music:
735         SIMULTANEOUS '{' Music_list '}'{
736                 $$ = new Simultaneous_music ($3);
737                 $$->set_spot ($3->spot ());
738         }
739         | '<' Music_list '>'    {
740                 $$ = new Simultaneous_music ($2);
741                 $$->set_spot ($2->spot ());
742         }
743         ;
744
745 Simple_music:
746         request_chord           { $$ = $1; }
747         | OUTPUTPROPERTY embedded_scm embedded_scm '=' embedded_scm     {
748                 SCM pred = $2;
749                 if (!gh_symbol_p ($3))
750                 {
751                         THIS->parser_error (_("Second argument must be a symbol")); 
752                 }
753                 /*hould check # args */
754                 if (!gh_procedure_p (pred))
755                 {
756                         THIS->parser_error (_("First argument must be a procedure taking 1 argument"));
757                 }
758         
759                 $$ = new Output_property (pred,$3, $5);
760         }
761         | MUSIC_IDENTIFIER { $$ = $1->access_content_Music (true); }
762         | property_def
763         | translator_change
764         | Simple_music '*' unsigned '/' unsigned        {
765                 $$ = $1;
766                 $$->compress (Moment($3, $5 ));
767         }
768         | Simple_music '*' unsigned              {
769                 $$ = $1;
770                 $$->compress (Moment ($3, 1));
771         }
772         ;
773
774
775 Composite_music:
776         CONTEXT STRING Music    {
777                 Context_specced_music *csm =  new Context_specced_music ($3);
778
779                 csm->translator_type_str_ = ly_scm2string ($2);
780                 csm->translator_id_str_ = "";
781
782
783                 $$ = csm;
784         }
785         | AUTOCHANGE STRING Music       {
786                 Auto_change_music * chm = new Auto_change_music (ly_scm2string ($2), $3);
787
788                 $$ = chm;
789                 chm->set_spot ($3->spot ());
790         }
791         | GRACE Music {
792                 $$ = new Grace_music ($2);
793         }
794         | CONTEXT STRING '=' STRING Music {
795                 Context_specced_music *csm =  new Context_specced_music ($5);
796
797                 csm->translator_type_str_ = ly_scm2string ($2);
798                 csm->translator_id_str_ = ly_scm2string ($4);
799
800                 $$ = csm;
801         }
802         | TIMES {
803                 THIS->remember_spot ();
804         }
805         /* CONTINUED */ 
806                 unsigned '/' unsigned Music     
807
808         {
809                 $$ = new Time_scaled_music ($3, $5, $6);
810                 $$->set_spot (THIS->pop_spot ());
811         }
812         | Repeated_music                { $$ = $1; }
813         | Simultaneous_music            { $$ = $1; }
814         | Sequential_music              { $$ = $1; }
815         | TRANSPOSE musical_pitch Music {
816                 $$ = new Transposed_music ($3, *$2);
817                 delete $2;
818         }
819         | TRANSPOSE steno_tonic_pitch Music {
820                 $$ = new Transposed_music ($3, *$2);
821                 delete $2;
822         }
823         | NOTES
824                 { THIS->lexer_p_->push_note_state (); }
825         Music
826                 { $$ = $3;
827                   THIS->lexer_p_->pop_state ();
828                 }
829         | CHORDS
830                 { THIS->lexer_p_->push_chord_state (); }
831         Music
832                 {
833                   $$ = $3;
834                   THIS->lexer_p_->pop_state ();
835         }
836         | LYRICS
837                 { THIS->lexer_p_->push_lyric_state (); }
838         Music
839                 {
840                   $$ = $3;
841                   THIS->lexer_p_->pop_state ();
842         }
843         | relative_music        { $$ = $1; }
844         | re_rhythmed_music     { $$ = $1; } 
845         ;
846
847 relative_music:
848         RELATIVE absolute_musical_pitch Music {
849                 $$ = new Relative_octave_music ($3, *$2);
850                 delete $2;
851         }
852         ;
853
854 re_rhythmed_music:
855         ADDLYRICS Music Music {
856                 Lyric_combine_music * l = new Lyric_combine_music ($2, $3);
857                 $$ = l;
858         }
859         ;
860
861 translator_change:
862         TRANSLATOR STRING '=' STRING  {
863                 Change_translator * t = new Change_translator;
864                 t-> change_to_type_str_ = ly_scm2string ($2);
865                 t-> change_to_id_str_ = ly_scm2string ($4);
866
867                 $$ = t;
868                 $$->set_spot (THIS->here_input ());
869         }
870         ;
871
872 property_def:
873         PROPERTY STRING '.' STRING '='  scalar {
874                 Translation_property *t = new Translation_property;
875
876                 t->var_str_ = ly_scm2string ($4);
877                 t->value_ = $6;
878
879                 Context_specced_music *csm = new Context_specced_music (t);
880                 $$ = csm;
881                 $$->set_spot (THIS->here_input ());
882
883                 csm-> translator_type_str_ = ly_scm2string ($2);
884         }
885         ;
886
887 scalar:
888         string          { $$ = $1; }
889         | int           { $$ = gh_int2scm ($1); }
890         | embedded_scm  { $$ = $1; }
891         ;
892
893
894 request_chord:
895         pre_requests simple_element post_requests       {
896                 Music_sequence *l = dynamic_cast<Music_sequence*>($2);
897                 if (l) {
898                         for (int i=0; i < $1->size(); i++)
899                                 l->add_music ($1->elem(i));
900                         for (int i=0; i < $3->size(); i++)
901                                 l->add_music ($3->elem(i));
902                         }
903                 else
904                         programming_error ("Need Sequence to add music to");
905                 $$ = $2;
906                 
907         }
908         | command_element
909         ;
910
911 command_element:
912         command_req {
913                 $$ = new Request_chord;
914                 $$-> set_spot (THIS->here_input ());
915                 $1-> set_spot (THIS->here_input ());
916                 ((Simultaneous_music*)$$) ->add_music ($1);//ugh
917         }
918         | PARTIAL duration_length ';'   {
919                 Translation_property * p = new Translation_property;
920                 p->var_str_ = "measurePosition";
921                 p->value_ =  (new Moment (-$2->length_mom ()))->smobify_self ();
922                 delete $2;
923                 Context_specced_music * sp = new Context_specced_music (p);
924                 $$ =sp ;
925                 sp-> translator_type_str_ = "Score";
926         }
927         ;
928
929 command_req:
930         shorthand_command_req
931         | verbose_command_req semicolon { $$ = $1; }
932         ;
933
934 shorthand_command_req:
935         extender_req {
936                 $$ = $1;
937         }
938         | hyphen_req {
939                 $$ = $1;
940         }
941         | '|'                           {
942                 $$ = new Barcheck_req;
943         }
944         | '~'   {
945                 $$ = new Tie_req;
946         }
947         | '['           {
948                 Span_req*b= new Span_req;
949                 b->span_dir_ = START;
950                 b->span_type_str_ = "beam";
951                 $$ =b;
952         }
953         | ']'           {
954              Span_req*b= new Span_req;
955              b->span_dir_ = STOP;
956              b->span_type_str_ = "beam";
957              $$ = b;
958         }
959         | BREATHE {
960                 $$ = new Breathing_sign_req;
961         }
962         ;
963
964
965 verbose_command_req:
966         
967         BAR STRING                      {
968                 $$ = new Bar_req (ly_scm2string ($2));
969         }
970         | COMMANDSPANREQUEST int STRING {
971                 Span_req * sp_p = new Span_req;
972                 sp_p-> span_dir_  = Direction($2);
973                 sp_p->span_type_str_ = ly_scm2string ($3);
974                 sp_p->set_spot (THIS->here_input ());
975                 $$ = sp_p;
976         }
977         | MARK  {
978                 Mark_req * m = new Mark_req;
979                 $$ = m;
980         }
981         | MARK STRING {
982                 Mark_req *m = new Mark_req;
983                 m->mark_label_ = $2;
984                 $$ = m;
985
986         }
987         | MARK unsigned {
988                 Mark_req *m = new Mark_req;
989                 m->mark_label_ =  gh_int2scm ($2);
990                 $$ = m;
991         }
992
993         | TIME_T unsigned '/' unsigned  {
994                 Time_signature_change_req *m = new Time_signature_change_req;
995                 m->beats_i_ = $2;
996                 m->one_beat_i_=$4;
997                 $$ = m;
998         }
999         | PENALTY int   {
1000                 Break_req * b = new Break_req;
1001                 b->penalty_f_ = $2 / 100.0;
1002                 b->set_spot (THIS->here_input ());
1003                 $$ = b;
1004         }
1005         | SKIP duration_length {
1006                 Skip_req * skip_p = new Skip_req;
1007                 skip_p->duration_ = *$2;
1008                 delete $2;
1009                 $$ = skip_p;
1010         }
1011         | tempo_request {
1012                 $$ = $1;
1013         }
1014         | CLEF STRING {
1015                 $$ = new Clef_change_req (ly_scm2string ($2));
1016
1017         }
1018         | KEY {
1019                 Key_change_req *key_p= new Key_change_req;
1020                 key_p->key_ = 0;
1021                 $$ = key_p;
1022         }
1023 /* UGH. optional.  */
1024
1025         | KEY NOTENAME_PITCH optional_modality  {
1026                 Key_change_req *key_p= new Key_change_req;
1027                 Key_def d;
1028                 d.pitch_arr_.push (*$2);
1029                 d.ordinary_key_b_ = true;
1030                 d.modality_i_ = $3;
1031
1032                 key_p->key_ = new Key_def (d);
1033                 $$ = key_p;
1034                 delete $2;
1035         }
1036         | KEYSIGNATURE pitch_list {
1037                 Key_change_req *key_p= new Key_change_req;
1038                 Key_def d;
1039                 d.pitch_arr_ = *$2;
1040                 d.ordinary_key_b_ = false;
1041
1042                 key_p->key_ = new Key_def(d);
1043                 $$ = key_p;
1044                 delete $2;
1045         }
1046         ;
1047
1048 post_requests:
1049         {
1050                 $$ = new Link_array<Request>;
1051         }
1052         | post_requests post_request {
1053                 $2->set_spot (THIS->here_input ());
1054                 $$->push ($2);
1055         }
1056         ;
1057
1058 post_request:
1059         verbose_request
1060         | request_with_dir
1061         | close_request
1062         ;
1063
1064
1065 request_that_take_dir:
1066         gen_text_def
1067         | verbose_request
1068         | script_abbreviation {
1069                 Identifier*i = THIS->lexer_p_->lookup_identifier ("dash-" + ly_scm2string ($1));
1070                 Articulation_req *a = new Articulation_req;
1071                 a->articulation_str_ = *i->access_content_String (false);
1072                 $$ = a;
1073         }
1074         ;
1075
1076 request_with_dir:
1077         script_dir request_that_take_dir        {
1078                 if (Script_req * gs = dynamic_cast<Script_req*> ($2))
1079                         gs->dir_ = Direction ($1);
1080                 else if ($1)
1081                         $2->warning (_ ("Can't specify direction for this request"));
1082                 $$ = $2;
1083         }
1084         ;
1085         
1086 verbose_request:
1087         REQUEST_IDENTIFIER      {
1088                 $$ = (Request*)$1->access_content_Request (true);
1089                 $$->set_spot (THIS->here_input ());
1090         }
1091         | TEXTSCRIPT STRING STRING      {
1092                 Text_script_req *ts_p = new Text_script_req;
1093                 ts_p-> text_str_ = ly_scm2string ($2);
1094                 ts_p-> style_str_ = ly_scm2string ($3);
1095                 ts_p->set_spot (THIS->here_input ());
1096
1097                 $$ = ts_p;
1098         }
1099         | SPANREQUEST int STRING {
1100                 Span_req * sp_p = new Span_req;
1101                 sp_p-> span_dir_  = Direction($2);
1102                 sp_p->span_type_str_ = ly_scm2string ($3);
1103                 sp_p->set_spot (THIS->here_input ());
1104                 $$ = sp_p;
1105         }
1106         | tremolo_type  {
1107                 Tremolo_req* a = new Tremolo_req;
1108                 a->set_spot (THIS->here_input ());
1109                 a->type_i_ = $1;
1110                 $$ = a;
1111         }
1112         | SCRIPT STRING         { 
1113                 Articulation_req * a = new Articulation_req;
1114                 a->articulation_str_ = ly_scm2string ($2);
1115                 a->set_spot (THIS->here_input ());
1116                 $$ = a;
1117         }
1118         ;
1119
1120 optional_modality:
1121         /* empty */     {
1122                 $$ = 0;
1123         }
1124         | int   {
1125                 $$ = $1;
1126         }
1127         ;
1128
1129 sup_quotes:
1130         '\'' {
1131                 $$ = 1;
1132         }
1133         | sup_quotes '\'' {
1134                 $$ ++;
1135         }
1136         ;
1137
1138 sub_quotes:
1139         ',' {
1140                 $$ = 1;
1141         }
1142         | sub_quotes ',' {
1143                 $$ ++ ;
1144         }
1145         ;
1146
1147 steno_musical_pitch:
1148         NOTENAME_PITCH  {
1149                 $$ = $1;
1150         }
1151         | NOTENAME_PITCH sup_quotes     {
1152                 $$ = $1;
1153                 $$->octave_i_ +=  $2;
1154         }
1155         | NOTENAME_PITCH sub_quotes      {
1156                 $$ = $1;
1157                 $$->octave_i_ += - $2;
1158         }
1159         ;
1160
1161 steno_tonic_pitch:
1162         TONICNAME_PITCH {
1163                 $$ = $1;
1164         }
1165         | TONICNAME_PITCH sup_quotes    {
1166                 $$ = $1;
1167                 $$->octave_i_ +=  $2;
1168         }
1169         | TONICNAME_PITCH sub_quotes     {
1170                 $$ = $1;
1171                 $$->octave_i_ += - $2;
1172         }
1173         ;
1174
1175 musical_pitch:
1176         steno_musical_pitch {
1177                 $$ = $1;
1178         }
1179         | MUSICAL_PITCH embedded_scm {
1180                 int sz = scm_ilength ($2);
1181                 if (sz != 3) {
1182                         THIS->parser_error (_f ("Expecting %d arguments", 3));
1183                         $2 = gh_list (gh_int2scm (0), gh_int2scm (0), gh_int2scm (0), SCM_UNDEFINED);
1184                 }
1185                 $$ = new Musical_pitch ($2);
1186         }
1187         ;
1188
1189 explicit_duration:
1190         DURATION '{' int_list '}'       {
1191                 $$ = new Duration;
1192                 Array<int> &a = *$3;
1193                 ARRAY_SIZE(a,2);
1194                         
1195                 $$-> durlog_i_ = a[0];
1196                 $$-> dots_i_ = a[1];
1197
1198                 delete &a;              
1199         }
1200         ;
1201
1202 extender_req:
1203         EXTENDER {
1204                 if (!THIS->lexer_p_->lyric_state_b ())
1205                         THIS->parser_error (_ ("Have to be in Lyric mode for lyrics"));
1206                 $$ = new Extender_req;
1207         }
1208         ;
1209
1210 hyphen_req:
1211         HYPHEN {
1212                 if (!THIS->lexer_p_->lyric_state_b ())
1213                         THIS->parser_error (_ ("Have to be in Lyric mode for lyrics"));
1214                 $$ = new Hyphen_req;
1215         }
1216         ;
1217
1218 close_request:
1219         close_request_parens {
1220                 $$ = $1;
1221                 dynamic_cast<Span_req*> ($$)->span_dir_ = START;
1222         }
1223         
1224 close_request_parens:
1225         '('     {
1226                 Span_req* s= new Span_req;
1227                 $$ = s;
1228                 s->span_type_str_ = "slur";
1229         }
1230         | E_SMALLER {
1231                 Span_req*s =new Span_req;
1232                 $$ = s;
1233                 s->span_type_str_ = "crescendo";
1234         }
1235         | E_BIGGER {
1236                 Span_req*s =new Span_req;
1237                 $$ = s;
1238                 s->span_type_str_ = "decrescendo";
1239         }
1240         ;
1241
1242
1243 open_request:
1244         open_request_parens {
1245                 $$ = $1;
1246                 dynamic_cast<Span_req*> ($$)->span_dir_ = STOP;
1247         }
1248         ;
1249
1250 open_request_parens:
1251         E_EXCLAMATION   {
1252                 Span_req *s =  new Span_req;
1253                 s->span_type_str_ = "crescendo";
1254                 $$ = s;
1255         }
1256         | ')'   {
1257                 Span_req* s= new Span_req;
1258                 $$ = s;
1259                 s->span_type_str_ = "slur";
1260         }
1261         ;
1262
1263 gen_text_def:
1264         string {
1265                 Text_script_req *t  = new Text_script_req;
1266                 $$ = t;
1267                 t->text_str_ = ly_scm2string ($1);
1268
1269                 $$->set_spot (THIS->here_input ());
1270         }
1271         | DIGIT {
1272                 Text_script_req* t  = new Text_script_req;
1273                 $$ = t;
1274                 t->text_str_ = to_str ($1);
1275                 t->style_str_ = "finger";
1276                 $$->set_spot (THIS->here_input ());
1277         }
1278         ;
1279
1280 script_abbreviation:
1281         '^'             {
1282                 $$ = gh_str02scm  ("hat");
1283         }
1284         | '+'           {
1285                 $$ = gh_str02scm("plus");
1286         }
1287         | '-'           {
1288                 $$ = gh_str02scm ("dash");
1289         }
1290         | '|'           {
1291                 $$ = gh_str02scm ("bar");
1292         }
1293         | '>'           {
1294                 $$ = gh_str02scm ("larger");
1295         }
1296         | '.'           {
1297                 $$ = gh_str02scm ("dot");
1298         }
1299         ;
1300
1301
1302 script_dir:
1303         '_'     { $$ = DOWN; }
1304         | '^'   { $$ = UP; }
1305         | '-'   { $$ = CENTER; }
1306         ;
1307
1308 pre_requests:
1309         {
1310                 $$ = new Link_array<Request>;
1311         }
1312         | pre_requests open_request {
1313                 $$->push ($2);
1314         }
1315         ;
1316
1317 absolute_musical_pitch:
1318         steno_musical_pitch     {
1319                 $$ = $1;
1320         }
1321         ;
1322
1323 duration_length:
1324         steno_duration {
1325                 $$ = $1;
1326         }
1327         | duration_length '*' unsigned {
1328                 $$->tuplet_iso_i_ *= $3;
1329         }
1330         | duration_length '/' unsigned {
1331                 $$->tuplet_type_i_ *= $3;
1332         }
1333         ;
1334
1335 entered_notemode_duration:
1336         steno_duration  {
1337                 THIS->set_last_duration ($1);
1338         }
1339         ;
1340
1341 optional_notemode_duration:
1342         {
1343                 $$ = new Duration (THIS->default_duration_);
1344         }
1345         | entered_notemode_duration {
1346                 $$ = $1;
1347         }
1348         ;
1349
1350 steno_duration:
1351         unsigned                {
1352                 $$ = new Duration;
1353                 if (!is_duration_b ($1))
1354                         THIS->parser_error (_f ("not a duration: %d", $1));
1355                 else {
1356                         $$->durlog_i_ = intlog2 ($1);
1357                      }
1358         }
1359         | DURATION_IDENTIFIER   {
1360                 $$ = $1->access_content_Duration (true);
1361         }
1362         | steno_duration '.'    {
1363                 $$->dots_i_ ++;
1364         }
1365         ;
1366
1367
1368 tremolo_type: 
1369         ':'     {
1370                 $$ =0;
1371         }
1372         | ':' unsigned {
1373                 if (!is_duration_b ($2))
1374                         THIS->parser_error (_f ("not a duration: %d", $2));
1375                 $$ = $2;
1376         }
1377         ;
1378
1379
1380 simple_element:
1381         musical_pitch exclamations questions optional_notemode_duration {
1382                 if (!THIS->lexer_p_->note_state_b ())
1383                         THIS->parser_error (_ ("Have to be in Note mode for notes"));
1384
1385
1386                 Note_req *n = new Note_req;
1387                 
1388                 n->pitch_ = *$1;
1389                 n->duration_ = *$4;
1390
1391                 n->cautionary_b_ = $3 % 2;
1392                 n->forceacc_b_ = $2 % 2 || n->cautionary_b_;
1393
1394                 Simultaneous_music*v = new Request_chord;
1395                 v->set_spot ($1->spot ());
1396                 n->set_spot ($1->spot ());
1397
1398                 v->add_music (n);
1399
1400                 $$ = v;
1401
1402                 delete $1;
1403                 delete $4;
1404
1405         }
1406         | RESTNAME optional_notemode_duration           {
1407                   Simultaneous_music* velt_p = new Request_chord;
1408                   velt_p->set_spot (THIS->here_input());
1409
1410                   if (ly_scm2string ($1) =="s")
1411                     { /* Space */
1412                       Skip_req * skip_p = new Skip_req;
1413                       skip_p->duration_ = *$2;
1414
1415                       skip_p->set_spot (THIS->here_input());
1416                       velt_p->add_music (skip_p);
1417                     }
1418                   else
1419                     {
1420                       Rest_req * rest_req_p = new Rest_req;
1421                       rest_req_p->duration_ = *$2;
1422                       rest_req_p->set_spot (THIS->here_input());
1423
1424                       velt_p->add_music (rest_req_p);
1425                     }
1426
1427                   delete $2;
1428                   $$ = velt_p;
1429         }
1430         | MEASURES optional_notemode_duration   {
1431                 Skip_req * sk = new Skip_req;
1432                 sk->duration_ = *$2;
1433                 Music_list * ms = new Music_list;
1434                 Request_chord * rqc1 = new Request_chord;
1435                 Request_chord * rqc2 = new Request_chord;
1436                 Request_chord * rqc3 = new Request_chord;
1437
1438                 Span_req *sp1 = new Span_req;
1439                 Span_req *sp2 = new Span_req;
1440                 sp1-> span_dir_ = START;
1441                 sp2-> span_dir_ = STOP;
1442                 sp1->span_type_str_ = sp2->span_type_str_ = "rest";
1443                 rqc1->add_music (sp1);
1444                 rqc2->add_music (sk);
1445                 rqc3->add_music (sp2);
1446                 
1447                 ms->add_music (rqc1);
1448                 ms->add_music (rqc2);
1449                 ms->add_music (rqc3);
1450
1451                 $$ = new Sequential_music (ms);
1452         }
1453         | STRING optional_notemode_duration     {
1454                 if (!THIS->lexer_p_->lyric_state_b ())
1455                         THIS->parser_error (_ ("Have to be in Lyric mode for lyrics"));
1456                   Simultaneous_music* velt_p = new Request_chord;
1457
1458                   Lyric_req* lreq_p = new Lyric_req;
1459                   lreq_p ->text_str_ = ly_scm2string ($1);
1460                   lreq_p->duration_ = *$2;
1461                   lreq_p->set_spot (THIS->here_input());
1462
1463                   velt_p->add_music (lreq_p);
1464
1465                   delete  $2;
1466                 $$= velt_p;
1467
1468         }
1469         | chord {
1470                 if (!THIS->lexer_p_->chord_state_b ())
1471                         THIS->parser_error (_ ("Have to be in Chord mode for chords"));
1472                 $$ = $1;
1473         }
1474         ;
1475
1476 chord:
1477         steno_tonic_pitch optional_notemode_duration chord_additions chord_subtractions chord_inversion chord_bass {
1478                 $$ = THIS->get_chord (*$1, $3, $4, $5, $6, *$2);
1479         };
1480
1481 chord_additions: 
1482         {
1483                 $$ = new Array<Musical_pitch>;
1484         } 
1485         | CHORD_COLON chord_notes {
1486                 $$ = $2;
1487         }
1488         ;
1489
1490 chord_notes:
1491         chord_step {
1492                 $$ = $1
1493         }
1494         | chord_notes '.' chord_step {
1495                 $$ = $1;
1496                 $$->concat (*$3);
1497         }
1498         ;
1499
1500 chord_subtractions: 
1501         {
1502                 $$ = new Array<Musical_pitch>;
1503         } 
1504         | CHORD_CARET chord_notes {
1505                 $$ = $2;
1506         }
1507         ;
1508
1509
1510 chord_inversion:
1511         {
1512                 $$ = 0;
1513         }
1514         | '/' steno_tonic_pitch {
1515                 $$ = $2;
1516                 $$->set_spot (THIS->here_input ());
1517         }
1518         ;
1519
1520 chord_bass:
1521         {
1522                 $$ = 0;
1523         }
1524         | CHORD_BASS steno_tonic_pitch {
1525                 $$ = $2;
1526                 $$->set_spot (THIS->here_input ());
1527         }
1528         ;
1529
1530 chord_step:
1531         chord_note {
1532                 $$ = new Array<Musical_pitch>;
1533                 $$->push (*$1);
1534         }
1535         | CHORDMODIFIER_PITCH {
1536                 $$ = new Array<Musical_pitch>;
1537                 $$->push (*$1);
1538         }
1539         | CHORDMODIFIER_PITCH chord_note { /* Ugh. */
1540                 $$ = new Array<Musical_pitch>;
1541                 $$->push (*$1);
1542                 $$->push (*$2);
1543         }
1544         ;
1545
1546 chord_note:
1547         unsigned {
1548                 $$ = new Musical_pitch;
1549                 $$->notename_i_ = ($1 - 1) % 7;
1550                 $$->octave_i_ = $1 > 7 ? 1 : 0;
1551                 $$->accidental_i_ = 0;
1552         } 
1553         | unsigned '+' {
1554                 $$ = new Musical_pitch;
1555                 $$->notename_i_ = ($1 - 1) % 7;
1556                 $$->octave_i_ = $1 > 7 ? 1 : 0;
1557                 $$->accidental_i_ = 1;
1558         }
1559         | unsigned CHORD_MINUS {
1560                 $$ = new Musical_pitch;
1561                 $$->notename_i_ = ($1 - 1) % 7;
1562                 $$->octave_i_ = $1 > 7 ? 1 : 0;
1563                 $$->accidental_i_ = -1;
1564         }
1565         ;
1566
1567 /*
1568         UTILITIES
1569  */
1570 pitch_list:                     {
1571                 $$ = new Array<Musical_pitch>;
1572         }
1573         | pitch_list musical_pitch      {
1574                 $$->push (*$2);
1575                 delete $2;
1576         }
1577         ;
1578
1579
1580 int_list:
1581         /**/                    {
1582                 $$ = new Array<int>
1583         }
1584         | int_list int          {
1585                 $$->push ($2);          
1586         }
1587         ;
1588
1589 unsigned:
1590         UNSIGNED        {
1591                 $$ = $1;
1592         }
1593         | DIGIT         {
1594                 $$ = $1;
1595         }
1596         ;
1597
1598 int:
1599         unsigned {
1600                 $$ = $1;
1601         }
1602         | '-' unsigned {
1603                 $$ = -$2;
1604         }
1605         | INT_IDENTIFIER        {
1606                 $$ = *$1->access_content_int (false);
1607         }
1608         ;
1609
1610
1611 string:
1612         STRING          {
1613                 $$ = $1;
1614         }
1615         | STRING_IDENTIFIER     {
1616                 $$ = ly_str02scm ($1->access_content_String (true)->ch_C ());
1617         }
1618         | string '+' string {
1619                 $$ = scm_string_append (scm_listify ($1, $3, SCM_UNDEFINED));
1620         }
1621         ;
1622
1623
1624 exclamations:
1625                 { $$ = 0; }
1626         | exclamations '!'      { $$ ++; }
1627         ;
1628
1629 questions:
1630                 { $$ = 0; }
1631         | questions '?' { $$ ++; }
1632         ;
1633
1634
1635 semicolon:
1636         ';'
1637         ;
1638 %%
1639
1640 void
1641 My_lily_parser::set_yydebug (bool b)
1642 {
1643 #ifdef YYDEBUG
1644         yydebug = b;
1645 #endif
1646 }
1647 void
1648 My_lily_parser::do_yyparse ()
1649 {
1650         yyparse ((void*)this);
1651 }
1652
1653