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