1 %{ // -*-Fundamental-*-
4 parser.yy -- Bison/C++ parser for mudela
6 source file of the GNU LilyPond music typesetter
8 (c) 1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
9 Jan Nieuwenhuizen <janneke@gnu.org>
13 #include "lily-guile.hh"
14 #include "translation-property.hh"
17 #include "my-lily-lexer.hh"
18 #include "paper-def.hh"
19 #include "midi-def.hh"
21 #include "file-path.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"
31 #include "music-list.hh"
32 #include "change-translator.hh"
33 #include "file-results.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"
50 return t && t == 1 << intlog2(t);
55 Mudela_version oldest_version ("1.3.59");
58 print_mudela_versions (ostream &os)
60 os << _f ("Oldest supported input version: %s", oldest_version.str ())
65 // needed for bison.simple's malloc() and free()
72 #define YYERROR_VERBOSE 1
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)
78 #define yyerror THIS->parser_error
79 #define ARRAY_SIZE(a,s) if (a.size () != s) THIS->parser_error (_f ("Expecting %d arguments", s))
85 Array<Musical_pitch> *pitch_arr;
86 Link_array<Request> *reqvec;
95 Music_output_def * outputdef;
96 Musical_pitch * pitch;
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. */
109 Translator_group* trans;
115 yylex (YYSTYPE *s, void * v_l)
117 My_lily_parser *pars_l = (My_lily_parser*) v_l;
118 My_lily_lexer * lex_l = pars_l->lexer_p_;
120 lex_l->lexval_l = (void*) s;
121 return lex_l->yylex ();
129 /* tokens which are not keywords */
136 %token CHORDMODIFIERS
178 %token COMMANDSPANREQUEST
180 %token OUTPUTPROPERTY
189 %token E_CHAR E_EXCLAMATION E_SMALLER E_BIGGER
190 %token CHORD_BASS CHORD_COLON CHORD_MINUS CHORD_CARET
192 %type <i> exclamations questions
194 %token <pitch> NOTENAME_PITCH
195 %token <pitch> TONICNAME_PITCH
196 %token <pitch> CHORDMODIFIER_PITCH
197 %token <id> DURATION_IDENTIFIER
198 %token <id> IDENTIFIER
199 %token <id> TRANS_IDENTIFIER
201 %token <id> SCORE_IDENTIFIER
202 %token <id> MUSIC_OUTPUT_DEF_IDENTIFIER
204 %token <scm> NUMBER_IDENTIFIER
205 %token <scm> REQUEST_IDENTIFIER
206 %token <scm> MUSIC_IDENTIFIER
207 %token <scm> STRING_IDENTIFIER SCM_IDENTIFIER
208 %token <scm> DURATION RESTNAME
214 %type <outputdef> output_def
215 %type <scope> mudela_header mudela_header_body
216 %type <request> open_request_parens close_request_parens open_request close_request
217 %type <request> request_with_dir request_that_take_dir verbose_request
218 %type <i> sub_quotes sup_quotes
219 %type <music> simple_element request_chord command_element Simple_music Composite_music
220 %type <music> Alternative_music Repeated_music
221 %type <i> tremolo_type
222 %type <i> bare_int bare_unsigned
225 %type <scm> identifier_init
227 %type <duration> steno_duration optional_notemode_duration
228 %type <duration> entered_notemode_duration explicit_duration
230 %type <reqvec> pre_requests post_requests
231 %type <request> gen_text_def
232 %type <pitch> steno_musical_pitch musical_pitch absolute_musical_pitch
233 %type <pitch> steno_tonic_pitch
235 %type <pitch_arr> chord_additions chord_subtractions chord_notes chord_step
237 %type <pitch> chord_note chord_inversion chord_bass
238 %type <duration> duration_length
240 %type <scm> embedded_scm scalar
241 %type <music> Music Sequential_music Simultaneous_music Music_sequence
242 %type <music> relative_music re_rhythmed_music part_combined_music
243 %type <music> property_def translator_change
244 %type <scm> Music_list
245 %type <outputdef> music_output_def_body
246 %type <request> shorthand_command_req
247 %type <request> post_request
248 %type <request> command_req verbose_command_req
249 %type <request> extender_req
250 %type <request> hyphen_req
251 %type <scm> string bare_number number_expression
252 %type <score> score_block score_body
254 %type <trans> translator_spec_block translator_spec_body
255 %type <tempo> tempo_request
256 %type <scm> notenames_body notenames_block chordmodifiers_block
257 %type <scm> script_abbreviation
268 | mudela toplevel_expression {}
269 | mudela assignment { }
272 THIS->error_level_i_ =1;
278 THIS->lexer_p_->pitchname_tab_ = $1;
280 | chordmodifiers_block {
281 THIS->lexer_p_->chordmodifier_tab_ = $1;
284 delete header_global_p;
285 header_global_p = $1;
288 score_global_array.push ($1);
291 Identifier * id = new
292 Music_output_def_identifier ($1, MUSIC_OUTPUT_DEF_IDENTIFIER);
293 if (dynamic_cast<Paper_def*> ($1))
294 THIS->lexer_p_->set_identifier ("$defaultpaper", id->self_scm ());
295 else if (dynamic_cast<Midi_def*> ($1))
296 THIS->lexer_p_->set_identifier ("$defaultmidi", id->self_scm ());
309 chordmodifiers_block:
310 CHORDMODIFIERS notenames_body { $$ = $2; }
315 NOTENAMES notenames_body { $$ = $2; }
322 int i = scm_ilength ($1);
324 SCM tab = scm_make_vector (gh_int2scm (i), SCM_EOL);
325 for (SCM s = $1; s != SCM_EOL; s = gh_cdr (s)) {
326 SCM pt = gh_cdar (s);
327 if (scm_ilength (pt) != 3)
328 THIS->parser_error ("Need three args");
329 scm_hashq_set_x (tab, gh_caar(s), pt);
339 THIS->lexer_p_-> scope_l_arr_.push ($$);
341 | mudela_header_body assignment semicolon {
347 HEADER '{' mudela_header_body '}' {
349 THIS->lexer_p_-> scope_l_arr_.pop ();
359 THIS->remember_spot ();
361 /* cont */ '=' identifier_init {
362 THIS->lexer_p_->set_identifier (ly_scm2string ($1), $4);
365 TODO: devise standard for protection in parser.
367 scm_unprotect_object ($4);
369 The parser stack lives on the C-stack, which means that
370 all objects can be unprotected as soon as they're here.
373 Identifier * id =unsmob_identifier ($4);
374 Input spot = THIS->pop_spot ();
375 if (id) id->set_spot (spot);
383 $$ = (new Score_identifier ($1, SCORE_IDENTIFIER))->self_scm();
386 $$ = (new Music_output_def_identifier ($1, MUSIC_OUTPUT_DEF_IDENTIFIER))->self_scm();
388 | translator_spec_block {
389 $$ = (new Translator_group_identifier ($1, TRANS_IDENTIFIER))->self_scm();
392 $$ = $1->self_scm ();
395 $$ = $1->self_scm ();
397 | explicit_duration {
398 $$ = (new Duration_identifier ($1, DURATION_IDENTIFIER))->self_scm ();
400 | number_expression {
411 translator_spec_block:
412 TRANSLATOR '{' translator_spec_body '}'
418 translator_spec_body:
420 $$ = $1->access_content_Translator_group (true);
421 $$-> set_spot (THIS->here_input ());
423 | TYPE STRING semicolon {
424 Translator* t = get_translator_l (ly_scm2string ($2));
425 Translator_group * tg = dynamic_cast<Translator_group*> (t);
428 THIS->parser_error (_("Need a translator group for a context"));
430 tg = dynamic_cast<Translator_group*> (t->clone ());
431 tg->set_spot (THIS->here_input ());
434 | translator_spec_body STRING '=' embedded_scm {
435 Translator_group* tg = $$;
436 tg->set_property (ly_scm2string ($2), $4);
438 | translator_spec_body STRING '=' identifier_init semicolon {
439 SCM v = gh_int2scm (0);
440 if (gh_string_p ($4) || gh_number_p ($4) || gh_boolean_p ($4))
443 THIS->parser_error (_("Wrong type for property value"));
446 Translator_group* tg = dynamic_cast<Translator_group*> ($$);
448 tg->set_property (ly_scm2string ($2), v);
450 | translator_spec_body NAME STRING semicolon {
451 $$->type_str_ = ly_scm2string ($3);
453 | translator_spec_body CONSISTS STRING semicolon {
454 dynamic_cast<Translator_group*> ($$)-> set_element (ly_scm2string ($3), true);
456 | translator_spec_body CONSISTSEND STRING semicolon {
457 dynamic_cast<Translator_group*> ($$)-> set_element (ly_scm2string ($3), true);
459 | translator_spec_body ACCEPTS STRING semicolon {
460 dynamic_cast<Translator_group*> ($$)-> set_acceptor (ly_scm2string ($3), true);
462 | translator_spec_body REMOVE STRING semicolon {
463 dynamic_cast<Translator_group*> ($$)-> set_element (ly_scm2string ($3), false);
473 /*cont*/ '{' score_body '}' {
475 if (!$$->def_p_arr_.size ())
478 unsmob_identifier (THIS->lexer_p_->lookup_identifier ("$defaultpaper"));
479 $$->add_output (id ? id->access_content_Music_output_def (true) : new Paper_def );
488 $$->set_spot (THIS->here_input ());
489 SCM m = $1->self_scm ();
490 // scm_unprotect_object (m);
494 $$ = $1->access_content_Score (true);
496 | score_body mudela_header {
499 | score_body output_def {
512 music_output_def_body '}' {
514 THIS-> lexer_p_-> scope_l_arr_.pop();
518 music_output_def_body:
520 Identifier *id = unsmob_identifier (THIS->lexer_p_->lookup_identifier ("$defaultmidi"));
525 p = dynamic_cast<Midi_def*> (id->access_content_Music_output_def (true));
530 THIS->lexer_p_->scope_l_arr_.push (p->scope_p_);
533 Identifier *id = unsmob_identifier (THIS->lexer_p_->lookup_identifier ("$defaultpaper"));
536 p = dynamic_cast<Paper_def*> (id->access_content_Music_output_def (true));
539 THIS-> lexer_p_-> scope_l_arr_.push (p->scope_p_);
542 | PAPER '{' MUSIC_OUTPUT_DEF_IDENTIFIER {
543 Music_output_def *p = $3->access_content_Music_output_def (true);
544 THIS->lexer_p_->scope_l_arr_.push (p->scope_p_);
547 | MIDI '{' MUSIC_OUTPUT_DEF_IDENTIFIER {
548 Music_output_def *p = $3->access_content_Music_output_def (true);
549 THIS->lexer_p_->scope_l_arr_.push (p->scope_p_);
552 | music_output_def_body assignment semicolon {
555 | music_output_def_body translator_spec_block {
556 $$-> assign_translator ($2);
558 | music_output_def_body tempo_request semicolon {
560 junk this ? there already is tempo stuff in
563 dynamic_cast<Midi_def*> ($$)->set_tempo ($2->dur_.length_mom (), $2->metronome_i_);
565 | music_output_def_body bare_int '=' FONT STRING { // ugh, what a syntax
566 SCM sl = Lookup::make_lookup();
567 Lookup * l =unsmob_lookup (sl);
568 l->font_name_ = ly_scm2string ($5);
569 dynamic_cast<Paper_def*> ($$)->set_lookup ($2, sl);
571 | music_output_def_body error {
577 TEMPO steno_duration '=' bare_unsigned {
581 $$-> metronome_i_ = $4;
585 Music_list: /* empty */ {
586 $$ = gh_cons (SCM_EOL, SCM_EOL);
590 SCM c = gh_cons ($2->self_scm (), SCM_EOL);
591 // scm_unprotect_object ($2->self_scm ()); /* UGH */
594 if (gh_pair_p (gh_cdr (s)))
595 gh_set_cdr_x (gh_cdr (s), c); /* append */
597 gh_set_car_x (s, c); /* set first cons */
598 gh_set_cdr_x (s, c) ; /* remember last cell */
614 | ALTERNATIVE Music_sequence {
616 $2->set_spot (THIS->here_input ());
624 REPEAT STRING bare_unsigned Music Alternative_music
626 Music_sequence* m = dynamic_cast <Music_sequence*> ($5);
627 if (m && $3 < m->length_i ())
628 $5->origin ()->warning (_ ("More alternatives than repeats. Junking excess alternatives."));
630 Repeated_music * r = new Repeated_music ($4, $3 >? 1, m);
632 r->type_ = ly_scm2string ($2);
633 r->fold_b_ = (r->type_ == "fold");
634 r->volta_fold_b_ = (r->type_ == "volta");
635 r->set_spot (*$4->origin ());
639 Music_sequence: '{' Music_list '}' {
640 $$ = new Music_sequence (gh_car ($2));
645 SEQUENTIAL '{' Music_list '}' {
646 $$ = new Sequential_music (gh_car ($3));
648 | '{' Music_list '}' {
649 $$ = new Sequential_music (gh_car ($2));
654 SIMULTANEOUS '{' Music_list '}'{
655 $$ = new Simultaneous_music (gh_car ($3));
657 | '<' Music_list '>' {
658 $$ = new Simultaneous_music (gh_car ($2));
663 request_chord { $$ = $1; }
664 | OUTPUTPROPERTY embedded_scm embedded_scm '=' embedded_scm {
666 if (!gh_symbol_p ($3))
668 THIS->parser_error (_("Second argument must be a symbol"));
670 /*hould check # args */
671 if (!gh_procedure_p (pred))
673 THIS->parser_error (_("First argument must be a procedure taking 1 argument"));
676 $$ = new Output_property (pred,$3, $5);
678 | MUSIC_IDENTIFIER { $$ = unsmob_music ($1)->clone (); }
681 | Simple_music '*' bare_unsigned '/' bare_unsigned {
683 $$->compress (Moment($3, $5 ));
685 | Simple_music '*' bare_unsigned {
687 $$->compress (Moment ($3, 1));
693 CONTEXT STRING Music {
694 Context_specced_music *csm = new Context_specced_music ($3);
696 csm->translator_type_str_ = ly_scm2string ($2);
697 csm->translator_id_str_ = "";
702 | AUTOCHANGE STRING Music {
703 Auto_change_music * chm = new Auto_change_music (ly_scm2string ($2), $3);
706 chm->set_spot (*$3->origin ());
709 $$ = new Grace_music ($2);
711 | CONTEXT STRING '=' STRING Music {
712 Context_specced_music *csm = new Context_specced_music ($5);
714 csm->translator_type_str_ = ly_scm2string ($2);
715 csm->translator_id_str_ = ly_scm2string ($4);
720 THIS->remember_spot ();
723 bare_unsigned '/' bare_unsigned Music
726 $$ = new Time_scaled_music ($3, $5, $6);
727 $$->set_spot (THIS->pop_spot ());
729 | Repeated_music { $$ = $1; }
730 | Simultaneous_music { $$ = $1; }
731 | Sequential_music { $$ = $1; }
732 | TRANSPOSE musical_pitch Music {
733 $$ = new Transposed_music ($3, *$2);
736 | TRANSPOSE steno_tonic_pitch Music {
737 $$ = new Transposed_music ($3, *$2);
741 { THIS->lexer_p_->push_note_state (); }
744 THIS->lexer_p_->pop_state ();
747 { THIS->lexer_p_->push_chord_state (); }
751 THIS->lexer_p_->pop_state ();
754 { THIS->lexer_p_->push_lyric_state (); }
758 THIS->lexer_p_->pop_state ();
760 | relative_music { $$ = $1; }
761 | re_rhythmed_music { $$ = $1; }
762 | part_combined_music { $$ = $1; }
766 RELATIVE absolute_musical_pitch Music {
767 $$ = new Relative_octave_music ($3, *$2);
773 ADDLYRICS Music Music {
774 Lyric_combine_music * l = new Lyric_combine_music ($2, $3);
780 PARTCOMBINE STRING Music Music {
781 Part_combine_music * p = new Part_combine_music (ly_scm2string ($2), $3, $4);
787 TRANSLATOR STRING '=' STRING {
788 Change_translator * t = new Change_translator;
789 t-> change_to_type_str_ = ly_scm2string ($2);
790 t-> change_to_id_str_ = ly_scm2string ($4);
793 $$->set_spot (THIS->here_input ());
798 PROPERTY STRING '.' STRING '=' scalar {
799 Translation_property *t = new Translation_property;
801 t->set_mus_property ("symbol", scm_string_to_symbol ($4));
802 t->set_mus_property ("value", $6);
804 Context_specced_music *csm = new Context_specced_music (t);
806 $$->set_spot (THIS->here_input ());
808 csm-> translator_type_str_ = ly_scm2string ($2);
814 | bare_int { $$ = gh_int2scm ($1); }
815 | embedded_scm { $$ = $1; }
820 pre_requests simple_element post_requests {
821 Music_sequence *l = dynamic_cast<Music_sequence*>($2);
823 for (int i=0; i < $1->size(); i++)
824 l->append_music ($1->elem(i));
825 for (int i=0; i < $3->size(); i++)
826 l->append_music ($3->elem(i));
829 programming_error ("Need Sequence to add music to");
838 $$ = new Request_chord (gh_cons ($1->self_scm (), SCM_EOL));
839 $$-> set_spot (THIS->here_input ());
840 $1-> set_spot (THIS->here_input ());
842 | PARTIAL duration_length ';' {
843 Translation_property * p = new Translation_property;
844 p->set_mus_property ("symbol", ly_symbol2scm ( "measurePosition"));
845 Moment m = - $2->length_mom ();
846 p->set_mus_property ("value", m.make_scm());
848 Context_specced_music * sp = new Context_specced_music (p);
850 sp-> translator_type_str_ = "Score";
855 shorthand_command_req
856 | verbose_command_req semicolon { $$ = $1; }
859 shorthand_command_req:
867 $$ = new Barcheck_req;
873 Span_req*b= new Span_req;
874 b->span_dir_ = START;
875 b->span_type_str_ = "beam";
879 Span_req*b= new Span_req;
881 b->span_type_str_ = "beam";
885 $$ = new Breathing_sign_req;
893 $$ = new Bar_req (ly_scm2string ($2));
895 | COMMANDSPANREQUEST bare_int STRING {
896 Span_req * sp_p = new Span_req;
897 sp_p-> span_dir_ = Direction($2);
898 sp_p->span_type_str_ = ly_scm2string ($3);
899 sp_p->set_spot (THIS->here_input ());
903 Mark_req * m = new Mark_req;
907 Mark_req *m = new Mark_req;
908 m->set_mus_property ("label", $2);
912 | MARK bare_unsigned {
913 Mark_req *m = new Mark_req;
914 m->set_mus_property ("label", gh_int2scm ($2));
918 | TIME_T bare_unsigned '/' bare_unsigned {
919 Time_signature_change_req *m = new Time_signature_change_req;
925 Break_req * b = new Break_req;
926 b->penalty_f_ = $2 / 100.0;
927 b->set_spot (THIS->here_input ());
930 | SKIP duration_length {
931 Skip_req * skip_p = new Skip_req;
932 skip_p->duration_ = *$2;
940 $$ = new Clef_change_req (ly_scm2string ($2));
944 Key_change_req *key_p= new Key_change_req;
947 | KEY NOTENAME_PITCH SCM_IDENTIFIER {
948 Key_change_req *key_p= new Key_change_req;
950 key_p->set_mus_property ("pitch-alist", $3);
951 ((Music* )key_p)->transpose (* $2);
958 $$ = new Link_array<Request>;
960 | post_requests post_request {
961 $2->set_spot (THIS->here_input ());
973 request_that_take_dir:
976 | script_abbreviation {
977 SCM s = THIS->lexer_p_->lookup_identifier ("dash-" + ly_scm2string ($1));
978 Articulation_req *a = new Articulation_req;
980 a->articulation_str_ = ly_scm2string (s);
981 else THIS->parser_error (_ ("Expecting string as script definition"));
987 script_dir request_that_take_dir {
988 if (Script_req * gs = dynamic_cast<Script_req*> ($2))
989 gs->dir_ = Direction ($1);
991 $2->origin ()->warning (_ ("Can't specify direction for this request"));
998 $$ = dynamic_cast<Request*> (unsmob_music ($1)->clone ());
999 $$->set_spot (THIS->here_input ());
1001 | TEXTSCRIPT STRING STRING {
1002 Text_script_req *ts_p = new Text_script_req;
1003 ts_p-> text_str_ = ly_scm2string ($2);
1004 ts_p-> style_str_ = ly_scm2string ($3);
1005 ts_p->set_spot (THIS->here_input ());
1009 | SPANREQUEST bare_int STRING {
1010 Span_req * sp_p = new Span_req;
1011 sp_p->span_dir_ = Direction($2);
1012 sp_p->span_type_str_ = ly_scm2string ($3);
1013 sp_p->set_spot (THIS->here_input ());
1017 Tremolo_req* a = new Tremolo_req;
1018 a->set_spot (THIS->here_input ());
1023 Articulation_req * a = new Articulation_req;
1024 a->articulation_str_ = ly_scm2string ($2);
1025 a->set_spot (THIS->here_input ());
1048 steno_musical_pitch:
1052 | NOTENAME_PITCH sup_quotes {
1054 $$->octave_i_ += $2;
1056 | NOTENAME_PITCH sub_quotes {
1058 $$->octave_i_ += - $2;
1066 | TONICNAME_PITCH sup_quotes {
1068 $$->octave_i_ += $2;
1070 | TONICNAME_PITCH sub_quotes {
1072 $$->octave_i_ += - $2;
1077 steno_musical_pitch {
1080 | MUSICAL_PITCH embedded_scm {
1081 int sz = scm_ilength ($2);
1083 THIS->parser_error (_f ("Expecting %d arguments", 3));
1084 $2 = gh_list (gh_int2scm (0), gh_int2scm (0), gh_int2scm (0), SCM_UNDEFINED);
1086 $$ = new Musical_pitch ($2);
1091 DURATION embedded_scm {
1093 if (scm_ilength ($2) == 2)
1095 $$-> durlog_i_ = gh_scm2int (gh_car($2));
1096 $$-> dots_i_ = gh_scm2int (gh_cadr($2));
1099 THIS->parser_error (_("Must have 2 arguments for duration"));
1105 if (!THIS->lexer_p_->lyric_state_b ())
1106 THIS->parser_error (_ ("Have to be in Lyric mode for lyrics"));
1107 $$ = new Extender_req;
1113 if (!THIS->lexer_p_->lyric_state_b ())
1114 THIS->parser_error (_ ("Have to be in Lyric mode for lyrics"));
1115 $$ = new Hyphen_req;
1120 close_request_parens {
1122 dynamic_cast<Span_req*> ($$)->span_dir_ = START;
1125 close_request_parens:
1127 Span_req* s= new Span_req;
1129 s->span_type_str_ = "slur";
1132 Span_req*s =new Span_req;
1134 s->span_type_str_ = "crescendo";
1137 Span_req*s =new Span_req;
1139 s->span_type_str_ = "decrescendo";
1145 open_request_parens {
1147 dynamic_cast<Span_req*> ($$)->span_dir_ = STOP;
1151 open_request_parens:
1153 Span_req *s = new Span_req;
1154 s->span_type_str_ = "crescendo";
1158 Span_req* s= new Span_req;
1160 s->span_type_str_ = "slur";
1166 Text_script_req *t = new Text_script_req;
1168 t->text_str_ = ly_scm2string ($1);
1170 $$->set_spot (THIS->here_input ());
1173 Text_script_req* t = new Text_script_req;
1175 t->text_str_ = to_str ($1);
1176 t->style_str_ = "finger";
1177 $$->set_spot (THIS->here_input ());
1181 script_abbreviation:
1183 $$ = gh_str02scm ("hat");
1186 $$ = gh_str02scm("plus");
1189 $$ = gh_str02scm ("dash");
1192 $$ = gh_str02scm ("bar");
1195 $$ = gh_str02scm ("larger");
1198 $$ = gh_str02scm ("dot");
1206 | '-' { $$ = CENTER; }
1211 $$ = new Link_array<Request>;
1213 | pre_requests open_request {
1218 absolute_musical_pitch:
1219 steno_musical_pitch {
1228 | duration_length '*' bare_unsigned {
1229 $$->tuplet_iso_i_ *= $3;
1231 | duration_length '/' bare_unsigned {
1232 $$->tuplet_type_i_ *= $3;
1236 entered_notemode_duration:
1238 THIS->set_last_duration ($1);
1242 optional_notemode_duration:
1244 $$ = new Duration (THIS->default_duration_);
1246 | entered_notemode_duration {
1254 if (!is_duration_b ($1))
1255 THIS->parser_error (_f ("not a duration: %d", $1));
1257 $$->durlog_i_ = intlog2 ($1);
1260 | DURATION_IDENTIFIER {
1261 $$ = $1->access_content_Duration (true);
1263 | steno_duration '.' {
1273 | ':' bare_unsigned {
1274 if (!is_duration_b ($2))
1275 THIS->parser_error (_f ("not a duration: %d", $2));
1282 musical_pitch exclamations questions optional_notemode_duration {
1283 if (!THIS->lexer_p_->note_state_b ())
1284 THIS->parser_error (_ ("Have to be in Note mode for notes"));
1287 Note_req *n = new Note_req;
1292 n->cautionary_b_ = $3 % 2;
1293 n->forceacc_b_ = $2 % 2 || n->cautionary_b_;
1296 Simultaneous_music*v = new Request_chord (gh_list (n->self_scm (), SCM_UNDEFINED));
1297 v->set_spot ($1->spot ());
1298 n->set_spot ($1->spot ());
1304 | RESTNAME optional_notemode_duration {
1306 SCM e = SCM_UNDEFINED;
1307 if (ly_scm2string ($1) =="s")
1309 Skip_req * skip_p = new Skip_req;
1310 skip_p->duration_ = *$2;
1312 skip_p->set_spot (THIS->here_input());
1313 e = skip_p->self_scm ();
1317 Rest_req * rest_req_p = new Rest_req;
1318 rest_req_p->duration_ = *$2;
1319 rest_req_p->set_spot (THIS->here_input());
1320 e = rest_req_p->self_scm ();
1322 Simultaneous_music* velt_p = new Request_chord (gh_list (e,SCM_UNDEFINED));
1323 velt_p->set_spot (THIS->here_input());
1328 | MEASURES optional_notemode_duration {
1329 Skip_req * sk = new Skip_req;
1330 sk->duration_ = *$2;
1333 Span_req *sp1 = new Span_req;
1334 Span_req *sp2 = new Span_req;
1335 sp1-> span_dir_ = START;
1336 sp2-> span_dir_ = STOP;
1337 sp1->span_type_str_ = sp2->span_type_str_ = "rest";
1339 Request_chord * rqc1 = new Request_chord (gh_list (sp1->self_scm (), SCM_UNDEFINED));
1340 Request_chord * rqc2 = new Request_chord (gh_list (sk->self_scm (), SCM_UNDEFINED));;
1341 Request_chord * rqc3 = new Request_chord(gh_list (sp2->self_scm (), SCM_UNDEFINED));;
1343 SCM ms = gh_list (rqc1->self_scm (), rqc2->self_scm (), rqc3->self_scm (), SCM_UNDEFINED);
1345 $$ = new Sequential_music (ms);
1347 | STRING optional_notemode_duration {
1348 if (!THIS->lexer_p_->lyric_state_b ())
1349 THIS->parser_error (_ ("Have to be in Lyric mode for lyrics"));
1350 Lyric_req* lreq_p = new Lyric_req;
1351 lreq_p ->text_str_ = ly_scm2string ($1);
1352 lreq_p->duration_ = *$2;
1353 lreq_p->set_spot (THIS->here_input());
1354 Simultaneous_music* velt_p = new Request_chord (gh_list (lreq_p->self_scm (), SCM_UNDEFINED));
1361 if (!THIS->lexer_p_->chord_state_b ())
1362 THIS->parser_error (_ ("Have to be in Chord mode for chords"));
1369 steno_tonic_pitch optional_notemode_duration chord_additions chord_subtractions chord_inversion chord_bass {
1370 $$ = THIS->get_chord (*$1, $3, $4, $5, $6, *$2);
1375 $$ = new Array<Musical_pitch>;
1377 | CHORD_COLON chord_notes {
1386 | chord_notes '.' chord_step {
1394 $$ = new Array<Musical_pitch>;
1396 | CHORD_CARET chord_notes {
1406 | '/' steno_tonic_pitch {
1408 $$->set_spot (THIS->here_input ());
1416 | CHORD_BASS steno_tonic_pitch {
1418 $$->set_spot (THIS->here_input ());
1424 $$ = new Array<Musical_pitch>;
1427 | CHORDMODIFIER_PITCH {
1428 $$ = new Array<Musical_pitch>;
1431 | CHORDMODIFIER_PITCH chord_note { /* Ugh. */
1432 $$ = new Array<Musical_pitch>;
1440 $$ = new Musical_pitch;
1441 $$->notename_i_ = ($1 - 1) % 7;
1442 $$->octave_i_ = $1 > 7 ? 1 : 0;
1443 $$->accidental_i_ = 0;
1445 | bare_unsigned '+' {
1446 $$ = new Musical_pitch;
1447 $$->notename_i_ = ($1 - 1) % 7;
1448 $$->octave_i_ = $1 > 7 ? 1 : 0;
1449 $$->accidental_i_ = 1;
1451 | bare_unsigned CHORD_MINUS {
1452 $$ = new Musical_pitch;
1453 $$->notename_i_ = ($1 - 1) % 7;
1454 $$->octave_i_ = $1 > 7 ? 1 : 0;
1455 $$->accidental_i_ = -1;
1466 | '-' number_expression %prec UNARY_MINUS {
1467 $$ = scm_difference ($2, SCM_UNDEFINED);
1469 | number_expression '*' number_expression {
1470 $$ = scm_product ($1, $3);
1472 | number_expression '/' number_expression {
1473 $$ = scm_divide ($1, $3);
1475 | number_expression '+' number_expression {
1476 $$ = scm_sum ($1, $3);
1478 | number_expression '-' number_expression {
1479 $$ = scm_difference ($1, $3);
1481 | '(' number_expression ')' {
1488 $$ = gh_int2scm ($1);
1491 $$ = gh_int2scm ($1);
1494 $$ = gh_double2scm ($1);
1496 | NUMBER_IDENTIFIER {
1500 $$ = gh_double2scm ($1 CM);
1503 $$ = gh_double2scm ($1 PT);
1506 $$ = gh_double2scm ($1 INCH);
1509 $$ = gh_double2scm ($1 MM);
1512 $$ = gh_double2scm ($1 CHAR);
1519 if (scm_integer_p ($1) == SCM_BOOL_T) {
1520 $$ = gh_scm2int ($1);
1523 THIS->parser_error (_("need integer number arg"));
1527 THIS->parser_error (_("Must be positive integer"));
1535 if (scm_integer_p ($1) == SCM_BOOL_T)
1537 int k = gh_scm2int ($1);
1541 THIS->parser_error (_("need integer number arg"));
1555 | STRING_IDENTIFIER {
1558 | string '+' string {
1559 $$ = scm_string_append (scm_listify ($1, $3, SCM_UNDEFINED));
1566 | exclamations '!' { $$ ++; }
1571 | questions '?' { $$ ++; }
1582 My_lily_parser::set_yydebug (bool b)
1589 My_lily_parser::do_yyparse ()
1591 yyparse ((void*)this);