1 %{ // -*-Fundamental-*-
4 parser.yy -- Bison/C++ parser for lilypond
6 source file of the GNU LilyPond music typesetter
8 (c) 1997--2004 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 "context-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 "ly-modules.hh"
78 #include "music-sequence.hh"
79 #include "input-smob.hh"
81 #include "text-item.hh"
82 #include "music-list.hh"
84 #define MY_MAKE_MUSIC(x) make_music_by_name (ly_symbol2scm (x))
86 Music *property_op_to_music (SCM op);
87 Music *context_spec_music (SCM type, SCM id, Music * m, SCM ops_);
88 SCM get_next_unique_context ();
90 #define YYERROR_VERBOSE 1
92 My_lily_parser* my_lily_parser;
93 #define YYPARSE_PARAM my_lily_parser
94 #define YYLEX_PARAM my_lily_parser
96 ((My_lily_parser *) my_lily_parser)
98 #define yyerror THIS->parser_error
101 Add symbols to the TAGS field of a music object.
105 tag_music (Music*m, SCM tag, Input ip)
107 SCM tags = m->get_property ("tags");
108 if (gh_symbol_p (tag))
109 tags = scm_cons (tag, tags);
110 else if (gh_list_p (tag))
111 tags = gh_append2 (tag, tags);
113 ip.warning (_("Tag must be symbol or list of symbols."));
115 m->set_property ("tags", tags);
121 is_regular_identifier (SCM id)
123 String str = ly_scm2string (id);
124 char const *s = str.to_str0 () ;
129 v = v && isalpha (*s);
136 make_simple_markup (SCM a)
140 simple = scm_c_eval_string ("simple-markup");
142 return scm_list_2 (simple, a);
147 is_is_duration (int t)
149 return t && t == 1 << intlog2 (t);
153 set_music_properties (Music *p, SCM a)
155 for (SCM k = a; gh_pair_p (k); k = ly_cdr (k))
157 p->internal_set_property (ly_caar (k), ly_cdar (k));
162 make_chord_step (int step, int alter)
169 Pitch m((step -1) / 7 , (step - 1) % 7, alter);
170 return m.smobbed_copy ();
175 make_chord (SCM pitch, SCM dur, SCM modification_list)
177 static SCM chord_ctor;
179 chord_ctor= scm_c_eval_string ("construct-chord");
180 SCM ch= scm_call_3 (chord_ctor, pitch, dur, modification_list);
181 scm_gc_protect_object (ch);
186 Todo: actually also use apply iso. call too ...
189 ly_input_procedure_p (SCM x)
191 return gh_procedure_p (x)
192 || (gh_pair_p (x) && gh_procedure_p (gh_car (x)));
196 set_property_music (SCM sym, SCM value)
198 Music * p = MY_MAKE_MUSIC("PropertySet");
199 p->set_property ("symbol", sym);
200 p->set_property ("value", value);
206 /* We use SCMs to do strings, because it saves us the trouble of
207 deleting them. Let's hope that a stack overflow doesnt trigger a move
208 of the parse stack onto the heap. */
215 Music_output_def * outputdef;
222 yylex (YYSTYPE *s, void * v)
224 My_lily_parser *pars = (My_lily_parser*) v;
225 My_lily_lexer * lex = pars->lexer_;
227 lex->lexval = (void*) s;
228 lex->prepare_for_next_token();
229 return lex->yylex ();
250 %token CHORDMODIFIERS
255 %token COMMANDSPANREQUEST
263 %token FIGURES FIGURE_OPEN FIGURE_CLOSE
264 %token FIGURE_BRACKET_CLOSE FIGURE_BRACKET_OPEN
268 %token GROBDESCRIPTIONS
276 %token MULTI_MEASURE_REST
282 %token OVERRIDE SET REVERT
308 %token E_CHAR E_EXCLAMATION E_SMALLER E_BIGGER E_OPEN E_CLOSE
309 %token E_LEFTSQUARE E_RIGHTSQUARE E_TILDE
311 %token <i> E_UNSIGNED
312 %token CHORD_BASS CHORD_COLON CHORD_MINUS CHORD_CARET CHORD_SLASH
315 %type <i> exclamations questions dots optional_rest
317 %type <scm> grace_head
318 %type <scm> oct_check
319 %type <scm> context_mod_list
320 %type <scm> lyric_element
321 %type <scm> bass_number br_bass_figure bass_figure figure_list figure_spec
323 %token <scm> NOTENAME_PITCH
324 %token <scm> TONICNAME_PITCH
325 %token <scm> CHORDMODIFIER_PITCH
326 %token <scm> DURATION_IDENTIFIER
327 %token <scm> FRACTION
328 %token <id> IDENTIFIER
330 %token <scm> DRUM_PITCH
331 %token <scm> CHORD_MODIFIER
332 %token <scm> SCORE_IDENTIFIER
333 %token <scm> MUSIC_OUTPUT_DEF_IDENTIFIER
334 %token <scm> NUMBER_IDENTIFIER
335 %token <scm> EVENT_IDENTIFIER
336 %token <scm> MUSIC_IDENTIFIER TRANSLATOR_IDENTIFIER
337 %token <scm> STRING_IDENTIFIER SCM_IDENTIFIER
338 %token <scm> RESTNAME
345 %token <scm> MARKUP_HEAD_MARKUP0
346 %token <scm> MARKUP_HEAD_EMPTY
347 %token <scm> MARKUP_HEAD_MARKUP0_MARKUP1
348 %token <scm> MARKUP_HEAD_SCM0
349 %token <scm> MARKUP_HEAD_SCM0_MARKUP1
350 %token <scm> MARKUP_HEAD_SCM0_SCM1
351 %token <scm> MARKUP_HEAD_SCM0_SCM1_SCM2
352 %token <scm> MARKUP_HEAD_SCM0_SCM1_MARKUP2
354 %token <scm> MARKUP_IDENTIFIER MARKUP_HEAD_LIST0
355 %type <scm> markup markup_line markup_list markup_list_body full_markup
357 %type <outputdef> output_def
358 %type <scm> lilypond_header lilypond_header_body
359 %type <music> open_event close_event
360 %type <i> sub_quotes sup_quotes
361 %type <music> simple_element event_chord command_element Simple_music Composite_music
362 %type <music> Repeated_music
363 %type <scm> Alternative_music
364 %type <i> tremolo_type
365 %type <i> bare_int bare_unsigned
367 %type <scm> identifier_init
369 %type <music> note_chord_element chord_body chord_body_element
370 %type <scm> chord_body_elements
371 %type <scm> steno_duration optional_notemode_duration multiplied_duration
373 %type <scm> post_events
374 %type <music> gen_text_def direction_less_event direction_reqd_event
375 %type <scm> steno_pitch pitch absolute_pitch pitch_also_in_chords
376 %type <scm> steno_tonic_pitch
377 %type <scm> duration_length fraction
379 %type <scm> new_chord step_number chord_items chord_item chord_separator step_numbers
381 %type <scm> embedded_scm scalar
382 %type <music> Music Sequential_music Simultaneous_music
383 %type <music> relative_music re_rhythmed_music
384 %type <music> music_property_def context_change
385 %type <scm> context_prop_spec
386 %type <scm> Music_list
387 %type <scm> property_operation context_mod translator_mod optional_context_mod
388 %type <outputdef> music_output_def_body music_output_def_head
389 %type <music> post_event tagged_post_event
390 %type <music> command_req
391 %type <music> string_number_event
392 %type <scm> string bare_number number_expression number_term number_factor
393 %type <score> score_block score_body
395 %type <scm> translator_spec_block translator_spec_body
396 %type <music> tempo_event
397 %type <scm> script_abbreviation
403 /* We don't assign precedence to / and *, because we might need varied
404 prec levels in different prods */
410 lilypond: /* empty */
411 | lilypond toplevel_expression {}
412 | lilypond assignment { }
414 THIS->error_level_ = 1;
417 THIS->error_level_ = 1;
423 THIS->input_file_->header_ = $1;
428 SCM head = ly_module_p (sc->header_) ? sc->header_ : THIS->input_file_->header_.to_SCM ();
430 Path p = split_path (THIS->output_basename_);
431 int *c = &THIS->input_file_->score_count_;
434 p.base += "-" + to_string (*c);
438 SCM outname = scm_makfrom0str (p.to_string ().to_str0());
440 for (int i=0; i < sc->defs_.size (); i++)
441 default_rendering (sc->music_, sc->defs_[i]->self_scm(), head, outname);
443 if (sc->defs_.is_empty ())
445 Music_output_def *id =
446 unsmob_music_output_def (THIS->lexer_->lookup_identifier
449 id = id ? id->clone () : new Paper_def;
451 default_rendering (sc->music_, id->self_scm(), head, outname);
453 scm_gc_unprotect_object (id->self_scm ());
455 scm_gc_unprotect_object (sc->self_scm());
459 if (dynamic_cast<Paper_def*> ($1))
460 id = scm_makfrom0str ("$defaultpaper");
461 else if (dynamic_cast<Midi_def*> ($1))
462 id = scm_makfrom0str ("$defaultmidi");
463 THIS->lexer_->set_identifier (id, $1->self_scm ());
464 scm_gc_unprotect_object ($1->self_scm ());
476 lilypond_header_body:
478 $$ = ly_make_anonymous_module ();
479 THIS->lexer_->add_scope ($$);
481 | lilypond_header_body assignment {
487 HEADER '{' lilypond_header_body '}' {
488 $$ = THIS->lexer_-> remove_scope();
500 /* cont */ '=' identifier_init {
503 Should find generic way of associating input with objects.
505 Input ip = THIS->pop_spot ();
507 if (! is_regular_identifier ($1))
509 ip.warning (_ ("Identifier should have alphabetic characters only"));
512 THIS->lexer_->set_identifier ($1, $4);
515 TODO: devise standard for protection in parser.
517 The parser stack lives on the C-stack, which means that
518 all objects can be unprotected as soon as they're here.
528 $$ = $1->self_scm ();
529 scm_gc_unprotect_object ($$);
535 $$ = $1->self_scm ();
536 scm_gc_unprotect_object ($$);
538 | translator_spec_block {
542 $$ = $1->self_scm ();
543 scm_gc_unprotect_object ($$);
546 $$ = $1->self_scm ();
547 scm_gc_unprotect_object ($$);
549 | number_expression {
560 translator_spec_block:
561 TRANSLATOR '{' translator_spec_body '}'
567 translator_spec_body:
569 $$ = Context_def::make_scm ();
570 unsmob_context_def ($$)->set_spot (THIS->here_input ());
572 | TRANSLATOR_IDENTIFIER {
574 unsmob_context_def ($$)->set_spot (THIS->here_input ());
576 | translator_spec_body GROBDESCRIPTIONS embedded_scm {
577 Context_def*td = unsmob_context_def($$);
579 for (SCM p = $3; gh_pair_p (p); p = ly_cdr (p)) {
580 SCM tag = gh_caar (p);
582 /* TODO: should make new tag "grob-definition" ? */
583 td->add_context_mod (scm_list_3 (ly_symbol2scm ("assign"),
584 tag, gh_cons (ly_cdar (p), SCM_EOL)));
587 | translator_spec_body context_mod {
588 unsmob_context_def ($$)->add_context_mod ($2);
599 /*cont*/ '{' score_body '}' {
610 $$->set_spot (THIS->here_input ());
611 SCM m = $1->self_scm ();
612 scm_gc_unprotect_object (m);
617 SCM check_funcs = scm_c_eval_string ("toplevel-music-functions");
618 for (; gh_pair_p (check_funcs); check_funcs = gh_cdr (check_funcs))
619 m = gh_call1 (gh_car (check_funcs), m);
624 $$ = new Score ( *unsmob_score ($1));
625 $$->set_spot (THIS->here_input ());
627 | score_body lilypond_header {
630 | score_body output_def {
632 scm_gc_unprotect_object ($2->self_scm ());
644 music_output_def_body '}' {
646 THIS-> lexer_-> remove_scope ();
650 music_output_def_head:
652 Music_output_def *id = unsmob_music_output_def (THIS->lexer_->lookup_identifier ("$defaultmidi"));
657 p = dynamic_cast<Midi_def*> (id->clone ());
662 THIS->lexer_->add_scope (p->scope_);
665 Music_output_def *id = unsmob_music_output_def (THIS->lexer_->lookup_identifier ("$defaultpaper"));
668 p = dynamic_cast<Paper_def*> (id->clone ());
672 THIS->lexer_->add_scope (p->scope_);
678 music_output_def_body:
679 music_output_def_head '{' {
682 | music_output_def_head '{' MUSIC_OUTPUT_DEF_IDENTIFIER {
683 scm_gc_unprotect_object ($1->self_scm ());
684 Music_output_def * o = unsmob_music_output_def ($3);
686 THIS->lexer_->remove_scope ();
687 THIS->lexer_->add_scope (o->scope_);
689 | music_output_def_body assignment {
692 | music_output_def_body translator_spec_block {
693 $$->assign_translator ($2);
695 | music_output_def_body tempo_event {
697 junk this ? there already is tempo stuff in
700 int m = gh_scm2int ( $2->get_property ("metronome-count"));
701 Duration *d = unsmob_duration ($2->get_property ("tempo-unit"));
702 Midi_def * md = dynamic_cast<Midi_def*> ($$);
704 md->set_tempo (d->get_length (), m);
705 scm_gc_unprotect_object ($2->self_scm ());
707 | music_output_def_body error {
713 TEMPO steno_duration '=' bare_unsigned {
714 $$ = MY_MAKE_MUSIC("MetronomeChangeEvent");
715 $$->set_property ("tempo-unit", $2);
716 $$->set_property ("metronome-count", gh_int2scm ( $4));
721 The representation of a list is the
725 to have efficient append.
729 $$ = scm_cons (SCM_EOL, SCM_EOL);
733 SCM c = scm_cons ($2->self_scm (), SCM_EOL);
734 scm_gc_unprotect_object ($2->self_scm ()); /* UGH */
735 if (gh_pair_p (ly_cdr (s)))
736 gh_set_cdr_x (ly_cdr (s), c); /* append */
738 gh_set_car_x (s, c); /* set first cons */
739 gh_set_cdr_x (s, c) ; /* remember last cell */
755 | ALTERNATIVE '{' Music_list '}' {
761 REPEAT string bare_unsigned Music Alternative_music
765 SCM alts = gh_pair_p ($5) ? gh_car ($5) : SCM_EOL;
766 if (times < scm_ilength (alts)) {
767 unsmob_music (gh_car (alts))
768 ->origin ()->warning (
769 _("More alternatives than repeats. Junking excess alternatives."));
770 alts = ly_truncate_list (times, alts);
776 proc = scm_c_eval_string ("make-repeated-music");
778 SCM mus = scm_call_1 (proc, $2);
779 scm_gc_protect_object (mus); // UGH.
780 Music *r =unsmob_music (mus);
783 r-> set_property ("element", beg->self_scm ());
784 scm_gc_unprotect_object (beg->self_scm ());
786 r->set_property ("repeat-count", gh_int2scm (times >? 1));
788 r-> set_property ("elements",alts);
789 if (gh_equal_p ($2, scm_makfrom0str ("tremolo"))) {
791 we can not get durations and other stuff correct down the line, so we have to
792 add to the duration log here.
797 func = scm_primitive_eval (ly_symbol2scm ("shift-duration-log"));
799 int dots = ($3 % 3) ? 0 : 1;
800 int shift = -intlog2 ((dots) ? ($3*2/3) : $3);
802 Sequential_music * seq = dynamic_cast<Sequential_music*> ($4);
805 int list_len =scm_ilength (seq->music_list ());
807 seq->origin ()->warning ("Chord tremolo must have 2 elements.");
809 r->compress (Moment (Rational (1,list_len)));
811 gh_call3 (func, r->self_scm (), gh_int2scm(shift),gh_int2scm(dots));
814 r->set_spot (*$4->origin ());
821 SEQUENTIAL '{' Music_list '}' {
822 $$ = MY_MAKE_MUSIC("SequentialMusic");
823 $$->set_property ("elements", ly_car ($3));
824 $$->set_spot(THIS->here_input());
826 | '{' Music_list '}' {
827 $$ = MY_MAKE_MUSIC("SequentialMusic");
828 $$->set_property ("elements", ly_car ($2));
829 $$->set_spot(THIS->here_input());
834 SIMULTANEOUS '{' Music_list '}'{
835 $$ = MY_MAKE_MUSIC("SimultaneousMusic");
836 $$->set_property ("elements", ly_car ($3));
837 $$->set_spot(THIS->here_input());
840 | simul_open Music_list simul_close {
841 $$ = MY_MAKE_MUSIC("SimultaneousMusic");
842 $$->set_property ("elements", ly_car ($2));
843 $$->set_spot(THIS->here_input());
848 event_chord { $$ = $1; }
849 | APPLYOUTPUT embedded_scm {
850 if (!ly_input_procedure_p ($2))
851 THIS->parser_error (_ ("\\applycontext takes function argument"));
852 $$ = MY_MAKE_MUSIC ("ApplyOutputEvent");
853 $$->set_property ("procedure", $2);
854 $$->set_spot (THIS->here_input());
856 | APPLYCONTEXT embedded_scm {
857 if (!ly_input_procedure_p ($2))
858 THIS->parser_error (_ ("\\applycontext takes function argument"));
859 $$ = MY_MAKE_MUSIC ("ApplyContext");
860 $$->set_property ("procedure", $2);
861 $$->set_spot (THIS->here_input());
864 $$ = unsmob_music ($1);
871 optional_context_mod:
872 /**/ { $$ = SCM_EOL; }
873 | WITH '{' context_mod_list '}' { $$ = $3; }
877 GRACE { $$ = scm_makfrom0str ("Grace"); }
878 | ACCIACCATURA { $$ = scm_makfrom0str ("Acciaccatura"); }
879 | APPOGGIATURA { $$ = scm_makfrom0str ("Appoggiatura"); }
883 /* */ { $$ = SCM_EOL; }
884 | context_mod_list context_mod {
885 $$ = gh_cons ($2, $1);
893 proc = scm_c_eval_string ("make-autochange-music");
895 SCM res = scm_call_1 (proc, $2->self_scm ());
896 scm_gc_unprotect_object ($2->self_scm ());
897 $$ = unsmob_music (res);
898 scm_gc_protect_object (res);
899 $$->set_spot (THIS->here_input());
901 | PARTCOMBINE Music Music {
904 proc = scm_c_eval_string ("make-part-combine-music");
906 SCM res = scm_call_1 (proc, gh_list ($2->self_scm (),
907 $3->self_scm (), SCM_UNDEFINED));
908 scm_gc_unprotect_object ($3->self_scm ());
909 scm_gc_unprotect_object ($2->self_scm ());
910 $$ = unsmob_music (res);
911 scm_gc_protect_object (res);
912 $$->set_spot (THIS->here_input());
917 The other version is for easier debugging of
918 Sequential_music_iterator in combination with grace notes.
923 TODO: should distinguish between both grace types in the
924 basic music objects too, since the meaning is different.
928 String start_str = "start" + ly_scm2string ($1) + "Music";
929 String stop_str = "stop" + ly_scm2string ($1) + "Music";
931 SCM start = THIS->lexer_->lookup_identifier (start_str);
932 SCM stop = THIS->lexer_->lookup_identifier (stop_str);
934 Music *startm = unsmob_music (start);
935 Music *stopm = unsmob_music (stop);
939 stopm = stopm->clone ();
940 ms = scm_cons (stopm->self_scm (), ms);
941 scm_gc_unprotect_object (stopm->self_scm ());
943 ms = scm_cons ($2->self_scm (), ms);
944 scm_gc_unprotect_object ($2->self_scm());
946 startm = startm->clone ();
947 ms = scm_cons (startm->self_scm () , ms);
948 scm_gc_unprotect_object (startm->self_scm ());
951 Music* seq = MY_MAKE_MUSIC("SequentialMusic");
952 seq->set_property ("elements", ms);
955 $$ = MY_MAKE_MUSIC("GraceMusic");
956 $$->set_property ("element", seq->self_scm ());
957 scm_gc_unprotect_object (seq->self_scm ());
959 $$ = MY_MAKE_MUSIC("GraceMusic");
960 $$->set_property ("element", $2->self_scm ());
961 scm_gc_unprotect_object ($2->self_scm ());
964 | CONTEXT string '=' string optional_context_mod Music {
965 $$ = context_spec_music ($2, $4, $6, $5);
968 | CONTEXT STRING optional_context_mod Music {
969 $$ = context_spec_music ($2, SCM_UNDEFINED, $4, $3);
971 | NEWCONTEXT string optional_context_mod Music {
972 $$ = context_spec_music ($2, get_next_unique_context (),
983 int n = gh_scm2int (ly_car ($3)); int d = gh_scm2int (ly_cdr ($3));
986 $$= MY_MAKE_MUSIC("TimeScaledMusic");
987 $$->set_spot (THIS->pop_spot ());
989 $$->set_property ("element", mp->self_scm ());
990 scm_gc_unprotect_object (mp->self_scm ());
991 $$->set_property ("numerator", gh_int2scm (n));
992 $$->set_property ("denominator", gh_int2scm (d));
993 $$->compress (Moment (Rational (n,d)));
996 | Repeated_music { $$ = $1; }
997 | Simultaneous_music { $$ = $1; }
998 | Sequential_music { $$ = $1; }
999 | TRANSPOSE pitch_also_in_chords pitch_also_in_chords Music {
1000 $$ = MY_MAKE_MUSIC("TransposedMusic");
1002 Pitch from = *unsmob_pitch ($2);
1003 Pitch to = *unsmob_pitch ($3);
1005 p->transpose (interval (from, to));
1006 $$->set_property ("element", p->self_scm ());
1007 scm_gc_unprotect_object (p->self_scm ());
1009 | APPLY embedded_scm Music {
1010 if (!ly_input_procedure_p ($2))
1012 THIS->parser_error (_ ("\\apply takes function argument"));
1017 SCM ret = gh_call1 ($2, $3->self_scm ());
1018 Music *m = unsmob_music (ret);
1020 THIS->parser_error ("\\apply must return a Music");
1021 m = MY_MAKE_MUSIC("Music");
1028 SCM nn = THIS->lexer_->lookup_identifier ("pitchnames");
1029 THIS->lexer_->push_note_state (alist_to_hashq (nn));
1033 THIS->lexer_->pop_state ();
1037 SCM nn = THIS->lexer_->lookup_identifier ("drumPitchNames");
1038 THIS->lexer_->push_note_state (alist_to_hashq (nn));
1042 THIS->lexer_->pop_state ();
1045 { THIS->lexer_->push_figuredbass_state (); }
1048 Music * chm = MY_MAKE_MUSIC("UntransposableMusic");
1049 chm->set_property ("element", $3->self_scm ());
1051 scm_gc_unprotect_object ($3->self_scm());
1053 THIS->lexer_->pop_state ();
1056 SCM nn = THIS->lexer_->lookup_identifier ("chordmodifiers");
1057 THIS->lexer_->chordmodifier_tab_ = alist_to_hashq (nn);
1058 nn = THIS->lexer_->lookup_identifier ("pitchnames");
1059 THIS->lexer_->push_chord_state (alist_to_hashq (nn));
1062 Music * chm = MY_MAKE_MUSIC("UnrelativableMusic");
1063 chm->set_property ("element", $3->self_scm ());
1064 scm_gc_unprotect_object ($3->self_scm());
1067 THIS->lexer_->pop_state ();
1070 { THIS->lexer_->push_lyric_state (); }
1074 THIS->lexer_->pop_state ();
1076 | relative_music { $$ = $1; }
1077 | re_rhythmed_music { $$ = $1; }
1078 | TAG embedded_scm Music {
1079 tag_music ($3, $2, THIS->here_input ());
1085 RELATIVE absolute_pitch Music {
1087 Pitch pit = *unsmob_pitch ($2);
1088 $$ = MY_MAKE_MUSIC("RelativeOctaveMusic");
1090 $$->set_property ("element", p->self_scm ());
1091 scm_gc_unprotect_object (p->self_scm ());
1094 Pitch retpitch = p->to_relative_octave (pit);
1095 if (lily_1_8_relative)
1096 $$->set_property ("last-pitch", retpitch.smobbed_copy ());
1101 ADDLYRICS Music Music {
1102 Music*l =MY_MAKE_MUSIC("LyricCombineMusic");
1103 l->set_property ("elements", gh_list ($2->self_scm (), $3->self_scm (), SCM_UNDEFINED));
1104 scm_gc_unprotect_object ($3->self_scm ());
1105 scm_gc_unprotect_object ($2->self_scm ());
1108 | NEWADDLYRICS string Music {
1109 Music*l =MY_MAKE_MUSIC("NewLyricCombineMusic");
1110 l->set_property ("element", $3->self_scm ());
1111 scm_gc_unprotect_object ($3->self_scm ());
1113 l->set_property ("associated-context", $2);
1118 CHANGE STRING '=' STRING {
1119 Music*t= MY_MAKE_MUSIC("TranslatorChange");
1120 t-> set_property ("change-to-type", scm_string_to_symbol ($2));
1121 t-> set_property ("change-to-id", $4);
1124 $$->set_spot (THIS->here_input ());
1130 $$ = scm_list_3 (ly_symbol2scm ("assign"),
1131 scm_string_to_symbol ($1), $3);
1134 $$ = scm_list_2 (ly_symbol2scm ("unset"),
1135 scm_string_to_symbol ($2));
1137 | OVERRIDE STRING embedded_scm '=' embedded_scm {
1138 $$ = scm_list_4 (ly_symbol2scm ("push"),
1139 scm_string_to_symbol ($2), $3, $5);
1141 | REVERT STRING embedded_scm {
1142 $$ = scm_list_3 (ly_symbol2scm ("pop"),
1143 scm_string_to_symbol ($2), $3);
1148 CONSISTSEND { $$ = ly_symbol2scm ("consists-end"); }
1149 | CONSISTS { $$ = ly_symbol2scm ("consists"); }
1150 | REMOVE { $$ = ly_symbol2scm ("remove"); }
1152 | ACCEPTS { $$ = ly_symbol2scm ("accepts"); }
1153 | DENIES { $$ = ly_symbol2scm ("denies"); }
1155 | ALIAS { $$ = ly_symbol2scm ("alias"); }
1156 | TYPE { $$ = ly_symbol2scm ("translator-type"); }
1157 | DESCRIPTION { $$ = ly_symbol2scm ("description"); }
1158 | NAME { $$ = ly_symbol2scm ("context-name"); }
1162 property_operation { $$ = $1; }
1163 | translator_mod STRING {
1164 $$ = scm_list_2 ($1, $2);
1170 $$ = scm_list_2 (ly_symbol2scm ("Bottom"), scm_string_to_symbol ($1));
1172 | STRING '.' STRING {
1173 $$ = scm_list_2 (scm_string_to_symbol ($1), scm_string_to_symbol ($3));
1178 OVERRIDE context_prop_spec embedded_scm '=' scalar {
1179 $$ = property_op_to_music (scm_list_4 (
1180 ly_symbol2scm ("poppush"),
1183 $$= context_spec_music (gh_car ($2), SCM_UNDEFINED, $$, SCM_EOL);
1185 | REVERT context_prop_spec embedded_scm {
1186 $$ = property_op_to_music (scm_list_3 (
1187 ly_symbol2scm ("pop"),
1191 $$= context_spec_music (gh_car ($2), SCM_UNDEFINED, $$, SCM_EOL);
1193 | SET context_prop_spec '=' scalar {
1194 $$ = property_op_to_music (scm_list_3 (
1195 ly_symbol2scm ("assign"),
1198 $$= context_spec_music (gh_car ($2), SCM_UNDEFINED, $$, SCM_EOL);
1200 | UNSET context_prop_spec {
1201 $$ = property_op_to_music (scm_list_2 (
1202 ly_symbol2scm ("unset"),
1204 $$= context_spec_music (gh_car ($2), SCM_UNDEFINED, $$, SCM_EOL);
1206 | ONCE music_property_def {
1207 SCM e = $2->get_property ("element");
1208 unsmob_music (e)->set_property ("once", SCM_BOOL_T);
1218 | bare_int { $$ = gh_int2scm ($1); }
1219 | embedded_scm { $$ = $1; }
1220 | full_markup { $$ = $1; }
1221 | DIGIT { $$ = gh_int2scm ($1); }
1227 Adding pre_events to the simple_element
1228 makes the choice between
1234 simple_element: STRING
1236 a single shift/reduction conflict.
1238 nevertheless, this is not very clean, and we should find a different
1248 pre_events simple_element post_events {
1249 SCM elts = $2-> get_property ("elements");
1251 elts = gh_append2 (elts, scm_reverse_x ($3, SCM_EOL));
1253 $2->set_property ("elements", elts);
1257 | note_chord_element
1262 chord_body optional_notemode_duration post_events
1264 SCM dur = unsmob_duration ($2)->smobbed_copy();
1265 SCM es = $1->get_property ("elements");
1266 SCM postevs = scm_reverse_x ($3, SCM_EOL);
1268 for (SCM s = es; gh_pair_p (s); s = gh_cdr (s))
1269 unsmob_music (gh_car(s))->set_property ("duration", dur);
1270 es = gh_append2 (es, postevs);
1272 $1-> set_property ("elements", es);
1283 simul_open: LESSLESS
1286 simul_close: MOREMORE
1290 chord_open chord_body_elements chord_close
1292 $$ = MY_MAKE_MUSIC("EventChord");
1293 $$->set_property ("elements",
1294 scm_reverse_x ($2, SCM_EOL));
1298 chord_body_elements:
1299 /* empty */ { $$ = SCM_EOL; }
1300 | chord_body_elements chord_body_element {
1301 $$ = gh_cons ($2->self_scm(), $1);
1302 scm_gc_unprotect_object ($2->self_scm());
1307 pitch exclamations questions post_events
1309 Music * n = MY_MAKE_MUSIC("NoteEvent");
1310 n->set_property ("pitch", $1);
1312 n->set_property ("cautionary", SCM_BOOL_T);
1313 if ($2 % 2 || $3 % 2)
1314 n->set_property ("force-accidental", SCM_BOOL_T);
1316 if (gh_pair_p ($4)) {
1317 SCM arts = scm_reverse_x ($4, SCM_EOL);
1318 n->set_property ("articulations", arts);
1322 | DRUM_PITCH post_events {
1323 Music *n = MY_MAKE_MUSIC("NoteEvent");
1324 n->set_property ("duration" ,$2);
1325 n->set_property ("drum-type" , $1);
1326 n->set_spot (THIS->here_input());
1328 if (gh_pair_p ($2)) {
1329 SCM arts = scm_reverse_x ($2, SCM_EOL);
1330 n->set_property ("articulations", arts);
1338 $$ = MY_MAKE_MUSIC("EventChord");
1339 $$->set_property ("elements", scm_cons ($1->self_scm (), SCM_EOL));
1340 scm_gc_unprotect_object ($1->self_scm());
1342 $$-> set_spot (THIS->here_input ());
1343 $1-> set_spot (THIS->here_input ());
1345 | SKIP duration_length {
1346 Music * skip = MY_MAKE_MUSIC("SkipMusic");
1347 skip->set_property ("duration", $2);
1351 | QUOTE duration_length STRING {
1352 SCM tab = THIS->lexer_->lookup_identifier ("musicQuotes");
1354 if (scm_hash_table_p (tab) == SCM_BOOL_T)
1356 SCM key = $3; // use symbol?
1357 evs = scm_hash_ref (tab, key, SCM_BOOL_F);
1360 if (scm_vector_p (evs) == SCM_BOOL_T)
1362 quote = MY_MAKE_MUSIC("QuoteMusic");
1363 quote->set_property ("duration", $2);
1364 quote->set_property ("quoted-events", evs);
1366 THIS->here_input ().warning (_f ("Can\'t find music."));
1367 quote = MY_MAKE_MUSIC ("Event");
1369 quote->set_spot (THIS->here_input ());
1372 | OCTAVE { THIS->push_spot (); }
1374 Music *l = MY_MAKE_MUSIC("RelativeOctaveCheck");
1376 $$->set_spot (THIS->pop_spot ());
1377 $$->set_property ("pitch", $3);
1380 Music *l = MY_MAKE_MUSIC("LigatureEvent");
1381 l->set_property ("span-direction", gh_int2scm (START));
1382 l->set_spot (THIS->here_input ());
1384 $$ = MY_MAKE_MUSIC("EventChord");
1385 $$->set_property ("elements", scm_cons (l->self_scm (), SCM_EOL));
1386 scm_gc_unprotect_object (l->self_scm());
1387 $$->set_spot (THIS->here_input ());
1390 Music *l = MY_MAKE_MUSIC("LigatureEvent");
1391 l->set_property ("span-direction", gh_int2scm (STOP));
1392 l->set_spot (THIS->here_input ());
1394 $$ = MY_MAKE_MUSIC("EventChord");
1395 $$->set_property ("elements", scm_cons (l->self_scm (), SCM_EOL));
1396 $$->set_spot (THIS->here_input ());
1397 scm_gc_unprotect_object (l->self_scm());
1400 $$ = MY_MAKE_MUSIC("VoiceSeparator");
1401 $$->set_spot (THIS->here_input ());
1405 $$ = MY_MAKE_MUSIC("BarCheck");
1406 $$->set_spot (THIS->here_input ());
1409 Music *t = set_property_music (ly_symbol2scm ("whichBar"), $2);
1411 Music *csm = context_spec_music (ly_symbol2scm ("Timing"), SCM_UNDEFINED,
1413 $$ = context_spec_music (ly_symbol2scm ("Score"), SCM_UNDEFINED, csm, SCM_EOL);
1414 $$->set_spot (THIS->here_input ());
1415 t->set_spot (THIS->here_input ());
1417 | PARTIAL duration_length {
1418 Moment m = - unsmob_duration ($2)->get_length ();
1419 Music * p = set_property_music (ly_symbol2scm ( "measurePosition"),m.smobbed_copy ());
1420 p->set_spot (THIS->here_input ());
1421 p = context_spec_music (ly_symbol2scm ("Timing"), SCM_UNDEFINED,
1423 p = context_spec_music (ly_symbol2scm ("Score"), SCM_UNDEFINED,
1430 proc = scm_c_eval_string ("make-clef-set");
1432 SCM result = scm_call_1 (proc, $2);
1433 scm_gc_protect_object (result);
1434 $$ = unsmob_music (result);
1439 proc = scm_c_eval_string ("make-time-signature-set");
1441 SCM result = scm_apply_2 (proc, gh_car ($2), gh_cdr ($2), SCM_EOL);
1442 scm_gc_protect_object (result);
1443 $$ = unsmob_music (result);
1448 proc = scm_c_eval_string ("make-mark-set");
1450 SCM result = scm_call_1 (proc, $2);
1451 scm_gc_protect_object (result);
1452 $$ = unsmob_music (result);
1458 $$ = MY_MAKE_MUSIC("BreathingSignEvent");
1461 $$ = MY_MAKE_MUSIC("PesOrFlexaEvent");
1464 Music * m = MY_MAKE_MUSIC("MarkEvent");
1471 Music *key= MY_MAKE_MUSIC("KeyChangeEvent");
1474 | KEY NOTENAME_PITCH SCM_IDENTIFIER {
1476 Music *key= MY_MAKE_MUSIC("KeyChangeEvent");
1477 if (scm_ilength ($3) > 0)
1479 key->set_property ("pitch-alist", $3);
1480 key->set_property ("tonic", Pitch (0,0,0).smobbed_copy());
1481 ((Music*)key)->transpose (* unsmob_pitch ($2));
1483 THIS->parser_error (_("Second argument must be pitch list."));
1494 | post_events post_event {
1495 $2->set_spot (THIS->here_input ());
1496 $$ = gh_cons ($2->self_scm(), $$);
1497 scm_gc_unprotect_object ($2->self_scm());
1499 | post_events tagged_post_event {
1500 $2 -> set_spot (THIS->here_input ());
1501 $$ = scm_cons ($2->self_scm(), $$);
1502 scm_gc_unprotect_object ($2->self_scm());
1508 '-' TAG embedded_scm post_event {
1509 tag_music ($4, $3, THIS->here_input ());
1515 direction_less_event {
1519 if (!THIS->lexer_->is_lyric_state ())
1520 THIS->parser_error (_ ("Have to be in Lyric mode for lyrics"));
1521 $$ = MY_MAKE_MUSIC("HyphenEvent");
1524 if (!THIS->lexer_->is_lyric_state ())
1525 THIS->parser_error (_ ("Have to be in Lyric mode for lyrics"));
1526 $$ = MY_MAKE_MUSIC("ExtenderEvent");
1528 | script_dir direction_reqd_event {
1530 $2->set_property ("direction", gh_int2scm ($1));
1533 | script_dir direction_less_event {
1535 $2->set_property ("direction", gh_int2scm ($1));
1538 | string_number_event
1541 string_number_event:
1543 Music * s = MY_MAKE_MUSIC("StringNumberEvent");
1544 s->set_property ("string-number", gh_int2scm($1));
1545 s->set_spot (THIS->here_input ());
1551 direction_less_event:
1557 TODO: should take all these defs out of the parser, adn make use
1561 (set-articulation '~ "trill")
1564 Music * m = MY_MAKE_MUSIC ("BeamEvent");
1565 m->set_spot (THIS->here_input());
1566 m->set_property ("span-direction" , gh_int2scm (START));
1570 Music * m = MY_MAKE_MUSIC ("BeamEvent");
1571 m->set_spot (THIS->here_input());
1572 m->set_property ("span-direction" , gh_int2scm (STOP));
1576 Music * m = MY_MAKE_MUSIC ("TieEvent");
1577 m->set_spot (THIS->here_input());
1582 dynamic_cast<Music *> ($$)->set_property ("span-direction",
1583 gh_int2scm (START));
1587 dynamic_cast<Music *> ($$)->set_property ("span-direction",
1590 | EVENT_IDENTIFIER {
1591 $$ = unsmob_music ($1);
1594 Music * a = MY_MAKE_MUSIC("TremoloEvent");
1595 a->set_spot (THIS->here_input ());
1596 a->set_property ("tremolo-type", gh_int2scm ($1));
1601 direction_reqd_event:
1605 | script_abbreviation {
1606 SCM s = THIS->lexer_->lookup_identifier ("dash" + ly_scm2string ($1));
1607 Music *a = MY_MAKE_MUSIC("ArticulationEvent");
1608 if (gh_string_p (s))
1609 a->set_property ("articulation-type", s);
1610 else THIS->parser_error (_ ("Expecting string as script definition"));
1616 /**/ { $$ = SCM_EOL; }
1617 | '=' { $$ = gh_int2scm (0); }
1618 | '=' sub_quotes { $$ = gh_int2scm ($2); }
1619 | '=' sup_quotes { $$ = gh_int2scm ($2); }
1644 | NOTENAME_PITCH sup_quotes {
1645 Pitch p = *unsmob_pitch ($1);
1646 p = p.transposed (Pitch ($2,0,0));
1647 $$ = p.smobbed_copy ();
1649 | NOTENAME_PITCH sub_quotes {
1650 Pitch p =* unsmob_pitch ($1);
1651 p = p.transposed (Pitch (-$2,0,0));
1652 $$ = p.smobbed_copy ();
1664 | TONICNAME_PITCH sup_quotes {
1665 Pitch p = *unsmob_pitch ($1);
1666 p = p.transposed (Pitch ($2,0,0));
1667 $$ = p.smobbed_copy ();
1669 | TONICNAME_PITCH sub_quotes {
1670 Pitch p =* unsmob_pitch ($1);
1672 p = p.transposed (Pitch (-$2,0,0));
1673 $$ = p.smobbed_copy ();
1683 pitch_also_in_chords:
1690 Music * s= MY_MAKE_MUSIC("SlurEvent");
1692 s->set_spot (THIS->here_input());
1695 Music * s= MY_MAKE_MUSIC("PhrasingSlurEvent");
1697 s->set_spot (THIS->here_input());
1700 Music *s =MY_MAKE_MUSIC("CrescendoEvent");
1702 s->set_spot (THIS->here_input());
1705 Music *s =MY_MAKE_MUSIC("DecrescendoEvent");
1707 s->set_spot (THIS->here_input());
1714 Music *s = MY_MAKE_MUSIC("CrescendoEvent");
1715 s->set_spot (THIS->here_input());
1720 Music * s= MY_MAKE_MUSIC("SlurEvent");
1722 s->set_spot (THIS->here_input());
1726 Music * s= MY_MAKE_MUSIC("PhrasingSlurEvent");
1728 s->set_property ("span-type", scm_makfrom0str ( "phrasing-slur"));
1729 s->set_spot (THIS->here_input());
1735 Music *t = MY_MAKE_MUSIC("TextScriptEvent");
1736 t->set_property ("text", $1);
1737 t->set_spot (THIS->here_input ());
1741 Music *t = MY_MAKE_MUSIC("TextScriptEvent");
1742 t->set_property ("text", make_simple_markup ($1));
1743 t->set_spot (THIS->here_input ());
1748 Music * t = MY_MAKE_MUSIC("FingerEvent");
1749 t->set_property ("digit", gh_int2scm ($1));
1750 t->set_spot (THIS->here_input ());
1755 script_abbreviation:
1757 $$ = scm_makfrom0str ("Hat");
1760 $$ = scm_makfrom0str ("Plus");
1763 $$ = scm_makfrom0str ("Dash");
1766 $$ = scm_makfrom0str ("Bar");
1769 $$ = scm_makfrom0str ("Larger");
1772 $$ = scm_makfrom0str ("Dot");
1775 $$ = scm_makfrom0str ("Underscore");
1782 | '-' { $$ = CENTER; }
1793 multiplied_duration {
1798 optional_notemode_duration:
1800 Duration dd = THIS->default_duration_;
1801 $$ = dd.smobbed_copy ();
1803 THIS->beam_check ($$);
1805 | multiplied_duration {
1807 THIS->default_duration_ = *unsmob_duration ($$);
1809 THIS->beam_check ($$);
1814 bare_unsigned dots {
1816 if (!is_is_duration ($1))
1817 THIS->parser_error (_f ("not a duration: %d", $1));
1821 $$ = Duration (l, $2).smobbed_copy ();
1823 | DURATION_IDENTIFIER dots {
1824 Duration *d =unsmob_duration ($1);
1825 Duration k (d->duration_log (),d->dot_count () + $2);
1835 multiplied_duration:
1839 | multiplied_duration '*' bare_unsigned {
1840 $$ = unsmob_duration ($$)->compressed ( $3) .smobbed_copy ();
1842 | multiplied_duration '*' FRACTION {
1843 Rational m (gh_scm2int (ly_car ($3)), gh_scm2int (ly_cdr ($3)));
1845 $$ = unsmob_duration ($$)->compressed (m).smobbed_copy ();
1850 FRACTION { $$ = $1; }
1851 | UNSIGNED '/' UNSIGNED {
1852 $$ = scm_cons (gh_int2scm ($1), gh_int2scm ($3));
1870 | ':' bare_unsigned {
1871 if (!is_is_duration ($2))
1872 THIS->parser_error (_f ("not a duration: %d", $2));
1879 /*****************************************************************
1881 *****************************************************************/
1884 $$ = scm_number_to_string (gh_int2scm ($1), gh_int2scm (10));
1887 $$ = scm_number_to_string (gh_int2scm ($1), gh_int2scm (10));
1889 | STRING { $$ = $1; }
1900 Music *bfr = MY_MAKE_MUSIC("BassFigureEvent");
1901 $$ = bfr->self_scm();
1902 scm_gc_unprotect_object ($$);
1905 Music *bfr = MY_MAKE_MUSIC("BassFigureEvent");
1906 $$ = bfr->self_scm();
1908 bfr->set_property ("figure", $1);
1910 scm_gc_unprotect_object ($$);
1912 | bass_figure bass_mod {
1913 Music *m = unsmob_music ($1);
1915 SCM salter =m->get_property ("alteration");
1916 int alter = gh_number_p ( salter) ? gh_scm2int (salter) : 0;
1917 m->set_property ("alteration",
1918 gh_int2scm (alter + $2));
1920 m->set_property ("alteration", gh_int2scm (0));
1928 unsmob_music ($$)->set_property ("bracket-start", SCM_BOOL_T);
1933 | br_bass_figure ']' {
1935 unsmob_music ($1)->set_property ("bracket-stop", SCM_BOOL_T);
1943 | figure_list br_bass_figure {
1944 $$ = scm_cons ($2, $1);
1949 FIGURE_OPEN figure_list FIGURE_CLOSE {
1950 Music * m = MY_MAKE_MUSIC("EventChord");
1951 $2 = scm_reverse_x ($2, SCM_EOL);
1952 m->set_property ("elements", $2);
1953 $$ = m->self_scm ();
1964 pitch exclamations questions oct_check optional_notemode_duration optional_rest {
1966 Input i = THIS->pop_spot ();
1967 if (!THIS->lexer_->is_note_state ())
1968 THIS->parser_error (_ ("Have to be in Note mode for notes"));
1972 n = MY_MAKE_MUSIC("RestEvent");
1974 n = MY_MAKE_MUSIC("NoteEvent");
1976 n->set_property ("pitch", $1);
1977 n->set_property ("duration", $5);
1979 if (gh_number_p ($4))
1981 int q = gh_scm2int ($4);
1982 n->set_property ("absolute-octave", gh_int2scm (q-1));
1986 n->set_property ("cautionary", SCM_BOOL_T);
1987 if ($2 % 2 || $3 % 2)
1988 n->set_property ("force-accidental", SCM_BOOL_T);
1990 Music *v = MY_MAKE_MUSIC("EventChord");
1991 v->set_property ("elements", scm_list_1 (n->self_scm ()));
1992 scm_gc_unprotect_object (n->self_scm());
1998 | DRUM_PITCH optional_notemode_duration {
1999 Input i = THIS->pop_spot ();
2001 Music *n = MY_MAKE_MUSIC("NoteEvent");
2002 n->set_property ("duration" ,$2);
2003 n->set_property ("drum-type" , $1);
2005 Music *v = MY_MAKE_MUSIC("EventChord");
2006 v->set_property ("elements", scm_list_1 (n->self_scm ()));
2007 scm_gc_unprotect_object (n->self_scm());
2013 | figure_spec optional_notemode_duration {
2014 Music * m = unsmob_music ($1);
2015 Input i = THIS->pop_spot ();
2017 for (SCM s = m->get_property ("elements"); gh_pair_p (s); s = ly_cdr (s))
2019 unsmob_music (ly_car (s))->set_property ("duration", $2);
2023 | RESTNAME optional_notemode_duration {
2025 Input i = THIS->pop_spot ();
2027 if (ly_scm2string ($1) =="s") {
2029 ev = MY_MAKE_MUSIC("SkipEvent");
2032 ev = MY_MAKE_MUSIC("RestEvent");
2035 ev->set_property ("duration" ,$2);
2037 Music * velt = MY_MAKE_MUSIC("EventChord");
2038 velt->set_property ("elements", scm_list_1 (ev->self_scm ()));
2041 scm_gc_unprotect_object (ev->self_scm());
2045 | MULTI_MEASURE_REST optional_notemode_duration {
2050 proc = scm_c_eval_string ("make-multi-measure-rest");
2052 SCM mus = scm_call_2 (proc, $2,
2053 make_input (THIS->here_input()));
2054 scm_gc_protect_object (mus);
2055 $$ = unsmob_music (mus);
2058 | lyric_element optional_notemode_duration {
2059 Input i = THIS->pop_spot ();
2060 if (!THIS->lexer_->is_lyric_state ())
2061 THIS->parser_error (_ ("Have to be in Lyric mode for lyrics"));
2063 Music * lreq = MY_MAKE_MUSIC("LyricEvent");
2064 lreq->set_property ("text", $1);
2065 lreq->set_property ("duration",$2);
2067 Music * velt = MY_MAKE_MUSIC("EventChord");
2068 velt->set_property ("elements", scm_list_1 (lreq->self_scm ()));
2075 if (!THIS->lexer_->is_chord_state ())
2076 THIS->parser_error (_ ("Have to be in Chord mode for chords"));
2077 $$ = unsmob_music ($1);
2082 full_markup { $$ = $1; }
2083 | STRING { $$ = $1 ; }
2087 steno_tonic_pitch optional_notemode_duration {
2088 $$ = make_chord ($1, $2, SCM_EOL);
2090 | steno_tonic_pitch optional_notemode_duration chord_separator chord_items {
2091 SCM its = scm_reverse_x ($4, SCM_EOL);
2092 $$ = make_chord ($1, $2, gh_cons ($3, its));
2100 | chord_items chord_item {
2101 $$ = gh_cons ($2, $$);
2107 $$ = ly_symbol2scm ("chord-colon");
2110 $$ = ly_symbol2scm ("chord-caret");
2112 | CHORD_SLASH steno_tonic_pitch {
2113 $$ = scm_list_2 (ly_symbol2scm ("chord-slash"), $2);
2115 | CHORD_BASS steno_tonic_pitch {
2116 $$ = scm_list_2 (ly_symbol2scm ("chord-bass"), $2);
2125 $$ = scm_reverse_x ($1, SCM_EOL);
2133 step_number { $$ = gh_cons ($1, SCM_EOL); }
2134 | step_numbers '.' step_number {
2135 $$ = gh_cons ($3, $$);
2141 $$ = make_chord_step ($1, 0);
2143 | bare_unsigned '+' {
2144 $$ = make_chord_step ($1, SHARP);
2146 | bare_unsigned CHORD_MINUS {
2147 $$ = make_chord_step ($1, FLAT);
2154 TODO: should deprecate in favor of Scheme?
2158 number_expression '+' number_term {
2159 $$ = scm_sum ($1, $3);
2161 | number_expression '-' number_term {
2162 $$ = scm_difference ($1, $3);
2171 | number_factor '*' number_factor {
2172 $$ = scm_product ($1, $3);
2174 | number_factor '/' number_factor {
2175 $$ = scm_divide ($1, $3);
2180 '-' number_factor { /* %prec UNARY_MINUS */
2181 $$ = scm_difference ($2, SCM_UNDEFINED);
2189 $$ = gh_int2scm ($1);
2194 | NUMBER_IDENTIFIER {
2197 | REAL NUMBER_IDENTIFIER {
2198 $$ = gh_double2scm (gh_scm2double ($1) * gh_scm2double ($2));
2200 | UNSIGNED NUMBER_IDENTIFIER {
2201 $$ = gh_double2scm ($1 * gh_scm2double ($2));
2217 if (scm_integer_p ($1) == SCM_BOOL_T)
2219 int k = gh_scm2int ($1);
2223 THIS->parser_error (_ ("need integer number arg"));
2237 | STRING_IDENTIFIER {
2240 | string '+' string {
2241 $$ = scm_string_append (scm_list_2 ($1, $3));
2248 | exclamations '!' { $$ ++; }
2253 | questions '?' { $$ ++; }
2263 { THIS->lexer_->push_markup_state (); }
2266 THIS->lexer_->pop_state ();
2272 This should be done more dynamically if possible.
2276 $$ = make_simple_markup ($1);
2278 | MARKUP_HEAD_EMPTY {
2279 $$ = scm_list_1 ($1);
2281 | MARKUP_HEAD_MARKUP0 markup {
2282 $$ = scm_list_2 ($1, $2);
2284 | MARKUP_HEAD_MARKUP0_MARKUP1 markup markup {
2285 $$ = scm_list_3 ($1, $2, $3);
2287 | MARKUP_HEAD_SCM0_MARKUP1 SCM_T markup {
2288 $$ = scm_list_3 ($1, $2, $3);
2293 | MARKUP_HEAD_LIST0 markup_list {
2294 $$ = scm_list_2 ($1,$2);
2296 | MARKUP_HEAD_SCM0 embedded_scm {
2297 $$ = scm_list_2 ($1, $2);
2299 | MARKUP_HEAD_SCM0_SCM1_MARKUP2 embedded_scm embedded_scm markup {
2300 $$ = scm_list_4 ($1, $2, $3, $4);
2302 | MARKUP_HEAD_SCM0_SCM1_SCM2 embedded_scm embedded_scm embedded_scm {
2303 $$ = scm_list_4 ($1, $2, $3, $4);
2305 | MARKUP_HEAD_SCM0_SCM1 embedded_scm embedded_scm {
2306 $$ = scm_list_3 ($1, $2, $3);
2308 | MARKUP_IDENTIFIER {
2315 chord_open markup_list_body chord_close { $$ = scm_reverse_x ($2, SCM_EOL); }
2319 '{' markup_list_body '}' {
2322 line = scm_c_eval_string ("line-markup");
2324 $$ = scm_list_2 (line, scm_reverse_x ($2, SCM_EOL));
2329 /**/ { $$ = SCM_EOL; }
2330 | markup_list_body markup {
2331 $$ = gh_cons ($2, $1) ;
2339 My_lily_parser::set_yydebug (bool )
2346 extern My_lily_parser * current_parser;
2349 My_lily_parser::do_yyparse ()
2351 current_parser = this;;
2352 yyparse ((void*)this);
2357 Should make this optional? It will also complain when you do
2361 which is entirely legitimate.
2363 Or we can scrap it. Barchecks should detect wrong durations, and
2364 skipTypesetting speeds it up a lot.
2368 My_lily_parser::beam_check (SCM dur)
2370 Duration *d = unsmob_duration (dur);
2371 if (unsmob_music (last_beam_start_) && d->duration_log () <= 2)
2373 Music * m = unsmob_music (last_beam_start_);
2374 m->origin ()->warning (_("Suspect duration found following this beam"));
2376 last_beam_start_ = SCM_EOL;
2384 It is a little strange to have this function in this file, but
2385 otherwise, we have to import music classes into the lexer.
2389 My_lily_lexer::try_special_identifiers (SCM * destination, SCM sid)
2391 if (gh_string_p (sid)) {
2393 return STRING_IDENTIFIER;
2394 } else if (gh_number_p (sid)) {
2396 return NUMBER_IDENTIFIER;
2397 } else if (unsmob_context_def (sid)) {
2398 *destination = unsmob_context_def (sid)->clone_scm();
2399 return TRANSLATOR_IDENTIFIER;
2400 } else if (unsmob_score (sid)) {
2401 Score *sc = new Score (*unsmob_score (sid));
2402 *destination =sc->self_scm ();
2403 return SCORE_IDENTIFIER;
2404 } else if (Music * mus =unsmob_music (sid)) {
2405 *destination = unsmob_music (sid)->clone ()->self_scm();
2406 unsmob_music (*destination)->
2407 set_property ("origin", make_input (last_input_));
2408 return dynamic_cast<Event*> (mus)
2409 ? EVENT_IDENTIFIER : MUSIC_IDENTIFIER;
2410 } else if (unsmob_duration (sid)) {
2411 *destination = unsmob_duration (sid)->smobbed_copy();
2412 return DURATION_IDENTIFIER;
2413 } else if (unsmob_music_output_def (sid)) {
2414 Music_output_def *p = unsmob_music_output_def (sid);
2417 *destination = p->self_scm();
2418 return MUSIC_OUTPUT_DEF_IDENTIFIER;
2419 } else if (Text_item::markup_p (sid)) {
2421 return MARKUP_IDENTIFIER;
2428 property_op_to_music (SCM op)
2431 SCM tag = gh_car (op);
2432 SCM symbol = gh_cadr (op);
2433 SCM args = gh_cddr (op);
2434 SCM grob_val = SCM_UNDEFINED;
2435 SCM grob_sym = SCM_UNDEFINED;
2436 SCM val = SCM_UNDEFINED;
2438 if (tag == ly_symbol2scm ("assign"))
2440 m = MY_MAKE_MUSIC("PropertySet");
2441 val = gh_car (args);
2443 else if (tag == ly_symbol2scm ("unset"))
2444 m = MY_MAKE_MUSIC("PropertyUnset");
2445 else if (tag == ly_symbol2scm ("poppush")
2446 || tag == ly_symbol2scm ("push"))
2448 m = MY_MAKE_MUSIC("OverrideProperty");
2449 grob_sym = gh_car (args);
2450 grob_val = gh_cadr (args);
2452 else if (tag == ly_symbol2scm ("pop")) {
2453 m = MY_MAKE_MUSIC("RevertProperty");
2454 grob_sym = gh_car (args);
2457 m->set_property ("symbol", symbol);
2459 if (val != SCM_UNDEFINED)
2460 m->set_property ("value", val);
2461 if (grob_val != SCM_UNDEFINED)
2462 m->set_property ("grob-value", grob_val);
2464 if (grob_sym != SCM_UNDEFINED)
2466 bool itc = internal_type_checking_global_b;
2469 bool autobeam = gh_equal_p (symbol, ly_symbol2scm ("autoBeamSettings"));
2471 internal_type_checking_global_b = false;
2472 m->set_property ("grob-property", grob_sym);
2474 internal_type_checking_global_b = itc;
2477 if (op == ly_symbol2scm ("poppush"))
2478 m->set_property ("pop-first", SCM_BOOL_T);
2485 context_spec_music (SCM type, SCM id, Music * m, SCM ops)
2487 Music * csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
2489 csm->set_property ("element", m->self_scm ());
2490 scm_gc_unprotect_object (m->self_scm ());
2492 csm->set_property ("context-type",
2493 gh_symbol_p (type) ? type : scm_string_to_symbol (type));
2494 csm->set_property ("property-operations", ops);
2496 if (gh_string_p (id))
2497 csm->set_property ("context-id", id);
2503 get_next_unique_context ()
2505 static int new_context_count;
2508 snprintf (s, 1024, "uniqueContext%d", new_context_count ++);
2510 return scm_makfrom0str (s);