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 Two shift/reduce problems:
17 "bar" -> String -> Lyric -> Music -> music-assignment
19 "bar" -> String -> string-assignment
23 \repeat .. \alternative
26 \repeat { \repeat .. \alternative }
30 \repeat { \repeat } \alternative
42 * The rules for who is protecting what are very shady. Uniformise
45 * There are too many lexical modes?
53 #include "scm-option.hh"
54 #include "translator-def.hh"
55 #include "lily-guile.hh"
57 #include "my-lily-lexer.hh"
58 #include "paper-def.hh"
59 #include "midi-def.hh"
61 #include "file-path.hh"
63 #include "dimensions.hh"
64 #include "my-lily-parser.hh"
66 #include "input-file-results.hh"
68 #include "lilypond-input-version.hh"
69 #include "scm-hash.hh"
70 #include "auto-change-iterator.hh"
71 #include "ly-modules.hh"
72 #include "music-sequence.hh"
73 #include "input-smob.hh"
75 #include "text-item.hh"
76 #include "music-list.hh"
79 #define MY_MAKE_MUSIC(x) make_music_by_name (ly_symbol2scm (x))
83 #define YYERROR_VERBOSE 1
85 My_lily_parser* my_lily_parser;
86 #define YYPARSE_PARAM my_lily_parser
87 #define YYLEX_PARAM my_lily_parser
89 ((My_lily_parser *) my_lily_parser)
91 #define yyerror THIS->parser_error
98 regular_identifier_b (SCM id)
100 String str = ly_scm2string (id);
101 char const *s = str.to_str0 () ;
106 v = v && isalpha (*s);
113 make_simple_markup (SCM a)
117 simple = scm_c_eval_string ("simple-markup");
119 return scm_list_n (simple, a, SCM_UNDEFINED);
124 is_duration_b (int t)
126 return t && t == 1 << intlog2 (t);
130 set_music_properties (Music *p, SCM a)
132 for (SCM k = a; gh_pair_p (k); k = ly_cdr (k))
134 p->internal_set_mus_property (ly_caar (k), ly_cdar (k));
139 make_chord_step (int step, int alter)
144 /* ugh: fucks up above 13 */
145 Pitch m(step > 7 ? 1 : 0,(step - 1) % 7, alter);
146 return m.smobbed_copy ();
151 make_chord (SCM pitch, SCM dur, SCM modification_list)
153 static SCM chord_ctor;
155 chord_ctor= scm_c_eval_string ("construct-chord");
156 SCM ch= scm_call_3 (chord_ctor, pitch, dur, modification_list);
157 scm_gc_protect_object (ch);
162 Todo: actually also use apply iso. call too ...
165 ly_input_procedure_p (SCM x)
167 return gh_procedure_p (x)
168 || (gh_pair_p (x) && gh_procedure_p (gh_car (x)));
172 set_property_music (SCM sym, SCM value)
174 Music * p = MY_MAKE_MUSIC("PropertySet");
175 p->set_mus_property ("symbol", sym);
176 p->set_mus_property ("value", value);
182 /* We use SCMs to do strings, because it saves us the trouble of
183 deleting them. Let's hope that a stack overflow doesnt trigger a move
184 of the parse stack onto the heap. */
191 Music_output_def * outputdef;
198 yylex (YYSTYPE *s, void * v)
200 My_lily_parser *pars = (My_lily_parser*) v;
201 My_lily_lexer * lex = pars->lexer_;
203 lex->lexval = (void*) s;
204 lex->prepare_for_next_token();
205 return lex->yylex ();
224 %token CHORDMODIFIERS
229 %token COMMANDSPANREQUEST
238 %token FIGURES FIGURE_OPEN FIGURE_CLOSE
239 %token FIGURE_BRACKET_CLOSE FIGURE_BRACKET_OPEN
241 %token GROBDESCRIPTIONS
249 %token MULTI_MEASURE_REST
255 %token OUTPUTPROPERTY
256 %token OVERRIDE SET REVERT
283 %token E_CHAR E_EXCLAMATION E_SMALLER E_BIGGER E_OPEN E_CLOSE
284 %token E_LEFTSQUARE E_RIGHTSQUARE E_TILDE
286 %token <i> E_UNSIGNED
287 %token CHORD_BASS CHORD_COLON CHORD_MINUS CHORD_CARET CHORD_SLASH
290 %type <i> exclamations questions dots optional_rest
292 %type <scm> bass_number br_bass_figure bass_figure figure_list figure_spec
294 %token <scm> NOTENAME_PITCH
295 %token <scm> TONICNAME_PITCH
296 %token <scm> CHORDMODIFIER_PITCH
297 %token <scm> DURATION_IDENTIFIER
298 %token <scm> FRACTION
299 %token <id> IDENTIFIER
300 %token <scm> CHORDNAMES
302 %token <scm> CHORD_MODIFIER
304 %token <scm> SCORE_IDENTIFIER
305 %token <scm> MUSIC_OUTPUT_DEF_IDENTIFIER
306 %token <scm> NUMBER_IDENTIFIER
307 %token <scm> EVENT_IDENTIFIER
308 %token <scm> MUSIC_IDENTIFIER TRANSLATOR_IDENTIFIER
309 %token <scm> STRING_IDENTIFIER SCM_IDENTIFIER
310 %token <scm> RESTNAME
317 %token <scm> MARKUP_HEAD_MARKUP0
318 %token <scm> MARKUP_HEAD_MARKUP0_MARKUP1
319 %token <scm> MARKUP_HEAD_SCM0
320 %token <scm> MARKUP_HEAD_SCM0_MARKUP1
321 %token <scm> MARKUP_HEAD_SCM0_SCM1
322 %token <scm> MARKUP_HEAD_SCM0_SCM1_SCM2
323 %token <scm> MARKUP_HEAD_SCM0_SCM1_MARKUP2
325 %token <scm> MARKUP_IDENTIFIER MARKUP_HEAD_LIST0
326 %type <scm> markup markup_line markup_list markup_list_body full_markup
328 %type <outputdef> output_def
329 %type <scm> lilypond_header lilypond_header_body
330 %type <music> open_event close_event
331 %type <i> sub_quotes sup_quotes
332 %type <music> simple_element event_chord command_element Simple_music Composite_music
333 %type <music> Repeated_music
334 %type <scm> Alternative_music
335 %type <i> tremolo_type
336 %type <i> bare_int bare_unsigned
338 %type <scm> identifier_init
340 %type <music> note_chord_element chord_body chord_body_element
341 %type <scm> chord_body_elements
342 %type <scm> steno_duration optional_notemode_duration multiplied_duration
343 %type <scm> verbose_duration
345 %type <scm> post_events
346 %type <music> gen_text_def direction_less_event direction_reqd_event
347 %type <scm> steno_pitch pitch absolute_pitch pitch_also_in_chords
348 %type <scm> explicit_pitch steno_tonic_pitch
349 %type <scm> duration_length fraction
351 %type <scm> new_chord step_number chord_items chord_item chord_separator step_numbers
353 %type <scm> embedded_scm scalar
354 %type <music> Music Sequential_music Simultaneous_music
355 %type <music> relative_music re_rhythmed_music part_combined_music
356 %type <music> property_def translator_change simple_property_def
357 %type <scm> Music_list
358 %type <outputdef> music_output_def_body
359 %type <music> shorthand_command_req
360 %type <music> post_event
361 %type <music> command_req verbose_command_req
362 %type <music> extender_req
363 %type <music> hyphen_req
364 %type <music> string_number_event
365 %type <scm> string bare_number number_expression number_term number_factor
366 %type <score> score_block score_body
368 %type <scm> translator_spec_block translator_spec_body
369 %type <music> tempo_event
370 %type <scm> notenames_body notenames_block chordmodifiers_block
371 %type <scm> script_abbreviation
377 /* We don't assign precedence to / and *, because we might need varied
378 prec levels in different prods */
384 lilypond: /* empty */
385 | lilypond toplevel_expression {}
386 | lilypond assignment { }
388 THIS->error_level_ = 1;
391 THIS->error_level_ = 1;
397 THIS->lexer_->pitchname_tab_ = $1;
399 | chordmodifiers_block {
400 THIS->lexer_->chordmodifier_tab_ = $1;
403 THIS->input_file_->header_ = $1;
406 THIS->input_file_->scores_.push ($1);
409 if (dynamic_cast<Paper_def*> ($1))
410 THIS->lexer_->set_identifier (scm_makfrom0str ("$defaultpaper"), $1->self_scm ());
411 else if (dynamic_cast<Midi_def*> ($1))
412 THIS->lexer_->set_identifier (scm_makfrom0str ("$defaultmidi"), $1->self_scm ());
422 chordmodifiers_block:
423 CHORDMODIFIERS notenames_body { $$ = $2; }
427 PITCHNAMES notenames_body { $$ = $2; }
432 int i = scm_ilength ($1);
434 SCM tab = scm_make_vector (gh_int2scm (i), SCM_EOL);
435 for (SCM s = $1; gh_pair_p (s); s = ly_cdr (s)) {
436 SCM pt = ly_cdar (s);
437 scm_hashq_set_x (tab, ly_caar (s), pt);
443 lilypond_header_body:
445 $$ = ly_make_anonymous_module ();
446 THIS->lexer_->add_scope ($$);
448 | lilypond_header_body assignment {
454 HEADER '{' lilypond_header_body '}' {
455 $$ = THIS->lexer_-> remove_scope();
467 /* cont */ '=' identifier_init {
470 Should find generic way of associating input with objects.
472 Input ip = THIS->pop_spot ();
474 if (! regular_identifier_b ($1))
476 ip.warning (_ ("Identifier should have alphabetic characters only"));
479 THIS->lexer_->set_identifier ($1, $4);
482 TODO: devise standard for protection in parser.
484 The parser stack lives on the C-stack, which means that
485 all objects can be unprotected as soon as they're here.
496 $$ = $1->self_scm ();
497 scm_gc_unprotect_object ($$);
503 $$ = $1->self_scm ();
504 scm_gc_unprotect_object ($$);
506 | translator_spec_block {
510 $$ = $1->self_scm ();
511 scm_gc_unprotect_object ($$);
514 $$ = $1->self_scm ();
515 scm_gc_unprotect_object ($$);
520 | number_expression {
531 translator_spec_block:
532 TRANSLATOR '{' translator_spec_body '}'
538 translator_spec_body:
539 TRANSLATOR_IDENTIFIER {
541 unsmob_translator_def ($$)-> set_spot (THIS->here_input ());
544 $$ = Translator_def::make_scm ();
545 Translator_def*td = unsmob_translator_def ($$);
546 td->translator_group_type_ = $2;
547 td->set_spot (THIS->here_input ());
549 | translator_spec_body DESCRIPTION string {
550 unsmob_translator_def ($$)->description_ = $3;
552 | translator_spec_body STRING '=' embedded_scm {
553 unsmob_translator_def ($$)->add_property_assign ($2, $4);
555 | translator_spec_body STRING OVERRIDE embedded_scm '=' embedded_scm {
556 unsmob_translator_def ($$)
557 ->add_push_property (scm_string_to_symbol ($2), $4, $6);
559 | translator_spec_body STRING SET embedded_scm '=' embedded_scm {
560 unsmob_translator_def ($$)
561 ->add_push_property (scm_string_to_symbol ($2), $4, $6);
563 | translator_spec_body STRING REVERT embedded_scm {
564 unsmob_translator_def ($$)->add_pop_property (
565 scm_string_to_symbol ($2), $4);
567 | translator_spec_body NAME STRING {
568 unsmob_translator_def ($$)->type_name_ = $3;
570 | translator_spec_body CONSISTS STRING {
571 unsmob_translator_def ($$)->add_element ($3);
573 | translator_spec_body ALIAS STRING {
574 Translator_def*td = unsmob_translator_def ($$);
575 td->type_aliases_ = scm_cons ($3, td->type_aliases_);
577 | translator_spec_body GROBDESCRIPTIONS embedded_scm {
578 Translator_def*td = unsmob_translator_def($$);
579 // td->add_property_assign (ly_symbol2scm ("allGrobDescriptions"), $3);
580 for (SCM p = $3; gh_pair_p (p); p = ly_cdr (p))
581 td->add_property_assign (scm_symbol_to_string (ly_caar (p)), ly_cdar (p));
583 | translator_spec_body CONSISTSEND STRING {
584 unsmob_translator_def ($$)->add_last_element ( $3);
586 | translator_spec_body ACCEPTS STRING {
587 unsmob_translator_def ($$)->set_acceptor ($3,true);
589 | translator_spec_body DENIES STRING {
590 unsmob_translator_def ($$)->set_acceptor ($3,false);
592 | translator_spec_body REMOVE STRING {
593 unsmob_translator_def ($$)->remove_element ($3);
604 /*cont*/ '{' score_body '}' {
607 if (!$$->defs_.size ())
609 Music_output_def *id =
610 unsmob_music_output_def (THIS->lexer_->lookup_identifier ("$defaultpaper"));
611 $$->add_output (id ? id->clone () : new Paper_def );
620 $$->set_spot (THIS->here_input ());
621 SCM m = $1->self_scm ();
622 scm_gc_unprotect_object (m);
627 SCM check_funcs = scm_c_eval_string ("toplevel-music-functions");
628 for (; gh_pair_p (check_funcs); check_funcs = gh_cdr (check_funcs))
629 m = gh_call1 (gh_car (check_funcs), m);
634 $$ = unsmob_score ($1);
635 $$->set_spot (THIS->here_input ());
637 | score_body lilypond_header {
640 | score_body output_def {
653 music_output_def_body '}' {
655 THIS-> lexer_-> remove_scope ();
659 music_output_def_body:
661 Music_output_def *id = unsmob_music_output_def (THIS->lexer_->lookup_identifier ("$defaultmidi"));
666 p = dynamic_cast<Midi_def*> (id->clone ());
671 THIS->lexer_->add_scope (p->scope_);
674 Music_output_def *id = unsmob_music_output_def (THIS->lexer_->lookup_identifier ("$defaultpaper"));
677 p = dynamic_cast<Paper_def*> (id->clone ());
681 THIS->lexer_->add_scope (p->scope_);
684 | PAPER '{' MUSIC_OUTPUT_DEF_IDENTIFIER {
685 Music_output_def * o = unsmob_music_output_def ($3);
688 THIS->lexer_->add_scope (o->scope_);
690 | MIDI '{' MUSIC_OUTPUT_DEF_IDENTIFIER {
691 Music_output_def * o = unsmob_music_output_def ($3);
694 THIS->lexer_->add_scope (o->scope_);
696 | music_output_def_body assignment {
699 | music_output_def_body translator_spec_block {
700 $$->assign_translator ($2);
702 | music_output_def_body tempo_event {
704 junk this ? there already is tempo stuff in
707 int m = gh_scm2int ( $2->get_mus_property ("metronome-count"));
708 Duration *d = unsmob_duration ($2->get_mus_property ("tempo-unit"));
709 Midi_def * md = dynamic_cast<Midi_def*> ($$);
711 md->set_tempo (d->get_length (), m);
713 | music_output_def_body error {
719 TEMPO steno_duration '=' bare_unsigned {
720 $$ = MY_MAKE_MUSIC("MetronomeChangeEvent");
721 $$->set_mus_property ("tempo-unit", $2);
722 $$->set_mus_property ("metronome-count", gh_int2scm ( $4));
727 The representation of a list is the
731 to have efficient append.
735 $$ = scm_cons (SCM_EOL, SCM_EOL);
739 SCM c = scm_cons ($2->self_scm (), SCM_EOL);
740 scm_gc_unprotect_object ($2->self_scm ()); /* UGH */
741 if (gh_pair_p (ly_cdr (s)))
742 gh_set_cdr_x (ly_cdr (s), c); /* append */
744 gh_set_car_x (s, c); /* set first cons */
745 gh_set_cdr_x (s, c) ; /* remember last cell */
761 | ALTERNATIVE '{' Music_list '}' {
767 REPEAT string bare_unsigned Music Alternative_music
771 SCM alts = gh_pair_p ($5) ? gh_car ($5) : SCM_EOL;
772 if (times < scm_ilength (alts)) {
773 unsmob_music (gh_car (alts))
774 ->origin ()->warning (
775 _("More alternatives than repeats. Junking excess alternatives."));
776 alts = ly_truncate_list (times, alts);
782 proc = scm_c_eval_string ("make-repeated-music");
784 SCM mus = scm_call_1 (proc, $2);
785 scm_gc_protect_object (mus); // UGH.
786 Music *r =unsmob_music (mus);
789 r-> set_mus_property ("element", beg->self_scm ());
790 scm_gc_unprotect_object (beg->self_scm ());
792 r->set_mus_property ("repeat-count", gh_int2scm (times >? 1));
794 r-> set_mus_property ("elements",alts);
795 if (gh_equal_p ($2, scm_makfrom0str ("tremolo"))) {
797 we can not get durations and other stuff correct down the line, so we have to
798 add to the duration log here.
803 func = scm_primitive_eval (ly_symbol2scm ("shift-duration-log"));
805 int dots = ($3 % 3) ? 0 : 1;
806 int shift = -intlog2 ((dots) ? ($3*2/3) : $3);
808 Sequential_music * seq = dynamic_cast<Sequential_music*> ($4);
811 int list_len =scm_ilength (seq->music_list ());
813 seq->origin ()->warning ("Chord tremolo must have 2 elements.");
815 r->compress (Moment (Rational (1,list_len)));
817 gh_call3 (func, r->self_scm (), gh_int2scm(shift),gh_int2scm(dots));
820 r->set_spot (*$4->origin ());
827 SEQUENTIAL '{' Music_list '}' {
828 $$ = MY_MAKE_MUSIC("SequentialMusic");
829 $$->set_mus_property ("elements", ly_car ($3));
830 $$->set_spot(THIS->here_input());
832 | '{' Music_list '}' {
833 $$ = MY_MAKE_MUSIC("SequentialMusic");
834 $$->set_mus_property ("elements", ly_car ($2));
835 $$->set_spot(THIS->here_input());
840 SIMULTANEOUS '{' Music_list '}'{
841 $$ = MY_MAKE_MUSIC("SimultaneousMusic");
842 $$->set_mus_property ("elements", ly_car ($3));
843 $$->set_spot(THIS->here_input());
846 | '<' Music_list '>' {
847 $$ = MY_MAKE_MUSIC("SimultaneousMusic");
848 $$->set_mus_property ("elements", ly_car ($2));
849 $$->set_spot(THIS->here_input());
854 event_chord { $$ = $1; }
855 | APPLYOUTPUT embedded_scm {
856 if (!ly_input_procedure_p ($2))
857 THIS->parser_error (_ ("\\applycontext takes function argument"));
858 $$ = MY_MAKE_MUSIC ("ApplyOutputEvent");
859 $$->set_mus_property ("procedure", $2);
860 $$->set_spot (THIS->here_input());
862 | APPLYCONTEXT embedded_scm {
863 if (!ly_input_procedure_p ($2))
864 THIS->parser_error (_ ("\\applycontext takes function argument"));
865 $$ = MY_MAKE_MUSIC ("ApplyContext");
866 $$->set_mus_property ("procedure", $2);
867 $$->set_spot (THIS->here_input());
869 | OUTPUTPROPERTY embedded_scm embedded_scm '=' embedded_scm {
871 if (!gh_symbol_p ($3))
873 THIS->parser_error (_ ("Second argument must be a symbol"));
875 /* Should check # args */
876 if (!gh_procedure_p (pred))
878 THIS->parser_error (_ ("First argument must be a procedure taking one argument"));
881 Music*m = MY_MAKE_MUSIC("OutputPropertySetMusic");
882 m->set_mus_property ("predicate", pred);
883 m->set_mus_property ("grob-property", $3);
884 m->set_mus_property ("grob-value", $5);
889 $$ = unsmob_music ($1);
897 CONTEXT STRING Music {
898 Music*csm =MY_MAKE_MUSIC("ContextSpeccedMusic");
900 csm->set_mus_property ("element", $3->self_scm ());
901 scm_gc_unprotect_object ($3->self_scm ());
903 csm->set_mus_property ("context-type",$2);
904 csm->set_mus_property ("context-id", scm_makfrom0str (""));
908 | AUTOCHANGE STRING Music {
909 Music*chm = MY_MAKE_MUSIC("AutoChangeMusic");
910 chm->set_mus_property ("element", $3->self_scm ());
911 chm->set_mus_property ("iterator-ctor", Auto_change_iterator::constructor_proc);
913 scm_gc_unprotect_object ($3->self_scm ());
914 chm->set_mus_property ("what", $2);
917 chm->set_spot (*$3->origin ());
922 The other version is for easier debugging of
923 Sequential_music_iterator in combination with grace notes.
926 SCM start = THIS->lexer_->lookup_identifier ("startGraceMusic");
927 SCM stop = THIS->lexer_->lookup_identifier ("stopGraceMusic");
928 Music *startm = unsmob_music (start);
929 Music *stopm = unsmob_music (stop);
933 stopm = stopm->clone ();
934 ms = scm_cons (stopm->self_scm (), ms);
935 scm_gc_unprotect_object (stopm->self_scm ());
937 ms = scm_cons ($2->self_scm (), ms);
938 scm_gc_unprotect_object ($2->self_scm());
940 startm = startm->clone ();
941 ms = scm_cons (startm->self_scm () , ms);
942 scm_gc_unprotect_object (startm->self_scm ());
946 Music* seq = MY_MAKE_MUSIC("SequentialMusic");
947 seq->set_mus_property ("elements", ms);
950 $$ = MY_MAKE_MUSIC("GraceMusic");
951 $$->set_mus_property ("element", seq->self_scm ());
952 scm_gc_unprotect_object (seq->self_scm ());
954 $$ = MY_MAKE_MUSIC("GraceMusic");
955 $$->set_mus_property ("element", $2->self_scm ());
956 scm_gc_unprotect_object ($2->self_scm ());
959 | CONTEXT string '=' string Music {
960 Music * csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
962 csm->set_mus_property ("element", $5->self_scm ());
963 scm_gc_unprotect_object ($5->self_scm ());
965 csm->set_mus_property ("context-type", $2);
966 csm->set_mus_property ("context-id", $4);
970 | NEWCONTEXT string Music {
971 static int new_context_count;
973 Music * csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
975 csm->set_mus_property ("element", $3->self_scm ());
976 scm_gc_unprotect_object ($3->self_scm ());
978 csm->set_mus_property ("context-type", $2);
980 SCM new_id = scm_number_to_string (gh_int2scm (new_context_count ++),
982 csm->set_mus_property ("context-id", new_id);
992 int n = gh_scm2int (ly_car ($3)); int d = gh_scm2int (ly_cdr ($3));
994 $$= MY_MAKE_MUSIC("TimeScaledMusic");
995 $$->set_spot (THIS->pop_spot ());
998 $$->set_mus_property ("element", mp->self_scm ());
999 scm_gc_unprotect_object (mp->self_scm ());
1000 $$->set_mus_property ("numerator", gh_int2scm (n));
1001 $$->set_mus_property ("denominator", gh_int2scm (d));
1002 $$->compress (Moment (Rational (n,d)));
1005 | Repeated_music { $$ = $1; }
1006 | Simultaneous_music { $$ = $1; }
1007 | Sequential_music { $$ = $1; }
1008 | TRANSPOSE pitch_also_in_chords pitch_also_in_chords Music {
1009 $$ = MY_MAKE_MUSIC("TransposedMusic");
1011 Pitch from = *unsmob_pitch ($2);
1012 Pitch to = *unsmob_pitch ($3);
1014 p->transpose (interval (from, to));
1015 $$->set_mus_property ("element", p->self_scm ());
1016 scm_gc_unprotect_object (p->self_scm ());
1018 | APPLY embedded_scm Music {
1019 if (!ly_input_procedure_p ($2))
1020 THIS->parser_error (_ ("\\apply takes function argument"));
1022 SCM ret = gh_call1 ($2, $3->self_scm ());
1023 Music *m = unsmob_music (ret);
1025 THIS->parser_error ("\\apply must return a Music");
1026 m = MY_MAKE_MUSIC("Music");
1031 { THIS->lexer_->push_note_state (); }
1034 THIS->lexer_->pop_state ();
1037 { THIS->lexer_->push_figuredbass_state (); }
1040 Music * chm = MY_MAKE_MUSIC("UntransposableMusic");
1041 chm->set_mus_property ("element", $3->self_scm ());
1043 scm_gc_unprotect_object ($3->self_scm());
1045 THIS->lexer_->pop_state ();
1048 { THIS->lexer_->push_chord_state (); }
1051 Music * chm = MY_MAKE_MUSIC("UnrelativableMusic");
1052 chm->set_mus_property ("element", $3->self_scm ());
1053 scm_gc_unprotect_object ($3->self_scm());
1056 THIS->lexer_->pop_state ();
1059 { THIS->lexer_->push_lyric_state (); }
1063 THIS->lexer_->pop_state ();
1065 | relative_music { $$ = $1; }
1066 | re_rhythmed_music { $$ = $1; }
1067 | part_combined_music { $$ = $1; }
1071 RELATIVE absolute_pitch Music {
1073 Pitch pit = *unsmob_pitch ($2);
1074 $$ = MY_MAKE_MUSIC("RelativeOctaveMusic");
1076 $$->set_mus_property ("element", p->self_scm ());
1077 scm_gc_unprotect_object (p->self_scm ());
1080 if (lily_1_8_relative)
1081 $$->set_mus_property ("last-pitch", p->to_relative_octave (pit).smobbed_copy ());
1087 ADDLYRICS Music Music {
1088 Music*l =MY_MAKE_MUSIC("LyricCombineMusic");
1089 l->set_mus_property ("elements", gh_list ($2->self_scm (), $3->self_scm (), SCM_UNDEFINED));
1090 scm_gc_unprotect_object ($3->self_scm ());
1091 scm_gc_unprotect_object ($2->self_scm ());
1096 part_combined_music:
1097 PARTCOMBINE STRING Music Music {
1098 Music * p= MY_MAKE_MUSIC("PartCombineMusic");
1099 p->set_mus_property ("what", $2);
1100 p->set_mus_property ("elements", gh_list ($3->self_scm (),$4->self_scm (), SCM_UNDEFINED));
1102 scm_gc_unprotect_object ($3->self_scm ());
1103 scm_gc_unprotect_object ($4->self_scm ());
1110 TRANSLATOR STRING '=' STRING {
1111 Music*t= MY_MAKE_MUSIC("TranslatorChange");
1112 t-> set_mus_property ("change-to-type", $2);
1113 t-> set_mus_property ("change-to-id", $4);
1116 $$->set_spot (THIS->here_input ());
1122 | ONCE simple_property_def {
1124 SCM e = $2->get_mus_property ("element");
1125 unsmob_music (e)->set_mus_property ("once", SCM_BOOL_T);
1129 simple_property_def:
1130 PROPERTY STRING '.' STRING '=' scalar {
1131 Music *t = set_property_music (scm_string_to_symbol ($4), $6);
1132 Music *csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
1134 csm->set_mus_property ("element", t->self_scm ());
1135 scm_gc_unprotect_object (t->self_scm ());
1138 $$->set_spot (THIS->here_input ());
1140 csm-> set_mus_property ("context-type", $2);
1142 | PROPERTY STRING '.' STRING UNSET {
1144 Music *t = MY_MAKE_MUSIC("PropertyUnset");
1145 t->set_mus_property ("symbol", scm_string_to_symbol ($4));
1147 Music *csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
1148 csm->set_mus_property ("element", t->self_scm ());
1149 scm_gc_unprotect_object (t->self_scm ());
1152 $$->set_spot (THIS->here_input ());
1154 csm-> set_mus_property ("context-type", $2);
1156 | PROPERTY STRING '.' STRING SET embedded_scm '=' embedded_scm {
1158 = gh_equal_p ($4, scm_makfrom0str ("autoBeamSettings"));
1159 bool itc = internal_type_checking_global_b;
1160 Music *t = MY_MAKE_MUSIC("OverrideProperty");
1161 t->set_mus_property ("symbol", scm_string_to_symbol ($4));
1162 t->set_mus_property ("pop-first", SCM_BOOL_T);
1164 internal_type_checking_global_b = false;
1165 t->set_mus_property ("grob-property", $6);
1167 internal_type_checking_global_b = itc;
1168 t->set_mus_property ("grob-value", $8);
1170 Music *csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
1171 csm->set_mus_property ("element", t->self_scm ());
1172 scm_gc_unprotect_object (t->self_scm ());
1174 $$->set_spot (THIS->here_input ());
1176 csm-> set_mus_property ("context-type", $2);
1178 | PROPERTY STRING '.' STRING OVERRIDE
1179 embedded_scm '=' embedded_scm
1185 = gh_equal_p ($4, scm_makfrom0str ("autoBeamSettings"));
1186 bool itc = internal_type_checking_global_b;
1188 Music *t = MY_MAKE_MUSIC("OverrideProperty");
1189 t->set_mus_property ("symbol", scm_string_to_symbol ($4));
1191 internal_type_checking_global_b = false;
1192 t->set_mus_property ("grob-property", $6);
1193 t->set_mus_property ("grob-value", $8);
1195 internal_type_checking_global_b = itc;
1197 Music *csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
1198 csm->set_mus_property ("element", t->self_scm ());
1199 scm_gc_unprotect_object (t->self_scm ());
1202 $$->set_spot (THIS->here_input ());
1204 csm-> set_mus_property ("context-type", $2);
1207 | PROPERTY STRING '.' STRING REVERT embedded_scm {
1208 Music *t = MY_MAKE_MUSIC("RevertProperty");
1210 = gh_equal_p ($4, scm_makfrom0str ("autoBeamSettings"));
1211 bool itc = internal_type_checking_global_b;
1213 t->set_mus_property ("symbol", scm_string_to_symbol ($4));
1215 internal_type_checking_global_b = false;
1216 t->set_mus_property ("grob-property", $6);
1218 internal_type_checking_global_b = itc;
1220 Music *csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
1221 csm->set_mus_property ("element", t->self_scm ());
1222 scm_gc_unprotect_object (t->self_scm ());
1225 $$->set_spot (THIS->here_input ());
1227 csm-> set_mus_property ("context-type", $2);
1234 | bare_int { $$ = gh_int2scm ($1); }
1235 | embedded_scm { $$ = $1; }
1236 | full_markup { $$ = $1; }
1237 | DIGIT { $$ = gh_int2scm ($1); }
1245 Adding pre_events to the simple_element
1246 makes the choice between
1252 simple_element: STRING
1254 a single shift/reduction conflict.
1256 nevertheless, this is not very clean, and we should find a different
1266 pre_events simple_element post_events {
1267 SCM elts = $2-> get_mus_property ("elements");
1269 elts = gh_append2 (elts, scm_reverse_x ($3, SCM_EOL));
1271 $2->set_mus_property ("elements", elts);
1275 | note_chord_element
1280 chord_body optional_notemode_duration post_events
1282 SCM dur = unsmob_duration ($2)->smobbed_copy();
1283 SCM es = $1->get_mus_property ("elements");
1284 SCM postevs = scm_reverse_x ($3, SCM_EOL);
1286 for (SCM s = es; gh_pair_p (s); s = gh_cdr (s))
1287 unsmob_music (gh_car(s))->set_mus_property ("duration", dur);
1288 es = gh_append2 (es, postevs);
1290 $1-> set_mus_property ("elements", es);
1296 CHORD_OPEN chord_body_elements CHORD_CLOSE
1298 $$ = MY_MAKE_MUSIC("EventChord");
1299 $$->set_mus_property ("elements",
1300 scm_reverse_x ($2, SCM_EOL));
1304 chord_body_elements:
1305 /* empty */ { $$ = SCM_EOL; }
1306 | chord_body_elements chord_body_element {
1307 $$ = gh_cons ($2->self_scm(), $1);
1308 scm_gc_unprotect_object ($2->self_scm());
1313 pitch exclamations questions post_events
1315 Music * n = MY_MAKE_MUSIC("NoteEvent");
1316 n->set_mus_property ("pitch", $1);
1318 n->set_mus_property ("cautionary", SCM_BOOL_T);
1319 if ($2 % 2 || $3 % 2)
1320 n->set_mus_property ("force-accidental", SCM_BOOL_T);
1322 SCM arts = scm_reverse_x ($4, SCM_EOL);
1323 n->set_mus_property ("articulations", arts);
1331 $$ = MY_MAKE_MUSIC("EventChord");
1332 $$->set_mus_property ("elements", scm_cons ($1->self_scm (), SCM_EOL));
1333 scm_gc_unprotect_object ($1->self_scm());
1335 $$-> set_spot (THIS->here_input ());
1336 $1-> set_spot (THIS->here_input ());
1338 | OCTAVE { THIS->push_spot (); }
1340 Music *l = MY_MAKE_MUSIC("RelativeOctaveCheck");
1342 $$->set_spot (THIS->pop_spot ());
1343 $$->set_mus_property ("pitch", $3);
1346 Music *l = MY_MAKE_MUSIC("LigatureEvent");
1347 l->set_mus_property ("span-direction", gh_int2scm (START));
1348 l->set_spot (THIS->here_input ());
1350 $$ = MY_MAKE_MUSIC("EventChord");
1351 $$->set_mus_property ("elements", scm_cons (l->self_scm (), SCM_EOL));
1352 scm_gc_unprotect_object (l->self_scm());
1353 $$->set_spot (THIS->here_input ());
1356 Music *l = MY_MAKE_MUSIC("LigatureEvent");
1357 l->set_mus_property ("span-direction", gh_int2scm (STOP));
1358 l->set_spot (THIS->here_input ());
1360 $$ = MY_MAKE_MUSIC("EventChord");
1361 $$->set_mus_property ("elements", scm_cons (l->self_scm (), SCM_EOL));
1362 $$->set_spot (THIS->here_input ());
1363 scm_gc_unprotect_object (l->self_scm());
1366 $$ = MY_MAKE_MUSIC("VoiceSeparator");
1367 $$->set_spot (THIS->here_input ());
1371 $$ = MY_MAKE_MUSIC("BarCheck");
1372 $$->set_spot (THIS->here_input ());
1375 Music *t = set_property_music (ly_symbol2scm ("whichBar"), $2);
1377 Music *csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
1378 csm->set_mus_property ("element", t->self_scm ());
1379 scm_gc_unprotect_object (t->self_scm ());
1382 $$->set_spot (THIS->here_input ());
1384 csm->set_mus_property ("context-type", scm_makfrom0str ("Timing"));
1386 | PARTIAL duration_length {
1387 Moment m = - unsmob_duration ($2)->get_length ();
1388 Music * p = set_property_music (ly_symbol2scm ( "measurePosition"),m.smobbed_copy ());
1390 Music * sp = MY_MAKE_MUSIC("ContextSpeccedMusic");
1391 sp->set_mus_property ("element", p->self_scm ());
1392 scm_gc_unprotect_object (p->self_scm ());
1395 sp-> set_mus_property ("context-type", scm_makfrom0str ("Timing"));
1400 proc = scm_c_eval_string ("make-clef-set");
1402 SCM result = scm_call_1 (proc, $2);
1403 scm_gc_protect_object (result);
1404 $$ = unsmob_music (result);
1409 proc = scm_c_eval_string ("make-time-signature-set");
1411 SCM result = scm_apply_2 (proc, gh_car ($2), gh_cdr ($2), SCM_EOL);
1412 scm_gc_protect_object (result);
1413 $$ = unsmob_music (result);
1418 shorthand_command_req { $$ = $1; }
1419 | verbose_command_req { $$ = $1; }
1422 shorthand_command_req:
1430 $$ = MY_MAKE_MUSIC("BreathingSignEvent");
1433 $$ = MY_MAKE_MUSIC("PesOrFlexaEvent");
1437 verbose_command_req:
1439 Music * m = MY_MAKE_MUSIC("MarkEvent");
1443 Music *m = MY_MAKE_MUSIC("MarkEvent");
1444 m->set_mus_property ("label", $2);
1447 | SKIP duration_length {
1448 Music * skip = MY_MAKE_MUSIC("SkipEvent");
1449 skip->set_mus_property ("duration", $2);
1457 Music *key= MY_MAKE_MUSIC("KeyChangeEvent");
1460 | KEY NOTENAME_PITCH SCM_IDENTIFIER {
1462 Music *key= MY_MAKE_MUSIC("KeyChangeEvent");
1463 if (scm_ilength ($3) > 0)
1465 key->set_mus_property ("pitch-alist", $3);
1466 key->set_mus_property ("tonic", Pitch (0,0,0).smobbed_copy());
1467 ((Music*)key)->transpose (* unsmob_pitch ($2));
1469 THIS->parser_error (_("Second argument must be pitch list."));
1480 | post_events post_event {
1481 $2->set_spot (THIS->here_input ());
1482 $$ = gh_cons ($2->self_scm(), $$);
1483 scm_gc_unprotect_object ($2->self_scm());
1490 direction_less_event {
1493 | script_dir direction_reqd_event {
1494 $2->set_mus_property ("direction", gh_int2scm ($1));
1497 | script_dir direction_less_event {
1498 $2->set_mus_property ("direction", gh_int2scm ($1));
1501 | string_number_event
1504 string_number_event:
1506 Music * s = MY_MAKE_MUSIC("StringNumberEvent");
1507 s->set_mus_property ("string-number", gh_int2scm($1));
1508 s->set_spot (THIS->here_input ());
1514 direction_less_event:
1520 TODO: should take all these defs out of the parser, adn make use
1524 (set-articulation '~ "trill")
1527 Music * m = MY_MAKE_MUSIC ("BeamEvent");
1528 m->set_spot (THIS->here_input());
1529 m->set_mus_property ("span-direction" , gh_int2scm (START));
1533 Music * m = MY_MAKE_MUSIC ("BeamEvent");
1534 m->set_spot (THIS->here_input());
1535 m->set_mus_property ("span-direction" , gh_int2scm (STOP));
1539 Music * m = MY_MAKE_MUSIC ("TieEvent");
1540 m->set_spot (THIS->here_input());
1545 dynamic_cast<Music *> ($$)->set_mus_property ("span-direction", gh_int2scm (START));
1549 dynamic_cast<Music *> ($$)->set_mus_property ("span-direction", gh_int2scm (STOP))
1551 | EVENT_IDENTIFIER {
1552 $$ = unsmob_music ($1);
1555 Music * a = MY_MAKE_MUSIC("TremoloEvent");
1556 a->set_spot (THIS->here_input ());
1557 a->set_mus_property ("tremolo-type", gh_int2scm ($1));
1562 direction_reqd_event:
1566 | script_abbreviation {
1567 SCM s = THIS->lexer_->lookup_identifier ("dash" + ly_scm2string ($1));
1568 Music *a = MY_MAKE_MUSIC("ArticulationEvent");
1569 if (gh_string_p (s))
1570 a->set_mus_property ("articulation-type", s);
1571 else THIS->parser_error (_ ("Expecting string as script definition"));
1598 | NOTENAME_PITCH sup_quotes {
1599 Pitch p = *unsmob_pitch ($1);
1600 p = p.transposed (Pitch ($2,0,0));
1601 $$ = p.smobbed_copy ();
1603 | NOTENAME_PITCH sub_quotes {
1604 Pitch p =* unsmob_pitch ($1);
1605 p = p.transposed (Pitch (-$2,0,0));
1606 $$ = p.smobbed_copy ();
1618 | TONICNAME_PITCH sup_quotes {
1619 Pitch p = *unsmob_pitch ($1);
1620 p = p.transposed (Pitch ($2,0,0));
1621 $$ = p.smobbed_copy ();
1623 | TONICNAME_PITCH sub_quotes {
1624 Pitch p =* unsmob_pitch ($1);
1626 p = p.transposed (Pitch (-$2,0,0));
1627 $$ = p.smobbed_copy ();
1640 pitch_also_in_chords:
1646 PITCH embedded_scm {
1648 if (!unsmob_pitch ($2)) {
1649 THIS->parser_error (_f ("Expecting musical-pitch value", 3));
1650 $$ = Pitch ().smobbed_copy ();
1656 DURATION embedded_scm {
1658 if (!unsmob_duration ($2))
1660 THIS->parser_error (_ ("Must have duration object"));
1661 $$ = Duration ().smobbed_copy ();
1668 if (!THIS->lexer_->lyric_state_b ())
1669 THIS->parser_error (_ ("Have to be in Lyric mode for lyrics"));
1670 $$ = MY_MAKE_MUSIC("ExtenderEvent");
1676 if (!THIS->lexer_->lyric_state_b ())
1677 THIS->parser_error (_ ("Have to be in Lyric mode for lyrics"));
1678 $$ = MY_MAKE_MUSIC("HyphenEvent");
1684 Music * s= MY_MAKE_MUSIC("SlurEvent");
1686 s->set_spot (THIS->here_input());
1689 Music * s= MY_MAKE_MUSIC("PhrasingSlurEvent");
1691 s->set_spot (THIS->here_input());
1694 Music *s =MY_MAKE_MUSIC("CrescendoEvent");
1696 s->set_spot (THIS->here_input());
1699 Music *s =MY_MAKE_MUSIC("DecrescendoEvent");
1701 s->set_spot (THIS->here_input());
1708 Music *s = MY_MAKE_MUSIC("CrescendoEvent");
1709 s->set_spot (THIS->here_input());
1714 Music * s= MY_MAKE_MUSIC("SlurEvent");
1716 s->set_spot (THIS->here_input());
1720 Music * s= MY_MAKE_MUSIC("PhrasingSlurEvent");
1722 s->set_mus_property ("span-type", scm_makfrom0str ( "phrasing-slur"));
1723 s->set_spot (THIS->here_input());
1729 Music *t = MY_MAKE_MUSIC("TextScriptEvent");
1730 t->set_mus_property ("text", $1);
1731 t->set_spot (THIS->here_input ());
1735 Music *t = MY_MAKE_MUSIC("TextScriptEvent");
1736 t->set_mus_property ("text", make_simple_markup ($1));
1737 t->set_spot (THIS->here_input ());
1742 Music * t = MY_MAKE_MUSIC("FingerEvent");
1743 t->set_mus_property ("digit", gh_int2scm ($1));
1744 t->set_spot (THIS->here_input ());
1749 script_abbreviation:
1751 $$ = scm_makfrom0str ("Hat");
1754 $$ = scm_makfrom0str ("Plus");
1757 $$ = scm_makfrom0str ("Dash");
1760 $$ = scm_makfrom0str ("Bar");
1763 $$ = scm_makfrom0str ("Larger");
1766 $$ = scm_makfrom0str ("Dot");
1769 $$ = scm_makfrom0str ("Underscore");
1776 | '-' { $$ = CENTER; }
1787 multiplied_duration {
1790 | verbose_duration {
1795 optional_notemode_duration:
1797 Duration dd = THIS->default_duration_;
1798 $$ = dd.smobbed_copy ();
1800 THIS->beam_check ($$);
1802 | multiplied_duration {
1804 THIS->default_duration_ = *unsmob_duration ($$);
1806 THIS->beam_check ($$);
1808 | verbose_duration {
1810 THIS->default_duration_ = *unsmob_duration ($$);
1815 bare_unsigned dots {
1817 if (!is_duration_b ($1))
1818 THIS->parser_error (_f ("not a duration: %d", $1));
1822 $$ = Duration (l, $2).smobbed_copy ();
1824 | DURATION_IDENTIFIER dots {
1825 Duration *d =unsmob_duration ($1);
1826 Duration k (d->duration_log (),d->dot_count () + $2);
1836 multiplied_duration:
1840 | multiplied_duration '*' bare_unsigned {
1841 $$ = unsmob_duration ($$)->compressed ( $3) .smobbed_copy ();
1843 | multiplied_duration '*' FRACTION {
1844 Rational m (gh_scm2int (ly_car ($3)), gh_scm2int (ly_cdr ($3)));
1846 $$ = unsmob_duration ($$)->compressed (m).smobbed_copy ();
1851 FRACTION { $$ = $1; }
1852 | UNSIGNED '/' UNSIGNED {
1853 $$ = scm_cons (gh_int2scm ($1), gh_int2scm ($3));
1871 | ':' bare_unsigned {
1872 if (!is_duration_b ($2))
1873 THIS->parser_error (_f ("not a duration: %d", $2));
1880 /*****************************************************************
1882 *****************************************************************/
1885 $$ = scm_number_to_string (gh_int2scm ($1), gh_int2scm (10));
1888 $$ = scm_number_to_string (gh_int2scm ($1), gh_int2scm (10));
1890 | STRING { $$ = $1 }
1901 Music *bfr = MY_MAKE_MUSIC("BassFigureEvent");
1902 $$ = bfr->self_scm();
1903 scm_gc_unprotect_object ($$);
1906 Music *bfr = MY_MAKE_MUSIC("BassFigureEvent");
1907 $$ = bfr->self_scm();
1909 bfr->set_mus_property ("figure", $1);
1911 scm_gc_unprotect_object ($$);
1913 | bass_figure bass_mod {
1914 Music *m = unsmob_music ($1);
1916 SCM salter =m->get_mus_property ("alteration");
1917 int alter = gh_number_p ( salter) ? gh_scm2int (salter) : 0;
1918 m->set_mus_property ("alteration",
1919 gh_int2scm (alter + $2));
1921 m->set_mus_property ("alteration", gh_int2scm (0));
1929 unsmob_music ($$)->set_mus_property ("bracket-start", SCM_BOOL_T);
1934 | br_bass_figure ']' {
1936 unsmob_music ($1)->set_mus_property ("bracket-stop", SCM_BOOL_T);
1944 | figure_list br_bass_figure {
1945 $$ = scm_cons ($2, $1);
1950 FIGURE_OPEN figure_list FIGURE_CLOSE {
1951 Music * m = MY_MAKE_MUSIC("EventChord");
1952 $2 = scm_reverse_x ($2, SCM_EOL);
1953 m->set_mus_property ("elements", $2);
1954 $$ = m->self_scm ();
1965 pitch exclamations questions optional_notemode_duration optional_rest {
1967 Input i = THIS->pop_spot ();
1968 if (!THIS->lexer_->note_state_b ())
1969 THIS->parser_error (_ ("Have to be in Note mode for notes"));
1973 n = MY_MAKE_MUSIC("RestEvent");
1975 n = MY_MAKE_MUSIC("NoteEvent");
1977 n->set_mus_property ("pitch", $1);
1978 n->set_mus_property ("duration", $4);
1982 n->set_mus_property ("cautionary", SCM_BOOL_T);
1983 if ($2 % 2 || $3 % 2)
1984 n->set_mus_property ("force-accidental", SCM_BOOL_T);
1986 Music *v = MY_MAKE_MUSIC("EventChord");
1987 v->set_mus_property ("elements", scm_list_n (n->self_scm (), SCM_UNDEFINED));
1988 scm_gc_unprotect_object (n->self_scm());
1994 | figure_spec optional_notemode_duration {
1995 Music * m = unsmob_music ($1);
1996 Input i = THIS->pop_spot ();
1998 for (SCM s = m->get_mus_property ("elements"); gh_pair_p (s); s = ly_cdr (s))
2000 unsmob_music (ly_car (s))->set_mus_property ("duration", $2);
2004 | RESTNAME optional_notemode_duration {
2006 Input i = THIS->pop_spot ();
2008 if (ly_scm2string ($1) =="s") {
2010 ev = MY_MAKE_MUSIC("SkipEvent");
2013 ev = MY_MAKE_MUSIC("RestEvent");
2016 ev->set_mus_property ("duration" ,$2);
2018 Music * velt = MY_MAKE_MUSIC("EventChord");
2019 velt->set_mus_property ("elements", scm_list_n (ev->self_scm (),SCM_UNDEFINED));
2024 | MULTI_MEASURE_REST optional_notemode_duration {
2029 proc = scm_c_eval_string ("make-multi-measure-rest");
2031 SCM mus = scm_call_2 (proc, $2,
2032 make_input (THIS->here_input()));
2033 scm_gc_protect_object (mus);
2034 $$ = unsmob_music (mus);
2036 | STRING optional_notemode_duration {
2037 Input i = THIS->pop_spot ();
2039 Music * lreq = MY_MAKE_MUSIC("LyricEvent");
2040 lreq->set_mus_property ("text", $1);
2041 lreq->set_mus_property ("duration",$2);
2043 Music * velt = MY_MAKE_MUSIC("EventChord");
2044 velt->set_mus_property ("elements", scm_list_n (lreq->self_scm (), SCM_UNDEFINED));
2051 if (!THIS->lexer_->chord_state_b ())
2052 THIS->parser_error (_ ("Have to be in Chord mode for chords"));
2053 $$ = unsmob_music ($1);
2058 steno_tonic_pitch optional_notemode_duration {
2059 $$ = make_chord ($1, $2, SCM_EOL);
2061 | steno_tonic_pitch optional_notemode_duration chord_separator chord_items {
2062 SCM its = scm_reverse_x ($4, SCM_EOL);
2063 $$ = make_chord ($1, $2, gh_cons ($3, its));
2071 | chord_items chord_item {
2072 $$ = gh_cons ($2, $$);
2078 $$ = ly_symbol2scm ("chord-colon");
2081 $$ = ly_symbol2scm ("chord-caret");
2083 | CHORD_SLASH steno_tonic_pitch {
2084 $$ = scm_list_n (ly_symbol2scm ("chord-slash"), $2, SCM_UNDEFINED);
2086 | CHORD_BASS steno_tonic_pitch {
2087 $$ = scm_list_n (ly_symbol2scm ("chord-bass"), $2, SCM_UNDEFINED);
2096 $$ = scm_reverse_x ($1, SCM_EOL);
2104 step_number { $$ = gh_cons ($1, SCM_EOL); }
2105 | step_numbers '.' step_number {
2106 $$ = gh_cons ($3, $$);
2112 $$ = make_chord_step ($1, 0);
2114 | bare_unsigned '+' {
2115 $$ = make_chord_step ($1, 1);
2117 | bare_unsigned CHORD_MINUS {
2118 $$ = make_chord_step ($1,-1);
2125 TODO: should deprecate in favor of Scheme?
2129 number_expression '+' number_term {
2130 $$ = scm_sum ($1, $3);
2132 | number_expression '-' number_term {
2133 $$ = scm_difference ($1, $3);
2142 | number_factor '*' number_factor {
2143 $$ = scm_product ($1, $3);
2145 | number_factor '/' number_factor {
2146 $$ = scm_divide ($1, $3);
2151 '-' number_factor { /* %prec UNARY_MINUS */
2152 $$ = scm_difference ($2, SCM_UNDEFINED);
2160 $$ = gh_int2scm ($1);
2165 | NUMBER_IDENTIFIER {
2168 | REAL NUMBER_IDENTIFIER {
2169 $$ = gh_double2scm (gh_scm2double ($1) * gh_scm2double ($2));
2171 | UNSIGNED NUMBER_IDENTIFIER {
2172 $$ = gh_double2scm ($1 * gh_scm2double ($2));
2188 if (scm_integer_p ($1) == SCM_BOOL_T)
2190 int k = gh_scm2int ($1);
2194 THIS->parser_error (_ ("need integer number arg"));
2208 | STRING_IDENTIFIER {
2211 | string '+' string {
2212 $$ = scm_string_append (scm_list_n ($1, $3, SCM_UNDEFINED));
2219 | exclamations '!' { $$ ++; }
2224 | questions '?' { $$ ++; }
2234 { THIS->lexer_->push_markup_state (); }
2237 THIS->lexer_->pop_state ();
2243 This should be done more dynamically if possible.
2247 $$ = make_simple_markup ($1);
2249 | MARKUP_HEAD_MARKUP0 markup {
2250 $$ = scm_list_n ($1, $2, SCM_UNDEFINED);
2252 | MARKUP_HEAD_MARKUP0_MARKUP1 markup markup {
2253 $$ = scm_list_n ($1, $2, $3, SCM_UNDEFINED);
2255 | MARKUP_HEAD_SCM0_MARKUP1 SCM_T markup {
2256 $$ = scm_list_n ($1, $2, $3, SCM_UNDEFINED);
2261 | MARKUP_HEAD_LIST0 markup_list {
2262 $$ = scm_list_n ($1,$2, SCM_UNDEFINED);
2264 | MARKUP_HEAD_SCM0 embedded_scm {
2265 $$ = scm_list_n ($1, $2, SCM_UNDEFINED);
2267 | MARKUP_HEAD_SCM0_SCM1_MARKUP2 embedded_scm embedded_scm markup {
2268 $$ = scm_list_n ($1, $2, $3, $4, SCM_UNDEFINED);
2270 | MARKUP_HEAD_SCM0_SCM1_SCM2 embedded_scm embedded_scm embedded_scm {
2271 $$ = scm_list_n ($1, $2, $3, $4, SCM_UNDEFINED);
2273 | MARKUP_IDENTIFIER {
2280 CHORD_OPEN markup_list_body CHORD_CLOSE { $$ = scm_reverse_x ($2, SCM_EOL); }
2284 '{' markup_list_body '}' {
2287 line = scm_c_eval_string ("line-markup");
2289 $$ = scm_list_n (line, scm_reverse_x ($2, SCM_EOL), SCM_UNDEFINED);
2294 /**/ { $$ = SCM_EOL; }
2295 | markup_list_body markup {
2296 $$ = gh_cons ($2, $1) ;
2304 My_lily_parser::set_yydebug (bool )
2311 extern My_lily_parser * current_parser;
2314 My_lily_parser::do_yyparse ()
2316 current_parser = this;;
2317 yyparse ((void*)this);
2322 Should make this optional? It will also complain when you do
2326 which is entirely legitimate.
2328 Or we can scrap it. Barchecks should detect wrong durations, and
2329 skipTypesetting speeds it up a lot.
2333 My_lily_parser::beam_check (SCM dur)
2335 Duration *d = unsmob_duration (dur);
2336 if (unsmob_music (last_beam_start_) && d->duration_log () <= 2)
2338 Music * m = unsmob_music (last_beam_start_);
2339 m->origin ()->warning (_("Suspect duration found following this beam"));
2341 last_beam_start_ = SCM_EOL;
2349 It is a little strange to have this function in this file, but
2350 otherwise, we have to import music classes into the lexer.
2354 My_lily_lexer::try_special_identifiers (SCM * destination, SCM sid)
2356 if (gh_string_p (sid)) {
2358 return STRING_IDENTIFIER;
2359 } else if (gh_number_p (sid)) {
2361 return NUMBER_IDENTIFIER;
2362 } else if (unsmob_translator_def (sid)) {
2363 *destination = unsmob_translator_def (sid)->clone_scm();
2364 return TRANSLATOR_IDENTIFIER;
2365 } else if (unsmob_score (sid)) {
2366 Score *sc = new Score (*unsmob_score (sid));
2367 *destination =sc->self_scm ();
2368 return SCORE_IDENTIFIER;
2369 } else if (Music * mus =unsmob_music (sid)) {
2370 *destination = unsmob_music (sid)->clone ()->self_scm();
2371 unsmob_music (*destination)->
2372 set_mus_property ("origin", make_input (last_input_));
2373 return dynamic_cast<Event*> (mus)
2374 ? EVENT_IDENTIFIER : MUSIC_IDENTIFIER;
2375 } else if (unsmob_duration (sid)) {
2376 *destination = unsmob_duration (sid)->smobbed_copy();
2377 return DURATION_IDENTIFIER;
2378 } else if (unsmob_music_output_def (sid)) {
2379 Music_output_def *p = unsmob_music_output_def (sid);
2382 *destination = p->self_scm();
2383 return MUSIC_OUTPUT_DEF_IDENTIFIER;
2384 } else if (Text_item::markup_p (sid)) {
2386 return MARKUP_IDENTIFIER;