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"
74 #include "music-list.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"))) {
799 we can not get durations and other stuff correct down the line, so we have to
800 add to the duration log here.
805 func = scm_primitive_eval (ly_symbol2scm ("shift-duration-log"));
807 int dots = ($3 % 3) ? 0 : 1;
808 int shift = -intlog2 ((dots) ? ($3*2/3) : $3);
810 Sequential_music * seq = dynamic_cast<Sequential_music*> ($4);
813 int list_len =scm_ilength (seq->music_list ());
815 seq->origin ()->warning ("Chord tremolo must have 2 elements.");
817 r->compress (Moment (Rational (1,list_len)));
819 gh_call3 (func, r->self_scm (), gh_int2scm(shift),gh_int2scm(dots));
822 r->set_spot (*$4->origin ());
829 SEQUENTIAL '{' Music_list '}' {
830 $$ = MY_MAKE_MUSIC("SequentialMusic");
831 $$->set_mus_property ("elements", ly_car ($3));
832 $$->set_spot(THIS->here_input());
834 | '{' Music_list '}' {
835 $$ = MY_MAKE_MUSIC("SequentialMusic");
836 $$->set_mus_property ("elements", ly_car ($2));
837 $$->set_spot(THIS->here_input());
842 SIMULTANEOUS '{' Music_list '}'{
843 $$ = MY_MAKE_MUSIC("SimultaneousMusic");
844 $$->set_mus_property ("elements", ly_car ($3));
845 $$->set_spot(THIS->here_input());
848 | '<' Music_list '>' {
849 $$ = MY_MAKE_MUSIC("SimultaneousMusic");
850 $$->set_mus_property ("elements", ly_car ($2));
851 $$->set_spot(THIS->here_input());
856 event_chord { $$ = $1; }
857 | APPLYOUTPUT embedded_scm {
858 if (!ly_input_procedure_p ($2))
859 THIS->parser_error (_ ("\applycontext takes function argument"));
860 $$ = MY_MAKE_MUSIC ("ApplyOutputEvent");
861 $$->set_mus_property ("procedure", $2);
862 $$->set_spot (THIS->here_input());
864 | APPLYCONTEXT embedded_scm {
865 if (!ly_input_procedure_p ($2))
866 THIS->parser_error (_ ("\applycontext takes function argument"));
867 $$ = MY_MAKE_MUSIC ("ApplyContext");
868 $$->set_mus_property ("procedure", $2);
869 $$->set_spot (THIS->here_input());
871 | OUTPUTPROPERTY embedded_scm embedded_scm '=' embedded_scm {
873 if (!gh_symbol_p ($3))
875 THIS->parser_error (_ ("Second argument must be a symbol"));
877 /* Should check # args */
878 if (!gh_procedure_p (pred))
880 THIS->parser_error (_ ("First argument must be a procedure taking one argument"));
883 Music*m = MY_MAKE_MUSIC("OutputPropertySetMusic");
884 m->set_mus_property ("predicate", pred);
885 m->set_mus_property ("grob-property", $3);
886 m->set_mus_property ("grob-value", $5);
891 $$ = unsmob_music ($1);
899 CONTEXT STRING Music {
900 Music*csm =MY_MAKE_MUSIC("ContextSpeccedMusic");
902 csm->set_mus_property ("element", $3->self_scm ());
903 scm_gc_unprotect_object ($3->self_scm ());
905 csm->set_mus_property ("context-type",$2);
906 csm->set_mus_property ("context-id", scm_makfrom0str (""));
910 | AUTOCHANGE STRING Music {
911 Music*chm = MY_MAKE_MUSIC("AutoChangeMusic");
912 chm->set_mus_property ("element", $3->self_scm ());
913 chm->set_mus_property ("iterator-ctor", Auto_change_iterator::constructor_proc);
915 scm_gc_unprotect_object ($3->self_scm ());
916 chm->set_mus_property ("what", $2);
919 chm->set_spot (*$3->origin ());
924 The other version is for easier debugging of
925 Sequential_music_iterator in combination with grace notes.
928 SCM start = THIS->lexer_->lookup_identifier ("startGraceMusic");
929 SCM stop = THIS->lexer_->lookup_identifier ("stopGraceMusic");
930 Music *startm = unsmob_music (start);
931 Music *stopm = unsmob_music (stop);
935 stopm = stopm->clone ();
936 ms = scm_cons (stopm->self_scm (), ms);
937 scm_gc_unprotect_object (stopm->self_scm ());
939 ms = scm_cons ($2->self_scm (), ms);
940 scm_gc_unprotect_object ($2->self_scm());
942 startm = startm->clone ();
943 ms = scm_cons (startm->self_scm () , ms);
944 scm_gc_unprotect_object (startm->self_scm ());
948 Music* seq = MY_MAKE_MUSIC("SequentialMusic");
949 seq->set_mus_property ("elements", ms);
952 $$ = MY_MAKE_MUSIC("GraceMusic");
953 $$->set_mus_property ("element", seq->self_scm ());
954 scm_gc_unprotect_object (seq->self_scm ());
956 $$ = MY_MAKE_MUSIC("GraceMusic");
957 $$->set_mus_property ("element", $2->self_scm ());
958 scm_gc_unprotect_object ($2->self_scm ());
961 | CONTEXT string '=' string Music {
962 Music * csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
964 csm->set_mus_property ("element", $5->self_scm ());
965 scm_gc_unprotect_object ($5->self_scm ());
967 csm->set_mus_property ("context-type", $2);
968 csm->set_mus_property ("context-id", $4);
979 int n = gh_scm2int (ly_car ($3)); int d = gh_scm2int (ly_cdr ($3));
981 $$= MY_MAKE_MUSIC("TimeScaledMusic");
982 $$->set_spot (THIS->pop_spot ());
985 $$->set_mus_property ("element", mp->self_scm ());
986 scm_gc_unprotect_object (mp->self_scm ());
987 $$->set_mus_property ("numerator", gh_int2scm (n));
988 $$->set_mus_property ("denominator", gh_int2scm (d));
989 $$->compress (Moment (Rational (n,d)));
992 | Repeated_music { $$ = $1; }
993 | Simultaneous_music { $$ = $1; }
994 | Sequential_music { $$ = $1; }
995 | TRANSPOSE pitch_also_in_chords pitch_also_in_chords Music {
996 $$ = MY_MAKE_MUSIC("TransposedMusic");
998 Pitch from = *unsmob_pitch ($2);
999 Pitch to = *unsmob_pitch ($3);
1001 p->transpose (interval (from, to));
1002 $$->set_mus_property ("element", p->self_scm ());
1003 scm_gc_unprotect_object (p->self_scm ());
1005 | APPLY embedded_scm Music {
1006 if (!ly_input_procedure_p ($2))
1007 THIS->parser_error (_ ("\apply takes function argument"));
1009 SCM ret = gh_call1 ($2, $3->self_scm ());
1010 Music *m = unsmob_music (ret);
1012 THIS->parser_error ("\\apply must return a Music");
1013 m = MY_MAKE_MUSIC("Music");
1018 { THIS->lexer_->push_note_state (); }
1021 THIS->lexer_->pop_state ();
1024 { THIS->lexer_->push_figuredbass_state (); }
1027 Music * chm = MY_MAKE_MUSIC("UntransposableMusic");
1028 chm->set_mus_property ("element", $3->self_scm ());
1030 scm_gc_unprotect_object ($3->self_scm());
1032 THIS->lexer_->pop_state ();
1035 { THIS->lexer_->push_chord_state (); }
1038 Music * chm = MY_MAKE_MUSIC("UnrelativableMusic");
1039 chm->set_mus_property ("element", $3->self_scm ());
1040 scm_gc_unprotect_object ($3->self_scm());
1043 THIS->lexer_->pop_state ();
1046 { THIS->lexer_->push_lyric_state (); }
1050 THIS->lexer_->pop_state ();
1052 | relative_music { $$ = $1; }
1053 | re_rhythmed_music { $$ = $1; }
1054 | part_combined_music { $$ = $1; }
1058 RELATIVE absolute_pitch Music {
1060 Pitch pit = *unsmob_pitch ($2);
1061 $$ = MY_MAKE_MUSIC("RelativeOctaveMusic");
1063 $$->set_mus_property ("element", p->self_scm ());
1064 scm_gc_unprotect_object (p->self_scm ());
1067 $$->set_mus_property ("last-pitch", p->to_relative_octave (pit).smobbed_copy ());
1073 ADDLYRICS Music Music {
1074 Music*l =MY_MAKE_MUSIC("LyricCombineMusic");
1075 l->set_mus_property ("elements", gh_list ($2->self_scm (), $3->self_scm (), SCM_UNDEFINED));
1076 scm_gc_unprotect_object ($3->self_scm ());
1077 scm_gc_unprotect_object ($2->self_scm ());
1082 part_combined_music:
1083 PARTCOMBINE STRING Music Music {
1084 Music * p= MY_MAKE_MUSIC("PartCombineMusic");
1085 p->set_mus_property ("what", $2);
1086 p->set_mus_property ("elements", gh_list ($3->self_scm (),$4->self_scm (), SCM_UNDEFINED));
1088 scm_gc_unprotect_object ($3->self_scm ());
1089 scm_gc_unprotect_object ($4->self_scm ());
1096 TRANSLATOR STRING '=' STRING {
1097 Music*t= MY_MAKE_MUSIC("TranslatorChange");
1098 t-> set_mus_property ("change-to-type", $2);
1099 t-> set_mus_property ("change-to-id", $4);
1102 $$->set_spot (THIS->here_input ());
1108 | ONCE simple_property_def {
1110 SCM e = $2->get_mus_property ("element");
1111 unsmob_music (e)->set_mus_property ("once", SCM_BOOL_T);
1115 simple_property_def:
1116 PROPERTY STRING '.' STRING '=' scalar {
1117 Music *t = set_property_music (scm_string_to_symbol ($4), $6);
1118 Music *csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
1120 csm->set_mus_property ("element", t->self_scm ());
1121 scm_gc_unprotect_object (t->self_scm ());
1124 $$->set_spot (THIS->here_input ());
1126 csm-> set_mus_property ("context-type", $2);
1128 | PROPERTY STRING '.' STRING UNSET {
1130 Music *t = MY_MAKE_MUSIC("PropertyUnset");
1131 t->set_mus_property ("symbol", scm_string_to_symbol ($4));
1133 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 SET embedded_scm '=' embedded_scm {
1144 = gh_equal_p ($4, scm_makfrom0str ("autoBeamSettings"));
1145 bool itc = internal_type_checking_global_b;
1146 Music *t = MY_MAKE_MUSIC("OverrideProperty");
1147 t->set_mus_property ("symbol", scm_string_to_symbol ($4));
1148 t->set_mus_property ("pop-first", SCM_BOOL_T);
1150 internal_type_checking_global_b = false;
1151 t->set_mus_property ("grob-property", $6);
1153 internal_type_checking_global_b = itc;
1154 t->set_mus_property ("grob-value", $8);
1156 Music *csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
1157 csm->set_mus_property ("element", t->self_scm ());
1158 scm_gc_unprotect_object (t->self_scm ());
1160 $$->set_spot (THIS->here_input ());
1162 csm-> set_mus_property ("context-type", $2);
1164 | PROPERTY STRING '.' STRING OVERRIDE
1165 embedded_scm '=' embedded_scm
1171 = gh_equal_p ($4, scm_makfrom0str ("autoBeamSettings"));
1172 bool itc = internal_type_checking_global_b;
1174 Music *t = MY_MAKE_MUSIC("OverrideProperty");
1175 t->set_mus_property ("symbol", scm_string_to_symbol ($4));
1177 internal_type_checking_global_b = false;
1178 t->set_mus_property ("grob-property", $6);
1179 t->set_mus_property ("grob-value", $8);
1181 internal_type_checking_global_b = itc;
1183 Music *csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
1184 csm->set_mus_property ("element", t->self_scm ());
1185 scm_gc_unprotect_object (t->self_scm ());
1188 $$->set_spot (THIS->here_input ());
1190 csm-> set_mus_property ("context-type", $2);
1193 | PROPERTY STRING '.' STRING REVERT embedded_scm {
1194 Music *t = MY_MAKE_MUSIC("RevertProperty");
1196 = gh_equal_p ($4, scm_makfrom0str ("autoBeamSettings"));
1197 bool itc = internal_type_checking_global_b;
1199 t->set_mus_property ("symbol", scm_string_to_symbol ($4));
1201 internal_type_checking_global_b = false;
1202 t->set_mus_property ("grob-property", $6);
1204 internal_type_checking_global_b = itc;
1206 Music *csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
1207 csm->set_mus_property ("element", t->self_scm ());
1208 scm_gc_unprotect_object (t->self_scm ());
1211 $$->set_spot (THIS->here_input ());
1213 csm-> set_mus_property ("context-type", $2);
1220 | bare_int { $$ = gh_int2scm ($1); }
1221 | embedded_scm { $$ = $1; }
1222 | full_markup { $$ = $1; }
1223 | DIGIT { $$ = gh_int2scm ($1); }
1230 } /*cont */ simple_element post_events {
1231 SCM elts = $3-> get_mus_property ("elements");
1233 elts = gh_append3 (elts, scm_reverse_x ($1, SCM_EOL),
1234 scm_reverse_x ($4, SCM_EOL));
1236 $3-> set_mus_property ("elements", elts);
1240 | note_chord_element
1245 chord_body optional_notemode_duration post_events
1247 SCM dur = unsmob_duration ($2)->smobbed_copy();
1248 SCM es = $1->get_mus_property ("elements");
1249 SCM postevs = scm_reverse_x ($3, SCM_EOL);
1251 for (SCM s = es; gh_pair_p (s); s = gh_cdr (s))
1252 unsmob_music (gh_car(s))->set_mus_property ("duration", dur);
1253 es = gh_append2 (es, postevs);
1255 $1-> set_mus_property ("elements", es);
1261 CHORD_OPEN chord_body_elements CHORD_CLOSE
1263 $$ = MY_MAKE_MUSIC("EventChord");
1264 $$->set_mus_property ("elements",
1265 scm_reverse_x ($2, SCM_EOL));
1269 chord_body_elements:
1270 /* empty */ { $$ = SCM_EOL; }
1271 | chord_body_elements chord_body_element {
1272 $$ = gh_cons ($2->self_scm(), $1);
1273 scm_gc_unprotect_object ($2->self_scm());
1278 pitch exclamations questions post_events
1280 Music * n = MY_MAKE_MUSIC("NoteEvent");
1281 n->set_mus_property ("pitch", $1);
1283 n->set_mus_property ("cautionary", SCM_BOOL_T);
1284 if ($2 % 2 || $3 % 2)
1285 n->set_mus_property ("force-accidental", SCM_BOOL_T);
1287 SCM arts = scm_reverse_x ($4, SCM_EOL);
1288 n->set_mus_property ("articulations", arts);
1296 $$ = MY_MAKE_MUSIC("EventChord");
1297 $$->set_mus_property ("elements", scm_cons ($1->self_scm (), SCM_EOL));
1298 scm_gc_unprotect_object ($1->self_scm());
1300 $$-> set_spot (THIS->here_input ());
1301 $1-> set_spot (THIS->here_input ());
1304 Music *l = MY_MAKE_MUSIC("LigatureEvent");
1305 l->set_mus_property ("span-direction", gh_int2scm (START));
1306 l->set_spot (THIS->here_input ());
1308 $$ = MY_MAKE_MUSIC("EventChord");
1309 $$->set_mus_property ("elements", scm_cons (l->self_scm (), SCM_EOL));
1310 scm_gc_unprotect_object (l->self_scm());
1311 $$->set_spot (THIS->here_input ());
1314 Music *l = MY_MAKE_MUSIC("LigatureEvent");
1315 l->set_mus_property ("span-direction", gh_int2scm (STOP));
1316 l->set_spot (THIS->here_input ());
1318 $$ = MY_MAKE_MUSIC("EventChord");
1319 $$->set_mus_property ("elements", scm_cons (l->self_scm (), SCM_EOL));
1320 $$->set_spot (THIS->here_input ());
1321 scm_gc_unprotect_object (l->self_scm());
1324 $$ = MY_MAKE_MUSIC("VoiceSeparator");
1325 $$->set_spot (THIS->here_input ());
1329 $$ = MY_MAKE_MUSIC("BarCheck");
1330 $$->set_spot (THIS->here_input ());
1333 Music *t = set_property_music (ly_symbol2scm ("whichBar"), $2);
1335 Music *csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
1336 csm->set_mus_property ("element", t->self_scm ());
1337 scm_gc_unprotect_object (t->self_scm ());
1340 $$->set_spot (THIS->here_input ());
1342 csm->set_mus_property ("context-type", scm_makfrom0str ("Timing"));
1344 | PARTIAL duration_length {
1345 Moment m = - unsmob_duration ($2)->get_length ();
1346 Music * p = set_property_music (ly_symbol2scm ( "measurePosition"),m.smobbed_copy ());
1348 Music * sp = MY_MAKE_MUSIC("ContextSpeccedMusic");
1349 sp->set_mus_property ("element", p->self_scm ());
1350 scm_gc_unprotect_object (p->self_scm ());
1353 sp-> set_mus_property ("context-type", scm_makfrom0str ("Timing"));
1358 proc = scm_c_eval_string ("make-clef-set");
1360 SCM result = scm_call_1 (proc, $2);
1361 scm_gc_protect_object (result);
1362 $$ = unsmob_music (result);
1367 proc = scm_c_eval_string ("make-time-signature-set");
1369 SCM result = scm_apply_2 (proc, gh_car ($2), gh_cdr ($2), SCM_EOL);
1370 scm_gc_protect_object (result);
1371 $$ = unsmob_music (result);
1376 shorthand_command_req { $$ = $1; }
1377 | verbose_command_req { $$ = $1; }
1380 shorthand_command_req:
1388 $$ = MY_MAKE_MUSIC("TieEvent");
1391 Music *b= MY_MAKE_MUSIC("BeamEvent");
1392 b->set_mus_property ("span-direction", gh_int2scm (START));
1395 THIS->last_beam_start_ = b->self_scm ();
1398 Music *b= MY_MAKE_MUSIC("BeamEvent");
1399 b->set_mus_property ("span-direction", gh_int2scm (STOP));
1403 $$ = MY_MAKE_MUSIC("BreathingSignEvent");
1406 $$ = MY_MAKE_MUSIC("PesOrFlexaEvent");
1410 verbose_command_req:
1412 Music * m = MY_MAKE_MUSIC("MarkEvent");
1416 Music *m = MY_MAKE_MUSIC("MarkEvent");
1417 m->set_mus_property ("label", $2);
1420 | SKIP duration_length {
1421 Music * skip = MY_MAKE_MUSIC("SkipEvent");
1422 skip->set_mus_property ("duration", $2);
1430 Music *key= MY_MAKE_MUSIC("KeyChangeEvent");
1433 | KEY NOTENAME_PITCH SCM_IDENTIFIER {
1434 Music *key= MY_MAKE_MUSIC("KeyChangeEvent");
1436 key->set_mus_property ("pitch-alist", $3);
1437 key->set_mus_property ("tonic", Pitch (0,0,0).smobbed_copy());
1438 ((Music*)key)->transpose (* unsmob_pitch ($2));
1448 | post_events post_event {
1449 $2->set_spot (THIS->here_input ());
1450 $$ = gh_cons ($2->self_scm(), $$);
1451 scm_gc_unprotect_object ($2->self_scm());
1464 Music * s = MY_MAKE_MUSIC("StringNumberEvent");
1465 s->set_mus_property ("string-number", gh_int2scm($1));
1466 s->set_spot (THIS->here_input ());
1472 event_that_take_dir:
1478 Music * m = MY_MAKE_MUSIC ("NewBeamEvent");
1479 m->set_spot (THIS->here_input());
1480 m->set_mus_property ("span-direction" , gh_int2scm (START));
1484 Music * m = MY_MAKE_MUSIC ("NewBeamEvent");
1485 m->set_spot (THIS->here_input());
1486 m->set_mus_property ("span-direction" , gh_int2scm (STOP));
1490 Music * m = MY_MAKE_MUSIC ("NewTieEvent");
1491 m->set_spot (THIS->here_input());
1494 | script_abbreviation {
1495 SCM s = THIS->lexer_->lookup_identifier ("dash" + ly_scm2string ($1));
1496 Music *a = MY_MAKE_MUSIC("ArticulationEvent");
1497 if (gh_string_p (s))
1498 a->set_mus_property ("articulation-type", s);
1499 else THIS->parser_error (_ ("Expecting string as script definition"));
1505 script_dir event_that_take_dir {
1506 $2->set_mus_property ("direction", gh_int2scm ($1));
1513 $$ = unsmob_music ($1);
1516 Music * a = MY_MAKE_MUSIC("TremoloEvent");
1517 a->set_spot (THIS->here_input ());
1518 a->set_mus_property ("tremolo-type", gh_int2scm ($1));
1545 | NOTENAME_PITCH sup_quotes {
1546 Pitch p = *unsmob_pitch ($1);
1547 p = p.transposed (Pitch ($2,0,0));
1548 $$ = p.smobbed_copy ();
1550 | NOTENAME_PITCH sub_quotes {
1551 Pitch p =* unsmob_pitch ($1);
1552 p = p.transposed (Pitch (-$2,0,0));
1553 $$ = p.smobbed_copy ();
1565 | TONICNAME_PITCH sup_quotes {
1566 Pitch p = *unsmob_pitch ($1);
1567 p = p.transposed (Pitch ($2,0,0));
1568 $$ = p.smobbed_copy ();
1570 | TONICNAME_PITCH sub_quotes {
1571 Pitch p =* unsmob_pitch ($1);
1573 p = p.transposed (Pitch (-$2,0,0));
1574 $$ = p.smobbed_copy ();
1587 pitch_also_in_chords:
1593 PITCH embedded_scm {
1595 if (!unsmob_pitch ($2)) {
1596 THIS->parser_error (_f ("Expecting musical-pitch value", 3));
1597 $$ = Pitch ().smobbed_copy ();
1603 DURATION embedded_scm {
1605 if (!unsmob_duration ($2))
1607 THIS->parser_error (_ ("Must have duration object"));
1608 $$ = Duration ().smobbed_copy ();
1615 if (!THIS->lexer_->lyric_state_b ())
1616 THIS->parser_error (_ ("Have to be in Lyric mode for lyrics"));
1617 $$ = MY_MAKE_MUSIC("ExtenderEvent");
1623 if (!THIS->lexer_->lyric_state_b ())
1624 THIS->parser_error (_ ("Have to be in Lyric mode for lyrics"));
1625 $$ = MY_MAKE_MUSIC("HyphenEvent");
1630 close_event_parens {
1632 dynamic_cast<Music *> ($$)->set_mus_property ("span-direction", gh_int2scm (START))
1639 Music * s= MY_MAKE_MUSIC("SlurEvent");
1641 s->set_spot (THIS->here_input());
1644 Music * s= MY_MAKE_MUSIC("PhrasingSlurEvent");
1646 s->set_spot (THIS->here_input());
1649 Music *s =MY_MAKE_MUSIC("CrescendoEvent");
1651 s->set_spot (THIS->here_input());
1654 Music *s =MY_MAKE_MUSIC("DecrescendoEvent");
1656 s->set_spot (THIS->here_input());
1664 dynamic_cast<Music *> ($$)->set_mus_property ("span-direction", gh_int2scm (STOP))
1671 Music *s = MY_MAKE_MUSIC("CrescendoEvent");
1672 s->set_spot (THIS->here_input());
1677 Music * s= MY_MAKE_MUSIC("SlurEvent");
1679 s->set_spot (THIS->here_input());
1683 Music * s= MY_MAKE_MUSIC("PhrasingSlurEvent");
1685 s->set_mus_property ("span-type", scm_makfrom0str ( "phrasing-slur"));
1686 s->set_spot (THIS->here_input());
1692 Music *t = MY_MAKE_MUSIC("TextScriptEvent");
1693 t->set_mus_property ("text", $1);
1694 t->set_spot (THIS->here_input ());
1698 Music *t = MY_MAKE_MUSIC("TextScriptEvent");
1699 t->set_mus_property ("text", $1);
1700 t->set_spot (THIS->here_input ());
1704 Music *t = MY_MAKE_MUSIC("TextScriptEvent");
1705 t->set_mus_property ("text", make_simple_markup ($1));
1706 t->set_spot (THIS->here_input ());
1711 Music * t = MY_MAKE_MUSIC("FingerEvent");
1712 t->set_mus_property ("digit", gh_int2scm ($1));
1713 t->set_spot (THIS->here_input ());
1718 script_abbreviation:
1720 $$ = scm_makfrom0str ("Hat");
1723 $$ = scm_makfrom0str ("Plus");
1726 $$ = scm_makfrom0str ("Dash");
1729 $$ = scm_makfrom0str ("Bar");
1732 $$ = scm_makfrom0str ("Larger");
1735 $$ = scm_makfrom0str ("Dot");
1738 $$ = scm_makfrom0str ("Underscore");
1745 | '-' { $$ = CENTER; }
1752 | pre_events open_event {
1753 $$ = gh_cons ($2->self_scm(), $$);
1754 scm_gc_unprotect_object ($2->self_scm());
1765 multiplied_duration {
1768 | verbose_duration {
1773 optional_notemode_duration:
1775 Duration dd = THIS->default_duration_;
1776 $$ = dd.smobbed_copy ();
1778 THIS->beam_check ($$);
1780 | multiplied_duration {
1782 THIS->default_duration_ = *unsmob_duration ($$);
1784 THIS->beam_check ($$);
1786 | verbose_duration {
1788 THIS->default_duration_ = *unsmob_duration ($$);
1793 bare_unsigned dots {
1795 if (!is_duration_b ($1))
1796 THIS->parser_error (_f ("not a duration: %d", $1));
1800 $$ = Duration (l, $2).smobbed_copy ();
1802 | DURATION_IDENTIFIER dots {
1803 Duration *d =unsmob_duration ($1);
1804 Duration k (d->duration_log (),d->dot_count () + $2);
1814 multiplied_duration:
1818 | multiplied_duration '*' bare_unsigned {
1819 $$ = unsmob_duration ($$)->compressed ( $3) .smobbed_copy ();
1821 | multiplied_duration '*' FRACTION {
1822 Rational m (gh_scm2int (ly_car ($3)), gh_scm2int (ly_cdr ($3)));
1824 $$ = unsmob_duration ($$)->compressed (m).smobbed_copy ();
1829 FRACTION { $$ = $1; }
1830 | UNSIGNED '/' UNSIGNED {
1831 $$ = scm_cons (gh_int2scm ($1), gh_int2scm ($3));
1849 | ':' bare_unsigned {
1850 if (!is_duration_b ($2))
1851 THIS->parser_error (_f ("not a duration: %d", $2));
1858 /*****************************************************************
1860 *****************************************************************/
1874 Music *bfr = MY_MAKE_MUSIC("BassFigureEvent");
1875 $$ = bfr->self_scm();
1876 scm_gc_unprotect_object ($$);
1879 Music *bfr = MY_MAKE_MUSIC("BassFigureEvent");
1880 $$ = bfr->self_scm();
1882 bfr->set_mus_property ("figure", gh_int2scm ($1));
1884 scm_gc_unprotect_object ($$);
1886 | bass_figure bass_mod {
1887 Music *m = unsmob_music ($1);
1889 SCM salter =m->get_mus_property ("alteration");
1890 int alter = gh_number_p ( salter) ? gh_scm2int (salter) : 0;
1891 m->set_mus_property ("alteration",
1892 gh_int2scm (alter + $2));
1894 m->set_mus_property ("alteration", gh_int2scm (0));
1902 unsmob_music ($$)->set_mus_property ("bracket-start", SCM_BOOL_T);
1907 | br_bass_figure ']' {
1909 unsmob_music ($1)->set_mus_property ("bracket-stop", SCM_BOOL_T);
1917 | figure_list br_bass_figure {
1918 $$ = scm_cons ($2, $1);
1923 FIGURE_OPEN figure_list FIGURE_CLOSE {
1924 Music * m = MY_MAKE_MUSIC("EventChord");
1925 $2 = scm_reverse_x ($2, SCM_EOL);
1926 m->set_mus_property ("elements", $2);
1927 $$ = m->self_scm ();
1938 pitch exclamations questions optional_notemode_duration optional_rest {
1940 Input i = THIS->pop_spot ();
1941 if (!THIS->lexer_->note_state_b ())
1942 THIS->parser_error (_ ("Have to be in Note mode for notes"));
1946 n = MY_MAKE_MUSIC("RestEvent");
1948 n = MY_MAKE_MUSIC("NoteEvent");
1950 n->set_mus_property ("pitch", $1);
1951 n->set_mus_property ("duration", $4);
1955 n->set_mus_property ("cautionary", SCM_BOOL_T);
1956 if ($2 % 2 || $3 % 2)
1957 n->set_mus_property ("force-accidental", SCM_BOOL_T);
1959 Music *v = MY_MAKE_MUSIC("EventChord");
1960 v->set_mus_property ("elements", scm_list_n (n->self_scm (), SCM_UNDEFINED));
1961 scm_gc_unprotect_object (n->self_scm());
1967 | figure_spec optional_notemode_duration {
1968 Music * m = unsmob_music ($1);
1969 Input i = THIS->pop_spot ();
1971 for (SCM s = m->get_mus_property ("elements"); gh_pair_p (s); s = ly_cdr (s))
1973 unsmob_music (ly_car (s))->set_mus_property ("duration", $2);
1977 | RESTNAME optional_notemode_duration {
1979 Input i = THIS->pop_spot ();
1981 if (ly_scm2string ($1) =="s") {
1983 ev = MY_MAKE_MUSIC("SkipEvent");
1986 ev = MY_MAKE_MUSIC("RestEvent");
1989 ev->set_mus_property ("duration" ,$2);
1991 Music * velt = MY_MAKE_MUSIC("EventChord");
1992 velt->set_mus_property ("elements", scm_list_n (ev->self_scm (),SCM_UNDEFINED));
1997 | MULTI_MEASURE_REST optional_notemode_duration {
2002 proc = scm_c_eval_string ("make-multi-measure-rest");
2004 SCM mus = scm_call_2 (proc, $2,
2005 make_input (THIS->here_input()));
2006 scm_gc_protect_object (mus);
2007 $$ = unsmob_music (mus);
2009 | STRING optional_notemode_duration {
2010 Input i = THIS->pop_spot ();
2012 Music * lreq = MY_MAKE_MUSIC("LyricEvent");
2013 lreq->set_mus_property ("text", $1);
2014 lreq->set_mus_property ("duration",$2);
2016 Music * velt = MY_MAKE_MUSIC("EventChord");
2017 velt->set_mus_property ("elements", scm_list_n (lreq->self_scm (), SCM_UNDEFINED));
2024 if (!THIS->lexer_->chord_state_b ())
2025 THIS->parser_error (_ ("Have to be in Chord mode for chords"));
2026 $$ = unsmob_music ($1);
2031 steno_tonic_pitch optional_notemode_duration {
2032 $$ = make_chord ($1, $2, SCM_EOL);
2034 | steno_tonic_pitch optional_notemode_duration chord_separator chord_items {
2035 SCM its = scm_reverse_x ($4, SCM_EOL);
2036 $$ = make_chord ($1, $2, gh_cons ($3, its));
2044 | chord_items chord_item {
2045 $$ = gh_cons ($2, $$);
2051 $$ = ly_symbol2scm ("chord-colon");
2054 $$ = ly_symbol2scm ("chord-caret");
2056 | CHORD_SLASH steno_tonic_pitch {
2057 $$ = scm_list_n (ly_symbol2scm ("chord-slash"), $2, SCM_UNDEFINED);
2059 | CHORD_BASS steno_tonic_pitch {
2060 $$ = scm_list_n (ly_symbol2scm ("chord-bass"), $2, SCM_UNDEFINED);
2069 $$ = scm_reverse_x ($1, SCM_EOL);
2077 step_number { $$ = gh_cons ($1, SCM_EOL); }
2078 | step_numbers '.' step_number {
2079 $$ = gh_cons ($3, $$);
2085 $$ = make_chord_step ($1, 0);
2087 | bare_unsigned '+' {
2088 $$ = make_chord_step ($1, 1);
2090 | bare_unsigned CHORD_MINUS {
2091 $$ = make_chord_step ($1,-1);
2099 number_expression '+' number_term {
2100 $$ = scm_sum ($1, $3);
2102 | number_expression '-' number_term {
2103 $$ = scm_difference ($1, $3);
2112 | number_factor '*' number_factor {
2113 $$ = scm_product ($1, $3);
2115 | number_factor '/' number_factor {
2116 $$ = scm_divide ($1, $3);
2121 '-' number_factor { /* %prec UNARY_MINUS */
2122 $$ = scm_difference ($2, SCM_UNDEFINED);
2130 $$ = gh_int2scm ($1);
2135 | NUMBER_IDENTIFIER {
2138 | REAL NUMBER_IDENTIFIER {
2139 $$ = gh_double2scm (gh_scm2double ($1) * gh_scm2double ($2));
2141 | UNSIGNED NUMBER_IDENTIFIER {
2142 $$ = gh_double2scm ($1 * gh_scm2double ($2));
2158 if (scm_integer_p ($1) == SCM_BOOL_T)
2160 int k = gh_scm2int ($1);
2164 THIS->parser_error (_ ("need integer number arg"));
2178 | STRING_IDENTIFIER {
2181 | string '+' string {
2182 $$ = scm_string_append (scm_list_n ($1, $3, SCM_UNDEFINED));
2189 | exclamations '!' { $$ ++; }
2194 | questions '?' { $$ ++; }
2204 { THIS->lexer_->push_markup_state (); }
2207 THIS->lexer_->pop_state ();
2213 This should be done more dynamically if possible.
2217 $$ = make_simple_markup ($1);
2219 | MARKUP_HEAD_MARKUP0 markup {
2220 $$ = scm_list_n ($1, $2, SCM_UNDEFINED);
2222 | MARKUP_HEAD_MARKUP0_MARKUP1 markup markup {
2223 $$ = scm_list_n ($1, $2, $3, SCM_UNDEFINED);
2225 | MARKUP_HEAD_SCM0_MARKUP1 SCM_T markup {
2226 $$ = scm_list_n ($1, $2, $3, SCM_UNDEFINED);
2231 | MARKUP_HEAD_LIST0 markup_list {
2232 $$ = scm_list_n ($1,$2, SCM_UNDEFINED);
2234 | MARKUP_HEAD_SCM0 embedded_scm {
2235 $$ = scm_list_n ($1, $2, SCM_UNDEFINED);
2237 | MARKUP_HEAD_SCM0_SCM1_MARKUP2 embedded_scm embedded_scm markup {
2238 $$ = scm_list_n ($1, $2, $3, $4, SCM_UNDEFINED);
2240 | MARKUP_HEAD_SCM0_SCM1_SCM2 embedded_scm embedded_scm embedded_scm {
2241 $$ = scm_list_n ($1, $2, $3, $4, SCM_UNDEFINED);
2243 | MARKUP_IDENTIFIER {
2250 CHORD_OPEN markup_list_body CHORD_CLOSE { $$ = scm_reverse_x ($2, SCM_EOL); }
2254 '{' markup_list_body '}' {
2257 line = scm_c_eval_string ("line-markup");
2259 $$ = scm_list_n (line, scm_reverse_x ($2, SCM_EOL), SCM_UNDEFINED);
2264 /**/ { $$ = SCM_EOL; }
2265 | markup_list_body markup {
2266 $$ = gh_cons ($2, $1) ;
2274 My_lily_parser::set_yydebug (bool )
2281 extern My_lily_parser * current_parser;
2284 My_lily_parser::do_yyparse ()
2286 current_parser = this;;
2287 yyparse ((void*)this);
2292 Should make this optional? It will also complain when you do
2296 which is entirely legitimate.
2298 Or we can scrap it. Barchecks should detect wrong durations, and
2299 skipTypesetting speeds it up a lot.
2303 My_lily_parser::beam_check (SCM dur)
2305 Duration *d = unsmob_duration (dur);
2306 if (unsmob_music (last_beam_start_) && d->duration_log () <= 2)
2308 Music * m = unsmob_music (last_beam_start_);
2309 m->origin ()->warning (_("Suspect duration found following this beam"));
2311 last_beam_start_ = SCM_EOL;
2319 return gh_pair_p (x)
2320 && SCM_BOOL_F != scm_object_property (gh_car (x), ly_symbol2scm ("markup-signature"));
2323 It is a little strange, to have this function in this file, but
2324 otherwise, we have to import music classes into the lexer.
2328 My_lily_lexer::try_special_identifiers (SCM * destination, SCM sid)
2330 if (gh_string_p (sid)) {
2332 return STRING_IDENTIFIER;
2333 } else if (gh_number_p (sid)) {
2335 return NUMBER_IDENTIFIER;
2336 } else if (unsmob_translator_def (sid)) {
2337 *destination = unsmob_translator_def (sid)->clone_scm();
2338 return TRANSLATOR_IDENTIFIER;
2339 } else if (unsmob_score (sid)) {
2340 Score *sc = new Score (*unsmob_score (sid));
2341 *destination =sc->self_scm ();
2342 return SCORE_IDENTIFIER;
2343 } else if (Music * mus =unsmob_music (sid)) {
2344 *destination = unsmob_music (sid)->clone ()->self_scm();
2345 unsmob_music (*destination)->
2346 set_mus_property ("origin", make_input (last_input_));
2347 return dynamic_cast<Event*> (mus)
2348 ? EVENT_IDENTIFIER : MUSIC_IDENTIFIER;
2349 } else if (unsmob_duration (sid)) {
2350 *destination = unsmob_duration (sid)->smobbed_copy();
2351 return DURATION_IDENTIFIER;
2352 } else if (unsmob_music_output_def (sid)) {
2353 Music_output_def *p = unsmob_music_output_def (sid);
2356 *destination = p->self_scm();
2357 return MUSIC_OUTPUT_DEF_IDENTIFIER;
2358 } else if (new_markup_p (sid)) {
2360 return MARKUP_IDENTIFIER;