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?
52 #include "translator-def.hh"
53 #include "lily-guile.hh"
55 #include "my-lily-lexer.hh"
56 #include "paper-def.hh"
57 #include "midi-def.hh"
59 #include "file-path.hh"
61 #include "dimensions.hh"
62 #include "my-lily-parser.hh"
64 #include "input-file-results.hh"
66 #include "lilypond-input-version.hh"
67 #include "scm-hash.hh"
68 #include "auto-change-iterator.hh"
69 #include "ly-modules.hh"
70 #include "music-sequence.hh"
71 #include "input-smob.hh"
73 #include "text-item.hh"
77 #define MY_MAKE_MUSIC(x) make_music_by_name (ly_symbol2scm (x))
81 #define YYERROR_VERBOSE 1
83 My_lily_parser* my_lily_parser;
84 #define YYPARSE_PARAM my_lily_parser
85 #define YYLEX_PARAM my_lily_parser
87 ((My_lily_parser *) my_lily_parser)
89 #define yyerror THIS->parser_error
96 regular_identifier_b (SCM id)
98 String str = ly_scm2string (id);
99 char const *s = str.to_str0 () ;
104 v = v && isalpha (*s);
111 make_simple_markup (SCM a)
115 simple = scm_c_eval_string ("simple-markup");
117 return scm_list_n (simple, a, SCM_UNDEFINED);
122 is_duration_b (int t)
124 return t && t == 1 << intlog2 (t);
128 set_music_properties (Music *p, SCM a)
130 for (SCM k = a; gh_pair_p (k); k = ly_cdr (k))
132 p->internal_set_mus_property (ly_caar (k), ly_cdar (k));
137 make_chord_step (int step, int alter)
142 /* ugh: fucks up above 13 */
143 Pitch m(step > 7 ? 1 : 0,(step - 1) % 7, alter);
144 return m.smobbed_copy ();
149 make_chord (SCM pitch, SCM dur, SCM modification_list)
151 static SCM chord_ctor;
153 chord_ctor= scm_c_eval_string ("construct-chord");
154 SCM ch= scm_call_3 (chord_ctor, pitch, dur, modification_list);
155 scm_gc_protect_object (ch);
160 Todo: actually also use apply iso. call too ...
163 ly_input_procedure_p (SCM x)
165 return gh_procedure_p (x)
166 || (gh_pair_p (x) && gh_procedure_p (gh_car (x)));
170 set_property_music (SCM sym, SCM value)
172 Music * p = MY_MAKE_MUSIC("PropertySet");
173 p->set_mus_property ("symbol", sym);
174 p->set_mus_property ("value", value);
180 /* We use SCMs to do strings, because it saves us the trouble of
181 deleting them. Let's hope that a stack overflow doesnt trigger a move
182 of the parse stack onto the heap. */
189 Music_output_def * outputdef;
196 yylex (YYSTYPE *s, void * v)
198 My_lily_parser *pars = (My_lily_parser*) v;
199 My_lily_lexer * lex = pars->lexer_;
201 lex->lexval = (void*) s;
202 lex->prepare_for_next_token();
203 return lex->yylex ();
211 /* tokens which are not keywords */
221 %token CHORDMODIFIERS
227 %token GROBDESCRIPTIONS
233 %token FIGURES FIGURE_OPEN FIGURE_CLOSE
234 %token FIGURE_BRACKET_CLOSE FIGURE_BRACKET_OPEN
242 %token MULTI_MEASURE_REST
253 %token OVERRIDE SET REVERT
263 %token COMMANDSPANREQUEST
265 %token OUTPUTPROPERTY
280 %token E_CHAR E_EXCLAMATION E_SMALLER E_BIGGER E_OPEN E_CLOSE
281 %token E_LEFTSQUARE E_RIGHTSQUARE E_TILDE
283 %token <i> E_UNSIGNED
284 %token CHORD_BASS CHORD_COLON CHORD_MINUS CHORD_CARET CHORD_SLASH
287 %type <i> exclamations questions dots optional_rest
288 %type <i> bass_number bass_mod
289 %type <scm> br_bass_figure bass_figure figure_list figure_spec
291 %token <scm> NOTENAME_PITCH
292 %token <scm> TONICNAME_PITCH
293 %token <scm> CHORDMODIFIER_PITCH
294 %token <scm> DURATION_IDENTIFIER
295 %token <scm> FRACTION
296 %token <id> IDENTIFIER
297 %token <scm> CHORDNAMES CHORDNAMES_IDENTIFIER
299 %token <scm> CHORD_MODIFIER
301 %token <scm> SCORE_IDENTIFIER
302 %token <scm> MUSIC_OUTPUT_DEF_IDENTIFIER
303 %token <scm> NUMBER_IDENTIFIER
304 %token <scm> EVENT_IDENTIFIER
305 %token <scm> MUSIC_IDENTIFIER TRANSLATOR_IDENTIFIER
306 %token <scm> STRING_IDENTIFIER SCM_IDENTIFIER
307 %token <scm> RESTNAME
314 %token <scm> MARKUP_HEAD_MARKUP0
315 %token <scm> MARKUP_HEAD_MARKUP0_MARKUP1
316 %token <scm> MARKUP_HEAD_SCM0
317 %token <scm> MARKUP_HEAD_SCM0_MARKUP1
318 %token <scm> MARKUP_HEAD_SCM0_SCM1
319 %token <scm> MARKUP_HEAD_SCM0_SCM1_SCM2
320 %token <scm> MARKUP_HEAD_SCM0_SCM1_MARKUP2
322 %token <scm> MARKUP_IDENTIFIER MARKUP_HEAD_LIST0
323 %type <scm> markup markup_line markup_list markup_list_body full_markup
325 %type <outputdef> output_def
326 %type <scm> lilypond_header lilypond_header_body
327 %type <music> open_event_parens close_event_parens open_event close_event
328 %type <music> event_with_dir event_that_take_dir verbose_event
329 %type <i> sub_quotes sup_quotes
330 %type <music> simple_element event_chord command_element Simple_music Composite_music
331 %type <music> Repeated_music
332 %type <scm> Alternative_music
333 %type <i> tremolo_type
334 %type <i> bare_int bare_unsigned
336 %type <scm> identifier_init
338 %type <music> note_chord_element chord_body chord_body_element
339 %type <scm> chord_body_elements
340 %type <scm> steno_duration optional_notemode_duration multiplied_duration
341 %type <scm> verbose_duration
343 %type <scm> pre_events post_events
344 %type <music> gen_text_def
345 %type <scm> steno_pitch pitch absolute_pitch pitch_also_in_chords
346 %type <scm> explicit_pitch steno_tonic_pitch
348 /* %type <scm> chord_additions chord_subtractions chord_notes chord_step */
349 /* %type <music> chord */
350 /* %type <scm> chord_note chord_inversion chord_bass */
351 %type <scm> duration_length fraction
353 %type <scm> new_chord step_number chord_items chord_item chord_separator step_numbers
355 %type <scm> embedded_scm scalar
356 %type <music> Music Sequential_music Simultaneous_music
357 %type <music> relative_music re_rhythmed_music part_combined_music
358 %type <music> property_def translator_change simple_property_def
359 %type <scm> Music_list
360 %type <outputdef> music_output_def_body
361 %type <music> shorthand_command_req
362 %type <music> post_event
363 %type <music> command_req verbose_command_req
364 %type <music> extender_req
365 %type <music> hyphen_req
366 %type <music> string_event
367 %type <scm> string bare_number number_expression number_term number_factor
368 %type <score> score_block score_body
370 %type <scm> translator_spec_block translator_spec_body
371 %type <music> tempo_event
372 %type <scm> notenames_body notenames_block chordmodifiers_block
373 %type <scm> script_abbreviation
379 /* We don't assign precedence to / and *, because we might need varied
380 prec levels in different prods */
386 lilypond: /* empty */
387 | lilypond toplevel_expression {}
388 | lilypond assignment { }
390 THIS->error_level_ = 1;
393 THIS->error_level_ = 1;
399 THIS->lexer_->pitchname_tab_ = $1;
401 | chordmodifiers_block {
402 THIS->lexer_->chordmodifier_tab_ = $1;
405 THIS->input_file_->header_ = $1;
408 THIS->input_file_->scores_.push ($1);
411 if (dynamic_cast<Paper_def*> ($1))
412 THIS->lexer_->set_identifier (scm_makfrom0str ("$defaultpaper"), $1->self_scm ());
413 else if (dynamic_cast<Midi_def*> ($1))
414 THIS->lexer_->set_identifier (scm_makfrom0str ("$defaultmidi"), $1->self_scm ());
424 chordmodifiers_block:
425 CHORDMODIFIERS notenames_body { $$ = $2; }
429 PITCHNAMES notenames_body { $$ = $2; }
434 int i = scm_ilength ($1);
436 SCM tab = scm_make_vector (gh_int2scm (i), SCM_EOL);
437 for (SCM s = $1; gh_pair_p (s); s = ly_cdr (s)) {
438 SCM pt = ly_cdar (s);
439 scm_hashq_set_x (tab, ly_caar (s), pt);
445 lilypond_header_body:
447 $$ = ly_make_anonymous_module ();
448 THIS->lexer_->add_scope ($$);
450 | lilypond_header_body assignment {
456 HEADER '{' lilypond_header_body '}' {
457 $$ = THIS->lexer_-> remove_scope();
469 /* cont */ '=' identifier_init {
472 Should find generic way of associating input with objects.
474 Input ip = THIS->pop_spot ();
476 if (! regular_identifier_b ($1))
478 ip.warning (_ ("Identifier should have alphabetic characters only"));
481 THIS->lexer_->set_identifier ($1, $4);
484 TODO: devise standard for protection in parser.
486 The parser stack lives on the C-stack, which means that
487 all objects can be unprotected as soon as they're here.
498 $$ = $1->self_scm ();
499 scm_gc_unprotect_object ($$);
505 $$ = $1->self_scm ();
506 scm_gc_unprotect_object ($$);
508 | translator_spec_block {
512 $$ = $1->self_scm ();
513 scm_gc_unprotect_object ($$);
516 $$ = $1->self_scm ();
517 scm_gc_unprotect_object ($$);
522 | number_expression {
533 translator_spec_block:
534 TRANSLATOR '{' translator_spec_body '}'
540 translator_spec_body:
541 TRANSLATOR_IDENTIFIER {
543 unsmob_translator_def ($$)-> set_spot (THIS->here_input ());
546 $$ = Translator_def::make_scm ();
547 Translator_def*td = unsmob_translator_def ($$);
548 td->translator_group_type_ = $2;
549 td->set_spot (THIS->here_input ());
551 | translator_spec_body DESCRIPTION string {
552 unsmob_translator_def ($$)->description_ = $3;
554 | translator_spec_body STRING '=' embedded_scm {
555 unsmob_translator_def ($$)->add_property_assign ($2, $4);
557 | translator_spec_body STRING OVERRIDE embedded_scm '=' embedded_scm {
558 unsmob_translator_def ($$)
559 ->add_push_property (scm_string_to_symbol ($2), $4, $6);
561 | translator_spec_body STRING SET embedded_scm '=' embedded_scm {
562 unsmob_translator_def ($$)
563 ->add_push_property (scm_string_to_symbol ($2), $4, $6);
565 | translator_spec_body STRING REVERT embedded_scm {
566 unsmob_translator_def ($$)->add_pop_property (
567 scm_string_to_symbol ($2), $4);
569 | translator_spec_body NAME STRING {
570 unsmob_translator_def ($$)->type_name_ = $3;
572 | translator_spec_body CONSISTS STRING {
573 unsmob_translator_def ($$)->add_element ($3);
575 | translator_spec_body ALIAS STRING {
576 Translator_def*td = unsmob_translator_def ($$);
577 td->type_aliases_ = scm_cons ($3, td->type_aliases_);
579 | translator_spec_body GROBDESCRIPTIONS embedded_scm {
580 Translator_def*td = unsmob_translator_def($$);
581 // td->add_property_assign (ly_symbol2scm ("allGrobDescriptions"), $3);
582 for (SCM p = $3; gh_pair_p (p); p = ly_cdr (p))
583 td->add_property_assign (scm_symbol_to_string (ly_caar (p)), ly_cdar (p));
585 | translator_spec_body CONSISTSEND STRING {
586 unsmob_translator_def ($$)->add_last_element ( $3);
588 | translator_spec_body ACCEPTS STRING {
589 unsmob_translator_def ($$)->set_acceptor ($3,true);
591 | translator_spec_body DENIES STRING {
592 unsmob_translator_def ($$)->set_acceptor ($3,false);
594 | translator_spec_body REMOVE STRING {
595 unsmob_translator_def ($$)->remove_element ($3);
606 /*cont*/ '{' score_body '}' {
609 if (!$$->defs_.size ())
611 Music_output_def *id =
612 unsmob_music_output_def (THIS->lexer_->lookup_identifier ("$defaultpaper"));
613 $$->add_output (id ? id->clone () : new Paper_def );
622 $$->set_spot (THIS->here_input ());
623 SCM m = $1->self_scm ();
624 scm_gc_unprotect_object (m);
629 SCM check_funcs = scm_c_eval_string ("toplevel-music-functions");
630 for (; gh_pair_p (check_funcs); check_funcs = gh_cdr (check_funcs))
631 m = gh_call1 (gh_car (check_funcs), m);
636 $$ = unsmob_score ($1);
637 $$->set_spot (THIS->here_input ());
639 | score_body lilypond_header {
642 | score_body output_def {
655 music_output_def_body '}' {
657 THIS-> lexer_-> remove_scope ();
661 music_output_def_body:
663 Music_output_def *id = unsmob_music_output_def (THIS->lexer_->lookup_identifier ("$defaultmidi"));
668 p = dynamic_cast<Midi_def*> (id->clone ());
673 THIS->lexer_->add_scope (p->scope_);
676 Music_output_def *id = unsmob_music_output_def (THIS->lexer_->lookup_identifier ("$defaultpaper"));
679 p = dynamic_cast<Paper_def*> (id->clone ());
683 THIS->lexer_->add_scope (p->scope_);
686 | PAPER '{' MUSIC_OUTPUT_DEF_IDENTIFIER {
687 Music_output_def * o = unsmob_music_output_def ($3);
690 THIS->lexer_->add_scope (o->scope_);
692 | MIDI '{' MUSIC_OUTPUT_DEF_IDENTIFIER {
693 Music_output_def * o = unsmob_music_output_def ($3);
696 THIS->lexer_->add_scope (o->scope_);
698 | music_output_def_body assignment {
701 | music_output_def_body translator_spec_block {
702 $$->assign_translator ($2);
704 | music_output_def_body tempo_event {
706 junk this ? there already is tempo stuff in
709 int m = gh_scm2int ( $2->get_mus_property ("metronome-count"));
710 Duration *d = unsmob_duration ($2->get_mus_property ("tempo-unit"));
711 Midi_def * md = dynamic_cast<Midi_def*> ($$);
713 md->set_tempo (d->get_length (), m);
715 | music_output_def_body error {
721 TEMPO steno_duration '=' bare_unsigned {
722 $$ = MY_MAKE_MUSIC("MetronomeChangeEvent");
723 $$->set_mus_property ("tempo-unit", $2);
724 $$->set_mus_property ("metronome-count", gh_int2scm ( $4));
729 The representation of a list is the
733 to have efficient append.
737 $$ = scm_cons (SCM_EOL, SCM_EOL);
741 SCM c = scm_cons ($2->self_scm (), SCM_EOL);
742 scm_gc_unprotect_object ($2->self_scm ()); /* UGH */
743 if (gh_pair_p (ly_cdr (s)))
744 gh_set_cdr_x (ly_cdr (s), c); /* append */
746 gh_set_car_x (s, c); /* set first cons */
747 gh_set_cdr_x (s, c) ; /* remember last cell */
763 | ALTERNATIVE '{' Music_list '}' {
769 REPEAT string bare_unsigned Music Alternative_music
773 SCM alts = gh_pair_p ($5) ? gh_car ($5) : SCM_EOL;
774 if (times < scm_ilength (alts)) {
775 unsmob_music (gh_car (alts))
776 ->origin ()->warning (
777 _("More alternatives than repeats. Junking excess alternatives."));
778 alts = ly_truncate_list (times, alts);
784 proc = scm_c_eval_string ("make-repeated-music");
786 SCM mus = scm_call_1 (proc, $2);
787 scm_gc_protect_object (mus); // UGH.
788 Music *r =unsmob_music (mus);
791 r-> set_mus_property ("element", beg->self_scm ());
792 scm_gc_unprotect_object (beg->self_scm ());
794 r->set_mus_property ("repeat-count", gh_int2scm (times >? 1));
796 r-> set_mus_property ("elements",alts);
797 if (gh_equal_p ($2, scm_makfrom0str ("tremolo")))
800 we can not get durations and other stuff correct down the line, so we have to
801 add to the duration log here.
803 SCM func = scm_primitive_eval (ly_symbol2scm ("shift-duration-log"));
805 gh_call3 (func, r->self_scm (), gh_int2scm(-intlog2 ($3*2/3)),gh_int2scm(1));
807 gh_call3 (func, r->self_scm (), gh_int2scm(-intlog2 ($3)), gh_int2scm(0));
809 r->set_spot (*$4->origin ());
816 SEQUENTIAL '{' Music_list '}' {
817 $$ = MY_MAKE_MUSIC("SequentialMusic");
818 $$->set_mus_property ("elements", ly_car ($3));
819 $$->set_spot(THIS->here_input());
821 | '{' Music_list '}' {
822 $$ = MY_MAKE_MUSIC("SequentialMusic");
823 $$->set_mus_property ("elements", ly_car ($2));
824 $$->set_spot(THIS->here_input());
829 SIMULTANEOUS '{' Music_list '}'{
830 $$ = MY_MAKE_MUSIC("SimultaneousMusic");
831 $$->set_mus_property ("elements", ly_car ($3));
832 $$->set_spot(THIS->here_input());
835 | '<' Music_list '>' {
836 $$ = MY_MAKE_MUSIC("SimultaneousMusic");
837 $$->set_mus_property ("elements", ly_car ($2));
838 $$->set_spot(THIS->here_input());
843 event_chord { $$ = $1; }
844 | APPLYOUTPUT embedded_scm {
845 if (!ly_input_procedure_p ($2))
846 THIS->parser_error (_ ("\applycontext takes function argument"));
847 $$ = MY_MAKE_MUSIC ("ApplyOutputEvent");
848 $$->set_mus_property ("procedure", $2);
849 $$->set_spot (THIS->here_input());
851 | APPLYCONTEXT embedded_scm {
852 if (!ly_input_procedure_p ($2))
853 THIS->parser_error (_ ("\applycontext takes function argument"));
854 $$ = MY_MAKE_MUSIC ("ApplyContext");
855 $$->set_mus_property ("procedure", $2);
856 $$->set_spot (THIS->here_input());
858 | OUTPUTPROPERTY embedded_scm embedded_scm '=' embedded_scm {
860 if (!gh_symbol_p ($3))
862 THIS->parser_error (_ ("Second argument must be a symbol"));
864 /* Should check # args */
865 if (!gh_procedure_p (pred))
867 THIS->parser_error (_ ("First argument must be a procedure taking one argument"));
870 Music*m = MY_MAKE_MUSIC("OutputPropertySetMusic");
871 m->set_mus_property ("predicate", pred);
872 m->set_mus_property ("grob-property", $3);
873 m->set_mus_property ("grob-value", $5);
878 $$ = unsmob_music ($1);
886 CONTEXT STRING Music {
887 Music*csm =MY_MAKE_MUSIC("ContextSpeccedMusic");
889 csm->set_mus_property ("element", $3->self_scm ());
890 scm_gc_unprotect_object ($3->self_scm ());
892 csm->set_mus_property ("context-type",$2);
893 csm->set_mus_property ("context-id", scm_makfrom0str (""));
897 | AUTOCHANGE STRING Music {
898 Music*chm = MY_MAKE_MUSIC("AutoChangeMusic");
899 chm->set_mus_property ("element", $3->self_scm ());
900 chm->set_mus_property ("iterator-ctor", Auto_change_iterator::constructor_proc);
902 scm_gc_unprotect_object ($3->self_scm ());
903 chm->set_mus_property ("what", $2);
906 chm->set_spot (*$3->origin ());
911 The other version is for easier debugging of
912 Sequential_music_iterator in combination with grace notes.
915 SCM start = THIS->lexer_->lookup_identifier ("startGraceMusic");
916 SCM stop = THIS->lexer_->lookup_identifier ("stopGraceMusic");
917 Music *startm = unsmob_music (start);
918 Music *stopm = unsmob_music (stop);
922 stopm = stopm->clone ();
923 ms = scm_cons (stopm->self_scm (), ms);
924 scm_gc_unprotect_object (stopm->self_scm ());
926 ms = scm_cons ($2->self_scm (), ms);
927 scm_gc_unprotect_object ($2->self_scm());
929 startm = startm->clone ();
930 ms = scm_cons (startm->self_scm () , ms);
931 scm_gc_unprotect_object (startm->self_scm ());
935 Music* seq = MY_MAKE_MUSIC("SequentialMusic");
936 seq->set_mus_property ("elements", ms);
939 $$ = MY_MAKE_MUSIC("GraceMusic");
940 $$->set_mus_property ("element", seq->self_scm ());
941 scm_gc_unprotect_object (seq->self_scm ());
943 $$ = MY_MAKE_MUSIC("GraceMusic");
944 $$->set_mus_property ("element", $2->self_scm ());
945 scm_gc_unprotect_object ($2->self_scm ());
948 | CONTEXT string '=' string Music {
949 Music * csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
951 csm->set_mus_property ("element", $5->self_scm ());
952 scm_gc_unprotect_object ($5->self_scm ());
954 csm->set_mus_property ("context-type", $2);
955 csm->set_mus_property ("context-id", $4);
966 int n = gh_scm2int (ly_car ($3)); int d = gh_scm2int (ly_cdr ($3));
968 $$= MY_MAKE_MUSIC("TimeScaledMusic");
969 $$->set_spot (THIS->pop_spot ());
972 $$->set_mus_property ("element", mp->self_scm ());
973 scm_gc_unprotect_object (mp->self_scm ());
974 $$->set_mus_property ("numerator", gh_int2scm (n));
975 $$->set_mus_property ("denominator", gh_int2scm (d));
976 $$->compress (Moment (Rational (n,d)));
979 | Repeated_music { $$ = $1; }
980 | Simultaneous_music { $$ = $1; }
981 | Sequential_music { $$ = $1; }
982 | TRANSPOSE pitch_also_in_chords pitch_also_in_chords Music {
983 $$ = MY_MAKE_MUSIC("TransposedMusic");
985 Pitch from = *unsmob_pitch ($2);
986 Pitch to = *unsmob_pitch ($3);
988 p->transpose (interval (from, to));
989 $$->set_mus_property ("element", p->self_scm ());
990 scm_gc_unprotect_object (p->self_scm ());
992 | APPLY embedded_scm Music {
993 if (!ly_input_procedure_p ($2))
994 THIS->parser_error (_ ("\apply takes function argument"));
996 SCM ret = gh_call1 ($2, $3->self_scm ());
997 Music *m = unsmob_music (ret);
999 THIS->parser_error ("\\apply must return a Music");
1000 m = MY_MAKE_MUSIC("Music");
1005 { THIS->lexer_->push_note_state (); }
1008 THIS->lexer_->pop_state ();
1011 { THIS->lexer_->push_figuredbass_state (); }
1014 Music * chm = MY_MAKE_MUSIC("UntransposableMusic");
1015 chm->set_mus_property ("element", $3->self_scm ());
1017 scm_gc_unprotect_object ($3->self_scm());
1019 THIS->lexer_->pop_state ();
1022 { THIS->lexer_->push_chord_state (); }
1025 Music * chm = MY_MAKE_MUSIC("UnrelativableMusic");
1026 chm->set_mus_property ("element", $3->self_scm ());
1027 scm_gc_unprotect_object ($3->self_scm());
1030 THIS->lexer_->pop_state ();
1033 { THIS->lexer_->push_lyric_state (); }
1037 THIS->lexer_->pop_state ();
1039 | relative_music { $$ = $1; }
1040 | re_rhythmed_music { $$ = $1; }
1041 | part_combined_music { $$ = $1; }
1045 RELATIVE absolute_pitch Music {
1047 Pitch pit = *unsmob_pitch ($2);
1048 $$ = MY_MAKE_MUSIC("RelativeOctaveMusic");
1050 $$->set_mus_property ("element", p->self_scm ());
1051 scm_gc_unprotect_object (p->self_scm ());
1054 $$->set_mus_property ("last-pitch", p->to_relative_octave (pit).smobbed_copy ());
1060 ADDLYRICS Music Music {
1061 Music*l =MY_MAKE_MUSIC("LyricCombineMusic");
1062 l->set_mus_property ("elements", gh_list ($2->self_scm (), $3->self_scm (), SCM_UNDEFINED));
1063 scm_gc_unprotect_object ($3->self_scm ());
1064 scm_gc_unprotect_object ($2->self_scm ());
1069 part_combined_music:
1070 PARTCOMBINE STRING Music Music {
1071 Music * p= MY_MAKE_MUSIC("PartCombineMusic");
1072 p->set_mus_property ("what", $2);
1073 p->set_mus_property ("elements", gh_list ($3->self_scm (),$4->self_scm (), SCM_UNDEFINED));
1075 scm_gc_unprotect_object ($3->self_scm ());
1076 scm_gc_unprotect_object ($4->self_scm ());
1083 TRANSLATOR STRING '=' STRING {
1084 Music*t= MY_MAKE_MUSIC("TranslatorChange");
1085 t-> set_mus_property ("change-to-type", $2);
1086 t-> set_mus_property ("change-to-id", $4);
1089 $$->set_spot (THIS->here_input ());
1095 | ONCE simple_property_def {
1097 SCM e = $2->get_mus_property ("element");
1098 unsmob_music (e)->set_mus_property ("once", SCM_BOOL_T);
1102 simple_property_def:
1103 PROPERTY STRING '.' STRING '=' scalar {
1104 Music *t = set_property_music (scm_string_to_symbol ($4), $6);
1105 Music *csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
1107 csm->set_mus_property ("element", t->self_scm ());
1108 scm_gc_unprotect_object (t->self_scm ());
1111 $$->set_spot (THIS->here_input ());
1113 csm-> set_mus_property ("context-type", $2);
1115 | PROPERTY STRING '.' STRING UNSET {
1117 Music *t = MY_MAKE_MUSIC("PropertyUnset");
1118 t->set_mus_property ("symbol", scm_string_to_symbol ($4));
1120 Music *csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
1121 csm->set_mus_property ("element", t->self_scm ());
1122 scm_gc_unprotect_object (t->self_scm ());
1125 $$->set_spot (THIS->here_input ());
1127 csm-> set_mus_property ("context-type", $2);
1129 | PROPERTY STRING '.' STRING SET embedded_scm '=' embedded_scm {
1131 = gh_equal_p ($4, scm_makfrom0str ("autoBeamSettings"));
1132 bool itc = internal_type_checking_global_b;
1133 Music *t = MY_MAKE_MUSIC("OverrideProperty");
1134 t->set_mus_property ("symbol", scm_string_to_symbol ($4));
1135 t->set_mus_property ("pop-first", SCM_BOOL_T);
1137 internal_type_checking_global_b = false;
1138 t->set_mus_property ("grob-property", $6);
1140 internal_type_checking_global_b = itc;
1141 t->set_mus_property ("grob-value", $8);
1143 Music *csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
1144 csm->set_mus_property ("element", t->self_scm ());
1145 scm_gc_unprotect_object (t->self_scm ());
1147 $$->set_spot (THIS->here_input ());
1149 csm-> set_mus_property ("context-type", $2);
1151 | PROPERTY STRING '.' STRING OVERRIDE
1152 embedded_scm '=' embedded_scm
1158 = gh_equal_p ($4, scm_makfrom0str ("autoBeamSettings"));
1159 bool itc = internal_type_checking_global_b;
1161 Music *t = MY_MAKE_MUSIC("OverrideProperty");
1162 t->set_mus_property ("symbol", scm_string_to_symbol ($4));
1164 internal_type_checking_global_b = false;
1165 t->set_mus_property ("grob-property", $6);
1166 t->set_mus_property ("grob-value", $8);
1168 internal_type_checking_global_b = itc;
1170 Music *csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
1171 csm->set_mus_property ("element", t->self_scm ());
1172 scm_gc_unprotect_object (t->self_scm ());
1175 $$->set_spot (THIS->here_input ());
1177 csm-> set_mus_property ("context-type", $2);
1180 | PROPERTY STRING '.' STRING REVERT embedded_scm {
1181 Music *t = MY_MAKE_MUSIC("RevertProperty");
1183 = gh_equal_p ($4, scm_makfrom0str ("autoBeamSettings"));
1184 bool itc = internal_type_checking_global_b;
1186 t->set_mus_property ("symbol", scm_string_to_symbol ($4));
1188 internal_type_checking_global_b = false;
1189 t->set_mus_property ("grob-property", $6);
1191 internal_type_checking_global_b = itc;
1193 Music *csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
1194 csm->set_mus_property ("element", t->self_scm ());
1195 scm_gc_unprotect_object (t->self_scm ());
1198 $$->set_spot (THIS->here_input ());
1200 csm-> set_mus_property ("context-type", $2);
1207 | bare_int { $$ = gh_int2scm ($1); }
1208 | embedded_scm { $$ = $1; }
1209 | full_markup { $$ = $1; }
1210 | DIGIT { $$ = gh_int2scm ($1); }
1217 } /*cont */ simple_element post_events {
1218 SCM elts = $3-> get_mus_property ("elements");
1220 elts = gh_append3 (elts, scm_reverse_x ($1, SCM_EOL),
1221 scm_reverse_x ($4, SCM_EOL));
1223 $3-> set_mus_property ("elements", elts);
1227 | note_chord_element
1232 chord_body optional_notemode_duration post_events
1234 SCM dur = unsmob_duration ($2)->smobbed_copy();
1235 SCM es = $1->get_mus_property ("elements");
1236 SCM postevs = scm_reverse_x ($3, SCM_EOL);
1238 for (SCM s = es; gh_pair_p (s); s = gh_cdr (s))
1239 unsmob_music (gh_car(s))->set_mus_property ("duration", dur);
1240 es = gh_append2 (es, postevs);
1242 $1-> set_mus_property ("elements", es);
1248 CHORD_OPEN chord_body_elements CHORD_CLOSE
1250 $$ = MY_MAKE_MUSIC("EventChord");
1251 $$->set_mus_property ("elements",
1252 scm_reverse_x ($2, SCM_EOL));
1256 chord_body_elements:
1257 /* empty */ { $$ = SCM_EOL; }
1258 | chord_body_elements chord_body_element {
1259 $$ = gh_cons ($2->self_scm(), $1);
1260 scm_gc_unprotect_object ($2->self_scm());
1265 pitch exclamations questions post_events
1267 Music * n = MY_MAKE_MUSIC("NoteEvent");
1268 n->set_mus_property ("pitch", $1);
1270 n->set_mus_property ("cautionary", SCM_BOOL_T);
1271 if ($2 % 2 || $3 % 2)
1272 n->set_mus_property ("force-accidental", SCM_BOOL_T);
1274 SCM arts = scm_reverse_x ($4, SCM_EOL);
1275 n->set_mus_property ("articulations", arts);
1283 $$ = MY_MAKE_MUSIC("EventChord");
1284 $$->set_mus_property ("elements", scm_cons ($1->self_scm (), SCM_EOL));
1285 scm_gc_unprotect_object ($1->self_scm());
1287 $$-> set_spot (THIS->here_input ());
1288 $1-> set_spot (THIS->here_input ());
1291 Music *l = MY_MAKE_MUSIC("LigatureEvent");
1292 l->set_mus_property ("span-direction", gh_int2scm (START));
1293 l->set_spot (THIS->here_input ());
1295 $$ = MY_MAKE_MUSIC("EventChord");
1296 $$->set_mus_property ("elements", scm_cons (l->self_scm (), SCM_EOL));
1297 scm_gc_unprotect_object (l->self_scm());
1298 $$->set_spot (THIS->here_input ());
1301 Music *l = MY_MAKE_MUSIC("LigatureEvent");
1302 l->set_mus_property ("span-direction", gh_int2scm (STOP));
1303 l->set_spot (THIS->here_input ());
1305 $$ = MY_MAKE_MUSIC("EventChord");
1306 $$->set_mus_property ("elements", scm_cons (l->self_scm (), SCM_EOL));
1307 $$->set_spot (THIS->here_input ());
1308 scm_gc_unprotect_object (l->self_scm());
1311 $$ = MY_MAKE_MUSIC("VoiceSeparator");
1312 $$->set_spot (THIS->here_input ());
1316 $$ = MY_MAKE_MUSIC("BarCheck");
1317 $$->set_spot (THIS->here_input ());
1320 Music *t = set_property_music (ly_symbol2scm ("whichBar"), $2);
1322 Music *csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
1323 csm->set_mus_property ("element", t->self_scm ());
1324 scm_gc_unprotect_object (t->self_scm ());
1327 $$->set_spot (THIS->here_input ());
1329 csm->set_mus_property ("context-type", scm_makfrom0str ("Timing"));
1331 | PARTIAL duration_length {
1332 Moment m = - unsmob_duration ($2)->get_length ();
1333 Music * p = set_property_music (ly_symbol2scm ( "measurePosition"),m.smobbed_copy ());
1335 Music * sp = MY_MAKE_MUSIC("ContextSpeccedMusic");
1336 sp->set_mus_property ("element", p->self_scm ());
1337 scm_gc_unprotect_object (p->self_scm ());
1340 sp-> set_mus_property ("context-type", scm_makfrom0str ("Timing"));
1345 proc = scm_c_eval_string ("make-clef-set");
1347 SCM result = scm_call_1 (proc, $2);
1348 scm_gc_protect_object (result);
1349 $$ = unsmob_music (result);
1354 proc = scm_c_eval_string ("make-time-signature-set");
1356 SCM result = scm_apply_2 (proc, gh_car ($2), gh_cdr ($2), SCM_EOL);
1357 scm_gc_protect_object (result);
1358 $$ = unsmob_music (result);
1363 shorthand_command_req { $$ = $1; }
1364 | verbose_command_req { $$ = $1; }
1367 shorthand_command_req:
1375 $$ = MY_MAKE_MUSIC("TieEvent");
1378 Music *b= MY_MAKE_MUSIC("BeamEvent");
1379 b->set_mus_property ("span-direction", gh_int2scm (START));
1382 THIS->last_beam_start_ = b->self_scm ();
1385 Music *b= MY_MAKE_MUSIC("BeamEvent");
1386 b->set_mus_property ("span-direction", gh_int2scm (STOP));
1390 $$ = MY_MAKE_MUSIC("BreathingSignEvent");
1393 $$ = MY_MAKE_MUSIC("PesOrFlexaEvent");
1397 verbose_command_req:
1399 Music * m = MY_MAKE_MUSIC("MarkEvent");
1403 Music *m = MY_MAKE_MUSIC("MarkEvent");
1404 m->set_mus_property ("label", $2);
1407 | SKIP duration_length {
1408 Music * skip = MY_MAKE_MUSIC("SkipEvent");
1409 skip->set_mus_property ("duration", $2);
1417 Music *key= MY_MAKE_MUSIC("KeyChangeEvent");
1420 | KEY NOTENAME_PITCH SCM_IDENTIFIER {
1421 Music *key= MY_MAKE_MUSIC("KeyChangeEvent");
1423 key->set_mus_property ("pitch-alist", $3);
1424 key->set_mus_property ("tonic", Pitch (0,0,0).smobbed_copy());
1425 ((Music*)key)->transpose (* unsmob_pitch ($2));
1435 | post_events post_event {
1436 $2->set_spot (THIS->here_input ());
1437 $$ = gh_cons ($2->self_scm(), $$);
1438 scm_gc_unprotect_object ($2->self_scm());
1451 Music * s = MY_MAKE_MUSIC("StringNumberEvent");
1452 s->set_mus_property ("string-number", gh_int2scm($1));
1453 s->set_spot (THIS->here_input ());
1459 event_that_take_dir:
1465 Music * m = MY_MAKE_MUSIC ("NewBeamEvent");
1466 m->set_spot (THIS->here_input());
1467 m->set_mus_property ("span-direction" , gh_int2scm (START));
1471 Music * m = MY_MAKE_MUSIC ("NewBeamEvent");
1472 m->set_spot (THIS->here_input());
1473 m->set_mus_property ("span-direction" , gh_int2scm (STOP));
1477 Music * m = MY_MAKE_MUSIC ("NewTieEvent");
1478 m->set_spot (THIS->here_input());
1481 | script_abbreviation {
1482 SCM s = THIS->lexer_->lookup_identifier ("dash" + ly_scm2string ($1));
1483 Music *a = MY_MAKE_MUSIC("ArticulationEvent");
1484 if (gh_string_p (s))
1485 a->set_mus_property ("articulation-type", s);
1486 else THIS->parser_error (_ ("Expecting string as script definition"));
1492 script_dir event_that_take_dir {
1493 $2->set_mus_property ("direction", gh_int2scm ($1));
1500 $$ = unsmob_music ($1);
1503 Music * a = MY_MAKE_MUSIC("TremoloEvent");
1504 a->set_spot (THIS->here_input ());
1505 a->set_mus_property ("tremolo-type", gh_int2scm ($1));
1532 | NOTENAME_PITCH sup_quotes {
1533 Pitch p = *unsmob_pitch ($1);
1534 p = p.transposed (Pitch ($2,0,0));
1535 $$ = p.smobbed_copy ();
1537 | NOTENAME_PITCH sub_quotes {
1538 Pitch p =* unsmob_pitch ($1);
1539 p = p.transposed (Pitch (-$2,0,0));
1540 $$ = p.smobbed_copy ();
1552 | TONICNAME_PITCH sup_quotes {
1553 Pitch p = *unsmob_pitch ($1);
1554 p = p.transposed (Pitch ($2,0,0));
1555 $$ = p.smobbed_copy ();
1557 | TONICNAME_PITCH sub_quotes {
1558 Pitch p =* unsmob_pitch ($1);
1560 p = p.transposed (Pitch (-$2,0,0));
1561 $$ = p.smobbed_copy ();
1574 pitch_also_in_chords:
1580 PITCH embedded_scm {
1582 if (!unsmob_pitch ($2)) {
1583 THIS->parser_error (_f ("Expecting musical-pitch value", 3));
1584 $$ = Pitch ().smobbed_copy ();
1590 DURATION embedded_scm {
1592 if (!unsmob_duration ($2))
1594 THIS->parser_error (_ ("Must have duration object"));
1595 $$ = Duration ().smobbed_copy ();
1602 if (!THIS->lexer_->lyric_state_b ())
1603 THIS->parser_error (_ ("Have to be in Lyric mode for lyrics"));
1604 $$ = MY_MAKE_MUSIC("ExtenderEvent");
1610 if (!THIS->lexer_->lyric_state_b ())
1611 THIS->parser_error (_ ("Have to be in Lyric mode for lyrics"));
1612 $$ = MY_MAKE_MUSIC("HyphenEvent");
1617 close_event_parens {
1619 dynamic_cast<Music *> ($$)->set_mus_property ("span-direction", gh_int2scm (START))
1626 Music * s= MY_MAKE_MUSIC("SlurEvent");
1628 s->set_spot (THIS->here_input());
1631 Music * s= MY_MAKE_MUSIC("PhrasingSlurEvent");
1633 s->set_spot (THIS->here_input());
1636 Music *s =MY_MAKE_MUSIC("CrescendoEvent");
1638 s->set_spot (THIS->here_input());
1641 Music *s =MY_MAKE_MUSIC("DecrescendoEvent");
1643 s->set_spot (THIS->here_input());
1651 dynamic_cast<Music *> ($$)->set_mus_property ("span-direction", gh_int2scm (STOP))
1658 Music *s = MY_MAKE_MUSIC("CrescendoEvent");
1659 s->set_spot (THIS->here_input());
1664 Music * s= MY_MAKE_MUSIC("SlurEvent");
1666 s->set_spot (THIS->here_input());
1670 Music * s= MY_MAKE_MUSIC("PhrasingSlurEvent");
1672 s->set_mus_property ("span-type", scm_makfrom0str ( "phrasing-slur"));
1673 s->set_spot (THIS->here_input());
1679 Music *t = MY_MAKE_MUSIC("TextScriptEvent");
1680 t->set_mus_property ("text", $1);
1681 t->set_spot (THIS->here_input ());
1685 Music *t = MY_MAKE_MUSIC("TextScriptEvent");
1686 t->set_mus_property ("text", $1);
1687 t->set_spot (THIS->here_input ());
1691 Music *t = MY_MAKE_MUSIC("TextScriptEvent");
1692 t->set_mus_property ("text", make_simple_markup ($1));
1693 t->set_spot (THIS->here_input ());
1698 Music * t = MY_MAKE_MUSIC("FingerEvent");
1699 t->set_mus_property ("digit", gh_int2scm ($1));
1700 t->set_spot (THIS->here_input ());
1705 script_abbreviation:
1707 $$ = scm_makfrom0str ("Hat");
1710 $$ = scm_makfrom0str ("Plus");
1713 $$ = scm_makfrom0str ("Dash");
1716 $$ = scm_makfrom0str ("Bar");
1719 $$ = scm_makfrom0str ("Larger");
1722 $$ = scm_makfrom0str ("Dot");
1725 $$ = scm_makfrom0str ("Underscore");
1732 | '-' { $$ = CENTER; }
1739 | pre_events open_event {
1740 $$ = gh_cons ($2->self_scm(), $$);
1741 scm_gc_unprotect_object ($2->self_scm());
1752 multiplied_duration {
1755 | verbose_duration {
1760 optional_notemode_duration:
1762 Duration dd = THIS->default_duration_;
1763 $$ = dd.smobbed_copy ();
1765 THIS->beam_check ($$);
1767 | multiplied_duration {
1769 THIS->default_duration_ = *unsmob_duration ($$);
1771 THIS->beam_check ($$);
1773 | verbose_duration {
1775 THIS->default_duration_ = *unsmob_duration ($$);
1780 bare_unsigned dots {
1782 if (!is_duration_b ($1))
1783 THIS->parser_error (_f ("not a duration: %d", $1));
1787 $$ = Duration (l, $2).smobbed_copy ();
1789 | DURATION_IDENTIFIER dots {
1790 Duration *d =unsmob_duration ($1);
1791 Duration k (d->duration_log (),d->dot_count () + $2);
1801 multiplied_duration:
1805 | multiplied_duration '*' bare_unsigned {
1806 $$ = unsmob_duration ($$)->compressed ( $3) .smobbed_copy ();
1808 | multiplied_duration '*' FRACTION {
1809 Rational m (gh_scm2int (ly_car ($3)), gh_scm2int (ly_cdr ($3)));
1811 $$ = unsmob_duration ($$)->compressed (m).smobbed_copy ();
1816 FRACTION { $$ = $1; }
1817 | UNSIGNED '/' UNSIGNED {
1818 $$ = scm_cons (gh_int2scm ($1), gh_int2scm ($3));
1836 | ':' bare_unsigned {
1837 if (!is_duration_b ($2))
1838 THIS->parser_error (_f ("not a duration: %d", $2));
1845 /*****************************************************************
1847 *****************************************************************/
1861 Music *bfr = MY_MAKE_MUSIC("BassFigureEvent");
1862 $$ = bfr->self_scm();
1863 scm_gc_unprotect_object ($$);
1866 Music *bfr = MY_MAKE_MUSIC("BassFigureEvent");
1867 $$ = bfr->self_scm();
1869 bfr->set_mus_property ("figure", gh_int2scm ($1));
1871 scm_gc_unprotect_object ($$);
1873 | bass_figure bass_mod {
1874 Music *m = unsmob_music ($1);
1876 SCM salter =m->get_mus_property ("alteration");
1877 int alter = gh_number_p ( salter) ? gh_scm2int (salter) : 0;
1878 m->set_mus_property ("alteration",
1879 gh_int2scm (alter + $2));
1881 m->set_mus_property ("alteration", gh_int2scm (0));
1889 unsmob_music ($$)->set_mus_property ("bracket-start", SCM_BOOL_T);
1894 | br_bass_figure ']' {
1896 unsmob_music ($1)->set_mus_property ("bracket-stop", SCM_BOOL_T);
1904 | figure_list br_bass_figure {
1905 $$ = scm_cons ($2, $1);
1910 FIGURE_OPEN figure_list FIGURE_CLOSE {
1911 Music * m = MY_MAKE_MUSIC("EventChord");
1912 $2 = scm_reverse_x ($2, SCM_EOL);
1913 m->set_mus_property ("elements", $2);
1914 $$ = m->self_scm ();
1925 pitch exclamations questions optional_notemode_duration optional_rest {
1927 Input i = THIS->pop_spot ();
1928 if (!THIS->lexer_->note_state_b ())
1929 THIS->parser_error (_ ("Have to be in Note mode for notes"));
1933 n = MY_MAKE_MUSIC("RestEvent");
1935 n = MY_MAKE_MUSIC("NoteEvent");
1937 n->set_mus_property ("pitch", $1);
1938 n->set_mus_property ("duration", $4);
1942 n->set_mus_property ("cautionary", SCM_BOOL_T);
1943 if ($2 % 2 || $3 % 2)
1944 n->set_mus_property ("force-accidental", SCM_BOOL_T);
1946 Music *v = MY_MAKE_MUSIC("EventChord");
1947 v->set_mus_property ("elements", scm_list_n (n->self_scm (), SCM_UNDEFINED));
1948 scm_gc_unprotect_object (n->self_scm());
1954 | figure_spec optional_notemode_duration {
1955 Music * m = unsmob_music ($1);
1956 Input i = THIS->pop_spot ();
1958 for (SCM s = m->get_mus_property ("elements"); gh_pair_p (s); s = ly_cdr (s))
1960 unsmob_music (ly_car (s))->set_mus_property ("duration", $2);
1964 | RESTNAME optional_notemode_duration {
1966 Input i = THIS->pop_spot ();
1968 if (ly_scm2string ($1) =="s") {
1970 ev = MY_MAKE_MUSIC("SkipEvent");
1973 ev = MY_MAKE_MUSIC("RestEvent");
1976 ev->set_mus_property ("duration" ,$2);
1978 Music * velt = MY_MAKE_MUSIC("EventChord");
1979 velt->set_mus_property ("elements", scm_list_n (ev->self_scm (),SCM_UNDEFINED));
1984 | MULTI_MEASURE_REST optional_notemode_duration {
1989 proc = scm_c_eval_string ("make-multi-measure-rest");
1991 SCM mus = scm_call_2 (proc, $2,
1992 make_input (THIS->here_input()));
1993 scm_gc_protect_object (mus);
1994 $$ = unsmob_music (mus);
1996 | STRING optional_notemode_duration {
1997 Input i = THIS->pop_spot ();
1999 Music * lreq = MY_MAKE_MUSIC("LyricEvent");
2000 lreq->set_mus_property ("text", $1);
2001 lreq->set_mus_property ("duration",$2);
2003 Music * velt = MY_MAKE_MUSIC("EventChord");
2004 velt->set_mus_property ("elements", scm_list_n (lreq->self_scm (), SCM_UNDEFINED));
2011 if (!THIS->lexer_->chord_state_b ())
2012 THIS->parser_error (_ ("Have to be in Chord mode for chords"));
2013 $$ = unsmob_music ($1);
2018 steno_tonic_pitch optional_notemode_duration {
2019 $$ = make_chord ($1, $2, SCM_EOL);
2021 | steno_tonic_pitch optional_notemode_duration chord_separator chord_items {
2022 SCM its = scm_reverse_x ($4, SCM_EOL);
2023 $$ = make_chord ($1, $2, gh_cons ($3, its));
2031 | chord_items chord_item {
2032 $$ = gh_cons ($2, $$);
2038 $$ = ly_symbol2scm ("chord-colon");
2041 $$ = ly_symbol2scm ("chord-caret");
2043 | CHORD_SLASH steno_tonic_pitch {
2044 $$ = scm_list_n (ly_symbol2scm ("chord-slash"), $2, SCM_UNDEFINED);
2046 | CHORD_BASS steno_tonic_pitch {
2047 $$ = scm_list_n (ly_symbol2scm ("chord-bass"), $2, SCM_UNDEFINED);
2056 $$ = scm_reverse_x ($1, SCM_EOL);
2064 step_number { $$ = gh_cons ($1, SCM_EOL); }
2065 | step_numbers '.' step_number {
2066 $$ = gh_cons ($3, $$);
2072 $$ = make_chord_step ($1, 0);
2074 | bare_unsigned '+' {
2075 $$ = make_chord_step ($1, 1);
2077 | bare_unsigned CHORD_MINUS {
2078 $$ = make_chord_step ($1,-1);
2086 number_expression '+' number_term {
2087 $$ = scm_sum ($1, $3);
2089 | number_expression '-' number_term {
2090 $$ = scm_difference ($1, $3);
2099 | number_factor '*' number_factor {
2100 $$ = scm_product ($1, $3);
2102 | number_factor '/' number_factor {
2103 $$ = scm_divide ($1, $3);
2108 '-' number_factor { /* %prec UNARY_MINUS */
2109 $$ = scm_difference ($2, SCM_UNDEFINED);
2117 $$ = gh_int2scm ($1);
2122 | NUMBER_IDENTIFIER {
2125 | REAL NUMBER_IDENTIFIER {
2126 $$ = gh_double2scm (gh_scm2double ($1) * gh_scm2double ($2));
2128 | UNSIGNED NUMBER_IDENTIFIER {
2129 $$ = gh_double2scm ($1 * gh_scm2double ($2));
2145 if (scm_integer_p ($1) == SCM_BOOL_T)
2147 int k = gh_scm2int ($1);
2151 THIS->parser_error (_ ("need integer number arg"));
2165 | STRING_IDENTIFIER {
2168 | string '+' string {
2169 $$ = scm_string_append (scm_list_n ($1, $3, SCM_UNDEFINED));
2176 | exclamations '!' { $$ ++; }
2181 | questions '?' { $$ ++; }
2191 { THIS->lexer_->push_markup_state (); }
2194 THIS->lexer_->pop_state ();
2200 This should be done more dynamically if possible.
2204 $$ = make_simple_markup ($1);
2206 | MARKUP_HEAD_MARKUP0 markup {
2207 $$ = scm_list_n ($1, $2, SCM_UNDEFINED);
2209 | MARKUP_HEAD_MARKUP0_MARKUP1 markup markup {
2210 $$ = scm_list_n ($1, $2, $3, SCM_UNDEFINED);
2212 | MARKUP_HEAD_SCM0_MARKUP1 SCM_T markup {
2213 $$ = scm_list_n ($1, $2, $3, SCM_UNDEFINED);
2218 | MARKUP_HEAD_LIST0 markup_list {
2219 $$ = scm_list_n ($1,$2, SCM_UNDEFINED);
2221 | MARKUP_HEAD_SCM0 embedded_scm {
2222 $$ = scm_list_n ($1, $2, SCM_UNDEFINED);
2224 | MARKUP_HEAD_SCM0_SCM1_MARKUP2 embedded_scm embedded_scm markup {
2225 $$ = scm_list_n ($1, $2, $3, $4, SCM_UNDEFINED);
2227 | MARKUP_HEAD_SCM0_SCM1_SCM2 embedded_scm embedded_scm embedded_scm {
2228 $$ = scm_list_n ($1, $2, $3, $4, SCM_UNDEFINED);
2230 | MARKUP_IDENTIFIER {
2237 CHORD_OPEN markup_list_body CHORD_CLOSE { $$ = scm_reverse_x ($2, SCM_EOL); }
2241 '{' markup_list_body '}' {
2244 line = scm_c_eval_string ("line-markup");
2246 $$ = scm_list_n (line, scm_reverse_x ($2, SCM_EOL), SCM_UNDEFINED);
2251 /**/ { $$ = SCM_EOL; }
2252 | markup_list_body markup {
2253 $$ = gh_cons ($2, $1) ;
2261 My_lily_parser::set_yydebug (bool )
2268 extern My_lily_parser * current_parser;
2271 My_lily_parser::do_yyparse ()
2273 current_parser = this;;
2274 yyparse ((void*)this);
2279 Should make this optional? It will also complain when you do
2283 which is entirely legitimate.
2285 Or we can scrap it. Barchecks should detect wrong durations, and
2286 skipTypesetting speeds it up a lot.
2290 My_lily_parser::beam_check (SCM dur)
2292 Duration *d = unsmob_duration (dur);
2293 if (unsmob_music (last_beam_start_) && d->duration_log () <= 2)
2295 Music * m = unsmob_music (last_beam_start_);
2296 m->origin ()->warning (_("Suspect duration found following this beam"));
2298 last_beam_start_ = SCM_EOL;
2306 return gh_pair_p (x)
2307 && SCM_BOOL_F != scm_object_property (gh_car (x), ly_symbol2scm ("markup-signature"));
2310 It is a little strange, to have this function in this file, but
2311 otherwise, we have to import music classes into the lexer.
2315 My_lily_lexer::try_special_identifiers (SCM * destination, SCM sid)
2317 if (gh_string_p (sid)) {
2319 return STRING_IDENTIFIER;
2320 } else if (gh_number_p (sid)) {
2322 return NUMBER_IDENTIFIER;
2323 } else if (unsmob_translator_def (sid)) {
2324 *destination = unsmob_translator_def (sid)->clone_scm();
2325 return TRANSLATOR_IDENTIFIER;
2326 } else if (unsmob_score (sid)) {
2327 Score *sc = new Score (*unsmob_score (sid));
2328 *destination =sc->self_scm ();
2329 return SCORE_IDENTIFIER;
2330 } else if (Music * mus =unsmob_music (sid)) {
2331 *destination = unsmob_music (sid)->clone ()->self_scm();
2332 unsmob_music (*destination)->
2333 set_mus_property ("origin", make_input (last_input_));
2334 return dynamic_cast<Event*> (mus)
2335 ? EVENT_IDENTIFIER : MUSIC_IDENTIFIER;
2336 } else if (unsmob_duration (sid)) {
2337 *destination = unsmob_duration (sid)->smobbed_copy();
2338 return DURATION_IDENTIFIER;
2339 } else if (unsmob_music_output_def (sid)) {
2340 Music_output_def *p = unsmob_music_output_def (sid);
2343 *destination = p->self_scm();
2344 return MUSIC_OUTPUT_DEF_IDENTIFIER;
2345 } else if (new_markup_p (sid)) {
2347 return MARKUP_IDENTIFIER;