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