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