1 %{ // -*-Fundamental-*-
4 parser.yy -- Bison/C++ parser for mudela
6 source file of the GNU LilyPond music typesetter
8 (c) 1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
9 Jan Nieuwenhuizen <janneke@gnu.org>
13 #include "lily-guile.hh"
14 #include "notename-table.hh"
15 #include "translation-property.hh"
18 #include "my-lily-lexer.hh"
19 #include "paper-def.hh"
20 #include "midi-def.hh"
22 #include "file-path.hh"
24 #include "dimensions.hh"
25 #include "identifier.hh"
26 #include "command-request.hh"
27 #include "musical-request.hh"
28 #include "my-lily-parser.hh"
29 #include "context-specced-music.hh"
30 #include "translator-group.hh"
32 #include "music-list.hh"
33 #include "change-translator.hh"
34 #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"
46 Mudela_version oldest_version ("1.3.4");
51 return t == 1 << intlog2(t);
58 print_mudela_versions (ostream &os)
60 os << _f ("Oldest supported input version: %s", oldest_version.str ())
63 // needed for bison.simple's malloc() and free()
70 #define YYERROR_VERBOSE 1
72 #define YYPARSE_PARAM my_lily_parser_l
73 #define YYLEX_PARAM my_lily_parser_l
74 #define THIS ((My_lily_parser *) my_lily_parser_l)
76 #define yyerror THIS->parser_error
77 #define ARRAY_SIZE(a,s) if (a.size () != s) THIS->parser_error (_f ("Expecting %d arguments", s))
83 Array<Musical_pitch> *pitch_arr;
84 Link_array<Request> *reqvec;
86 Notename_table *chordmodifiertab;
91 Music_list *music_list;
96 Music_output_def * outputdef;
97 Musical_pitch * pitch;
100 Notename_table *notenametab;
105 /* We use SCMs to do strings, because it saves us the trouble of
106 deleting them. Let's hope that a stack overflow doesnt trigger a move
107 of the parse stack onto the heap. */
111 Translator_group* trans;
119 yylex (YYSTYPE *s, void * v_l)
121 My_lily_parser *pars_l = (My_lily_parser*) v_l;
122 My_lily_lexer * lex_l = pars_l->lexer_p_;
124 lex_l->lexval_l = (void*) s;
125 return lex_l->yylex ();
133 /* tokens which are not keywords */
140 %token CHORDMODIFIERS
182 %token COMMANDSPANREQUEST
192 %token E_CHAR E_EXCLAMATION E_SMALLER E_BIGGER
193 %token CHORD_BASS CHORD_COLON CHORD_MINUS CHORD_CARET
195 %type <i> exclamations questions
197 %token <pitch> NOTENAME_PITCH
198 %token <pitch> TONICNAME_PITCH
199 %token <pitch> CHORDMODIFIER_PITCH
200 %token <id> DURATION_IDENTIFIER
201 %token <id> IDENTIFIER
202 %token <id> NOTENAME_TABLE_IDENTIFIER
203 %token <id> MUSIC_IDENTIFIER
204 %token <id> REQUEST_IDENTIFIER
205 %token <id> REAL_IDENTIFIER
206 %token <id> STRING_IDENTIFIER
207 %token <id> TRANS_IDENTIFIER
208 %token <id> INT_IDENTIFIER
209 %token <id> SCORE_IDENTIFIER
210 %token <id> MIDI_IDENTIFIER
211 %token <id> PAPER_IDENTIFIER
213 %token <scm> DURATION RESTNAME
219 %type <outputdef> output_def
220 %type <scope> mudela_header mudela_header_body
221 %type <request> open_request_parens close_request_parens open_request close_request
222 %type <request> request_with_dir request_that_take_dir verbose_request
223 %type <i> sub_quotes sup_quotes
224 %type <music> simple_element request_chord command_element Simple_music Composite_music
225 %type <music> Alternative_music Repeated_music
226 %type <i> abbrev_type
227 %type <i> int unsigned
229 %type <i> optional_modality
230 %type <id> identifier_init
231 %type <duration> steno_duration optional_notemode_duration
232 %type <duration> entered_notemode_duration explicit_duration
233 %type <intvec> int_list
234 %type <reqvec> pre_requests post_requests
235 %type <request> gen_text_def
236 %type <pitch> explicit_musical_pitch steno_musical_pitch musical_pitch absolute_musical_pitch
237 %type <pitch> steno_tonic_pitch
239 %type <pitch_arr> pitch_list
241 %type <pitch_arr> chord_additions chord_subtractions chord_notes chord_step
242 %type <pitch> chord_note chord_inversion chord_bass
243 %type <midi> midi_block midi_body
244 %type <duration> duration_length
246 %type <scm> embedded_scm scalar
247 %type <music> Music Sequential_music Simultaneous_music Music_sequence
248 %type <music> relative_music re_rhythmed_music
249 %type <music> property_def translator_change
250 %type <music_list> Music_list
251 %type <paper> paper_block paper_def_body
252 %type <real> real real_with_dimension
253 %type <request> abbrev_command_req
254 %type <request> post_request
255 %type <request> command_req verbose_command_req
256 %type <request> extender_req
257 %type <request> hyphen_req
259 %type <score> score_block score_body
261 %type <scm> script_abbreviation
262 %type <trans> translator_spec_block translator_spec_body
263 %type <tempo> tempo_request
264 %type <notenametab> notenames_body notenames_block chordmodifiers_block
275 | mudela toplevel_expression {}
276 | mudela assignment { }
279 THIS->error_level_i_ =1;
285 THIS->lexer_p_->set_notename_table ($1);
287 | chordmodifiers_block {
288 THIS->lexer_p_->set_chordmodifier_table ($1);
291 delete header_global_p;
292 header_global_p = $1;
295 score_global_array.push ($1);
298 Identifier * id = new
299 Paper_def_identifier ($1, PAPER_IDENTIFIER);
300 THIS->lexer_p_->set_identifier ("$defaultpaper", id)
303 Identifier * id = new
304 Midi_def_identifier ($1, MIDI_IDENTIFIER);
305 THIS->lexer_p_->set_identifier ("$defaultmidi", id)
317 chordmodifiers_block:
318 CHORDMODIFIERS '{' notenames_body '}' { $$ = $3; }
323 NOTENAMES '{' notenames_body '}' { $$ = $3; }
330 $$ = new Notename_table;
332 | NOTENAME_TABLE_IDENTIFIER {
333 $$ = $1-> access_content_Notename_table(true);
335 | notenames_body STRING '=' explicit_musical_pitch {
336 $$->add_note_name (ly_scm2string ($2), $4);
344 THIS->lexer_p_-> scope_l_arr_.push ($$);
346 | mudela_header_body assignment semicolon {
352 HEADER '{' mudela_header_body '}' {
354 THIS->lexer_p_-> scope_l_arr_.pop ();
364 THIS->remember_spot ();
366 /* cont */ '=' identifier_init {
367 THIS->lexer_p_->set_identifier (ly_scm2string ($1), $4);
368 $4->init_b_ = THIS->init_parse_b_;
369 $4->set_spot (THIS->pop_spot ());
377 $$ = new Score_identifier ($1, SCORE_IDENTIFIER);
380 | chordmodifiers_block {
381 $$ = new Notename_table_identifier ($1, NOTENAME_TABLE_IDENTIFIER);
384 $$ = new Notename_table_identifier ($1, NOTENAME_TABLE_IDENTIFIER);
387 $$ = new Paper_def_identifier ($1, PAPER_IDENTIFIER);
390 $$ = new Midi_def_identifier ($1, MIDI_IDENTIFIER);
393 | translator_spec_block {
394 $$ = new Translator_group_identifier ($1, TRANS_IDENTIFIER);
397 $$ = new Music_identifier ($1, MUSIC_IDENTIFIER);
401 $$ = new Request_identifier ($1, REQUEST_IDENTIFIER);
403 | explicit_duration {
404 $$ = new Duration_identifier ($1, DURATION_IDENTIFIER);
407 $$ = new Real_identifier (new Real ($1), REAL_IDENTIFIER);
410 $$ = new String_identifier (new String (ly_scm2string ($1)), STRING_IDENTIFIER);
413 $$ = new int_identifier (new int ($1), INT_IDENTIFIER);
417 translator_spec_block:
418 TRANSLATOR '{' translator_spec_body '}'
424 translator_spec_body:
426 $$ = $1->access_content_Translator_group (true);
427 $$-> set_spot (THIS->here_input ());
429 | TYPE STRING semicolon {
430 Translator* t = get_translator_l (ly_scm2string ($2));
431 Translator_group * tg = dynamic_cast<Translator_group*> (t);
434 THIS->parser_error (_("Need a translator group for a context"));
436 tg = dynamic_cast<Translator_group*> (t->clone ());
437 tg->set_spot (THIS->here_input ());
440 | translator_spec_body STRING '=' embedded_scm {
441 Translator_group* tg = dynamic_cast<Translator_group*> ($$);
442 tg->set_property (ly_scm2string ($2), $4);
444 | translator_spec_body STRING '=' identifier_init semicolon {
446 String_identifier *s = dynamic_cast<String_identifier*> (id);
447 Real_identifier *r= dynamic_cast<Real_identifier*>(id);
448 int_identifier *i = dynamic_cast<int_identifier*> (id);
451 if (s) v = ly_str02scm (s->access_content_String (false)->ch_C());
452 if (i) v = gh_int2scm (*i->access_content_int (false));
453 if (r) v = gh_double2scm (*r->access_content_Real (false));
455 THIS->parser_error (_("Wrong type for property value"));
459 Translator_group* tg = dynamic_cast<Translator_group*> ($$);
461 tg->set_property (ly_scm2string ($2), v);
463 | translator_spec_body NAME STRING semicolon {
464 $$->type_str_ = ly_scm2string ($3);
466 | translator_spec_body CONSISTS STRING semicolon {
467 dynamic_cast<Translator_group*> ($$)-> set_element (ly_scm2string ($3), true);
469 | translator_spec_body CONSISTSEND STRING semicolon {
470 dynamic_cast<Translator_group*> ($$)-> set_element (ly_scm2string ($3), true);
472 | translator_spec_body ACCEPTS STRING semicolon {
473 dynamic_cast<Translator_group*> ($$)-> set_acceptor (ly_scm2string ($3), true);
475 | translator_spec_body REMOVE STRING semicolon {
476 dynamic_cast<Translator_group*> ($$)-> set_element (ly_scm2string ($3), false);
486 /*cont*/ '{' score_body '}' {
488 if (!$$->def_p_arr_.size ())
489 $$->add_output (THIS->default_paper_p ());
495 $$->set_spot (THIS->here_input ());
498 $$ = $1->access_content_Score (true);
500 | score_body mudela_header {
505 $2->warning (_ ("More than one music block"));
508 | score_body output_def {
530 PAPER '{' paper_def_body '}' {
532 THIS-> lexer_p_->scope_l_arr_.pop ();
539 Paper_def *p = THIS->default_paper_p ();
540 THIS-> lexer_p_-> scope_l_arr_.push (p->scope_p_);
544 Paper_def *p = $1->access_content_Paper_def (true);
545 THIS->lexer_p_->scope_l_arr_.push (p->scope_p_);
548 | paper_def_body int '=' FONT STRING { // ugh, what a syntax
549 Lookup * l = new Lookup;
550 l->font_name_ = ly_scm2string ($5);
551 $$->set_lookup ($2, l);
553 | paper_def_body assignment semicolon {
556 | paper_def_body SCM_T '=' SCM_T {
557 if (!gh_symbol_p ($2))
558 THIS->parser_error ("expect a symbol as lvalue");
560 $$->default_properties_[$2] = $4;
562 | paper_def_body SCM_T '=' real semicolon {
563 if (!gh_symbol_p ($2))
564 THIS->parser_error ("expect a symbol as lvalue");
566 $$->default_properties_[$2] = gh_double2scm ($4);
568 | paper_def_body translator_spec_block {
569 $$->assign_translator ($2);
571 | paper_def_body error {
597 | real_with_dimension
599 $$= *$1->access_content_Real (false);
601 | '-' real %prec UNARY_MINUS {
628 THIS-> lexer_p_-> scope_l_arr_.pop();
632 midi_body: /* empty */ {
633 Midi_def * p =THIS->default_midi_p ();
635 THIS->lexer_p_->scope_l_arr_.push (p->scope_p_);
638 Midi_def * p =$1-> access_content_Midi_def (true);
640 THIS->lexer_p_->scope_l_arr_.push (p->scope_p_);
642 | midi_body assignment semicolon {
645 | midi_body translator_spec_block {
646 $$-> assign_translator ($2);
648 | midi_body tempo_request semicolon {
649 $$->set_tempo ($2->dur_.length_mom (), $2->metronome_i_);
658 TEMPO steno_duration '=' unsigned {
662 $$-> metronome_i_ = $4;
666 Music_list: /* empty */ {
668 $$->set_spot (THIS->here_input ());
687 | ALTERNATIVE Music_sequence {
689 $2->set_spot (THIS->here_input ());
697 REPEAT STRING unsigned Music Alternative_music
699 Music_sequence* m = dynamic_cast <Music_sequence*> ($5);
700 if (m && $3 < m->length_i ())
701 $5->warning (_ ("More alternatives than repeats. Junking excess alternatives."));
703 Repeated_music * r = new Repeated_music ($4, $3 >? 1, m);
705 r->fold_b_ = (ly_scm2string ($2) == "fold");
706 r->volta_fold_b_ = (ly_scm2string ($2) == "volta");
707 r->set_spot ($4->spot ());
711 Music_sequence: '{' Music_list '}' {
712 $$ = new Music_sequence ($2);
713 $$->set_spot ($2->spot ());
718 SEQUENTIAL '{' Music_list '}' {
719 $$ = new Sequential_music ($3);
720 $$->set_spot ($3->spot ());
722 | '{' Music_list '}' {
723 $$ = new Sequential_music ($2);
724 $$->set_spot ($2->spot ());
729 SIMULTANEOUS '{' Music_list '}'{
730 $$ = new Simultaneous_music ($3);
731 $$->set_spot ($3->spot ());
733 | '<' Music_list '>' {
734 $$ = new Simultaneous_music ($2);
735 $$->set_spot ($2->spot ());
740 request_chord { $$ = $1; }
741 | MUSIC_IDENTIFIER { $$ = $1->access_content_Music (true); }
744 | Simple_music '*' unsigned '/' unsigned {
746 $$->compress (Moment($3, $5 ));
748 | Simple_music '*' unsigned {
750 $$->compress (Moment ($3, 1));
756 CONTEXT STRING Music {
757 Context_specced_music *csm = new Context_specced_music ($3);
759 csm->translator_type_str_ = ly_scm2string ($2);
760 csm->translator_id_str_ = "";
765 | AUTOCHANGE STRING Music {
766 Auto_change_music * chm = new Auto_change_music (ly_scm2string ($2), $3);
769 chm->set_spot ($3->spot ());
772 $$ = new Grace_music ($2);
774 | CONTEXT STRING '=' STRING Music {
775 Context_specced_music *csm = new Context_specced_music ($5);
777 csm->translator_type_str_ = ly_scm2string ($2);
778 csm->translator_id_str_ = ly_scm2string ($4);
783 THIS->remember_spot ();
786 unsigned '/' unsigned Music
789 $$ = new Time_scaled_music ($3, $5, $6);
790 $$->set_spot (THIS->pop_spot ());
792 | Repeated_music { $$ = $1; }
793 | Simultaneous_music { $$ = $1; }
794 | Sequential_music { $$ = $1; }
795 | TRANSPOSE musical_pitch Music {
796 $$ = new Transposed_music ($3, *$2);
799 | TRANSPOSE steno_tonic_pitch Music {
800 $$ = new Transposed_music ($3, *$2);
804 { THIS->lexer_p_->push_note_state (); }
807 THIS->lexer_p_->pop_state ();
810 { THIS->lexer_p_->push_chord_state (); }
814 THIS->lexer_p_->pop_state ();
817 { THIS->lexer_p_->push_lyric_state (); }
821 THIS->lexer_p_->pop_state ();
823 | relative_music { $$ = $1; }
824 | re_rhythmed_music { $$ = $1; }
828 RELATIVE absolute_musical_pitch Music {
829 $$ = new Relative_octave_music ($3, *$2);
835 ADDLYRICS Music Music {
836 Lyric_combine_music * l = new Lyric_combine_music ($2, $3);
842 TRANSLATOR STRING '=' STRING {
843 Change_translator * t = new Change_translator;
844 t-> change_to_type_str_ = ly_scm2string ($2);
845 t-> change_to_id_str_ = ly_scm2string ($4);
848 $$->set_spot (THIS->here_input ());
853 PROPERTY STRING '.' STRING '=' scalar {
854 Translation_property *t = new Translation_property;
856 t->var_str_ = ly_scm2string ($4);
859 Context_specced_music *csm = new Context_specced_music (t);
861 $$->set_spot (THIS->here_input ());
863 csm-> translator_type_str_ = ly_scm2string ($2);
869 | int { $$ = gh_int2scm ($1); }
870 | embedded_scm { $$ = $1; }
875 pre_requests simple_element post_requests {
876 Music_sequence *l = dynamic_cast<Music_sequence*>($2);
878 for (int i=0; i < $1->size(); i++)
879 l->add_music ($1->elem(i));
880 for (int i=0; i < $3->size(); i++)
881 l->add_music ($3->elem(i));
884 programming_error ("Need Sequence to add music to");
893 $$ = new Request_chord;
894 $$-> set_spot (THIS->here_input ());
895 $1-> set_spot (THIS->here_input ());
896 ((Simultaneous_music*)$$) ->add_music ($1);//ugh
898 | PARTIAL duration_length ';' {
899 Translation_property * p = new Translation_property;
900 p->var_str_ = "measurePosition";
901 p->value_ = (new Moment (-$2->length_mom ()))->smobify_self ();
903 Context_specced_music * sp = new Context_specced_music (p);
905 sp-> translator_type_str_ = "Score";
911 | verbose_command_req semicolon { $$ = $1; }
922 $$ = new Barcheck_req;
928 Span_req*b= new Span_req;
929 b->span_dir_ = START;
930 b->span_type_str_ = "beam";
934 if (!is_duration_b ($3))
935 THIS->parser_error (_f ("not a duration: %d", $3));
937 THIS->parser_error (_ ("Can't abbreviate"));
939 THIS->set_abbrev_beam ($3);
941 Chord_tremolo_req* a = new Chord_tremolo_req;
942 a->span_dir_ = START;
943 a->type_i_ = THIS->abbrev_beam_type_i_;
947 if (!THIS->abbrev_beam_type_i_)
949 Span_req*b= new Span_req;
951 b->span_type_str_ = "beam";
956 Chord_tremolo_req* a = new Chord_tremolo_req;
958 a->type_i_ = THIS->abbrev_beam_type_i_;
959 THIS->set_abbrev_beam (0);
964 $$ = new Breathing_sign_req;
972 $$ = new Bar_req (ly_scm2string ($2));
974 | COMMANDSPANREQUEST int STRING {
975 Span_req * sp_p = new Span_req;
976 sp_p-> span_dir_ = Direction($2);
977 sp_p->span_type_str_ = ly_scm2string ($3);
978 sp_p->set_spot (THIS->here_input ());
982 Mark_req *m = new Mark_req;
983 m->str_ = ly_scm2string ($2);
988 Mark_req *m = new Mark_req;
989 m->str_ = to_str ($2);
992 | TIME_T unsigned '/' unsigned {
993 Time_signature_change_req *m = new Time_signature_change_req;
999 Break_req * b = new Break_req;
1000 b->penalty_f_ = $2 / 100.0;
1001 b->set_spot (THIS->here_input ());
1004 | SKIP duration_length {
1005 Skip_req * skip_p = new Skip_req;
1006 skip_p->duration_ = *$2;
1014 $$ = new Clef_change_req (ly_scm2string ($2));
1017 /* UGH. optional. */
1018 | KEY NOTENAME_PITCH optional_modality {
1019 Key_change_req *key_p= new Key_change_req;
1020 key_p->key_.pitch_arr_.push (*$2);
1021 key_p->key_.ordinary_key_b_ = true;
1022 key_p->key_.modality_i_ = $3;
1026 | KEYSIGNATURE pitch_list {
1027 Key_change_req *key_p= new Key_change_req;
1028 key_p->key_.pitch_arr_ = *$2;
1029 key_p->key_.ordinary_key_b_ = false;
1037 $$ = new Link_array<Request>;
1039 | post_requests post_request {
1040 $2->set_spot (THIS->here_input ());
1052 request_that_take_dir:
1055 | script_abbreviation {
1056 Identifier*i = THIS->lexer_p_->lookup_identifier ("dash-" + ly_scm2string ($1));
1057 Articulation_req *a = new Articulation_req;
1058 a->articulation_str_ = *i->access_content_String (false);
1064 script_dir request_that_take_dir {
1065 if (Script_req * gs = dynamic_cast<Script_req*> ($2))
1066 gs->dir_ = Direction ($1);
1068 $2->warning (_ ("Can't specify direction for this request"));
1074 REQUEST_IDENTIFIER {
1075 $$ = (Request*)$1->access_content_Request (true);
1076 $$->set_spot (THIS->here_input ());
1078 | TEXTSCRIPT STRING STRING {
1079 Text_script_req *ts_p = new Text_script_req;
1080 ts_p-> text_str_ = ly_scm2string ($2);
1081 ts_p-> style_str_ = ly_scm2string ($3);
1082 ts_p->set_spot (THIS->here_input ());
1086 | SPANREQUEST int STRING {
1087 Span_req * sp_p = new Span_req;
1088 sp_p-> span_dir_ = Direction($2);
1089 sp_p->span_type_str_ = ly_scm2string ($3);
1090 sp_p->set_spot (THIS->here_input ());
1094 Tremolo_req* a = new Tremolo_req;
1095 a->set_spot (THIS->here_input ());
1100 Articulation_req * a = new Articulation_req;
1101 a->articulation_str_ = ly_scm2string ($2);
1102 a->set_spot (THIS->here_input ());
1135 steno_musical_pitch:
1139 | NOTENAME_PITCH sup_quotes {
1141 $$->octave_i_ += $2;
1143 | NOTENAME_PITCH sub_quotes {
1145 $$->octave_i_ += - $2;
1153 | TONICNAME_PITCH sup_quotes {
1155 $$->octave_i_ += $2;
1157 | TONICNAME_PITCH sub_quotes {
1159 $$->octave_i_ += - $2;
1163 explicit_musical_pitch:
1164 MUSICAL_PITCH '{' int_list '}' {/* ugh */
1165 Array<int> &a = *$3;
1167 $$ = new Musical_pitch;
1168 $$->octave_i_ = a[0];
1169 $$->notename_i_ = a[1];
1170 $$->accidental_i_ = a[2];
1176 steno_musical_pitch {
1179 | explicit_musical_pitch {
1185 DURATION '{' int_list '}' {
1187 Array<int> &a = *$3;
1190 $$-> durlog_i_ = a[0];
1191 $$-> dots_i_ = a[1];
1199 if (!THIS->lexer_p_->lyric_state_b ())
1200 THIS->parser_error (_ ("Have to be in Lyric mode for lyrics"));
1201 $$ = new Extender_req;
1207 if (!THIS->lexer_p_->lyric_state_b ())
1208 THIS->parser_error (_ ("Have to be in Lyric mode for lyrics"));
1209 $$ = new Hyphen_req;
1214 close_request_parens {
1216 dynamic_cast<Span_req*> ($$)->span_dir_ = START;
1219 close_request_parens:
1221 Span_req* s= new Span_req;
1223 s->span_type_str_ = "slur";
1226 Span_req*s =new Span_req;
1228 s->span_type_str_ = "crescendo";
1231 Span_req*s =new Span_req;
1233 s->span_type_str_ = "decrescendo";
1239 open_request_parens {
1241 dynamic_cast<Span_req*> ($$)->span_dir_ = STOP;
1245 open_request_parens:
1247 Span_req *s = new Span_req;
1248 s->span_type_str_ = "crescendo";
1252 Span_req* s= new Span_req;
1254 s->span_type_str_ = "slur";
1260 Text_script_req *t = new Text_script_req;
1262 t->text_str_ = ly_scm2string ($1);
1264 $$->set_spot (THIS->here_input ());
1267 Text_script_req* t = new Text_script_req;
1269 t->text_str_ = to_str ($1);
1270 t->style_str_ = "finger";
1271 $$->set_spot (THIS->here_input ());
1275 script_abbreviation:
1277 $$ = gh_str02scm ("hat");
1280 $$ = gh_str02scm("plus");
1283 $$ = gh_str02scm ("dash");
1286 $$ = gh_str02scm ("bar");
1289 $$ = gh_str02scm ("larger");
1292 $$ = gh_str02scm ("dot");
1300 | '-' { $$ = CENTER; }
1305 $$ = new Link_array<Request>;
1307 | pre_requests open_request {
1312 absolute_musical_pitch:
1313 steno_musical_pitch {
1322 | duration_length '*' unsigned {
1323 $$->tuplet_iso_i_ *= $3;
1325 | duration_length '/' unsigned {
1326 $$->tuplet_type_i_ *= $3;
1330 entered_notemode_duration:
1332 THIS->set_last_duration ($1);
1336 optional_notemode_duration:
1338 $$ = new Duration (THIS->default_duration_);
1340 | entered_notemode_duration {
1348 if (!is_duration_b ($1))
1349 THIS->parser_error (_f ("not a duration: %d", $1));
1351 $$->durlog_i_ = intlog2 ($1);
1354 | DURATION_IDENTIFIER {
1355 $$ = $1->access_content_Duration (true);
1357 | steno_duration '.' {
1368 if (!is_duration_b ($2))
1369 THIS->parser_error (_f ("not a duration: %d", $2));
1371 THIS->parser_error (_ ("Can't abbreviate"));
1378 musical_pitch exclamations questions optional_notemode_duration {
1379 if (!THIS->lexer_p_->note_state_b ())
1380 THIS->parser_error (_ ("Have to be in Note mode for notes"));
1383 Note_req *n = new Note_req;
1387 if (THIS->abbrev_beam_type_i_)
1389 if (n->duration_.plet_b ())
1390 THIS->parser_error (_ ("Can't abbreviate tuplet"));
1392 n->duration_.set_plet (1, 2);
1394 n->cautionary_b_ = $3 % 2;
1395 n->forceacc_b_ = $2 % 2 || n->cautionary_b_;
1397 Simultaneous_music*v = new Request_chord;
1398 v->set_spot ($1->spot ());
1399 n->set_spot ($1->spot ());
1409 | RESTNAME optional_notemode_duration {
1410 Simultaneous_music* velt_p = new Request_chord;
1411 velt_p->set_spot (THIS->here_input());
1413 if (ly_scm2string ($1) =="s")
1415 Skip_req * skip_p = new Skip_req;
1416 skip_p->duration_ = *$2;
1418 skip_p->set_spot (THIS->here_input());
1419 velt_p->add_music (skip_p);
1423 Rest_req * rest_req_p = new Rest_req;
1424 rest_req_p->duration_ = *$2;
1425 rest_req_p->set_spot (THIS->here_input());
1427 velt_p->add_music (rest_req_p);
1433 | MEASURES optional_notemode_duration {
1434 Skip_req * sk = new Skip_req;
1435 sk->duration_ = *$2;
1436 Music_list * ms = new Music_list;
1437 Request_chord * rqc1 = new Request_chord;
1438 Request_chord * rqc2 = new Request_chord;
1439 Request_chord * rqc3 = new Request_chord;
1441 Span_req *sp1 = new Span_req;
1442 Span_req *sp2 = new Span_req;
1443 sp1-> span_dir_ = START;
1444 sp2-> span_dir_ = STOP;
1445 sp1->span_type_str_ = sp2->span_type_str_ = "rest";
1446 rqc1->add_music (sp1);
1447 rqc2->add_music (sk);
1448 rqc3->add_music (sp2);
1450 ms->add_music (rqc1);
1451 ms->add_music (rqc2);
1452 ms->add_music (rqc3);
1454 $$ = new Sequential_music (ms);
1456 | STRING optional_notemode_duration {
1457 if (!THIS->lexer_p_->lyric_state_b ())
1458 THIS->parser_error (_ ("Have to be in Lyric mode for lyrics"));
1459 Simultaneous_music* velt_p = new Request_chord;
1461 Lyric_req* lreq_p = new Lyric_req;
1462 lreq_p ->text_str_ = ly_scm2string ($1);
1463 lreq_p->duration_ = *$2;
1464 lreq_p->set_spot (THIS->here_input());
1466 velt_p->add_music (lreq_p);
1473 if (!THIS->lexer_p_->chord_state_b ())
1474 THIS->parser_error (_ ("Have to be in Chord mode for chords"));
1480 steno_tonic_pitch optional_notemode_duration chord_additions chord_subtractions chord_inversion chord_bass {
1481 $$ = THIS->get_chord (*$1, $3, $4, $5, $6, *$2);
1486 $$ = new Array<Musical_pitch>;
1488 | CHORD_COLON chord_notes {
1497 | chord_notes '.' chord_step {
1505 $$ = new Array<Musical_pitch>;
1507 | CHORD_CARET chord_notes {
1517 | '/' steno_tonic_pitch {
1519 $$->set_spot (THIS->here_input ());
1527 | CHORD_BASS steno_tonic_pitch {
1529 $$->set_spot (THIS->here_input ());
1535 $$ = new Array<Musical_pitch>;
1538 | CHORDMODIFIER_PITCH {
1539 $$ = new Array<Musical_pitch>;
1542 | CHORDMODIFIER_PITCH chord_note { /* Ugh. */
1543 $$ = new Array<Musical_pitch>;
1551 $$ = new Musical_pitch;
1552 $$->notename_i_ = ($1 - 1) % 7;
1553 $$->octave_i_ = $1 > 7 ? 1 : 0;
1554 $$->accidental_i_ = 0;
1557 $$ = new Musical_pitch;
1558 $$->notename_i_ = ($1 - 1) % 7;
1559 $$->octave_i_ = $1 > 7 ? 1 : 0;
1560 $$->accidental_i_ = 1;
1562 | unsigned CHORD_MINUS {
1563 $$ = new Musical_pitch;
1564 $$->notename_i_ = ($1 - 1) % 7;
1565 $$->octave_i_ = $1 > 7 ? 1 : 0;
1566 $$->accidental_i_ = -1;
1574 $$ = new Array<Musical_pitch>;
1576 | pitch_list musical_pitch {
1609 $$ = *$1->access_content_int (false);
1618 | STRING_IDENTIFIER {
1619 $$ = ly_str02scm ($1->access_content_String (true)->ch_C ());
1621 | string '+' string {
1622 $$ = scm_string_append (scm_listify ($1, $3, SCM_UNDEFINED));
1629 | exclamations '!' { $$ ++; }
1634 | questions '?' { $$ ++; }
1644 My_lily_parser::set_yydebug (bool b)
1651 My_lily_parser::do_yyparse ()
1653 yyparse ((void*)this);