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