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
183 %token COMMANDSPANREQUEST
193 %token E_CHAR E_EXCLAMATION E_SMALLER E_BIGGER
194 %token CHORD_BASS CHORD_COLON CHORD_MINUS CHORD_CARET
196 %type <i> exclamations questions
198 %token <pitch> NOTENAME_PITCH
199 %token <pitch> TONICNAME_PITCH
200 %token <pitch> CHORDMODIFIER_PITCH
201 %token <id> DURATION_IDENTIFIER
202 %token <id> IDENTIFIER
203 %token <id> NOTENAME_TABLE_IDENTIFIER
204 %token <id> MUSIC_IDENTIFIER
205 %token <id> REQUEST_IDENTIFIER
206 %token <id> REAL_IDENTIFIER
207 %token <id> STRING_IDENTIFIER
208 %token <id> TRANS_IDENTIFIER
209 %token <id> INT_IDENTIFIER
210 %token <id> SCORE_IDENTIFIER
211 %token <id> MIDI_IDENTIFIER
212 %token <id> PAPER_IDENTIFIER
214 %token <scm> DURATION RESTNAME
220 %type <outputdef> output_def
221 %type <scope> mudela_header mudela_header_body
222 %type <request> open_request_parens close_request_parens open_request close_request
223 %type <request> request_with_dir request_that_take_dir verbose_request
224 %type <i> sub_quotes sup_quotes
225 %type <music> simple_element request_chord command_element Simple_music Composite_music
226 %type <music> Alternative_music Repeated_music
227 %type <i> abbrev_type
228 %type <i> int unsigned
230 %type <i> optional_modality
231 %type <id> identifier_init
232 %type <duration> steno_duration optional_notemode_duration
233 %type <duration> entered_notemode_duration explicit_duration
234 %type <intvec> int_list
235 %type <reqvec> pre_requests post_requests
236 %type <request> gen_text_def
237 %type <pitch> explicit_musical_pitch steno_musical_pitch musical_pitch absolute_musical_pitch
238 %type <pitch> steno_tonic_pitch
240 %type <pitch_arr> pitch_list
242 %type <pitch_arr> chord_additions chord_subtractions chord_notes chord_step
243 %type <pitch> chord_note chord_inversion chord_bass
244 %type <midi> midi_block midi_body
245 %type <duration> duration_length
247 %type <scm> embedded_scm scalar
248 %type <music> Music Sequential_music Simultaneous_music Music_sequence
249 %type <music> relative_music re_rhythmed_music
250 %type <music> property_def translator_change
251 %type <music_list> Music_list
252 %type <paper> paper_block paper_def_body
253 %type <real> real real_with_dimension
254 %type <request> abbrev_command_req
255 %type <request> post_request
256 %type <request> command_req verbose_command_req
257 %type <request> extender_req
258 %type <request> hyphen_req
260 %type <score> score_block score_body
262 %type <scm> script_abbreviation
263 %type <trans> translator_spec_block translator_spec_body
264 %type <tempo> tempo_request
265 %type <notenametab> notenames_body notenames_block chordmodifiers_block
276 | mudela toplevel_expression {}
277 | mudela assignment { }
280 THIS->error_level_i_ =1;
286 THIS->lexer_p_->set_notename_table ($1);
288 | chordmodifiers_block {
289 THIS->lexer_p_->set_chordmodifier_table ($1);
292 delete header_global_p;
293 header_global_p = $1;
296 score_global_array.push ($1);
299 Identifier * id = new
300 Paper_def_identifier ($1, PAPER_IDENTIFIER);
301 THIS->lexer_p_->set_identifier ("$defaultpaper", id)
304 Identifier * id = new
305 Midi_def_identifier ($1, MIDI_IDENTIFIER);
306 THIS->lexer_p_->set_identifier ("$defaultmidi", id)
318 chordmodifiers_block:
319 CHORDMODIFIERS '{' notenames_body '}' { $$ = $3; }
324 NOTENAMES '{' notenames_body '}' { $$ = $3; }
331 $$ = new Notename_table;
333 | NOTENAME_TABLE_IDENTIFIER {
334 $$ = $1-> access_content_Notename_table(true);
336 | notenames_body STRING '=' explicit_musical_pitch {
337 $$->add_note_name (ly_scm2string ($2), $4);
345 THIS->lexer_p_-> scope_l_arr_.push ($$);
347 | mudela_header_body assignment semicolon {
353 HEADER '{' mudela_header_body '}' {
355 THIS->lexer_p_-> scope_l_arr_.pop ();
365 THIS->remember_spot ();
367 /* cont */ '=' identifier_init {
368 THIS->lexer_p_->set_identifier (ly_scm2string ($1), $4);
369 $4->init_b_ = THIS->init_parse_b_;
370 $4->set_spot (THIS->pop_spot ());
378 $$ = new Score_identifier ($1, SCORE_IDENTIFIER);
381 | chordmodifiers_block {
382 $$ = new Notename_table_identifier ($1, NOTENAME_TABLE_IDENTIFIER);
385 $$ = new Notename_table_identifier ($1, NOTENAME_TABLE_IDENTIFIER);
388 $$ = new Paper_def_identifier ($1, PAPER_IDENTIFIER);
391 $$ = new Midi_def_identifier ($1, MIDI_IDENTIFIER);
394 | translator_spec_block {
395 $$ = new Translator_group_identifier ($1, TRANS_IDENTIFIER);
398 $$ = new Music_identifier ($1, MUSIC_IDENTIFIER);
402 $$ = new Request_identifier ($1, REQUEST_IDENTIFIER);
404 | explicit_duration {
405 $$ = new Duration_identifier ($1, DURATION_IDENTIFIER);
408 $$ = new Real_identifier (new Real ($1), REAL_IDENTIFIER);
411 $$ = new String_identifier (new String (ly_scm2string ($1)), STRING_IDENTIFIER);
414 $$ = new int_identifier (new int ($1), INT_IDENTIFIER);
418 translator_spec_block:
419 TRANSLATOR '{' translator_spec_body '}'
425 translator_spec_body:
427 $$ = $1->access_content_Translator_group (true);
428 $$-> set_spot (THIS->here_input ());
430 | TYPE STRING semicolon {
431 Translator* t = get_translator_l (ly_scm2string ($2));
432 Translator_group * tg = dynamic_cast<Translator_group*> (t);
435 THIS->parser_error (_("Need a translator group for a context"));
437 tg = dynamic_cast<Translator_group*> (t->clone ());
438 tg->set_spot (THIS->here_input ());
441 | translator_spec_body STRING '=' embedded_scm {
442 Translator_group* tg = dynamic_cast<Translator_group*> ($$);
443 tg->set_property (ly_scm2string ($2), $4);
445 | translator_spec_body STRING '=' identifier_init semicolon {
447 String_identifier *s = dynamic_cast<String_identifier*> (id);
448 Real_identifier *r= dynamic_cast<Real_identifier*>(id);
449 int_identifier *i = dynamic_cast<int_identifier*> (id);
452 if (s) v = ly_str02scm (s->access_content_String (false)->ch_C());
453 if (i) v = gh_int2scm (*i->access_content_int (false));
454 if (r) v = gh_double2scm (*r->access_content_Real (false));
456 THIS->parser_error (_("Wrong type for property value"));
460 Translator_group* tg = dynamic_cast<Translator_group*> ($$);
462 tg->set_property (ly_scm2string ($2), v);
464 | translator_spec_body NAME STRING semicolon {
465 $$->type_str_ = ly_scm2string ($3);
467 | translator_spec_body CONSISTS STRING semicolon {
468 dynamic_cast<Translator_group*> ($$)-> set_element (ly_scm2string ($3), true);
470 | translator_spec_body CONSISTSEND STRING semicolon {
471 dynamic_cast<Translator_group*> ($$)-> set_element (ly_scm2string ($3), true);
473 | translator_spec_body ACCEPTS STRING semicolon {
474 dynamic_cast<Translator_group*> ($$)-> set_acceptor (ly_scm2string ($3), true);
476 | translator_spec_body REMOVE STRING semicolon {
477 dynamic_cast<Translator_group*> ($$)-> set_element (ly_scm2string ($3), false);
487 /*cont*/ '{' score_body '}' {
489 if (!$$->def_p_arr_.size ())
490 $$->add_output (THIS->default_paper_p ());
496 $$->set_spot (THIS->here_input ());
499 $$ = $1->access_content_Score (true);
501 | score_body mudela_header {
506 $2->warning (_ ("More than one music block"));
509 | score_body output_def {
531 PAPER '{' paper_def_body '}' {
533 THIS-> lexer_p_->scope_l_arr_.pop ();
540 Paper_def *p = THIS->default_paper_p ();
541 THIS-> lexer_p_-> scope_l_arr_.push (p->scope_p_);
545 Paper_def *p = $1->access_content_Paper_def (true);
546 THIS->lexer_p_->scope_l_arr_.push (p->scope_p_);
549 | paper_def_body int '=' FONT STRING { // ugh, what a syntax
550 Lookup * l = new Lookup;
551 l->font_name_ = ly_scm2string ($5);
552 $$->set_lookup ($2, l);
554 | paper_def_body assignment semicolon {
557 | paper_def_body SCM_T '=' SCM_T {
558 if (!gh_symbol_p ($2))
559 THIS->parser_error ("expect a symbol as lvalue");
561 $$->default_properties_[$2] = $4;
563 | paper_def_body SCM_T '=' real semicolon {
564 if (!gh_symbol_p ($2))
565 THIS->parser_error ("expect a symbol as lvalue");
567 $$->default_properties_[$2] = gh_double2scm ($4);
569 | paper_def_body translator_spec_block {
570 $$->assign_translator ($2);
572 | paper_def_body error {
601 | real_with_dimension
603 $$= *$1->access_content_Real (false);
605 | '-' real %prec UNARY_MINUS {
632 THIS-> lexer_p_-> scope_l_arr_.pop();
636 midi_body: /* empty */ {
637 Midi_def * p =THIS->default_midi_p ();
639 THIS->lexer_p_->scope_l_arr_.push (p->scope_p_);
642 Midi_def * p =$1-> access_content_Midi_def (true);
644 THIS->lexer_p_->scope_l_arr_.push (p->scope_p_);
646 | midi_body assignment semicolon {
649 | midi_body translator_spec_block {
650 $$-> assign_translator ($2);
652 | midi_body tempo_request semicolon {
653 $$->set_tempo ($2->dur_.length_mom (), $2->metronome_i_);
662 TEMPO steno_duration '=' unsigned {
666 $$-> metronome_i_ = $4;
670 Music_list: /* empty */ {
672 $$->set_spot (THIS->here_input ());
691 | ALTERNATIVE Music_sequence {
693 $2->set_spot (THIS->here_input ());
701 REPEAT STRING unsigned Music Alternative_music
703 Music_sequence* m = dynamic_cast <Music_sequence*> ($5);
704 if (m && $3 < m->length_i ())
705 $5->warning (_ ("More alternatives than repeats. Junking excess alternatives."));
707 Repeated_music * r = new Repeated_music ($4, $3 >? 1, m);
709 r->fold_b_ = (ly_scm2string ($2) == "fold");
710 r->volta_fold_b_ = (ly_scm2string ($2) == "volta");
711 r->set_spot ($4->spot ());
715 Music_sequence: '{' Music_list '}' {
716 $$ = new Music_sequence ($2);
717 $$->set_spot ($2->spot ());
722 SEQUENTIAL '{' Music_list '}' {
723 $$ = new Sequential_music ($3);
724 $$->set_spot ($3->spot ());
726 | '{' Music_list '}' {
727 $$ = new Sequential_music ($2);
728 $$->set_spot ($2->spot ());
733 SIMULTANEOUS '{' Music_list '}'{
734 $$ = new Simultaneous_music ($3);
735 $$->set_spot ($3->spot ());
737 | '<' Music_list '>' {
738 $$ = new Simultaneous_music ($2);
739 $$->set_spot ($2->spot ());
744 request_chord { $$ = $1; }
745 | MUSIC_IDENTIFIER { $$ = $1->access_content_Music (true); }
748 | Simple_music '*' unsigned '/' unsigned {
750 $$->compress (Moment($3, $5 ));
752 | Simple_music '*' unsigned {
754 $$->compress (Moment ($3, 1));
760 CONTEXT STRING Music {
761 Context_specced_music *csm = new Context_specced_music ($3);
763 csm->translator_type_str_ = ly_scm2string ($2);
764 csm->translator_id_str_ = "";
769 | AUTOCHANGE STRING Music {
770 Auto_change_music * chm = new Auto_change_music (ly_scm2string ($2), $3);
773 chm->set_spot ($3->spot ());
776 $$ = new Grace_music ($2);
778 | CONTEXT STRING '=' STRING Music {
779 Context_specced_music *csm = new Context_specced_music ($5);
781 csm->translator_type_str_ = ly_scm2string ($2);
782 csm->translator_id_str_ = ly_scm2string ($4);
787 THIS->remember_spot ();
790 unsigned '/' unsigned Music
793 $$ = new Time_scaled_music ($3, $5, $6);
794 $$->set_spot (THIS->pop_spot ());
796 | Repeated_music { $$ = $1; }
797 | Simultaneous_music { $$ = $1; }
798 | Sequential_music { $$ = $1; }
799 | TRANSPOSE musical_pitch Music {
800 $$ = new Transposed_music ($3, *$2);
803 | TRANSPOSE steno_tonic_pitch Music {
804 $$ = new Transposed_music ($3, *$2);
808 { THIS->lexer_p_->push_note_state (); }
811 THIS->lexer_p_->pop_state ();
814 { THIS->lexer_p_->push_chord_state (); }
818 THIS->lexer_p_->pop_state ();
821 { THIS->lexer_p_->push_lyric_state (); }
825 THIS->lexer_p_->pop_state ();
827 | relative_music { $$ = $1; }
828 | re_rhythmed_music { $$ = $1; }
832 RELATIVE absolute_musical_pitch Music {
833 $$ = new Relative_octave_music ($3, *$2);
839 ADDLYRICS Music Music {
840 Lyric_combine_music * l = new Lyric_combine_music ($2, $3);
846 TRANSLATOR STRING '=' STRING {
847 Change_translator * t = new Change_translator;
848 t-> change_to_type_str_ = ly_scm2string ($2);
849 t-> change_to_id_str_ = ly_scm2string ($4);
852 $$->set_spot (THIS->here_input ());
857 PROPERTY STRING '.' STRING '=' scalar {
858 Translation_property *t = new Translation_property;
860 t->var_str_ = ly_scm2string ($4);
863 Context_specced_music *csm = new Context_specced_music (t);
865 $$->set_spot (THIS->here_input ());
867 csm-> translator_type_str_ = ly_scm2string ($2);
873 | int { $$ = gh_int2scm ($1); }
874 | embedded_scm { $$ = $1; }
879 pre_requests simple_element post_requests {
880 Music_sequence *l = dynamic_cast<Music_sequence*>($2);
882 for (int i=0; i < $1->size(); i++)
883 l->add_music ($1->elem(i));
884 for (int i=0; i < $3->size(); i++)
885 l->add_music ($3->elem(i));
888 programming_error ("Need Sequence to add music to");
897 $$ = new Request_chord;
898 $$-> set_spot (THIS->here_input ());
899 $1-> set_spot (THIS->here_input ());
900 ((Simultaneous_music*)$$) ->add_music ($1);//ugh
902 | PARTIAL duration_length ';' {
903 Translation_property * p = new Translation_property;
904 p->var_str_ = "measurePosition";
905 p->value_ = (new Moment (-$2->length_mom ()))->smobify_self ();
907 Context_specced_music * sp = new Context_specced_music (p);
909 sp-> translator_type_str_ = "Score";
915 | verbose_command_req semicolon { $$ = $1; }
926 $$ = new Barcheck_req;
932 Span_req*b= new Span_req;
933 b->span_dir_ = START;
934 b->span_type_str_ = "beam";
938 if (!is_duration_b ($3))
939 THIS->parser_error (_f ("not a duration: %d", $3));
941 THIS->parser_error (_ ("Can't abbreviate"));
943 THIS->set_abbrev_beam ($3);
945 Chord_tremolo_req* a = new Chord_tremolo_req;
946 a->span_dir_ = START;
947 a->type_i_ = THIS->abbrev_beam_type_i_;
951 if (!THIS->abbrev_beam_type_i_)
953 Span_req*b= new Span_req;
955 b->span_type_str_ = "beam";
960 Chord_tremolo_req* a = new Chord_tremolo_req;
962 a->type_i_ = THIS->abbrev_beam_type_i_;
963 THIS->set_abbrev_beam (0);
968 $$ = new Breathing_sign_req;
976 $$ = new Bar_req (ly_scm2string ($2));
978 | COMMANDSPANREQUEST int STRING {
979 Span_req * sp_p = new Span_req;
980 sp_p-> span_dir_ = Direction($2);
981 sp_p->span_type_str_ = ly_scm2string ($3);
982 sp_p->set_spot (THIS->here_input ());
986 Mark_req *m = new Mark_req;
987 m->str_ = ly_scm2string ($2);
992 Mark_req *m = new Mark_req;
993 m->str_ = to_str ($2);
996 | TIME_T unsigned '/' unsigned {
997 Time_signature_change_req *m = new Time_signature_change_req;
1003 Break_req * b = new Break_req;
1004 b->penalty_f_ = $2 / 100.0;
1005 b->set_spot (THIS->here_input ());
1008 | SKIP duration_length {
1009 Skip_req * skip_p = new Skip_req;
1010 skip_p->duration_ = *$2;
1018 $$ = new Clef_change_req (ly_scm2string ($2));
1021 /* UGH. optional. */
1022 | KEY NOTENAME_PITCH optional_modality {
1023 Key_change_req *key_p= new Key_change_req;
1024 key_p->key_.pitch_arr_.push (*$2);
1025 key_p->key_.ordinary_key_b_ = true;
1026 key_p->key_.modality_i_ = $3;
1030 | KEYSIGNATURE pitch_list {
1031 Key_change_req *key_p= new Key_change_req;
1032 key_p->key_.pitch_arr_ = *$2;
1033 key_p->key_.ordinary_key_b_ = false;
1041 $$ = new Link_array<Request>;
1043 | post_requests post_request {
1044 $2->set_spot (THIS->here_input ());
1056 request_that_take_dir:
1059 | script_abbreviation {
1060 Identifier*i = THIS->lexer_p_->lookup_identifier ("dash-" + ly_scm2string ($1));
1061 Articulation_req *a = new Articulation_req;
1062 a->articulation_str_ = *i->access_content_String (false);
1068 script_dir request_that_take_dir {
1069 if (Script_req * gs = dynamic_cast<Script_req*> ($2))
1070 gs->dir_ = Direction ($1);
1072 $2->warning (_ ("Can't specify direction for this request"));
1078 REQUEST_IDENTIFIER {
1079 $$ = (Request*)$1->access_content_Request (true);
1080 $$->set_spot (THIS->here_input ());
1082 | TEXTSCRIPT STRING STRING {
1083 Text_script_req *ts_p = new Text_script_req;
1084 ts_p-> text_str_ = ly_scm2string ($2);
1085 ts_p-> style_str_ = ly_scm2string ($3);
1086 ts_p->set_spot (THIS->here_input ());
1090 | SPANREQUEST int STRING {
1091 Span_req * sp_p = new Span_req;
1092 sp_p-> span_dir_ = Direction($2);
1093 sp_p->span_type_str_ = ly_scm2string ($3);
1094 sp_p->set_spot (THIS->here_input ());
1098 Tremolo_req* a = new Tremolo_req;
1099 a->set_spot (THIS->here_input ());
1104 Articulation_req * a = new Articulation_req;
1105 a->articulation_str_ = ly_scm2string ($2);
1106 a->set_spot (THIS->here_input ());
1139 steno_musical_pitch:
1143 | NOTENAME_PITCH sup_quotes {
1145 $$->octave_i_ += $2;
1147 | NOTENAME_PITCH sub_quotes {
1149 $$->octave_i_ += - $2;
1157 | TONICNAME_PITCH sup_quotes {
1159 $$->octave_i_ += $2;
1161 | TONICNAME_PITCH sub_quotes {
1163 $$->octave_i_ += - $2;
1167 explicit_musical_pitch:
1168 MUSICAL_PITCH '{' int_list '}' {/* ugh */
1169 Array<int> &a = *$3;
1171 $$ = new Musical_pitch;
1172 $$->octave_i_ = a[0];
1173 $$->notename_i_ = a[1];
1174 $$->accidental_i_ = a[2];
1180 steno_musical_pitch {
1183 | explicit_musical_pitch {
1189 DURATION '{' int_list '}' {
1191 Array<int> &a = *$3;
1194 $$-> durlog_i_ = a[0];
1195 $$-> dots_i_ = a[1];
1203 if (!THIS->lexer_p_->lyric_state_b ())
1204 THIS->parser_error (_ ("Have to be in Lyric mode for lyrics"));
1205 $$ = new Extender_req;
1211 if (!THIS->lexer_p_->lyric_state_b ())
1212 THIS->parser_error (_ ("Have to be in Lyric mode for lyrics"));
1213 $$ = new Hyphen_req;
1218 close_request_parens {
1220 dynamic_cast<Span_req*> ($$)->span_dir_ = START;
1223 close_request_parens:
1225 Span_req* s= new Span_req;
1227 s->span_type_str_ = "slur";
1230 Span_req*s =new Span_req;
1232 s->span_type_str_ = "crescendo";
1235 Span_req*s =new Span_req;
1237 s->span_type_str_ = "decrescendo";
1243 open_request_parens {
1245 dynamic_cast<Span_req*> ($$)->span_dir_ = STOP;
1249 open_request_parens:
1251 Span_req *s = new Span_req;
1252 s->span_type_str_ = "crescendo";
1256 Span_req* s= new Span_req;
1258 s->span_type_str_ = "slur";
1264 Text_script_req *t = new Text_script_req;
1266 t->text_str_ = ly_scm2string ($1);
1268 $$->set_spot (THIS->here_input ());
1271 Text_script_req* t = new Text_script_req;
1273 t->text_str_ = to_str ($1);
1274 t->style_str_ = "finger";
1275 $$->set_spot (THIS->here_input ());
1279 script_abbreviation:
1281 $$ = gh_str02scm ("hat");
1284 $$ = gh_str02scm("plus");
1287 $$ = gh_str02scm ("dash");
1290 $$ = gh_str02scm ("bar");
1293 $$ = gh_str02scm ("larger");
1296 $$ = gh_str02scm ("dot");
1304 | '-' { $$ = CENTER; }
1309 $$ = new Link_array<Request>;
1311 | pre_requests open_request {
1316 absolute_musical_pitch:
1317 steno_musical_pitch {
1326 | duration_length '*' unsigned {
1327 $$->tuplet_iso_i_ *= $3;
1329 | duration_length '/' unsigned {
1330 $$->tuplet_type_i_ *= $3;
1334 entered_notemode_duration:
1336 THIS->set_last_duration ($1);
1340 optional_notemode_duration:
1342 $$ = new Duration (THIS->default_duration_);
1344 | entered_notemode_duration {
1352 if (!is_duration_b ($1))
1353 THIS->parser_error (_f ("not a duration: %d", $1));
1355 $$->durlog_i_ = intlog2 ($1);
1358 | DURATION_IDENTIFIER {
1359 $$ = $1->access_content_Duration (true);
1361 | steno_duration '.' {
1372 if (!is_duration_b ($2))
1373 THIS->parser_error (_f ("not a duration: %d", $2));
1375 THIS->parser_error (_ ("Can't abbreviate"));
1382 musical_pitch exclamations questions optional_notemode_duration {
1383 if (!THIS->lexer_p_->note_state_b ())
1384 THIS->parser_error (_ ("Have to be in Note mode for notes"));
1387 Note_req *n = new Note_req;
1391 if (THIS->abbrev_beam_type_i_)
1393 if (n->duration_.plet_b ())
1394 THIS->parser_error (_ ("Can't abbreviate tuplet"));
1396 n->duration_.set_plet (1, 2);
1398 n->cautionary_b_ = $3 % 2;
1399 n->forceacc_b_ = $2 % 2 || n->cautionary_b_;
1401 Simultaneous_music*v = new Request_chord;
1402 v->set_spot ($1->spot ());
1403 n->set_spot ($1->spot ());
1413 | RESTNAME optional_notemode_duration {
1414 Simultaneous_music* velt_p = new Request_chord;
1415 velt_p->set_spot (THIS->here_input());
1417 if (ly_scm2string ($1) =="s")
1419 Skip_req * skip_p = new Skip_req;
1420 skip_p->duration_ = *$2;
1422 skip_p->set_spot (THIS->here_input());
1423 velt_p->add_music (skip_p);
1427 Rest_req * rest_req_p = new Rest_req;
1428 rest_req_p->duration_ = *$2;
1429 rest_req_p->set_spot (THIS->here_input());
1431 velt_p->add_music (rest_req_p);
1437 | MEASURES optional_notemode_duration {
1438 Skip_req * sk = new Skip_req;
1439 sk->duration_ = *$2;
1440 Music_list * ms = new Music_list;
1441 Request_chord * rqc1 = new Request_chord;
1442 Request_chord * rqc2 = new Request_chord;
1443 Request_chord * rqc3 = new Request_chord;
1445 Span_req *sp1 = new Span_req;
1446 Span_req *sp2 = new Span_req;
1447 sp1-> span_dir_ = START;
1448 sp2-> span_dir_ = STOP;
1449 sp1->span_type_str_ = sp2->span_type_str_ = "rest";
1450 rqc1->add_music (sp1);
1451 rqc2->add_music (sk);
1452 rqc3->add_music (sp2);
1454 ms->add_music (rqc1);
1455 ms->add_music (rqc2);
1456 ms->add_music (rqc3);
1458 $$ = new Sequential_music (ms);
1460 | STRING optional_notemode_duration {
1461 if (!THIS->lexer_p_->lyric_state_b ())
1462 THIS->parser_error (_ ("Have to be in Lyric mode for lyrics"));
1463 Simultaneous_music* velt_p = new Request_chord;
1465 Lyric_req* lreq_p = new Lyric_req;
1466 lreq_p ->text_str_ = ly_scm2string ($1);
1467 lreq_p->duration_ = *$2;
1468 lreq_p->set_spot (THIS->here_input());
1470 velt_p->add_music (lreq_p);
1477 if (!THIS->lexer_p_->chord_state_b ())
1478 THIS->parser_error (_ ("Have to be in Chord mode for chords"));
1484 steno_tonic_pitch optional_notemode_duration chord_additions chord_subtractions chord_inversion chord_bass {
1485 $$ = THIS->get_chord (*$1, $3, $4, $5, $6, *$2);
1490 $$ = new Array<Musical_pitch>;
1492 | CHORD_COLON chord_notes {
1501 | chord_notes '.' chord_step {
1509 $$ = new Array<Musical_pitch>;
1511 | CHORD_CARET chord_notes {
1521 | '/' steno_tonic_pitch {
1523 $$->set_spot (THIS->here_input ());
1531 | CHORD_BASS steno_tonic_pitch {
1533 $$->set_spot (THIS->here_input ());
1539 $$ = new Array<Musical_pitch>;
1542 | CHORDMODIFIER_PITCH {
1543 $$ = new Array<Musical_pitch>;
1546 | CHORDMODIFIER_PITCH chord_note { /* Ugh. */
1547 $$ = new Array<Musical_pitch>;
1555 $$ = new Musical_pitch;
1556 $$->notename_i_ = ($1 - 1) % 7;
1557 $$->octave_i_ = $1 > 7 ? 1 : 0;
1558 $$->accidental_i_ = 0;
1561 $$ = new Musical_pitch;
1562 $$->notename_i_ = ($1 - 1) % 7;
1563 $$->octave_i_ = $1 > 7 ? 1 : 0;
1564 $$->accidental_i_ = 1;
1566 | unsigned CHORD_MINUS {
1567 $$ = new Musical_pitch;
1568 $$->notename_i_ = ($1 - 1) % 7;
1569 $$->octave_i_ = $1 > 7 ? 1 : 0;
1570 $$->accidental_i_ = -1;
1578 $$ = new Array<Musical_pitch>;
1580 | pitch_list musical_pitch {
1613 $$ = *$1->access_content_int (false);
1622 | STRING_IDENTIFIER {
1623 $$ = ly_str02scm ($1->access_content_String (true)->ch_C ());
1625 | string '+' string {
1626 $$ = scm_string_append (scm_listify ($1, $3, SCM_UNDEFINED));
1633 | exclamations '!' { $$ ++; }
1638 | questions '?' { $$ ++; }
1648 My_lily_parser::set_yydebug (bool b)
1655 My_lily_parser::do_yyparse ()
1657 yyparse ((void*)this);