1 %{ // -*-Fundamental-*-
4 parser.yy -- Bison/C++ parser for lilypond
6 source file of the GNU LilyPond music typesetter
8 (c) 1997--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
9 Jan Nieuwenhuizen <janneke@gnu.org>
13 Two shift/reduce problems:
25 "bar" -> String -> Lyric -> Music
31 \repeat .. \alternative
34 \repeat { \repeat .. \alternative }
38 \repeat { \repeat } \alternative
50 * The rules for who is protecting what are very shady. Uniformise
53 * There are too many lexical modes.
60 #include "translator-def.hh"
61 #include "lily-guile.hh"
63 #include "my-lily-lexer.hh"
64 #include "paper-def.hh"
65 #include "midi-def.hh"
67 #include "file-path.hh"
69 #include "dimensions.hh"
70 #include "my-lily-parser.hh"
72 #include "input-file-results.hh"
74 #include "lilypond-input-version.hh"
75 #include "scm-hash.hh"
76 #include "auto-change-iterator.hh"
78 #include "ly-modules.hh"
79 #include "music-sequence.hh"
80 #include "input-smob.hh"
84 regular_identifier_b (SCM id)
86 String str = ly_scm2string (id);
87 char const *s = str.to_str0 () ;
92 v = v && isalpha (*s);
101 is_duration_b (int t)
103 return t && t == 1 << intlog2 (t);
107 set_music_properties (Music *p, SCM a)
109 for (SCM k = a; gh_pair_p (k); k = ly_cdr (k))
111 p->internal_set_mus_property (ly_caar (k), ly_cdar (k));
117 #define MY_MAKE_MUSIC(x) make_music_by_name (ly_symbol2scm (x))
120 set_property_music (SCM sym, SCM value)
122 Music * p = MY_MAKE_MUSIC("PropertySet");
123 p->set_mus_property ("symbol", sym);
124 p->set_mus_property ("value", value);
129 // needed for bison.simple's malloc () and free ()
131 // #include <malloc.h>
136 #define YYERROR_VERBOSE 1
138 My_lily_parser* my_lily_parser;
139 #define YYPARSE_PARAM my_lily_parser
140 #define YYLEX_PARAM my_lily_parser
142 ((My_lily_parser *) my_lily_parser)
144 #define yyerror THIS->parser_error
148 /* We use SCMs to do strings, because it saves us the trouble of
149 deleting them. Let's hope that a stack overflow doesnt trigger a move
150 of the parse stack onto the heap. */
157 Music_output_def * outputdef;
164 yylex (YYSTYPE *s, void * v)
166 My_lily_parser *pars = (My_lily_parser*) v;
167 My_lily_lexer * lex = pars->lexer_;
169 lex->lexval = (void*) s;
170 lex->prepare_for_next_token();
171 return lex->yylex ();
179 /* tokens which are not keywords */
188 %token CHORDMODIFIERS
194 %token GROBDESCRIPTIONS
199 %token FIGURES FIGURE_OPEN FIGURE_CLOSE
200 %token FIGURE_BRACKET_CLOSE FIGURE_BRACKET_OPEN
208 %token MULTI_MEASURE_REST
219 %token OVERRIDE SET REVERT
229 %token COMMANDSPANREQUEST
231 %token OUTPUTPROPERTY
246 %token E_CHAR E_EXCLAMATION E_SMALLER E_BIGGER E_OPEN E_CLOSE
247 %token E_LEFTSQUARE E_RIGHTSQUARE E_TILDE
249 %token <i> E_UNSIGNED
250 %token CHORD_BASS CHORD_COLON CHORD_MINUS CHORD_CARET CHORD_SLASH
253 %type <i> exclamations questions dots optional_rest
254 %type <i> bass_number bass_mod
255 %type <scm> br_bass_figure bass_figure figure_list figure_spec
257 %token <scm> NOTENAME_PITCH
258 %token <scm> TONICNAME_PITCH
259 %token <scm> CHORDMODIFIER_PITCH
260 %token <scm> DURATION_IDENTIFIER
261 %token <scm> FRACTION
262 %token <id> IDENTIFIER
265 %token <scm> SCORE_IDENTIFIER
266 %token <scm> MUSIC_OUTPUT_DEF_IDENTIFIER
267 %token <scm> NUMBER_IDENTIFIER
268 %token <scm> EVENT_IDENTIFIER
269 %token <scm> MUSIC_IDENTIFIER TRANSLATOR_IDENTIFIER
270 %token <scm> STRING_IDENTIFIER SCM_IDENTIFIER
271 %token <scm> RESTNAME
278 %token <scm> MARKUP_HEAD_MARKUP0 MARKUP_HEAD_SCM0_MARKUP1 MARKUP_HEAD_MARKUP0_MARKUP1
279 %token <scm> MARKUP_HEAD_SCM0 MARKUP_HEAD_SCM0_MARKUP1 MARKUP_HEAD_SCM0_SCM1_MARKUP2 MARKUP_HEAD_SCM0_SCM1
281 %token <scm> MARKUP_IDENTIFIER MARKUP_HEAD_LIST0
282 %type <scm> markup markup_line markup_list markup_list_body full_markup
284 %type <outputdef> output_def
285 %type <scm> lilypond_header lilypond_header_body
286 %type <music> open_event_parens close_event_parens open_event close_event
287 %type <music> event_with_dir event_that_take_dir verbose_event
288 %type <i> sub_quotes sup_quotes
289 %type <music> simple_element event_chord command_element Simple_music Composite_music
290 %type <music> Repeated_music
291 %type <scm> Alternative_music
292 %type <i> tremolo_type
293 %type <i> bare_int bare_unsigned
295 %type <scm> identifier_init
297 %type <music> note_chord_element chord_body chord_body_element
298 %type <scm> chord_body_elements
299 %type <scm> steno_duration optional_notemode_duration multiplied_duration
300 %type <scm> verbose_duration
302 %type <scm> pre_events post_events
303 %type <music> gen_text_def
304 %type <scm> steno_pitch pitch absolute_pitch pitch_also_in_chords
305 %type <scm> explicit_pitch steno_tonic_pitch
307 %type <scm> chord_additions chord_subtractions chord_notes chord_step
309 %type <scm> chord_note chord_inversion chord_bass
310 %type <scm> duration_length fraction
312 %type <scm> embedded_scm scalar
313 %type <music> Music Sequential_music Simultaneous_music
314 %type <music> relative_music re_rhythmed_music part_combined_music
315 %type <music> property_def translator_change simple_property_def
316 %type <scm> Music_list
317 %type <outputdef> music_output_def_body
318 %type <music> shorthand_command_req
319 %type <music> post_event
320 %type <music> command_req verbose_command_req
321 %type <music> extender_req
322 %type <music> hyphen_req
323 %type <music> string_event
324 %type <scm> string bare_number number_expression number_term number_factor
325 %type <score> score_block score_body
327 %type <scm> translator_spec_block translator_spec_body
328 %type <music> tempo_event
329 %type <scm> notenames_body notenames_block chordmodifiers_block
330 %type <scm> script_abbreviation
336 /* We don't assign precedence to / and *, because we might need varied
337 prec levels in different prods */
343 lilypond: /* empty */
344 | lilypond toplevel_expression {}
345 | lilypond assignment { }
347 THIS->error_level_ = 1;
350 THIS->error_level_ = 1;
356 THIS->lexer_->pitchname_tab_ = $1;
358 | chordmodifiers_block {
359 THIS->lexer_->chordmodifier_tab_ = $1;
362 THIS->input_file_->header_ = $1;
365 THIS->input_file_->scores_.push ($1);
368 if (dynamic_cast<Paper_def*> ($1))
369 THIS->lexer_->set_identifier (scm_makfrom0str ("$defaultpaper"), $1->self_scm ());
370 else if (dynamic_cast<Midi_def*> ($1))
371 THIS->lexer_->set_identifier (scm_makfrom0str ("$defaultmidi"), $1->self_scm ());
381 chordmodifiers_block:
382 CHORDMODIFIERS notenames_body { $$ = $2; }
386 PITCHNAMES notenames_body { $$ = $2; }
391 int i = scm_ilength ($1);
393 SCM tab = scm_make_vector (gh_int2scm (i), SCM_EOL);
394 for (SCM s = $1; gh_pair_p (s); s = ly_cdr (s)) {
395 SCM pt = ly_cdar (s);
396 if (!unsmob_pitch (pt))
397 THIS->parser_error ("Need pitch object.");
399 scm_hashq_set_x (tab, ly_caar (s), pt);
406 lilypond_header_body:
408 $$ = ly_make_anonymous_module ();
409 THIS->lexer_->add_scope ($$);
411 | lilypond_header_body assignment {
417 HEADER '{' lilypond_header_body '}' {
418 $$ = THIS->lexer_-> remove_scope();
430 /* cont */ '=' identifier_init {
433 Should find generic way of associating input with objects.
435 Input ip = THIS->pop_spot ();
437 if (! regular_identifier_b ($1))
439 ip.warning (_ ("Identifier should have alphabetic characters only"));
442 THIS->lexer_->set_identifier ($1, $4);
445 TODO: devise standard for protection in parser.
447 The parser stack lives on the C-stack, which means that
448 all objects can be unprotected as soon as they're here.
459 $$ = $1->self_scm ();
460 scm_gc_unprotect_object ($$);
466 $$ = $1->self_scm ();
467 scm_gc_unprotect_object ($$);
469 | translator_spec_block {
473 $$ = $1->self_scm ();
474 scm_gc_unprotect_object ($$);
477 $$ = $1->self_scm ();
478 scm_gc_unprotect_object ($$);
483 | number_expression {
494 translator_spec_block:
495 TRANSLATOR '{' translator_spec_body '}'
501 translator_spec_body:
502 TRANSLATOR_IDENTIFIER {
504 unsmob_translator_def ($$)-> set_spot (THIS->here_input ());
507 $$ = Translator_def::make_scm ();
508 Translator_def*td = unsmob_translator_def ($$);
509 td->translator_group_type_ = $2;
510 td->set_spot (THIS->here_input ());
512 | translator_spec_body STRING '=' embedded_scm {
513 unsmob_translator_def ($$)->add_property_assign ($2, $4);
515 | translator_spec_body STRING OVERRIDE embedded_scm '=' embedded_scm {
516 unsmob_translator_def ($$)
517 ->add_push_property (scm_string_to_symbol ($2), $4, $6);
519 | translator_spec_body STRING SET embedded_scm '=' embedded_scm {
520 unsmob_translator_def ($$)
521 ->add_push_property (scm_string_to_symbol ($2), $4, $6);
523 | translator_spec_body STRING REVERT embedded_scm {
524 unsmob_translator_def ($$)->add_pop_property (
525 scm_string_to_symbol ($2), $4);
527 | translator_spec_body NAME STRING {
528 unsmob_translator_def ($$)->type_name_ = $3;
530 | translator_spec_body CONSISTS STRING {
531 unsmob_translator_def ($$)->add_element ($3);
533 | translator_spec_body ALIAS STRING {
534 Translator_def*td = unsmob_translator_def ($$);
535 td->type_aliases_ = scm_cons ($3, td->type_aliases_);
537 | translator_spec_body GROBDESCRIPTIONS embedded_scm {
538 Translator_def*td = unsmob_translator_def($$);
539 // td->add_property_assign (ly_symbol2scm ("allGrobDescriptions"), $3);
540 for (SCM p = $3; gh_pair_p (p); p = ly_cdr (p))
541 td->add_property_assign (scm_symbol_to_string (ly_caar (p)), ly_cdar (p));
543 | translator_spec_body CONSISTSEND STRING {
544 unsmob_translator_def ($$)->add_last_element ( $3);
546 | translator_spec_body ACCEPTS STRING {
547 unsmob_translator_def ($$)->set_acceptor ($3,true);
549 | translator_spec_body DENIES STRING {
550 unsmob_translator_def ($$)->set_acceptor ($3,false);
552 | translator_spec_body REMOVE STRING {
553 unsmob_translator_def ($$)->remove_element ($3);
564 /*cont*/ '{' score_body '}' {
567 if (!$$->defs_.size ())
569 Music_output_def *id =
570 unsmob_music_output_def (THIS->lexer_->lookup_identifier ("$defaultpaper"));
571 $$->add_output (id ? id->clone () : new Paper_def );
580 $$->set_spot (THIS->here_input ());
581 SCM m = $1->self_scm ();
582 scm_gc_unprotect_object (m);
587 SCM check_funcs = scm_c_eval_string ("toplevel-music-functions");
588 for (; gh_pair_p (check_funcs); check_funcs = gh_cdr (check_funcs))
589 m = gh_call1 (gh_car (check_funcs), m);
594 $$ = unsmob_score ($1);
595 $$->set_spot (THIS->here_input ());
597 | score_body lilypond_header {
600 | score_body output_def {
613 music_output_def_body '}' {
615 THIS-> lexer_-> remove_scope ();
619 music_output_def_body:
621 Music_output_def *id = unsmob_music_output_def (THIS->lexer_->lookup_identifier ("$defaultmidi"));
626 p = dynamic_cast<Midi_def*> (id->clone ());
631 THIS->lexer_->add_scope (p->scope_);
634 Music_output_def *id = unsmob_music_output_def (THIS->lexer_->lookup_identifier ("$defaultpaper"));
637 p = dynamic_cast<Paper_def*> (id->clone ());
641 THIS->lexer_->add_scope (p->scope_);
644 | PAPER '{' MUSIC_OUTPUT_DEF_IDENTIFIER {
645 Music_output_def * o = unsmob_music_output_def ($3);
648 THIS->lexer_->add_scope (o->scope_);
650 | MIDI '{' MUSIC_OUTPUT_DEF_IDENTIFIER {
651 Music_output_def * o = unsmob_music_output_def ($3);
654 THIS->lexer_->add_scope (o->scope_);
656 | music_output_def_body assignment {
659 | music_output_def_body translator_spec_block {
660 $$->assign_translator ($2);
662 | music_output_def_body tempo_event {
664 junk this ? there already is tempo stuff in
667 int m = gh_scm2int ( $2->get_mus_property ("metronome-count"));
668 Duration *d = unsmob_duration ($2->get_mus_property ("tempo-unit"));
669 Midi_def * md = dynamic_cast<Midi_def*> ($$);
671 md->set_tempo (d->get_length (), m);
673 | music_output_def_body error {
679 TEMPO steno_duration '=' bare_unsigned {
680 $$ = MY_MAKE_MUSIC("TempoEvent");
681 $$->set_mus_property ("tempo-unit", $2);
682 $$->set_mus_property ("metronome-count", gh_int2scm ( $4));
687 The representation of a list is the
691 to have efficient append.
695 $$ = scm_cons (SCM_EOL, SCM_EOL);
699 SCM c = scm_cons ($2->self_scm (), SCM_EOL);
700 scm_gc_unprotect_object ($2->self_scm ()); /* UGH */
701 if (gh_pair_p (ly_cdr (s)))
702 gh_set_cdr_x (ly_cdr (s), c); /* append */
704 gh_set_car_x (s, c); /* set first cons */
705 gh_set_cdr_x (s, c) ; /* remember last cell */
721 | ALTERNATIVE '{' Music_list '}' {
727 REPEAT string bare_unsigned Music Alternative_music
731 SCM alts = gh_pair_p ($5) ? gh_car ($5) : SCM_EOL;
732 if (times < scm_ilength (alts)) {
733 unsmob_music (gh_car (alts))
734 ->origin ()->warning (
735 _("More alternatives than repeats. Junking excess alternatives."));
736 alts = ly_truncate_list (times, alts);
742 proc = scm_c_eval_string ("make-repeated-music");
744 SCM mus = scm_call_1 (proc, $2);
745 scm_gc_protect_object (mus); // UGH.
746 Music *r =unsmob_music (mus);
749 r-> set_mus_property ("element", beg->self_scm ());
750 scm_gc_unprotect_object (beg->self_scm ());
752 r->set_mus_property ("repeat-count", gh_int2scm (times >? 1));
754 r-> set_mus_property ("elements",alts);
755 if (gh_equal_p ($2, scm_makfrom0str ("tremolo")))
758 we can not get durations and other stuff correct down the line, so we have to
759 add to the duration log here.
761 SCM func = scm_primitive_eval (ly_symbol2scm ("shift-duration-log"));
763 gh_call3 (func, r->self_scm (), gh_int2scm(-intlog2 ($3*2/3)),gh_int2scm(1));
765 gh_call3 (func, r->self_scm (), gh_int2scm(-intlog2 ($3)), gh_int2scm(0));
767 r->set_spot (*$4->origin ());
774 SEQUENTIAL '{' Music_list '}' {
775 $$ = MY_MAKE_MUSIC("SequentialMusic");
776 $$->set_mus_property ("elements", ly_car ($3));
777 $$->set_spot(THIS->here_input());
779 | '{' Music_list '}' {
780 $$ = MY_MAKE_MUSIC("SequentialMusic");
781 $$->set_mus_property ("elements", ly_car ($2));
782 $$->set_spot(THIS->here_input());
787 SIMULTANEOUS '{' Music_list '}'{
788 $$ = MY_MAKE_MUSIC("SimultaneousMusic");
789 $$->set_mus_property ("elements", ly_car ($3));
790 $$->set_spot(THIS->here_input());
793 | '<' Music_list '>' {
794 $$ = MY_MAKE_MUSIC("SimultaneousMusic");
795 $$->set_mus_property ("elements", ly_car ($2));
796 $$->set_spot(THIS->here_input());
801 event_chord { $$ = $1; }
802 | APPLYCONTEXT embedded_scm {
803 if (!gh_procedure_p ($2))
804 THIS->parser_error (_ ("\applycontext takes function argument"));
805 $$ = MY_MAKE_MUSIC ("ApplyContext");
806 $$->set_mus_property ("procedure", $2);
807 $$->set_spot (THIS->here_input());
809 | OUTPUTPROPERTY embedded_scm embedded_scm '=' embedded_scm {
811 if (!gh_symbol_p ($3))
813 THIS->parser_error (_ ("Second argument must be a symbol"));
815 /* Should check # args */
816 if (!gh_procedure_p (pred))
818 THIS->parser_error (_ ("First argument must be a procedure taking one argument"));
821 Music*m = MY_MAKE_MUSIC("OutputPropertySetMusic");
822 m->set_mus_property ("predicate", pred);
823 m->set_mus_property ("grob-property", $3);
824 m->set_mus_property ("grob-value", $5);
829 $$ = unsmob_music ($1);
837 CONTEXT STRING Music {
838 Music*csm =MY_MAKE_MUSIC("ContextSpeccedMusic");
840 csm->set_mus_property ("element", $3->self_scm ());
841 scm_gc_unprotect_object ($3->self_scm ());
843 csm->set_mus_property ("context-type",$2);
844 csm->set_mus_property ("context-id", scm_makfrom0str (""));
848 | AUTOCHANGE STRING Music {
849 Music*chm = MY_MAKE_MUSIC("AutoChangeMusic");
850 chm->set_mus_property ("element", $3->self_scm ());
851 chm->set_mus_property ("iterator-ctor", Auto_change_iterator::constructor_proc);
853 scm_gc_unprotect_object ($3->self_scm ());
854 chm->set_mus_property ("what", $2);
857 chm->set_spot (*$3->origin ());
862 The other version is for easier debugging of
863 Sequential_music_iterator in combination with grace notes.
866 SCM start = THIS->lexer_->lookup_identifier ("startGraceMusic");
867 SCM stop = THIS->lexer_->lookup_identifier ("stopGraceMusic");
868 Music *startm = unsmob_music (start);
869 Music *stopm = unsmob_music (stop);
873 stopm = stopm->clone ();
874 ms = scm_cons (stopm->self_scm (), ms);
875 scm_gc_unprotect_object (stopm->self_scm ());
877 ms = scm_cons ($2->self_scm (), ms);
878 scm_gc_unprotect_object ($2->self_scm());
880 startm = startm->clone ();
881 ms = scm_cons (startm->self_scm () , ms);
882 scm_gc_unprotect_object (startm->self_scm ());
886 Music* seq = MY_MAKE_MUSIC("SequentialMusic");
887 seq->set_mus_property ("elements", ms);
890 $$ = MY_MAKE_MUSIC("GraceMusic");
891 $$->set_mus_property ("element", seq->self_scm ());
892 scm_gc_unprotect_object (seq->self_scm ());
894 $$ = MY_MAKE_MUSIC("GraceMusic");
895 $$->set_mus_property ("element", $2->self_scm ());
896 scm_gc_unprotect_object ($2->self_scm ());
899 | CONTEXT string '=' string Music {
900 Music * csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
902 csm->set_mus_property ("element", $5->self_scm ());
903 scm_gc_unprotect_object ($5->self_scm ());
905 csm->set_mus_property ("context-type", $2);
906 csm->set_mus_property ("context-id", $4);
917 int n = gh_scm2int (ly_car ($3)); int d = gh_scm2int (ly_cdr ($3));
919 $$= MY_MAKE_MUSIC("TimeScaledMusic");
920 $$->set_spot (THIS->pop_spot ());
923 $$->set_mus_property ("element", mp->self_scm ());
924 scm_gc_unprotect_object (mp->self_scm ());
925 $$->set_mus_property ("numerator", gh_int2scm (n));
926 $$->set_mus_property ("denominator", gh_int2scm (d));
927 $$->compress (Moment (Rational (n,d)));
930 | Repeated_music { $$ = $1; }
931 | Simultaneous_music { $$ = $1; }
932 | Sequential_music { $$ = $1; }
933 | TRANSPOSE pitch_also_in_chords pitch_also_in_chords Music {
934 $$ = MY_MAKE_MUSIC("TransposedMusic");
936 Pitch from = *unsmob_pitch ($2);
937 Pitch to = *unsmob_pitch ($3);
939 p->transpose (interval (from, to));
940 $$->set_mus_property ("element", p->self_scm ());
941 scm_gc_unprotect_object (p->self_scm ());
943 | APPLY embedded_scm Music {
944 SCM ret = gh_call1 ($2, $3->self_scm ());
945 Music *m = unsmob_music (ret);
947 THIS->parser_error ("\\apply must return a Music");
948 m = MY_MAKE_MUSIC("Music");
953 { THIS->lexer_->push_note_state (); }
956 THIS->lexer_->pop_state ();
959 { THIS->lexer_->push_figuredbass_state (); }
962 Music * chm = MY_MAKE_MUSIC("UntransposableMusic");
963 chm->set_mus_property ("element", $3->self_scm ());
965 scm_gc_unprotect_object ($3->self_scm());
967 THIS->lexer_->pop_state ();
970 { THIS->lexer_->push_chord_state (); }
973 Music * chm = MY_MAKE_MUSIC("UnrelativableMusic");
974 chm->set_mus_property ("element", $3->self_scm ());
975 scm_gc_unprotect_object ($3->self_scm());
978 THIS->lexer_->pop_state ();
981 { THIS->lexer_->push_lyric_state (); }
985 THIS->lexer_->pop_state ();
987 | relative_music { $$ = $1; }
988 | re_rhythmed_music { $$ = $1; }
989 | part_combined_music { $$ = $1; }
993 RELATIVE absolute_pitch Music {
995 Pitch pit = *unsmob_pitch ($2);
996 $$ = MY_MAKE_MUSIC("RelativeOctaveMusic");
998 $$->set_mus_property ("element", p->self_scm ());
999 scm_gc_unprotect_object (p->self_scm ());
1001 $$->set_mus_property ("last-pitch", p->to_relative_octave (pit).smobbed_copy ());
1007 ADDLYRICS Music Music {
1008 Music*l =MY_MAKE_MUSIC("LyricCombineMusic");
1009 l->set_mus_property ("elements", gh_list ($2->self_scm (), $3->self_scm (), SCM_UNDEFINED));
1010 scm_gc_unprotect_object ($3->self_scm ());
1011 scm_gc_unprotect_object ($2->self_scm ());
1016 part_combined_music:
1017 PARTCOMBINE STRING Music Music {
1018 Music * p= MY_MAKE_MUSIC("PartCombineMusic");
1019 p->set_mus_property ("what", $2);
1020 p->set_mus_property ("elements", gh_list ($3->self_scm (),$4->self_scm (), SCM_UNDEFINED));
1022 scm_gc_unprotect_object ($3->self_scm ());
1023 scm_gc_unprotect_object ($4->self_scm ());
1030 TRANSLATOR STRING '=' STRING {
1031 Music*t= MY_MAKE_MUSIC("TranslatorChange");
1032 t-> set_mus_property ("change-to-type", $2);
1033 t-> set_mus_property ("change-to-id", $4);
1036 $$->set_spot (THIS->here_input ());
1042 | ONCE simple_property_def {
1044 SCM e = $2->get_mus_property ("element");
1045 unsmob_music (e)->set_mus_property ("once", SCM_BOOL_T);
1049 simple_property_def:
1050 PROPERTY STRING '.' STRING '=' scalar {
1051 Music *t = set_property_music (scm_string_to_symbol ($4), $6);
1052 Music *csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
1054 csm->set_mus_property ("element", t->self_scm ());
1055 scm_gc_unprotect_object (t->self_scm ());
1058 $$->set_spot (THIS->here_input ());
1060 csm-> set_mus_property ("context-type", $2);
1062 | PROPERTY STRING '.' STRING UNSET {
1064 Music *t = MY_MAKE_MUSIC("PropertyUnset");
1065 t->set_mus_property ("symbol", scm_string_to_symbol ($4));
1067 Music *csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
1068 csm->set_mus_property ("element", t->self_scm ());
1069 scm_gc_unprotect_object (t->self_scm ());
1072 $$->set_spot (THIS->here_input ());
1074 csm-> set_mus_property ("context-type", $2);
1076 | PROPERTY STRING '.' STRING SET embedded_scm '=' embedded_scm {
1078 = gh_equal_p ($4, scm_makfrom0str ("autoBeamSettings"));
1079 bool itc = internal_type_checking_global_b;
1080 Music *t = MY_MAKE_MUSIC("OverrideProperty");
1081 t->set_mus_property ("symbol", scm_string_to_symbol ($4));
1082 t->set_mus_property ("pop-first", SCM_BOOL_T);
1084 internal_type_checking_global_b = false;
1085 t->set_mus_property ("grob-property", $6);
1087 internal_type_checking_global_b = itc;
1088 t->set_mus_property ("grob-value", $8);
1090 Music *csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
1091 csm->set_mus_property ("element", t->self_scm ());
1092 scm_gc_unprotect_object (t->self_scm ());
1094 $$->set_spot (THIS->here_input ());
1096 csm-> set_mus_property ("context-type", $2);
1098 | PROPERTY STRING '.' STRING OVERRIDE
1099 embedded_scm '=' embedded_scm
1105 = gh_equal_p ($4, scm_makfrom0str ("autoBeamSettings"));
1106 bool itc = internal_type_checking_global_b;
1108 Music *t = MY_MAKE_MUSIC("OverrideProperty");
1109 t->set_mus_property ("symbol", scm_string_to_symbol ($4));
1111 internal_type_checking_global_b = false;
1112 t->set_mus_property ("grob-property", $6);
1113 t->set_mus_property ("grob-value", $8);
1115 internal_type_checking_global_b = itc;
1117 Music *csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
1118 csm->set_mus_property ("element", t->self_scm ());
1119 scm_gc_unprotect_object (t->self_scm ());
1122 $$->set_spot (THIS->here_input ());
1124 csm-> set_mus_property ("context-type", $2);
1127 | PROPERTY STRING '.' STRING REVERT embedded_scm {
1128 Music *t = MY_MAKE_MUSIC("RevertProperty");
1130 = gh_equal_p ($4, scm_makfrom0str ("autoBeamSettings"));
1131 bool itc = internal_type_checking_global_b;
1133 t->set_mus_property ("symbol", scm_string_to_symbol ($4));
1135 internal_type_checking_global_b = false;
1136 t->set_mus_property ("grob-property", $6);
1138 internal_type_checking_global_b = itc;
1140 Music *csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
1141 csm->set_mus_property ("element", t->self_scm ());
1142 scm_gc_unprotect_object (t->self_scm ());
1145 $$->set_spot (THIS->here_input ());
1147 csm-> set_mus_property ("context-type", $2);
1154 | bare_int { $$ = gh_int2scm ($1); }
1155 | embedded_scm { $$ = $1; }
1162 } /*cont */ simple_element post_events {
1163 SCM elts = $3-> get_mus_property ("elements");
1165 elts = gh_append3 (elts, scm_reverse_x ($1, SCM_EOL),
1166 scm_reverse_x ($4, SCM_EOL));
1168 $3-> set_mus_property ("elements", elts);
1172 | note_chord_element
1177 chord_body optional_notemode_duration post_events
1179 SCM dur = unsmob_duration ($2)->smobbed_copy();
1180 SCM es = $1->get_mus_property ("elements");
1181 SCM postevs = scm_reverse_x ($3, SCM_EOL);
1183 for (SCM s = es; gh_pair_p (s); s = gh_cdr (s))
1184 unsmob_music (gh_car(s))->set_mus_property ("duration", dur);
1185 es = gh_append2 (es, postevs);
1187 $1-> set_mus_property ("elements", es);
1193 CHORD_OPEN chord_body_elements CHORD_CLOSE
1195 $$ = MY_MAKE_MUSIC("EventChord");
1196 $$->set_mus_property ("elements",
1197 scm_reverse_x ($2, SCM_EOL));
1201 chord_body_elements:
1202 /* empty */ { $$ = SCM_EOL; }
1203 | chord_body_elements chord_body_element {
1204 $$ = gh_cons ($2->self_scm(), $1);
1205 scm_gc_unprotect_object ($2->self_scm());
1210 pitch exclamations questions post_events
1212 Music * n = MY_MAKE_MUSIC("NoteEvent");
1213 n->set_mus_property ("pitch", $1);
1215 n->set_mus_property ("cautionary", SCM_BOOL_T);
1216 if ($2 % 2 || $3 % 2)
1217 n->set_mus_property ("force-accidental", SCM_BOOL_T);
1219 SCM arts = scm_reverse_x ($4, SCM_EOL);
1220 n->set_mus_property ("articulations", arts);
1228 $$ = MY_MAKE_MUSIC("EventChord");
1229 $$->set_mus_property ("elements", scm_cons ($1->self_scm (), SCM_EOL));
1230 scm_gc_unprotect_object ($1->self_scm());
1232 $$-> set_spot (THIS->here_input ());
1233 $1-> set_spot (THIS->here_input ());
1236 Music *l = MY_MAKE_MUSIC("LigatureEvent");
1237 l->set_mus_property ("span-direction", gh_int2scm (START));
1238 l->set_spot (THIS->here_input ());
1240 $$ = MY_MAKE_MUSIC("EventChord");
1241 $$->set_mus_property ("elements", scm_cons (l->self_scm (), SCM_EOL));
1242 scm_gc_unprotect_object (l->self_scm());
1243 $$->set_spot (THIS->here_input ());
1246 Music *l = MY_MAKE_MUSIC("LigatureEvent");
1247 l->set_mus_property ("span-direction", gh_int2scm (STOP));
1248 l->set_spot (THIS->here_input ());
1250 $$ = MY_MAKE_MUSIC("EventChord");
1251 $$->set_mus_property ("elements", scm_cons (l->self_scm (), SCM_EOL));
1252 $$->set_spot (THIS->here_input ());
1253 scm_gc_unprotect_object (l->self_scm());
1256 $$ = MY_MAKE_MUSIC("VoiceSeparator");
1257 $$->set_spot (THIS->here_input ());
1261 $$ = MY_MAKE_MUSIC("BarCheck");
1262 $$->set_spot (THIS->here_input ());
1265 Music *t = set_property_music (ly_symbol2scm ("whichBar"), $2);
1267 Music *csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
1268 csm->set_mus_property ("element", t->self_scm ());
1269 scm_gc_unprotect_object (t->self_scm ());
1272 $$->set_spot (THIS->here_input ());
1274 csm->set_mus_property ("context-type", scm_makfrom0str ("Timing"));
1276 | PARTIAL duration_length {
1277 Moment m = - unsmob_duration ($2)->get_length ();
1278 Music * p = set_property_music (ly_symbol2scm ( "measurePosition"),m.smobbed_copy ());
1280 Music * sp = MY_MAKE_MUSIC("ContextSpeccedMusic");
1281 sp->set_mus_property ("element", p->self_scm ());
1282 scm_gc_unprotect_object (p->self_scm ());
1285 sp-> set_mus_property ("context-type", scm_makfrom0str ("Timing"));
1290 proc = scm_c_eval_string ("make-clef-set");
1292 SCM result = scm_call_1 (proc, $2);
1293 scm_gc_protect_object (result);
1294 $$ = unsmob_music (result);
1299 proc = scm_c_eval_string ("make-time-signature-set");
1301 SCM result = scm_apply_2 (proc, gh_car ($2), gh_cdr ($2), SCM_EOL);
1302 scm_gc_protect_object (result);
1303 $$ = unsmob_music (result);
1308 shorthand_command_req { $$ = $1; }
1309 | verbose_command_req { $$ = $1; }
1312 shorthand_command_req:
1320 $$ = MY_MAKE_MUSIC("TieEvent");
1323 Music *b= MY_MAKE_MUSIC("BeamEvent");
1324 b->set_mus_property ("span-direction", gh_int2scm (START));
1327 THIS->last_beam_start_ = b->self_scm ();
1330 Music *b= MY_MAKE_MUSIC("BeamEvent");
1331 b->set_mus_property ("span-direction", gh_int2scm (STOP));
1335 $$ = MY_MAKE_MUSIC("BreathingSignEvent");
1338 $$ = MY_MAKE_MUSIC("PorrectusEvent");
1342 verbose_command_req:
1344 Music * m = MY_MAKE_MUSIC("MarkEvent");
1348 Music *m = MY_MAKE_MUSIC("MarkEvent");
1349 m->set_mus_property ("label", $2);
1352 | SKIP duration_length {
1353 Music * skip = MY_MAKE_MUSIC("SkipEvent");
1354 skip->set_mus_property ("duration", $2);
1362 Music *key= MY_MAKE_MUSIC("KeyChangeEvent");
1365 | KEY NOTENAME_PITCH SCM_IDENTIFIER {
1366 Music *key= MY_MAKE_MUSIC("KeyChangeEvent");
1368 key->set_mus_property ("pitch-alist", $3);
1369 ((Music*)key)->transpose (* unsmob_pitch ($2));
1378 | post_events post_event {
1379 $2->set_spot (THIS->here_input ());
1380 $$ = gh_cons ($2->self_scm(), $$);
1381 scm_gc_unprotect_object ($2->self_scm());
1394 Music * s = MY_MAKE_MUSIC("StringNumberEvent");
1395 s->set_mus_property ("string-number", gh_int2scm($1));
1396 s->set_spot (THIS->here_input ());
1402 event_that_take_dir:
1408 Music * m = MY_MAKE_MUSIC ("NewBeamEvent");
1409 m->set_spot (THIS->here_input());
1410 m->set_mus_property ("span-direction" , gh_int2scm (START));
1414 Music * m = MY_MAKE_MUSIC ("NewBeamEvent");
1415 m->set_spot (THIS->here_input());
1416 m->set_mus_property ("span-direction" , gh_int2scm (STOP));
1420 Music * m = MY_MAKE_MUSIC ("NewTieEvent");
1421 m->set_spot (THIS->here_input());
1424 | script_abbreviation {
1425 SCM s = THIS->lexer_->lookup_identifier ("dash" + ly_scm2string ($1));
1426 Music *a = MY_MAKE_MUSIC("ArticulationEvent");
1427 if (gh_string_p (s))
1428 a->set_mus_property ("articulation-type", s);
1429 else THIS->parser_error (_ ("Expecting string as script definition"));
1435 script_dir event_that_take_dir {
1436 $2->set_mus_property ("direction", gh_int2scm ($1));
1443 $$ = unsmob_music ($1);
1446 Music * a = MY_MAKE_MUSIC("TremoloEvent");
1447 a->set_spot (THIS->here_input ());
1448 a->set_mus_property ("tremolo-type", gh_int2scm ($1));
1475 | NOTENAME_PITCH sup_quotes {
1476 Pitch p = *unsmob_pitch ($1);
1478 $$ = p.smobbed_copy ();
1480 | NOTENAME_PITCH sub_quotes {
1481 Pitch p =* unsmob_pitch ($1);
1484 $$ = p.smobbed_copy ();
1497 | TONICNAME_PITCH sup_quotes {
1498 Pitch p = *unsmob_pitch ($1);
1500 $$ = p.smobbed_copy ();
1502 | TONICNAME_PITCH sub_quotes {
1503 Pitch p =* unsmob_pitch ($1);
1506 $$ = p.smobbed_copy ();
1520 pitch_also_in_chords:
1526 PITCH embedded_scm {
1528 if (!unsmob_pitch ($2)) {
1529 THIS->parser_error (_f ("Expecting musical-pitch value", 3));
1530 $$ = Pitch ().smobbed_copy ();
1536 DURATION embedded_scm {
1538 if (!unsmob_duration ($2))
1540 THIS->parser_error (_ ("Must have duration object"));
1541 $$ = Duration ().smobbed_copy ();
1548 if (!THIS->lexer_->lyric_state_b ())
1549 THIS->parser_error (_ ("Have to be in Lyric mode for lyrics"));
1550 $$ = MY_MAKE_MUSIC("ExtenderEvent");
1556 if (!THIS->lexer_->lyric_state_b ())
1557 THIS->parser_error (_ ("Have to be in Lyric mode for lyrics"));
1558 $$ = MY_MAKE_MUSIC("HyphenEvent");
1563 close_event_parens {
1565 dynamic_cast<Music *> ($$)->set_mus_property ("span-direction", gh_int2scm (START))
1572 Music * s= MY_MAKE_MUSIC("SlurEvent");
1574 s->set_spot (THIS->here_input());
1577 Music * s= MY_MAKE_MUSIC("PhrasingSlurEvent");
1579 s->set_spot (THIS->here_input());
1582 Music *s =MY_MAKE_MUSIC("CrescendoEvent");
1584 s->set_spot (THIS->here_input());
1587 Music *s =MY_MAKE_MUSIC("DecrescendoEvent");
1589 s->set_spot (THIS->here_input());
1597 dynamic_cast<Music *> ($$)->set_mus_property ("span-direction", gh_int2scm (STOP))
1604 Music *s = MY_MAKE_MUSIC("CrescendoEvent");
1605 s->set_spot (THIS->here_input());
1610 Music * s= MY_MAKE_MUSIC("SlurEvent");
1612 s->set_spot (THIS->here_input());
1616 Music * s= MY_MAKE_MUSIC("PhrasingSlurEvent");
1618 s->set_mus_property ("span-type", scm_makfrom0str ( "phrasing-slur"));
1619 s->set_spot (THIS->here_input());
1625 Music *t = MY_MAKE_MUSIC("TextScriptEvent");
1626 t->set_mus_property ("text", $1);
1627 t->set_spot (THIS->here_input ());
1631 Music *t = MY_MAKE_MUSIC("TextScriptEvent");
1632 t->set_mus_property ("text", $1);
1633 t->set_spot (THIS->here_input ());
1637 Music *t = MY_MAKE_MUSIC("TextScriptEvent");
1638 t->set_mus_property ("text", $1);
1639 t->set_spot (THIS->here_input ());
1643 Music * t = MY_MAKE_MUSIC("FingerEvent");
1644 t->set_mus_property ("digit", gh_int2scm ($1));
1645 t->set_spot (THIS->here_input ());
1650 script_abbreviation:
1652 $$ = scm_makfrom0str ("Hat");
1655 $$ = scm_makfrom0str ("Plus");
1658 $$ = scm_makfrom0str ("Dash");
1661 $$ = scm_makfrom0str ("Bar");
1664 $$ = scm_makfrom0str ("Larger");
1667 $$ = scm_makfrom0str ("Dot");
1670 $$ = scm_makfrom0str ("Underscore");
1677 | '-' { $$ = CENTER; }
1684 | pre_events open_event {
1685 $$ = gh_cons ($2->self_scm(), $$);
1686 scm_gc_unprotect_object ($2->self_scm());
1697 multiplied_duration {
1700 | verbose_duration {
1705 optional_notemode_duration:
1707 Duration dd = THIS->default_duration_;
1708 $$ = dd.smobbed_copy ();
1710 THIS->beam_check ($$);
1712 | multiplied_duration {
1714 THIS->default_duration_ = *unsmob_duration ($$);
1716 THIS->beam_check ($$);
1718 | verbose_duration {
1720 THIS->default_duration_ = *unsmob_duration ($$);
1725 bare_unsigned dots {
1727 if (!is_duration_b ($1))
1728 THIS->parser_error (_f ("not a duration: %d", $1));
1732 $$ = Duration (l, $2).smobbed_copy ();
1734 | DURATION_IDENTIFIER dots {
1735 Duration *d =unsmob_duration ($1);
1736 Duration k (d->duration_log (),d->dot_count () + $2);
1746 multiplied_duration:
1750 | multiplied_duration '*' bare_unsigned {
1751 $$ = unsmob_duration ($$)->compressed ( $3) .smobbed_copy ();
1753 | multiplied_duration '*' FRACTION {
1754 Rational m (gh_scm2int (ly_car ($3)), gh_scm2int (ly_cdr ($3)));
1756 $$ = unsmob_duration ($$)->compressed (m).smobbed_copy ();
1761 FRACTION { $$ = $1; }
1762 | UNSIGNED '/' UNSIGNED {
1763 $$ = scm_cons (gh_int2scm ($1), gh_int2scm ($3));
1781 | ':' bare_unsigned {
1782 if (!is_duration_b ($2))
1783 THIS->parser_error (_f ("not a duration: %d", $2));
1790 /*****************************************************************
1792 *****************************************************************/
1806 Music *bfr = MY_MAKE_MUSIC("BassFigureEvent");
1807 $$ = bfr->self_scm();
1808 scm_gc_unprotect_object ($$);
1811 Music *bfr = MY_MAKE_MUSIC("BassFigureEvent");
1812 $$ = bfr->self_scm();
1814 bfr->set_mus_property ("figure", gh_int2scm ($1));
1816 scm_gc_unprotect_object ($$);
1818 | bass_figure bass_mod {
1819 Music *m = unsmob_music ($1);
1821 SCM salter =m->get_mus_property ("alteration");
1822 int alter = gh_number_p ( salter) ? gh_scm2int (salter) : 0;
1823 m->set_mus_property ("alteration",
1824 gh_int2scm (alter + $2));
1826 m->set_mus_property ("alteration", gh_int2scm (0));
1834 unsmob_music ($$)->set_mus_property ("bracket-start", SCM_BOOL_T);
1839 | br_bass_figure ']' {
1841 unsmob_music ($1)->set_mus_property ("bracket-stop", SCM_BOOL_T);
1849 | figure_list br_bass_figure {
1850 $$ = scm_cons ($2, $1);
1855 FIGURE_OPEN figure_list FIGURE_CLOSE {
1856 Music * m = MY_MAKE_MUSIC("EventChord");
1857 $2 = scm_reverse_x ($2, SCM_EOL);
1858 m->set_mus_property ("elements", $2);
1859 $$ = m->self_scm ();
1870 pitch exclamations questions optional_notemode_duration optional_rest {
1872 Input i = THIS->pop_spot ();
1873 if (!THIS->lexer_->note_state_b ())
1874 THIS->parser_error (_ ("Have to be in Note mode for notes"));
1878 n = MY_MAKE_MUSIC("RestEvent");
1880 n = MY_MAKE_MUSIC("NoteEvent");
1882 n->set_mus_property ("pitch", $1);
1883 n->set_mus_property ("duration", $4);
1887 n->set_mus_property ("cautionary", SCM_BOOL_T);
1888 if ($2 % 2 || $3 % 2)
1889 n->set_mus_property ("force-accidental", SCM_BOOL_T);
1891 Music *v = MY_MAKE_MUSIC("EventChord");
1892 v->set_mus_property ("elements", scm_list_n (n->self_scm (), SCM_UNDEFINED));
1893 scm_gc_unprotect_object (n->self_scm());
1899 | figure_spec optional_notemode_duration {
1900 Music * m = unsmob_music ($1);
1901 Input i = THIS->pop_spot ();
1903 for (SCM s = m->get_mus_property ("elements"); gh_pair_p (s); s = ly_cdr (s))
1905 unsmob_music (ly_car (s))->set_mus_property ("duration", $2);
1909 | RESTNAME optional_notemode_duration {
1911 Input i = THIS->pop_spot ();
1913 if (ly_scm2string ($1) =="s") {
1915 ev = MY_MAKE_MUSIC("SkipEvent");
1918 ev = MY_MAKE_MUSIC("RestEvent");
1921 ev->set_mus_property ("duration" ,$2);
1923 Music * velt = MY_MAKE_MUSIC("EventChord");
1924 velt->set_mus_property ("elements", scm_list_n (ev->self_scm (),SCM_UNDEFINED));
1929 | MULTI_MEASURE_REST optional_notemode_duration {
1934 proc = scm_c_eval_string ("make-multi-measure-rest");
1936 SCM mus = scm_call_2 (proc, $2,
1937 make_input (THIS->here_input()));
1938 scm_gc_protect_object (mus);
1939 $$ = unsmob_music (mus);
1941 | STRING optional_notemode_duration {
1942 Input i = THIS->pop_spot ();
1944 Music * lreq = MY_MAKE_MUSIC("LyricEvent");
1945 lreq->set_mus_property ("text", $1);
1946 lreq->set_mus_property ("duration",$2);
1948 Music * velt = MY_MAKE_MUSIC("EventChord");
1949 velt->set_mus_property ("elements", scm_list_n (lreq->self_scm (), SCM_UNDEFINED));
1956 if (!THIS->lexer_->chord_state_b ())
1957 THIS->parser_error (_ ("Have to be in Chord mode for chords"));
1964 steno_tonic_pitch optional_notemode_duration chord_additions chord_subtractions chord_inversion chord_bass {
1965 $$ = Chord::get_chord ($1, $3, $4, $5, $6, $2);
1966 $$->set_spot (THIS->here_input ());
1973 | CHORD_COLON chord_notes {
1982 | chord_notes '.' chord_step {
1983 $$ = gh_append2 ($$, $3);
1991 | CHORD_CARET chord_notes {
2001 | CHORD_SLASH steno_tonic_pitch {
2010 | CHORD_BASS steno_tonic_pitch {
2017 $$ = scm_cons ($1, SCM_EOL);
2019 | CHORDMODIFIER_PITCH {
2020 $$ = scm_cons (unsmob_pitch ($1)->smobbed_copy (), SCM_EOL);
2022 | CHORDMODIFIER_PITCH chord_note { /* Ugh. */
2023 $$ = scm_list_n (unsmob_pitch ($1)->smobbed_copy (),
2031 m.notename_ = ($1 - 1) % 7;
2032 m.octave_ = $1 > 7 ? 1 : 0;
2035 $$ = m.smobbed_copy ();
2037 | bare_unsigned '+' {
2039 m.notename_ = ($1 - 1) % 7;
2040 m.octave_ = $1 > 7 ? 1 : 0;
2044 $$ = m.smobbed_copy ();
2046 | bare_unsigned CHORD_MINUS {
2048 m.notename_ = ($1 - 1) % 7;
2049 m.octave_ = $1 > 7 ? 1 : 0;
2052 $$ = m.smobbed_copy ();
2060 number_expression '+' number_term {
2061 $$ = scm_sum ($1, $3);
2063 | number_expression '-' number_term {
2064 $$ = scm_difference ($1, $3);
2073 | number_factor '*' number_factor {
2074 $$ = scm_product ($1, $3);
2076 | number_factor '/' number_factor {
2077 $$ = scm_divide ($1, $3);
2082 '-' number_factor { /* %prec UNARY_MINUS */
2083 $$ = scm_difference ($2, SCM_UNDEFINED);
2091 $$ = gh_int2scm ($1);
2096 | NUMBER_IDENTIFIER {
2099 | REAL NUMBER_IDENTIFIER {
2100 $$ = gh_double2scm (gh_scm2double ($1) * gh_scm2double ($2));
2102 | UNSIGNED NUMBER_IDENTIFIER {
2103 $$ = gh_double2scm ($1 * gh_scm2double ($2));
2119 if (scm_integer_p ($1) == SCM_BOOL_T)
2121 int k = gh_scm2int ($1);
2125 THIS->parser_error (_ ("need integer number arg"));
2139 | STRING_IDENTIFIER {
2142 | string '+' string {
2143 $$ = scm_string_append (scm_list_n ($1, $3, SCM_UNDEFINED));
2150 | exclamations '!' { $$ ++; }
2155 | questions '?' { $$ ++; }
2162 { THIS->lexer_->push_markup_state (); }
2165 THIS->lexer_->pop_state ();
2173 simple = scm_c_eval_string ("simple-markup");
2175 $$ = scm_list_n (simple, $1, SCM_UNDEFINED);
2177 | MARKUP_HEAD_MARKUP0 markup {
2178 $$ = scm_list_n ($1, $2, SCM_UNDEFINED);
2180 | MARKUP_HEAD_SCM0_MARKUP1 SCM_T markup {
2181 $$ = scm_list_n ($1, $2, $3, SCM_UNDEFINED);
2186 | MARKUP_HEAD_LIST0 markup_list {
2187 $$ = scm_list_n ($1,$2, SCM_UNDEFINED);
2189 | MARKUP_HEAD_SCM0 embedded_scm {
2190 $$ = scm_list_n ($1, $2, SCM_UNDEFINED);
2192 | MARKUP_HEAD_SCM0_SCM1_MARKUP2 embedded_scm embedded_scm markup {
2193 $$ = scm_list_n ($1, $2, $3, $4, SCM_UNDEFINED);
2195 | MARKUP_IDENTIFIER {
2202 '<' markup_list_body '>' { $$ = scm_reverse_x ($2, SCM_EOL); }
2206 '{' markup_list_body '}' {
2209 line = scm_c_eval_string ("line-markup");
2211 $$ = scm_list_n (line, scm_reverse_x ($2, SCM_EOL), SCM_UNDEFINED);
2216 /**/ { $$ = SCM_EOL; }
2217 | markup_list_body markup {
2218 $$ = gh_cons ($2, $1) ;
2226 My_lily_parser::set_yydebug (bool )
2233 extern My_lily_parser * current_parser;
2236 My_lily_parser::do_yyparse ()
2238 current_parser = this;;
2239 yyparse ((void*)this);
2244 Should make this optional? It will also complain when you do
2248 which is entirely legitimate.
2250 Or we can scrap it. Barchecks should detect wrong durations, and
2251 skipTypesetting speeds it up a lot.
2255 My_lily_parser::beam_check (SCM dur)
2257 Duration *d = unsmob_duration (dur);
2258 if (unsmob_music (last_beam_start_) && d->duration_log () <= 2)
2260 Music * m = unsmob_music (last_beam_start_);
2261 m->origin ()->warning (_("Suspect duration found following this beam"));
2263 last_beam_start_ = SCM_EOL;
2271 return gh_pair_p (x)
2272 && SCM_BOOL_F != scm_object_property (gh_car (x), ly_symbol2scm ("markup-signature"));
2275 It is a little strange, to have this function in this file, but
2276 otherwise, we have to import music classes into the lexer.
2280 My_lily_lexer::try_special_identifiers (SCM * destination, SCM sid)
2282 if (gh_string_p (sid)) {
2284 return STRING_IDENTIFIER;
2285 } else if (gh_number_p (sid)) {
2287 return NUMBER_IDENTIFIER;
2288 } else if (unsmob_translator_def (sid)) {
2289 *destination = unsmob_translator_def (sid)->clone_scm();
2290 return TRANSLATOR_IDENTIFIER;
2291 } else if (unsmob_score (sid)) {
2292 Score *sc = new Score (*unsmob_score (sid));
2293 *destination =sc->self_scm ();
2294 return SCORE_IDENTIFIER;
2295 } else if (Music * mus =unsmob_music (sid)) {
2296 *destination = unsmob_music (sid)->clone ()->self_scm();
2297 unsmob_music (*destination)->
2298 set_mus_property ("origin", make_input (last_input_));
2299 return dynamic_cast<Event*> (mus)
2300 ? EVENT_IDENTIFIER : MUSIC_IDENTIFIER;
2301 } else if (unsmob_duration (sid)) {
2302 *destination = unsmob_duration (sid)->smobbed_copy();
2303 return DURATION_IDENTIFIER;
2304 } else if (unsmob_music_output_def (sid)) {
2305 Music_output_def *p = unsmob_music_output_def (sid);
2308 *destination = p->self_scm();
2309 return MUSIC_OUTPUT_DEF_IDENTIFIER;
2310 } else if (markup_p (sid)) {
2312 return MARKUP_IDENTIFIER;