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