1 %{ // -*-Fundamental-*-
4 parser.yy -- Bison/C++ parser for lilypond
6 source file of the GNU LilyPond music typesetter
8 (c) 1997--2003 Han-Wen Nienhuys <hanwen@cs.uu.nl>
9 Jan Nieuwenhuizen <janneke@gnu.org>
13 Four shift/reduce problems:
17 "bar" -> String -> Lyric -> Music -> music-assignment
19 "bar" -> String -> string-assignment
29 \repeat .. \alternative
32 \repeat { \repeat .. \alternative }
36 \repeat { \repeat } \alternative
48 * The rules for who is protecting what are very shady. Uniformise
51 * There are too many lexical modes?
60 #include "scm-option.hh"
61 #include "translator-def.hh"
62 #include "lily-guile.hh"
64 #include "my-lily-lexer.hh"
65 #include "paper-def.hh"
66 #include "midi-def.hh"
68 #include "file-path.hh"
70 #include "dimensions.hh"
71 #include "my-lily-parser.hh"
73 #include "input-file-results.hh"
75 #include "lilypond-input-version.hh"
76 #include "scm-hash.hh"
77 #include "auto-change-iterator.hh"
78 #include "ly-modules.hh"
79 #include "music-sequence.hh"
80 #include "input-smob.hh"
82 #include "text-item.hh"
83 #include "music-list.hh"
85 #define MY_MAKE_MUSIC(x) make_music_by_name (ly_symbol2scm (x))
89 #define YYERROR_VERBOSE 1
91 My_lily_parser* my_lily_parser;
92 #define YYPARSE_PARAM my_lily_parser
93 #define YYLEX_PARAM my_lily_parser
95 ((My_lily_parser *) my_lily_parser)
97 #define yyerror THIS->parser_error
100 Add symbols to the TAGS field of a music object.
104 tag_music (Music*m, SCM tag, Input ip)
106 SCM tags = m->get_mus_property ("tags");
107 if (gh_symbol_p (tag))
108 tags = scm_cons (tag, tags);
109 else if (gh_list_p (tag))
110 tags = gh_append2 (tag, tags);
112 ip.warning (_("Tag must be symbol or list of symbols."));
114 m->set_mus_property ("tags", tags);
120 regular_identifier_b (SCM id)
122 String str = ly_scm2string (id);
123 char const *s = str.to_str0 () ;
128 v = v && isalpha (*s);
135 make_simple_markup (SCM a)
139 simple = scm_c_eval_string ("simple-markup");
141 return scm_list_n (simple, a, SCM_UNDEFINED);
146 is_duration_b (int t)
148 return t && t == 1 << intlog2 (t);
152 set_music_properties (Music *p, SCM a)
154 for (SCM k = a; gh_pair_p (k); k = ly_cdr (k))
156 p->internal_set_mus_property (ly_caar (k), ly_cdar (k));
161 make_chord_step (int step, int alter)
168 Pitch m((step -1) / 7 , (step - 1) % 7, alter);
169 return m.smobbed_copy ();
174 make_chord (SCM pitch, SCM dur, SCM modification_list)
176 static SCM chord_ctor;
178 chord_ctor= scm_c_eval_string ("construct-chord");
179 SCM ch= scm_call_3 (chord_ctor, pitch, dur, modification_list);
180 scm_gc_protect_object (ch);
185 Todo: actually also use apply iso. call too ...
188 ly_input_procedure_p (SCM x)
190 return gh_procedure_p (x)
191 || (gh_pair_p (x) && gh_procedure_p (gh_car (x)));
195 set_property_music (SCM sym, SCM value)
197 Music * p = MY_MAKE_MUSIC("PropertySet");
198 p->set_mus_property ("symbol", sym);
199 p->set_mus_property ("value", value);
205 /* We use SCMs to do strings, because it saves us the trouble of
206 deleting them. Let's hope that a stack overflow doesnt trigger a move
207 of the parse stack onto the heap. */
214 Music_output_def * outputdef;
221 yylex (YYSTYPE *s, void * v)
223 My_lily_parser *pars = (My_lily_parser*) v;
224 My_lily_lexer * lex = pars->lexer_;
226 lex->lexval = (void*) s;
227 lex->prepare_for_next_token();
228 return lex->yylex ();
247 %token CHORDMODIFIERS
252 %token COMMANDSPANREQUEST
260 %token FIGURES FIGURE_OPEN FIGURE_CLOSE
261 %token FIGURE_BRACKET_CLOSE FIGURE_BRACKET_OPEN
265 %token GROBDESCRIPTIONS
273 %token MULTI_MEASURE_REST
279 %token OVERRIDE SET REVERT
306 %token E_CHAR E_EXCLAMATION E_SMALLER E_BIGGER E_OPEN E_CLOSE
307 %token E_LEFTSQUARE E_RIGHTSQUARE E_TILDE
309 %token <i> E_UNSIGNED
310 %token CHORD_BASS CHORD_COLON CHORD_MINUS CHORD_CARET CHORD_SLASH
313 %type <i> exclamations questions dots optional_rest
315 %type <scm> grace_head
316 %type <scm> lyric_element
317 %type <scm> bass_number br_bass_figure bass_figure figure_list figure_spec
319 %token <scm> NOTENAME_PITCH
320 %token <scm> TONICNAME_PITCH
321 %token <scm> CHORDMODIFIER_PITCH
322 %token <scm> DURATION_IDENTIFIER
323 %token <scm> FRACTION
324 %token <id> IDENTIFIER
325 %token <scm> CHORDNAMES
327 %token <scm> CHORD_MODIFIER
329 %token <scm> SCORE_IDENTIFIER
330 %token <scm> MUSIC_OUTPUT_DEF_IDENTIFIER
331 %token <scm> NUMBER_IDENTIFIER
332 %token <scm> EVENT_IDENTIFIER
333 %token <scm> MUSIC_IDENTIFIER TRANSLATOR_IDENTIFIER
334 %token <scm> STRING_IDENTIFIER SCM_IDENTIFIER
335 %token <scm> RESTNAME
342 %token <scm> MARKUP_HEAD_MARKUP0
343 %token <scm> MARKUP_HEAD_MARKUP0_MARKUP1
344 %token <scm> MARKUP_HEAD_SCM0
345 %token <scm> MARKUP_HEAD_SCM0_MARKUP1
346 %token <scm> MARKUP_HEAD_SCM0_SCM1
347 %token <scm> MARKUP_HEAD_SCM0_SCM1_SCM2
348 %token <scm> MARKUP_HEAD_SCM0_SCM1_MARKUP2
350 %token <scm> MARKUP_IDENTIFIER MARKUP_HEAD_LIST0
351 %type <scm> markup markup_line markup_list markup_list_body full_markup
353 %type <outputdef> output_def
354 %type <scm> lilypond_header lilypond_header_body
355 %type <music> open_event close_event
356 %type <i> sub_quotes sup_quotes
357 %type <music> simple_element event_chord command_element Simple_music Composite_music
358 %type <music> Repeated_music
359 %type <scm> Alternative_music
360 %type <i> tremolo_type
361 %type <i> bare_int bare_unsigned
363 %type <scm> identifier_init
365 %type <music> note_chord_element chord_body chord_body_element
366 %type <scm> chord_body_elements
367 %type <scm> steno_duration optional_notemode_duration multiplied_duration
369 %type <scm> post_events
370 %type <music> gen_text_def direction_less_event direction_reqd_event
371 %type <scm> steno_pitch pitch absolute_pitch pitch_also_in_chords
372 %type <scm> steno_tonic_pitch
373 %type <scm> duration_length fraction
375 %type <scm> new_chord step_number chord_items chord_item chord_separator step_numbers
377 %type <scm> embedded_scm scalar
378 %type <music> Music Sequential_music Simultaneous_music
379 %type <music> relative_music re_rhythmed_music part_combined_music
380 %type <music> property_def translator_change simple_property_def
381 %type <scm> Music_list
382 %type <outputdef> music_output_def_body
383 %type <music> shorthand_command_req
384 %type <music> post_event tagged_post_event
385 %type <music> command_req verbose_command_req
386 %type <music> extender_req
387 %type <music> hyphen_req
388 %type <music> string_number_event
389 %type <scm> string bare_number number_expression number_term number_factor
390 %type <score> score_block score_body
392 %type <scm> translator_spec_block translator_spec_body
393 %type <music> tempo_event
394 %type <scm> notenames_body notenames_block chordmodifiers_block
395 %type <scm> script_abbreviation
401 /* We don't assign precedence to / and *, because we might need varied
402 prec levels in different prods */
408 lilypond: /* empty */
409 | lilypond toplevel_expression {}
410 | lilypond assignment { }
412 THIS->error_level_ = 1;
415 THIS->error_level_ = 1;
421 THIS->lexer_->pitchname_tab_ = $1;
423 | chordmodifiers_block {
424 THIS->lexer_->chordmodifier_tab_ = $1;
427 THIS->input_file_->header_ = $1;
432 SCM head = ly_module_p (sc->header_) ? sc->header_ : THIS->input_file_->header_.to_SCM ();
434 Path p = split_path (THIS->output_basename_);
435 int *c = &THIS->input_file_->score_count_;
438 p.base += "-" + to_string (*c);
442 SCM outname = scm_makfrom0str (p.to_string ().to_str0());
444 for (int i=0; i < sc->defs_.size (); i++)
445 default_rendering (sc->music_, sc->defs_[i]->self_scm(),head, outname);
447 if (sc->defs_.empty ())
449 Music_output_def *id =
450 unsmob_music_output_def (THIS->lexer_->lookup_identifier
453 id = id ? id->clone () : new Paper_def;
455 default_rendering (sc->music_, id->self_scm(), head, outname);
457 scm_gc_unprotect_object (id->self_scm ());
459 scm_gc_unprotect_object (sc->self_scm());
462 if (dynamic_cast<Paper_def*> ($1))
463 THIS->lexer_->set_identifier (scm_makfrom0str ("$defaultpaper"), $1->self_scm ());
464 else if (dynamic_cast<Midi_def*> ($1))
465 THIS->lexer_->set_identifier (scm_makfrom0str ("$defaultmidi"), $1->self_scm ());
475 chordmodifiers_block:
476 CHORDMODIFIERS notenames_body { $$ = $2; }
480 PITCHNAMES notenames_body { $$ = $2; }
485 int i = scm_ilength ($1);
487 SCM tab = scm_make_vector (gh_int2scm (i), SCM_EOL);
488 for (SCM s = $1; gh_pair_p (s); s = ly_cdr (s)) {
489 SCM pt = ly_cdar (s);
490 scm_hashq_set_x (tab, ly_caar (s), pt);
496 lilypond_header_body:
498 $$ = ly_make_anonymous_module ();
499 THIS->lexer_->add_scope ($$);
501 | lilypond_header_body assignment {
507 HEADER '{' lilypond_header_body '}' {
508 $$ = THIS->lexer_-> remove_scope();
520 /* cont */ '=' identifier_init {
523 Should find generic way of associating input with objects.
525 Input ip = THIS->pop_spot ();
527 if (! regular_identifier_b ($1))
529 ip.warning (_ ("Identifier should have alphabetic characters only"));
532 THIS->lexer_->set_identifier ($1, $4);
535 TODO: devise standard for protection in parser.
537 The parser stack lives on the C-stack, which means that
538 all objects can be unprotected as soon as they're here.
549 $$ = $1->self_scm ();
550 scm_gc_unprotect_object ($$);
556 $$ = $1->self_scm ();
557 scm_gc_unprotect_object ($$);
559 | translator_spec_block {
563 $$ = $1->self_scm ();
564 scm_gc_unprotect_object ($$);
567 $$ = $1->self_scm ();
568 scm_gc_unprotect_object ($$);
570 | number_expression {
581 translator_spec_block:
582 TRANSLATOR '{' translator_spec_body '}'
588 translator_spec_body:
590 $$ = Translator_def::make_scm ();
591 unsmob_translator_def ($$)->set_spot (THIS->here_input ());
593 | TRANSLATOR_IDENTIFIER {
595 unsmob_translator_def ($$)-> set_spot (THIS->here_input ());
597 | translator_spec_body TYPE STRING {
598 unsmob_translator_def ($$)->translator_group_type_ = $3;
600 | translator_spec_body DESCRIPTION string {
601 unsmob_translator_def ($$)->description_ = $3;
603 | translator_spec_body STRING '=' embedded_scm {
604 unsmob_translator_def ($$)->add_property_assign ($2, $4);
606 | translator_spec_body STRING OVERRIDE embedded_scm '=' embedded_scm {
607 unsmob_translator_def ($$)
608 ->add_push_property (scm_string_to_symbol ($2), $4, $6);
610 | translator_spec_body STRING SET embedded_scm '=' embedded_scm {
611 unsmob_translator_def ($$)
612 ->add_push_property (scm_string_to_symbol ($2), $4, $6);
614 | translator_spec_body STRING REVERT embedded_scm {
615 unsmob_translator_def ($$)->add_pop_property (
616 scm_string_to_symbol ($2), $4);
618 | translator_spec_body NAME STRING {
619 unsmob_translator_def ($$)->type_name_ = scm_string_to_symbol ($3);
621 | translator_spec_body CONSISTS STRING {
622 unsmob_translator_def ($$)->add_element ($3);
624 | translator_spec_body ALIAS STRING {
625 Translator_def*td = unsmob_translator_def ($$);
626 td->type_aliases_ = scm_cons (scm_string_to_symbol ($3), td->type_aliases_);
628 | translator_spec_body GROBDESCRIPTIONS embedded_scm {
629 Translator_def*td = unsmob_translator_def($$);
630 // td->add_property_assign (ly_symbol2scm ("allGrobDescriptions"), $3);
631 for (SCM p = $3; gh_pair_p (p); p = ly_cdr (p))
632 td->add_property_assign (scm_symbol_to_string (ly_caar (p)), ly_cdar (p));
634 | translator_spec_body CONSISTSEND STRING {
635 unsmob_translator_def ($$)->add_last_element ( $3);
637 | translator_spec_body ACCEPTS STRING {
638 unsmob_translator_def ($$)->set_acceptor (scm_string_to_symbol ($3), true);
640 | translator_spec_body DENIES STRING {
641 unsmob_translator_def ($$)->set_acceptor (scm_string_to_symbol ($3), false);
643 | translator_spec_body REMOVE STRING {
644 unsmob_translator_def ($$)->remove_element ($3);
655 /*cont*/ '{' score_body '}' {
666 $$->set_spot (THIS->here_input ());
667 SCM m = $1->self_scm ();
668 scm_gc_unprotect_object (m);
673 SCM check_funcs = scm_c_eval_string ("toplevel-music-functions");
674 for (; gh_pair_p (check_funcs); check_funcs = gh_cdr (check_funcs))
675 m = gh_call1 (gh_car (check_funcs), m);
680 $$ = unsmob_score ($1);
681 $$->set_spot (THIS->here_input ());
683 | score_body lilypond_header {
686 | score_body output_def {
699 music_output_def_body '}' {
701 THIS-> lexer_-> remove_scope ();
705 music_output_def_body:
707 Music_output_def *id = unsmob_music_output_def (THIS->lexer_->lookup_identifier ("$defaultmidi"));
712 p = dynamic_cast<Midi_def*> (id->clone ());
717 THIS->lexer_->add_scope (p->scope_);
720 Music_output_def *id = unsmob_music_output_def (THIS->lexer_->lookup_identifier ("$defaultpaper"));
723 p = dynamic_cast<Paper_def*> (id->clone ());
727 THIS->lexer_->add_scope (p->scope_);
730 | PAPER '{' MUSIC_OUTPUT_DEF_IDENTIFIER {
731 Music_output_def * o = unsmob_music_output_def ($3);
734 THIS->lexer_->add_scope (o->scope_);
736 | MIDI '{' MUSIC_OUTPUT_DEF_IDENTIFIER {
737 Music_output_def * o = unsmob_music_output_def ($3);
740 THIS->lexer_->add_scope (o->scope_);
742 | music_output_def_body assignment {
745 | music_output_def_body translator_spec_block {
746 $$->assign_translator ($2);
748 | music_output_def_body tempo_event {
750 junk this ? there already is tempo stuff in
753 int m = gh_scm2int ( $2->get_mus_property ("metronome-count"));
754 Duration *d = unsmob_duration ($2->get_mus_property ("tempo-unit"));
755 Midi_def * md = dynamic_cast<Midi_def*> ($$);
757 md->set_tempo (d->get_length (), m);
759 | music_output_def_body error {
765 TEMPO steno_duration '=' bare_unsigned {
766 $$ = MY_MAKE_MUSIC("MetronomeChangeEvent");
767 $$->set_mus_property ("tempo-unit", $2);
768 $$->set_mus_property ("metronome-count", gh_int2scm ( $4));
773 The representation of a list is the
777 to have efficient append.
781 $$ = scm_cons (SCM_EOL, SCM_EOL);
785 SCM c = scm_cons ($2->self_scm (), SCM_EOL);
786 scm_gc_unprotect_object ($2->self_scm ()); /* UGH */
787 if (gh_pair_p (ly_cdr (s)))
788 gh_set_cdr_x (ly_cdr (s), c); /* append */
790 gh_set_car_x (s, c); /* set first cons */
791 gh_set_cdr_x (s, c) ; /* remember last cell */
807 | ALTERNATIVE '{' Music_list '}' {
813 REPEAT string bare_unsigned Music Alternative_music
817 SCM alts = gh_pair_p ($5) ? gh_car ($5) : SCM_EOL;
818 if (times < scm_ilength (alts)) {
819 unsmob_music (gh_car (alts))
820 ->origin ()->warning (
821 _("More alternatives than repeats. Junking excess alternatives."));
822 alts = ly_truncate_list (times, alts);
828 proc = scm_c_eval_string ("make-repeated-music");
830 SCM mus = scm_call_1 (proc, $2);
831 scm_gc_protect_object (mus); // UGH.
832 Music *r =unsmob_music (mus);
835 r-> set_mus_property ("element", beg->self_scm ());
836 scm_gc_unprotect_object (beg->self_scm ());
838 r->set_mus_property ("repeat-count", gh_int2scm (times >? 1));
840 r-> set_mus_property ("elements",alts);
841 if (gh_equal_p ($2, scm_makfrom0str ("tremolo"))) {
843 we can not get durations and other stuff correct down the line, so we have to
844 add to the duration log here.
849 func = scm_primitive_eval (ly_symbol2scm ("shift-duration-log"));
851 int dots = ($3 % 3) ? 0 : 1;
852 int shift = -intlog2 ((dots) ? ($3*2/3) : $3);
854 Sequential_music * seq = dynamic_cast<Sequential_music*> ($4);
857 int list_len =scm_ilength (seq->music_list ());
859 seq->origin ()->warning ("Chord tremolo must have 2 elements.");
861 r->compress (Moment (Rational (1,list_len)));
863 gh_call3 (func, r->self_scm (), gh_int2scm(shift),gh_int2scm(dots));
866 r->set_spot (*$4->origin ());
873 SEQUENTIAL '{' Music_list '}' {
874 $$ = MY_MAKE_MUSIC("SequentialMusic");
875 $$->set_mus_property ("elements", ly_car ($3));
876 $$->set_spot(THIS->here_input());
878 | '{' Music_list '}' {
879 $$ = MY_MAKE_MUSIC("SequentialMusic");
880 $$->set_mus_property ("elements", ly_car ($2));
881 $$->set_spot(THIS->here_input());
886 SIMULTANEOUS '{' Music_list '}'{
887 $$ = MY_MAKE_MUSIC("SimultaneousMusic");
888 $$->set_mus_property ("elements", ly_car ($3));
889 $$->set_spot(THIS->here_input());
892 | simul_open Music_list simul_close {
893 $$ = MY_MAKE_MUSIC("SimultaneousMusic");
894 $$->set_mus_property ("elements", ly_car ($2));
895 $$->set_spot(THIS->here_input());
900 event_chord { $$ = $1; }
901 | APPLYOUTPUT embedded_scm {
902 if (!ly_input_procedure_p ($2))
903 THIS->parser_error (_ ("\\applycontext takes function argument"));
904 $$ = MY_MAKE_MUSIC ("ApplyOutputEvent");
905 $$->set_mus_property ("procedure", $2);
906 $$->set_spot (THIS->here_input());
908 | APPLYCONTEXT embedded_scm {
909 if (!ly_input_procedure_p ($2))
910 THIS->parser_error (_ ("\\applycontext takes function argument"));
911 $$ = MY_MAKE_MUSIC ("ApplyContext");
912 $$->set_mus_property ("procedure", $2);
913 $$->set_spot (THIS->here_input());
916 $$ = unsmob_music ($1);
924 GRACE { $$ = scm_makfrom0str ("Grace"); }
925 | ACCIACCATURA { $$ = scm_makfrom0str ("Acciaccatura"); }
926 | APPOGGIATURA { $$ = scm_makfrom0str ("Appoggiatura"); }
931 CONTEXT STRING Music {
932 Music*csm =MY_MAKE_MUSIC("ContextSpeccedMusic");
934 csm->set_mus_property ("element", $3->self_scm ());
935 scm_gc_unprotect_object ($3->self_scm ());
937 csm->set_mus_property ("context-type", scm_string_to_symbol ($2));
938 csm->set_mus_property ("context-id", scm_makfrom0str (""));
942 | AUTOCHANGE STRING Music {
943 Music*chm = MY_MAKE_MUSIC("AutoChangeMusic");
944 chm->set_mus_property ("element", $3->self_scm ());
945 chm->set_mus_property ("iterator-ctor", Auto_change_iterator::constructor_proc);
947 scm_gc_unprotect_object ($3->self_scm ());
948 chm->set_mus_property ("what", scm_string_to_symbol ($2));
951 chm->set_spot (*$3->origin ());
956 The other version is for easier debugging of
957 Sequential_music_iterator in combination with grace notes.
962 TODO: should distinguish between both grace types in the
963 basic music objects too, since the meaning is different.
967 String start_str = "start" + ly_scm2string ($1) + "Music";
968 String stop_str = "stop" + ly_scm2string ($1) + "Music";
970 SCM start = THIS->lexer_->lookup_identifier (start_str);
971 SCM stop = THIS->lexer_->lookup_identifier (stop_str);
973 Music *startm = unsmob_music (start);
974 Music *stopm = unsmob_music (stop);
978 stopm = stopm->clone ();
979 ms = scm_cons (stopm->self_scm (), ms);
980 scm_gc_unprotect_object (stopm->self_scm ());
982 ms = scm_cons ($2->self_scm (), ms);
983 scm_gc_unprotect_object ($2->self_scm());
985 startm = startm->clone ();
986 ms = scm_cons (startm->self_scm () , ms);
987 scm_gc_unprotect_object (startm->self_scm ());
991 Music* seq = MY_MAKE_MUSIC("SequentialMusic");
992 seq->set_mus_property ("elements", ms);
995 $$ = MY_MAKE_MUSIC("GraceMusic");
996 $$->set_mus_property ("element", seq->self_scm ());
997 scm_gc_unprotect_object (seq->self_scm ());
999 $$ = MY_MAKE_MUSIC("GraceMusic");
1000 $$->set_mus_property ("element", $2->self_scm ());
1001 scm_gc_unprotect_object ($2->self_scm ());
1004 | CONTEXT string '=' string Music {
1005 Music * csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
1007 csm->set_mus_property ("element", $5->self_scm ());
1008 scm_gc_unprotect_object ($5->self_scm ());
1010 csm->set_mus_property ("context-type", scm_string_to_symbol ($2));
1011 csm->set_mus_property ("context-id", $4);
1015 | NEWCONTEXT string Music {
1016 static int new_context_count;
1018 Music * csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
1020 csm->set_mus_property ("element", $3->self_scm ());
1021 scm_gc_unprotect_object ($3->self_scm ());
1023 csm->set_mus_property ("context-type", scm_string_to_symbol ($2));
1026 snprintf (s, 1024, "uniqueContext%d", new_context_count ++);
1028 SCM new_id = scm_makfrom0str (s);
1029 csm->set_mus_property ("context-id", new_id);
1039 int n = gh_scm2int (ly_car ($3)); int d = gh_scm2int (ly_cdr ($3));
1042 $$= MY_MAKE_MUSIC("TimeScaledMusic");
1043 $$->set_spot (THIS->pop_spot ());
1045 $$->set_mus_property ("element", mp->self_scm ());
1046 scm_gc_unprotect_object (mp->self_scm ());
1047 $$->set_mus_property ("numerator", gh_int2scm (n));
1048 $$->set_mus_property ("denominator", gh_int2scm (d));
1049 $$->compress (Moment (Rational (n,d)));
1052 | Repeated_music { $$ = $1; }
1053 | Simultaneous_music { $$ = $1; }
1054 | Sequential_music { $$ = $1; }
1055 | TRANSPOSE pitch_also_in_chords pitch_also_in_chords Music {
1056 $$ = MY_MAKE_MUSIC("TransposedMusic");
1058 Pitch from = *unsmob_pitch ($2);
1059 Pitch to = *unsmob_pitch ($3);
1061 p->transpose (interval (from, to));
1062 $$->set_mus_property ("element", p->self_scm ());
1063 scm_gc_unprotect_object (p->self_scm ());
1065 | APPLY embedded_scm Music {
1066 if (!ly_input_procedure_p ($2))
1068 THIS->parser_error (_ ("\\apply takes function argument"));
1073 SCM ret = gh_call1 ($2, $3->self_scm ());
1074 Music *m = unsmob_music (ret);
1076 THIS->parser_error ("\\apply must return a Music");
1077 m = MY_MAKE_MUSIC("Music");
1083 { THIS->lexer_->push_note_state (); }
1086 THIS->lexer_->pop_state ();
1089 { THIS->lexer_->push_figuredbass_state (); }
1092 Music * chm = MY_MAKE_MUSIC("UntransposableMusic");
1093 chm->set_mus_property ("element", $3->self_scm ());
1095 scm_gc_unprotect_object ($3->self_scm());
1097 THIS->lexer_->pop_state ();
1100 { THIS->lexer_->push_chord_state (); }
1103 Music * chm = MY_MAKE_MUSIC("UnrelativableMusic");
1104 chm->set_mus_property ("element", $3->self_scm ());
1105 scm_gc_unprotect_object ($3->self_scm());
1108 THIS->lexer_->pop_state ();
1111 { THIS->lexer_->push_lyric_state (); }
1115 THIS->lexer_->pop_state ();
1117 | relative_music { $$ = $1; }
1118 | re_rhythmed_music { $$ = $1; }
1119 | part_combined_music { $$ = $1; }
1120 | TAG embedded_scm Music {
1121 tag_music ($3, $2, THIS->here_input ());
1127 RELATIVE absolute_pitch Music {
1129 Pitch pit = *unsmob_pitch ($2);
1130 $$ = MY_MAKE_MUSIC("RelativeOctaveMusic");
1132 $$->set_mus_property ("element", p->self_scm ());
1133 scm_gc_unprotect_object (p->self_scm ());
1136 Pitch retpitch = p->to_relative_octave (pit);
1137 if (lily_1_8_relative)
1138 $$->set_mus_property ("last-pitch", retpitch.smobbed_copy ());
1143 ADDLYRICS Music Music {
1144 Music*l =MY_MAKE_MUSIC("LyricCombineMusic");
1145 l->set_mus_property ("elements", gh_list ($2->self_scm (), $3->self_scm (), SCM_UNDEFINED));
1146 scm_gc_unprotect_object ($3->self_scm ());
1147 scm_gc_unprotect_object ($2->self_scm ());
1152 part_combined_music:
1153 PARTCOMBINE STRING Music Music {
1154 Music * p= MY_MAKE_MUSIC("PartCombineMusic");
1155 p->set_mus_property ("what", scm_string_to_symbol ($2));
1156 p->set_mus_property ("elements", gh_list ($3->self_scm (),$4->self_scm (), SCM_UNDEFINED));
1158 scm_gc_unprotect_object ($3->self_scm ());
1159 scm_gc_unprotect_object ($4->self_scm ());
1166 TRANSLATOR STRING '=' STRING {
1167 Music*t= MY_MAKE_MUSIC("TranslatorChange");
1168 t-> set_mus_property ("change-to-type", scm_string_to_symbol ($2));
1169 t-> set_mus_property ("change-to-id", $4);
1172 $$->set_spot (THIS->here_input ());
1178 | ONCE simple_property_def {
1180 SCM e = $2->get_mus_property ("element");
1181 unsmob_music (e)->set_mus_property ("once", SCM_BOOL_T);
1185 simple_property_def:
1186 PROPERTY STRING '.' STRING '=' scalar {
1187 Music *t = set_property_music (scm_string_to_symbol ($4), $6);
1188 Music *csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
1190 csm->set_mus_property ("element", t->self_scm ());
1191 scm_gc_unprotect_object (t->self_scm ());
1194 $$->set_spot (THIS->here_input ());
1196 csm-> set_mus_property ("context-type", scm_string_to_symbol ($2));
1198 | PROPERTY STRING '.' STRING UNSET {
1200 Music *t = MY_MAKE_MUSIC("PropertyUnset");
1201 t->set_mus_property ("symbol", scm_string_to_symbol ($4));
1203 Music *csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
1204 csm->set_mus_property ("element", t->self_scm ());
1205 scm_gc_unprotect_object (t->self_scm ());
1208 $$->set_spot (THIS->here_input ());
1210 csm-> set_mus_property ("context-type", scm_string_to_symbol ($2));
1212 | PROPERTY STRING '.' STRING SET embedded_scm '=' embedded_scm {
1214 = gh_equal_p ($4, scm_makfrom0str ("autoBeamSettings"));
1215 bool itc = internal_type_checking_global_b;
1216 Music *t = MY_MAKE_MUSIC("OverrideProperty");
1217 t->set_mus_property ("symbol", scm_string_to_symbol ($4));
1218 t->set_mus_property ("pop-first", SCM_BOOL_T);
1220 internal_type_checking_global_b = false;
1221 t->set_mus_property ("grob-property", $6);
1223 internal_type_checking_global_b = itc;
1224 t->set_mus_property ("grob-value", $8);
1226 Music *csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
1227 csm->set_mus_property ("element", t->self_scm ());
1228 scm_gc_unprotect_object (t->self_scm ());
1230 $$->set_spot (THIS->here_input ());
1232 csm-> set_mus_property ("context-type", scm_string_to_symbol ($2));
1234 | PROPERTY STRING '.' STRING OVERRIDE
1235 embedded_scm '=' embedded_scm
1241 = gh_equal_p ($4, scm_makfrom0str ("autoBeamSettings"));
1242 bool itc = internal_type_checking_global_b;
1244 Music *t = MY_MAKE_MUSIC("OverrideProperty");
1245 t->set_mus_property ("symbol", scm_string_to_symbol ($4));
1247 internal_type_checking_global_b = false;
1248 t->set_mus_property ("grob-property", $6);
1249 t->set_mus_property ("grob-value", $8);
1251 internal_type_checking_global_b = itc;
1253 Music *csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
1254 csm->set_mus_property ("element", t->self_scm ());
1255 scm_gc_unprotect_object (t->self_scm ());
1258 $$->set_spot (THIS->here_input ());
1260 csm-> set_mus_property ("context-type", scm_string_to_symbol ($2));
1263 | PROPERTY STRING '.' STRING REVERT embedded_scm {
1264 Music *t = MY_MAKE_MUSIC("RevertProperty");
1266 = gh_equal_p ($4, scm_makfrom0str ("autoBeamSettings"));
1267 bool itc = internal_type_checking_global_b;
1269 t->set_mus_property ("symbol", scm_string_to_symbol ($4));
1271 internal_type_checking_global_b = false;
1272 t->set_mus_property ("grob-property", $6);
1274 internal_type_checking_global_b = itc;
1276 Music *csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
1277 csm->set_mus_property ("element", t->self_scm ());
1278 scm_gc_unprotect_object (t->self_scm ());
1281 $$->set_spot (THIS->here_input ());
1283 csm-> set_mus_property ("context-type", scm_string_to_symbol ($2));
1290 | bare_int { $$ = gh_int2scm ($1); }
1291 | embedded_scm { $$ = $1; }
1292 | full_markup { $$ = $1; }
1293 | DIGIT { $$ = gh_int2scm ($1); }
1301 Adding pre_events to the simple_element
1302 makes the choice between
1308 simple_element: STRING
1310 a single shift/reduction conflict.
1312 nevertheless, this is not very clean, and we should find a different
1322 pre_events simple_element post_events {
1323 SCM elts = $2-> get_mus_property ("elements");
1325 elts = gh_append2 (elts, scm_reverse_x ($3, SCM_EOL));
1327 $2->set_mus_property ("elements", elts);
1331 | note_chord_element
1336 chord_body optional_notemode_duration post_events
1338 SCM dur = unsmob_duration ($2)->smobbed_copy();
1339 SCM es = $1->get_mus_property ("elements");
1340 SCM postevs = scm_reverse_x ($3, SCM_EOL);
1342 for (SCM s = es; gh_pair_p (s); s = gh_cdr (s))
1343 unsmob_music (gh_car(s))->set_mus_property ("duration", dur);
1344 es = gh_append2 (es, postevs);
1346 $1-> set_mus_property ("elements", es);
1357 simul_open: LESSLESS
1360 simul_close: MOREMORE
1364 chord_open chord_body_elements chord_close
1366 $$ = MY_MAKE_MUSIC("EventChord");
1367 $$->set_mus_property ("elements",
1368 scm_reverse_x ($2, SCM_EOL));
1372 chord_body_elements:
1373 /* empty */ { $$ = SCM_EOL; }
1374 | chord_body_elements chord_body_element {
1375 $$ = gh_cons ($2->self_scm(), $1);
1376 scm_gc_unprotect_object ($2->self_scm());
1381 pitch exclamations questions post_events
1383 Music * n = MY_MAKE_MUSIC("NoteEvent");
1384 n->set_mus_property ("pitch", $1);
1386 n->set_mus_property ("cautionary", SCM_BOOL_T);
1387 if ($2 % 2 || $3 % 2)
1388 n->set_mus_property ("force-accidental", SCM_BOOL_T);
1390 SCM arts = scm_reverse_x ($4, SCM_EOL);
1391 n->set_mus_property ("articulations", arts);
1399 $$ = MY_MAKE_MUSIC("EventChord");
1400 $$->set_mus_property ("elements", scm_cons ($1->self_scm (), SCM_EOL));
1401 scm_gc_unprotect_object ($1->self_scm());
1403 $$-> set_spot (THIS->here_input ());
1404 $1-> set_spot (THIS->here_input ());
1406 | OCTAVE { THIS->push_spot (); }
1408 Music *l = MY_MAKE_MUSIC("RelativeOctaveCheck");
1410 $$->set_spot (THIS->pop_spot ());
1411 $$->set_mus_property ("pitch", $3);
1414 Music *l = MY_MAKE_MUSIC("LigatureEvent");
1415 l->set_mus_property ("span-direction", gh_int2scm (START));
1416 l->set_spot (THIS->here_input ());
1418 $$ = MY_MAKE_MUSIC("EventChord");
1419 $$->set_mus_property ("elements", scm_cons (l->self_scm (), SCM_EOL));
1420 scm_gc_unprotect_object (l->self_scm());
1421 $$->set_spot (THIS->here_input ());
1424 Music *l = MY_MAKE_MUSIC("LigatureEvent");
1425 l->set_mus_property ("span-direction", gh_int2scm (STOP));
1426 l->set_spot (THIS->here_input ());
1428 $$ = MY_MAKE_MUSIC("EventChord");
1429 $$->set_mus_property ("elements", scm_cons (l->self_scm (), SCM_EOL));
1430 $$->set_spot (THIS->here_input ());
1431 scm_gc_unprotect_object (l->self_scm());
1434 $$ = MY_MAKE_MUSIC("VoiceSeparator");
1435 $$->set_spot (THIS->here_input ());
1439 $$ = MY_MAKE_MUSIC("BarCheck");
1440 $$->set_spot (THIS->here_input ());
1443 Music *t = set_property_music (ly_symbol2scm ("whichBar"), $2);
1445 Music *csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
1446 csm->set_mus_property ("element", t->self_scm ());
1447 scm_gc_unprotect_object (t->self_scm ());
1450 $$->set_spot (THIS->here_input ());
1452 csm->set_mus_property ("context-type", ly_symbol2scm ("Timing"));
1454 | PARTIAL duration_length {
1455 Moment m = - unsmob_duration ($2)->get_length ();
1456 Music * p = set_property_music (ly_symbol2scm ( "measurePosition"),m.smobbed_copy ());
1458 Music * sp = MY_MAKE_MUSIC("ContextSpeccedMusic");
1459 sp->set_mus_property ("element", p->self_scm ());
1460 scm_gc_unprotect_object (p->self_scm ());
1463 sp-> set_mus_property ("context-type", ly_symbol2scm ("Timing"));
1468 proc = scm_c_eval_string ("make-clef-set");
1470 SCM result = scm_call_1 (proc, $2);
1471 scm_gc_protect_object (result);
1472 $$ = unsmob_music (result);
1477 proc = scm_c_eval_string ("make-time-signature-set");
1479 SCM result = scm_apply_2 (proc, gh_car ($2), gh_cdr ($2), SCM_EOL);
1480 scm_gc_protect_object (result);
1481 $$ = unsmob_music (result);
1486 shorthand_command_req { $$ = $1; }
1487 | verbose_command_req { $$ = $1; }
1490 shorthand_command_req:
1498 $$ = MY_MAKE_MUSIC("BreathingSignEvent");
1501 $$ = MY_MAKE_MUSIC("PesOrFlexaEvent");
1505 verbose_command_req:
1507 Music * m = MY_MAKE_MUSIC("MarkEvent");
1511 Music *m = MY_MAKE_MUSIC("MarkEvent");
1512 m->set_mus_property ("label", $2);
1515 | SKIP duration_length {
1516 Music * skip = MY_MAKE_MUSIC("SkipEvent");
1517 skip->set_mus_property ("duration", $2);
1525 Music *key= MY_MAKE_MUSIC("KeyChangeEvent");
1528 | KEY NOTENAME_PITCH SCM_IDENTIFIER {
1530 Music *key= MY_MAKE_MUSIC("KeyChangeEvent");
1531 if (scm_ilength ($3) > 0)
1533 key->set_mus_property ("pitch-alist", $3);
1534 key->set_mus_property ("tonic", Pitch (0,0,0).smobbed_copy());
1535 ((Music*)key)->transpose (* unsmob_pitch ($2));
1537 THIS->parser_error (_("Second argument must be pitch list."));
1548 | post_events post_event {
1549 $2->set_spot (THIS->here_input ());
1550 $$ = gh_cons ($2->self_scm(), $$);
1551 scm_gc_unprotect_object ($2->self_scm());
1553 | post_events tagged_post_event {
1554 $2 -> set_spot (THIS->here_input ());
1555 $$ = scm_cons ($2->self_scm(), $$);
1556 scm_gc_unprotect_object ($2->self_scm());
1562 '-' TAG embedded_scm post_event {
1563 tag_music ($4, $3, THIS->here_input ());
1569 direction_less_event {
1572 | script_dir direction_reqd_event {
1574 $2->set_mus_property ("direction", gh_int2scm ($1));
1577 | script_dir direction_less_event {
1579 $2->set_mus_property ("direction", gh_int2scm ($1));
1582 | string_number_event
1585 string_number_event:
1587 Music * s = MY_MAKE_MUSIC("StringNumberEvent");
1588 s->set_mus_property ("string-number", gh_int2scm($1));
1589 s->set_spot (THIS->here_input ());
1595 direction_less_event:
1601 TODO: should take all these defs out of the parser, adn make use
1605 (set-articulation '~ "trill")
1608 Music * m = MY_MAKE_MUSIC ("BeamEvent");
1609 m->set_spot (THIS->here_input());
1610 m->set_mus_property ("span-direction" , gh_int2scm (START));
1614 Music * m = MY_MAKE_MUSIC ("BeamEvent");
1615 m->set_spot (THIS->here_input());
1616 m->set_mus_property ("span-direction" , gh_int2scm (STOP));
1620 Music * m = MY_MAKE_MUSIC ("TieEvent");
1621 m->set_spot (THIS->here_input());
1626 dynamic_cast<Music *> ($$)->set_mus_property ("span-direction", gh_int2scm (START));
1630 dynamic_cast<Music *> ($$)->set_mus_property ("span-direction", gh_int2scm (STOP));
1632 | EVENT_IDENTIFIER {
1633 $$ = unsmob_music ($1);
1636 Music * a = MY_MAKE_MUSIC("TremoloEvent");
1637 a->set_spot (THIS->here_input ());
1638 a->set_mus_property ("tremolo-type", gh_int2scm ($1));
1643 direction_reqd_event:
1647 | script_abbreviation {
1648 SCM s = THIS->lexer_->lookup_identifier ("dash" + ly_scm2string ($1));
1649 Music *a = MY_MAKE_MUSIC("ArticulationEvent");
1650 if (gh_string_p (s))
1651 a->set_mus_property ("articulation-type", s);
1652 else THIS->parser_error (_ ("Expecting string as script definition"));
1679 | NOTENAME_PITCH sup_quotes {
1680 Pitch p = *unsmob_pitch ($1);
1681 p = p.transposed (Pitch ($2,0,0));
1682 $$ = p.smobbed_copy ();
1684 | NOTENAME_PITCH sub_quotes {
1685 Pitch p =* unsmob_pitch ($1);
1686 p = p.transposed (Pitch (-$2,0,0));
1687 $$ = p.smobbed_copy ();
1699 | TONICNAME_PITCH sup_quotes {
1700 Pitch p = *unsmob_pitch ($1);
1701 p = p.transposed (Pitch ($2,0,0));
1702 $$ = p.smobbed_copy ();
1704 | TONICNAME_PITCH sub_quotes {
1705 Pitch p =* unsmob_pitch ($1);
1707 p = p.transposed (Pitch (-$2,0,0));
1708 $$ = p.smobbed_copy ();
1718 pitch_also_in_chords:
1729 if (!THIS->lexer_->lyric_state_b ())
1730 THIS->parser_error (_ ("Have to be in Lyric mode for lyrics"));
1731 $$ = MY_MAKE_MUSIC("ExtenderEvent");
1737 if (!THIS->lexer_->lyric_state_b ())
1738 THIS->parser_error (_ ("Have to be in Lyric mode for lyrics"));
1739 $$ = MY_MAKE_MUSIC("HyphenEvent");
1745 Music * s= MY_MAKE_MUSIC("SlurEvent");
1747 s->set_spot (THIS->here_input());
1750 Music * s= MY_MAKE_MUSIC("PhrasingSlurEvent");
1752 s->set_spot (THIS->here_input());
1755 Music *s =MY_MAKE_MUSIC("CrescendoEvent");
1757 s->set_spot (THIS->here_input());
1760 Music *s =MY_MAKE_MUSIC("DecrescendoEvent");
1762 s->set_spot (THIS->here_input());
1769 Music *s = MY_MAKE_MUSIC("CrescendoEvent");
1770 s->set_spot (THIS->here_input());
1775 Music * s= MY_MAKE_MUSIC("SlurEvent");
1777 s->set_spot (THIS->here_input());
1781 Music * s= MY_MAKE_MUSIC("PhrasingSlurEvent");
1783 s->set_mus_property ("span-type", scm_makfrom0str ( "phrasing-slur"));
1784 s->set_spot (THIS->here_input());
1790 Music *t = MY_MAKE_MUSIC("TextScriptEvent");
1791 t->set_mus_property ("text", $1);
1792 t->set_spot (THIS->here_input ());
1796 Music *t = MY_MAKE_MUSIC("TextScriptEvent");
1797 t->set_mus_property ("text", make_simple_markup ($1));
1798 t->set_spot (THIS->here_input ());
1803 Music * t = MY_MAKE_MUSIC("FingerEvent");
1804 t->set_mus_property ("digit", gh_int2scm ($1));
1805 t->set_spot (THIS->here_input ());
1810 script_abbreviation:
1812 $$ = scm_makfrom0str ("Hat");
1815 $$ = scm_makfrom0str ("Plus");
1818 $$ = scm_makfrom0str ("Dash");
1821 $$ = scm_makfrom0str ("Bar");
1824 $$ = scm_makfrom0str ("Larger");
1827 $$ = scm_makfrom0str ("Dot");
1830 $$ = scm_makfrom0str ("Underscore");
1837 | '-' { $$ = CENTER; }
1848 multiplied_duration {
1853 optional_notemode_duration:
1855 Duration dd = THIS->default_duration_;
1856 $$ = dd.smobbed_copy ();
1858 THIS->beam_check ($$);
1860 | multiplied_duration {
1862 THIS->default_duration_ = *unsmob_duration ($$);
1864 THIS->beam_check ($$);
1869 bare_unsigned dots {
1871 if (!is_duration_b ($1))
1872 THIS->parser_error (_f ("not a duration: %d", $1));
1876 $$ = Duration (l, $2).smobbed_copy ();
1878 | DURATION_IDENTIFIER dots {
1879 Duration *d =unsmob_duration ($1);
1880 Duration k (d->duration_log (),d->dot_count () + $2);
1890 multiplied_duration:
1894 | multiplied_duration '*' bare_unsigned {
1895 $$ = unsmob_duration ($$)->compressed ( $3) .smobbed_copy ();
1897 | multiplied_duration '*' FRACTION {
1898 Rational m (gh_scm2int (ly_car ($3)), gh_scm2int (ly_cdr ($3)));
1900 $$ = unsmob_duration ($$)->compressed (m).smobbed_copy ();
1905 FRACTION { $$ = $1; }
1906 | UNSIGNED '/' UNSIGNED {
1907 $$ = scm_cons (gh_int2scm ($1), gh_int2scm ($3));
1925 | ':' bare_unsigned {
1926 if (!is_duration_b ($2))
1927 THIS->parser_error (_f ("not a duration: %d", $2));
1934 /*****************************************************************
1936 *****************************************************************/
1939 $$ = scm_number_to_string (gh_int2scm ($1), gh_int2scm (10));
1942 $$ = scm_number_to_string (gh_int2scm ($1), gh_int2scm (10));
1944 | STRING { $$ = $1; }
1955 Music *bfr = MY_MAKE_MUSIC("BassFigureEvent");
1956 $$ = bfr->self_scm();
1957 scm_gc_unprotect_object ($$);
1960 Music *bfr = MY_MAKE_MUSIC("BassFigureEvent");
1961 $$ = bfr->self_scm();
1963 bfr->set_mus_property ("figure", $1);
1965 scm_gc_unprotect_object ($$);
1967 | bass_figure bass_mod {
1968 Music *m = unsmob_music ($1);
1970 SCM salter =m->get_mus_property ("alteration");
1971 int alter = gh_number_p ( salter) ? gh_scm2int (salter) : 0;
1972 m->set_mus_property ("alteration",
1973 gh_int2scm (alter + $2));
1975 m->set_mus_property ("alteration", gh_int2scm (0));
1983 unsmob_music ($$)->set_mus_property ("bracket-start", SCM_BOOL_T);
1988 | br_bass_figure ']' {
1990 unsmob_music ($1)->set_mus_property ("bracket-stop", SCM_BOOL_T);
1998 | figure_list br_bass_figure {
1999 $$ = scm_cons ($2, $1);
2004 FIGURE_OPEN figure_list FIGURE_CLOSE {
2005 Music * m = MY_MAKE_MUSIC("EventChord");
2006 $2 = scm_reverse_x ($2, SCM_EOL);
2007 m->set_mus_property ("elements", $2);
2008 $$ = m->self_scm ();
2019 pitch exclamations questions optional_notemode_duration optional_rest {
2021 Input i = THIS->pop_spot ();
2022 if (!THIS->lexer_->note_state_b ())
2023 THIS->parser_error (_ ("Have to be in Note mode for notes"));
2027 n = MY_MAKE_MUSIC("RestEvent");
2029 n = MY_MAKE_MUSIC("NoteEvent");
2031 n->set_mus_property ("pitch", $1);
2032 n->set_mus_property ("duration", $4);
2036 n->set_mus_property ("cautionary", SCM_BOOL_T);
2037 if ($2 % 2 || $3 % 2)
2038 n->set_mus_property ("force-accidental", SCM_BOOL_T);
2040 Music *v = MY_MAKE_MUSIC("EventChord");
2041 v->set_mus_property ("elements", scm_list_n (n->self_scm (), SCM_UNDEFINED));
2042 scm_gc_unprotect_object (n->self_scm());
2048 | figure_spec optional_notemode_duration {
2049 Music * m = unsmob_music ($1);
2050 Input i = THIS->pop_spot ();
2052 for (SCM s = m->get_mus_property ("elements"); gh_pair_p (s); s = ly_cdr (s))
2054 unsmob_music (ly_car (s))->set_mus_property ("duration", $2);
2058 | RESTNAME optional_notemode_duration {
2060 Input i = THIS->pop_spot ();
2062 if (ly_scm2string ($1) =="s") {
2064 ev = MY_MAKE_MUSIC("SkipEvent");
2067 ev = MY_MAKE_MUSIC("RestEvent");
2070 ev->set_mus_property ("duration" ,$2);
2072 Music * velt = MY_MAKE_MUSIC("EventChord");
2073 velt->set_mus_property ("elements", scm_list_n (ev->self_scm (),SCM_UNDEFINED));
2078 | MULTI_MEASURE_REST optional_notemode_duration {
2083 proc = scm_c_eval_string ("make-multi-measure-rest");
2085 SCM mus = scm_call_2 (proc, $2,
2086 make_input (THIS->here_input()));
2087 scm_gc_protect_object (mus);
2088 $$ = unsmob_music (mus);
2091 | lyric_element optional_notemode_duration {
2092 Input i = THIS->pop_spot ();
2093 if (!THIS->lexer_->lyric_state_b ())
2094 THIS->parser_error (_ ("Have to be in Lyric mode for lyrics"));
2096 Music * lreq = MY_MAKE_MUSIC("LyricEvent");
2097 lreq->set_mus_property ("text", $1);
2098 lreq->set_mus_property ("duration",$2);
2100 Music * velt = MY_MAKE_MUSIC("EventChord");
2101 velt->set_mus_property ("elements", scm_list_n (lreq->self_scm (), SCM_UNDEFINED));
2108 if (!THIS->lexer_->chord_state_b ())
2109 THIS->parser_error (_ ("Have to be in Chord mode for chords"));
2110 $$ = unsmob_music ($1);
2115 full_markup { $$ = $1; }
2116 | STRING { $$ = $1 ; }
2120 steno_tonic_pitch optional_notemode_duration {
2121 $$ = make_chord ($1, $2, SCM_EOL);
2123 | steno_tonic_pitch optional_notemode_duration chord_separator chord_items {
2124 SCM its = scm_reverse_x ($4, SCM_EOL);
2125 $$ = make_chord ($1, $2, gh_cons ($3, its));
2133 | chord_items chord_item {
2134 $$ = gh_cons ($2, $$);
2140 $$ = ly_symbol2scm ("chord-colon");
2143 $$ = ly_symbol2scm ("chord-caret");
2145 | CHORD_SLASH steno_tonic_pitch {
2146 $$ = scm_list_n (ly_symbol2scm ("chord-slash"), $2, SCM_UNDEFINED);
2148 | CHORD_BASS steno_tonic_pitch {
2149 $$ = scm_list_n (ly_symbol2scm ("chord-bass"), $2, SCM_UNDEFINED);
2158 $$ = scm_reverse_x ($1, SCM_EOL);
2166 step_number { $$ = gh_cons ($1, SCM_EOL); }
2167 | step_numbers '.' step_number {
2168 $$ = gh_cons ($3, $$);
2174 $$ = make_chord_step ($1, 0);
2176 | bare_unsigned '+' {
2177 $$ = make_chord_step ($1, SHARP);
2179 | bare_unsigned CHORD_MINUS {
2180 $$ = make_chord_step ($1, FLAT);
2187 TODO: should deprecate in favor of Scheme?
2191 number_expression '+' number_term {
2192 $$ = scm_sum ($1, $3);
2194 | number_expression '-' number_term {
2195 $$ = scm_difference ($1, $3);
2204 | number_factor '*' number_factor {
2205 $$ = scm_product ($1, $3);
2207 | number_factor '/' number_factor {
2208 $$ = scm_divide ($1, $3);
2213 '-' number_factor { /* %prec UNARY_MINUS */
2214 $$ = scm_difference ($2, SCM_UNDEFINED);
2222 $$ = gh_int2scm ($1);
2227 | NUMBER_IDENTIFIER {
2230 | REAL NUMBER_IDENTIFIER {
2231 $$ = gh_double2scm (gh_scm2double ($1) * gh_scm2double ($2));
2233 | UNSIGNED NUMBER_IDENTIFIER {
2234 $$ = gh_double2scm ($1 * gh_scm2double ($2));
2250 if (scm_integer_p ($1) == SCM_BOOL_T)
2252 int k = gh_scm2int ($1);
2256 THIS->parser_error (_ ("need integer number arg"));
2270 | STRING_IDENTIFIER {
2273 | string '+' string {
2274 $$ = scm_string_append (scm_list_n ($1, $3, SCM_UNDEFINED));
2281 | exclamations '!' { $$ ++; }
2286 | questions '?' { $$ ++; }
2296 { THIS->lexer_->push_markup_state (); }
2299 THIS->lexer_->pop_state ();
2305 This should be done more dynamically if possible.
2309 $$ = make_simple_markup ($1);
2311 | MARKUP_HEAD_MARKUP0 markup {
2312 $$ = scm_list_n ($1, $2, SCM_UNDEFINED);
2314 | MARKUP_HEAD_MARKUP0_MARKUP1 markup markup {
2315 $$ = scm_list_n ($1, $2, $3, SCM_UNDEFINED);
2317 | MARKUP_HEAD_SCM0_MARKUP1 SCM_T markup {
2318 $$ = scm_list_n ($1, $2, $3, SCM_UNDEFINED);
2323 | MARKUP_HEAD_LIST0 markup_list {
2324 $$ = scm_list_n ($1,$2, SCM_UNDEFINED);
2326 | MARKUP_HEAD_SCM0 embedded_scm {
2327 $$ = scm_list_n ($1, $2, SCM_UNDEFINED);
2329 | MARKUP_HEAD_SCM0_SCM1_MARKUP2 embedded_scm embedded_scm markup {
2330 $$ = scm_list_n ($1, $2, $3, $4, SCM_UNDEFINED);
2332 | MARKUP_HEAD_SCM0_SCM1_SCM2 embedded_scm embedded_scm embedded_scm {
2333 $$ = scm_list_n ($1, $2, $3, $4, SCM_UNDEFINED);
2335 | MARKUP_IDENTIFIER {
2342 chord_open markup_list_body chord_close { $$ = scm_reverse_x ($2, SCM_EOL); }
2346 '{' markup_list_body '}' {
2349 line = scm_c_eval_string ("line-markup");
2351 $$ = scm_list_n (line, scm_reverse_x ($2, SCM_EOL), SCM_UNDEFINED);
2356 /**/ { $$ = SCM_EOL; }
2357 | markup_list_body markup {
2358 $$ = gh_cons ($2, $1) ;
2366 My_lily_parser::set_yydebug (bool )
2373 extern My_lily_parser * current_parser;
2376 My_lily_parser::do_yyparse ()
2378 current_parser = this;;
2379 yyparse ((void*)this);
2384 Should make this optional? It will also complain when you do
2388 which is entirely legitimate.
2390 Or we can scrap it. Barchecks should detect wrong durations, and
2391 skipTypesetting speeds it up a lot.
2395 My_lily_parser::beam_check (SCM dur)
2397 Duration *d = unsmob_duration (dur);
2398 if (unsmob_music (last_beam_start_) && d->duration_log () <= 2)
2400 Music * m = unsmob_music (last_beam_start_);
2401 m->origin ()->warning (_("Suspect duration found following this beam"));
2403 last_beam_start_ = SCM_EOL;
2411 It is a little strange to have this function in this file, but
2412 otherwise, we have to import music classes into the lexer.
2416 My_lily_lexer::try_special_identifiers (SCM * destination, SCM sid)
2418 if (gh_string_p (sid)) {
2420 return STRING_IDENTIFIER;
2421 } else if (gh_number_p (sid)) {
2423 return NUMBER_IDENTIFIER;
2424 } else if (unsmob_translator_def (sid)) {
2425 *destination = unsmob_translator_def (sid)->clone_scm();
2426 return TRANSLATOR_IDENTIFIER;
2427 } else if (unsmob_score (sid)) {
2428 Score *sc = new Score (*unsmob_score (sid));
2429 *destination =sc->self_scm ();
2430 return SCORE_IDENTIFIER;
2431 } else if (Music * mus =unsmob_music (sid)) {
2432 *destination = unsmob_music (sid)->clone ()->self_scm();
2433 unsmob_music (*destination)->
2434 set_mus_property ("origin", make_input (last_input_));
2435 return dynamic_cast<Event*> (mus)
2436 ? EVENT_IDENTIFIER : MUSIC_IDENTIFIER;
2437 } else if (unsmob_duration (sid)) {
2438 *destination = unsmob_duration (sid)->smobbed_copy();
2439 return DURATION_IDENTIFIER;
2440 } else if (unsmob_music_output_def (sid)) {
2441 Music_output_def *p = unsmob_music_output_def (sid);
2444 *destination = p->self_scm();
2445 return MUSIC_OUTPUT_DEF_IDENTIFIER;
2446 } else if (Text_item::markup_p (sid)) {
2448 return MARKUP_IDENTIFIER;