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