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
279 %token <scm> MARKUP_HEAD_MARKUP0_MARKUP1
280 %token <scm> MARKUP_HEAD_SCM0
281 %token <scm> MARKUP_HEAD_SCM0_MARKUP1
282 %token <scm> MARKUP_HEAD_SCM0_SCM1
283 %token <scm> MARKUP_HEAD_SCM0_SCM1_MARKUP2
285 %token <scm> MARKUP_IDENTIFIER MARKUP_HEAD_LIST0
286 %type <scm> markup markup_line markup_list markup_list_body full_markup
288 %type <outputdef> output_def
289 %type <scm> lilypond_header lilypond_header_body
290 %type <music> open_event_parens close_event_parens open_event close_event
291 %type <music> event_with_dir event_that_take_dir verbose_event
292 %type <i> sub_quotes sup_quotes
293 %type <music> simple_element event_chord command_element Simple_music Composite_music
294 %type <music> Repeated_music
295 %type <scm> Alternative_music
296 %type <i> tremolo_type
297 %type <i> bare_int bare_unsigned
299 %type <scm> identifier_init
301 %type <music> note_chord_element chord_body chord_body_element
302 %type <scm> chord_body_elements
303 %type <scm> steno_duration optional_notemode_duration multiplied_duration
304 %type <scm> verbose_duration
306 %type <scm> pre_events post_events
307 %type <music> gen_text_def
308 %type <scm> steno_pitch pitch absolute_pitch pitch_also_in_chords
309 %type <scm> explicit_pitch steno_tonic_pitch
311 %type <scm> chord_additions chord_subtractions chord_notes chord_step
313 %type <scm> chord_note chord_inversion chord_bass
314 %type <scm> duration_length fraction
316 %type <scm> embedded_scm scalar
317 %type <music> Music Sequential_music Simultaneous_music
318 %type <music> relative_music re_rhythmed_music part_combined_music
319 %type <music> property_def translator_change simple_property_def
320 %type <scm> Music_list
321 %type <outputdef> music_output_def_body
322 %type <music> shorthand_command_req
323 %type <music> post_event
324 %type <music> command_req verbose_command_req
325 %type <music> extender_req
326 %type <music> hyphen_req
327 %type <music> string_event
328 %type <scm> string bare_number number_expression number_term number_factor
329 %type <score> score_block score_body
331 %type <scm> translator_spec_block translator_spec_body
332 %type <music> tempo_event
333 %type <scm> notenames_body notenames_block chordmodifiers_block
334 %type <scm> script_abbreviation
340 /* We don't assign precedence to / and *, because we might need varied
341 prec levels in different prods */
347 lilypond: /* empty */
348 | lilypond toplevel_expression {}
349 | lilypond assignment { }
351 THIS->error_level_ = 1;
354 THIS->error_level_ = 1;
360 THIS->lexer_->pitchname_tab_ = $1;
362 | chordmodifiers_block {
363 THIS->lexer_->chordmodifier_tab_ = $1;
366 THIS->input_file_->header_ = $1;
369 THIS->input_file_->scores_.push ($1);
372 if (dynamic_cast<Paper_def*> ($1))
373 THIS->lexer_->set_identifier (scm_makfrom0str ("$defaultpaper"), $1->self_scm ());
374 else if (dynamic_cast<Midi_def*> ($1))
375 THIS->lexer_->set_identifier (scm_makfrom0str ("$defaultmidi"), $1->self_scm ());
385 chordmodifiers_block:
386 CHORDMODIFIERS notenames_body { $$ = $2; }
390 PITCHNAMES notenames_body { $$ = $2; }
395 int i = scm_ilength ($1);
397 SCM tab = scm_make_vector (gh_int2scm (i), SCM_EOL);
398 for (SCM s = $1; gh_pair_p (s); s = ly_cdr (s)) {
399 SCM pt = ly_cdar (s);
400 if (!unsmob_pitch (pt))
401 THIS->parser_error ("Need pitch object.");
403 scm_hashq_set_x (tab, ly_caar (s), pt);
410 lilypond_header_body:
412 $$ = ly_make_anonymous_module ();
413 THIS->lexer_->add_scope ($$);
415 | lilypond_header_body assignment {
421 HEADER '{' lilypond_header_body '}' {
422 $$ = THIS->lexer_-> remove_scope();
434 /* cont */ '=' identifier_init {
437 Should find generic way of associating input with objects.
439 Input ip = THIS->pop_spot ();
441 if (! regular_identifier_b ($1))
443 ip.warning (_ ("Identifier should have alphabetic characters only"));
446 THIS->lexer_->set_identifier ($1, $4);
449 TODO: devise standard for protection in parser.
451 The parser stack lives on the C-stack, which means that
452 all objects can be unprotected as soon as they're here.
463 $$ = $1->self_scm ();
464 scm_gc_unprotect_object ($$);
470 $$ = $1->self_scm ();
471 scm_gc_unprotect_object ($$);
473 | translator_spec_block {
477 $$ = $1->self_scm ();
478 scm_gc_unprotect_object ($$);
481 $$ = $1->self_scm ();
482 scm_gc_unprotect_object ($$);
487 | number_expression {
498 translator_spec_block:
499 TRANSLATOR '{' translator_spec_body '}'
505 translator_spec_body:
506 TRANSLATOR_IDENTIFIER {
508 unsmob_translator_def ($$)-> set_spot (THIS->here_input ());
511 $$ = Translator_def::make_scm ();
512 Translator_def*td = unsmob_translator_def ($$);
513 td->translator_group_type_ = $2;
514 td->set_spot (THIS->here_input ());
516 | translator_spec_body STRING '=' embedded_scm {
517 unsmob_translator_def ($$)->add_property_assign ($2, $4);
519 | translator_spec_body STRING OVERRIDE embedded_scm '=' embedded_scm {
520 unsmob_translator_def ($$)
521 ->add_push_property (scm_string_to_symbol ($2), $4, $6);
523 | translator_spec_body STRING SET embedded_scm '=' embedded_scm {
524 unsmob_translator_def ($$)
525 ->add_push_property (scm_string_to_symbol ($2), $4, $6);
527 | translator_spec_body STRING REVERT embedded_scm {
528 unsmob_translator_def ($$)->add_pop_property (
529 scm_string_to_symbol ($2), $4);
531 | translator_spec_body NAME STRING {
532 unsmob_translator_def ($$)->type_name_ = $3;
534 | translator_spec_body CONSISTS STRING {
535 unsmob_translator_def ($$)->add_element ($3);
537 | translator_spec_body ALIAS STRING {
538 Translator_def*td = unsmob_translator_def ($$);
539 td->type_aliases_ = scm_cons ($3, td->type_aliases_);
541 | translator_spec_body GROBDESCRIPTIONS embedded_scm {
542 Translator_def*td = unsmob_translator_def($$);
543 // td->add_property_assign (ly_symbol2scm ("allGrobDescriptions"), $3);
544 for (SCM p = $3; gh_pair_p (p); p = ly_cdr (p))
545 td->add_property_assign (scm_symbol_to_string (ly_caar (p)), ly_cdar (p));
547 | translator_spec_body CONSISTSEND STRING {
548 unsmob_translator_def ($$)->add_last_element ( $3);
550 | translator_spec_body ACCEPTS STRING {
551 unsmob_translator_def ($$)->set_acceptor ($3,true);
553 | translator_spec_body DENIES STRING {
554 unsmob_translator_def ($$)->set_acceptor ($3,false);
556 | translator_spec_body REMOVE STRING {
557 unsmob_translator_def ($$)->remove_element ($3);
568 /*cont*/ '{' score_body '}' {
571 if (!$$->defs_.size ())
573 Music_output_def *id =
574 unsmob_music_output_def (THIS->lexer_->lookup_identifier ("$defaultpaper"));
575 $$->add_output (id ? id->clone () : new Paper_def );
584 $$->set_spot (THIS->here_input ());
585 SCM m = $1->self_scm ();
586 scm_gc_unprotect_object (m);
591 SCM check_funcs = scm_c_eval_string ("toplevel-music-functions");
592 for (; gh_pair_p (check_funcs); check_funcs = gh_cdr (check_funcs))
593 m = gh_call1 (gh_car (check_funcs), m);
598 $$ = unsmob_score ($1);
599 $$->set_spot (THIS->here_input ());
601 | score_body lilypond_header {
604 | score_body output_def {
617 music_output_def_body '}' {
619 THIS-> lexer_-> remove_scope ();
623 music_output_def_body:
625 Music_output_def *id = unsmob_music_output_def (THIS->lexer_->lookup_identifier ("$defaultmidi"));
630 p = dynamic_cast<Midi_def*> (id->clone ());
635 THIS->lexer_->add_scope (p->scope_);
638 Music_output_def *id = unsmob_music_output_def (THIS->lexer_->lookup_identifier ("$defaultpaper"));
641 p = dynamic_cast<Paper_def*> (id->clone ());
645 THIS->lexer_->add_scope (p->scope_);
648 | PAPER '{' MUSIC_OUTPUT_DEF_IDENTIFIER {
649 Music_output_def * o = unsmob_music_output_def ($3);
652 THIS->lexer_->add_scope (o->scope_);
654 | MIDI '{' MUSIC_OUTPUT_DEF_IDENTIFIER {
655 Music_output_def * o = unsmob_music_output_def ($3);
658 THIS->lexer_->add_scope (o->scope_);
660 | music_output_def_body assignment {
663 | music_output_def_body translator_spec_block {
664 $$->assign_translator ($2);
666 | music_output_def_body tempo_event {
668 junk this ? there already is tempo stuff in
671 int m = gh_scm2int ( $2->get_mus_property ("metronome-count"));
672 Duration *d = unsmob_duration ($2->get_mus_property ("tempo-unit"));
673 Midi_def * md = dynamic_cast<Midi_def*> ($$);
675 md->set_tempo (d->get_length (), m);
677 | music_output_def_body error {
683 TEMPO steno_duration '=' bare_unsigned {
684 $$ = MY_MAKE_MUSIC("TempoEvent");
685 $$->set_mus_property ("tempo-unit", $2);
686 $$->set_mus_property ("metronome-count", gh_int2scm ( $4));
691 The representation of a list is the
695 to have efficient append.
699 $$ = scm_cons (SCM_EOL, SCM_EOL);
703 SCM c = scm_cons ($2->self_scm (), SCM_EOL);
704 scm_gc_unprotect_object ($2->self_scm ()); /* UGH */
705 if (gh_pair_p (ly_cdr (s)))
706 gh_set_cdr_x (ly_cdr (s), c); /* append */
708 gh_set_car_x (s, c); /* set first cons */
709 gh_set_cdr_x (s, c) ; /* remember last cell */
725 | ALTERNATIVE '{' Music_list '}' {
731 REPEAT string bare_unsigned Music Alternative_music
735 SCM alts = gh_pair_p ($5) ? gh_car ($5) : SCM_EOL;
736 if (times < scm_ilength (alts)) {
737 unsmob_music (gh_car (alts))
738 ->origin ()->warning (
739 _("More alternatives than repeats. Junking excess alternatives."));
740 alts = ly_truncate_list (times, alts);
746 proc = scm_c_eval_string ("make-repeated-music");
748 SCM mus = scm_call_1 (proc, $2);
749 scm_gc_protect_object (mus); // UGH.
750 Music *r =unsmob_music (mus);
753 r-> set_mus_property ("element", beg->self_scm ());
754 scm_gc_unprotect_object (beg->self_scm ());
756 r->set_mus_property ("repeat-count", gh_int2scm (times >? 1));
758 r-> set_mus_property ("elements",alts);
759 if (gh_equal_p ($2, scm_makfrom0str ("tremolo")))
762 we can not get durations and other stuff correct down the line, so we have to
763 add to the duration log here.
765 SCM func = scm_primitive_eval (ly_symbol2scm ("shift-duration-log"));
767 gh_call3 (func, r->self_scm (), gh_int2scm(-intlog2 ($3*2/3)),gh_int2scm(1));
769 gh_call3 (func, r->self_scm (), gh_int2scm(-intlog2 ($3)), gh_int2scm(0));
771 r->set_spot (*$4->origin ());
778 SEQUENTIAL '{' Music_list '}' {
779 $$ = MY_MAKE_MUSIC("SequentialMusic");
780 $$->set_mus_property ("elements", ly_car ($3));
781 $$->set_spot(THIS->here_input());
783 | '{' Music_list '}' {
784 $$ = MY_MAKE_MUSIC("SequentialMusic");
785 $$->set_mus_property ("elements", ly_car ($2));
786 $$->set_spot(THIS->here_input());
791 SIMULTANEOUS '{' Music_list '}'{
792 $$ = MY_MAKE_MUSIC("SimultaneousMusic");
793 $$->set_mus_property ("elements", ly_car ($3));
794 $$->set_spot(THIS->here_input());
797 | '<' Music_list '>' {
798 $$ = MY_MAKE_MUSIC("SimultaneousMusic");
799 $$->set_mus_property ("elements", ly_car ($2));
800 $$->set_spot(THIS->here_input());
805 event_chord { $$ = $1; }
806 | APPLYCONTEXT embedded_scm {
807 if (!gh_procedure_p ($2))
808 THIS->parser_error (_ ("\applycontext takes function argument"));
809 $$ = MY_MAKE_MUSIC ("ApplyContext");
810 $$->set_mus_property ("procedure", $2);
811 $$->set_spot (THIS->here_input());
813 | OUTPUTPROPERTY embedded_scm embedded_scm '=' embedded_scm {
815 if (!gh_symbol_p ($3))
817 THIS->parser_error (_ ("Second argument must be a symbol"));
819 /* Should check # args */
820 if (!gh_procedure_p (pred))
822 THIS->parser_error (_ ("First argument must be a procedure taking one argument"));
825 Music*m = MY_MAKE_MUSIC("OutputPropertySetMusic");
826 m->set_mus_property ("predicate", pred);
827 m->set_mus_property ("grob-property", $3);
828 m->set_mus_property ("grob-value", $5);
833 $$ = unsmob_music ($1);
841 CONTEXT STRING Music {
842 Music*csm =MY_MAKE_MUSIC("ContextSpeccedMusic");
844 csm->set_mus_property ("element", $3->self_scm ());
845 scm_gc_unprotect_object ($3->self_scm ());
847 csm->set_mus_property ("context-type",$2);
848 csm->set_mus_property ("context-id", scm_makfrom0str (""));
852 | AUTOCHANGE STRING Music {
853 Music*chm = MY_MAKE_MUSIC("AutoChangeMusic");
854 chm->set_mus_property ("element", $3->self_scm ());
855 chm->set_mus_property ("iterator-ctor", Auto_change_iterator::constructor_proc);
857 scm_gc_unprotect_object ($3->self_scm ());
858 chm->set_mus_property ("what", $2);
861 chm->set_spot (*$3->origin ());
866 The other version is for easier debugging of
867 Sequential_music_iterator in combination with grace notes.
870 SCM start = THIS->lexer_->lookup_identifier ("startGraceMusic");
871 SCM stop = THIS->lexer_->lookup_identifier ("stopGraceMusic");
872 Music *startm = unsmob_music (start);
873 Music *stopm = unsmob_music (stop);
877 stopm = stopm->clone ();
878 ms = scm_cons (stopm->self_scm (), ms);
879 scm_gc_unprotect_object (stopm->self_scm ());
881 ms = scm_cons ($2->self_scm (), ms);
882 scm_gc_unprotect_object ($2->self_scm());
884 startm = startm->clone ();
885 ms = scm_cons (startm->self_scm () , ms);
886 scm_gc_unprotect_object (startm->self_scm ());
890 Music* seq = MY_MAKE_MUSIC("SequentialMusic");
891 seq->set_mus_property ("elements", ms);
894 $$ = MY_MAKE_MUSIC("GraceMusic");
895 $$->set_mus_property ("element", seq->self_scm ());
896 scm_gc_unprotect_object (seq->self_scm ());
898 $$ = MY_MAKE_MUSIC("GraceMusic");
899 $$->set_mus_property ("element", $2->self_scm ());
900 scm_gc_unprotect_object ($2->self_scm ());
903 | CONTEXT string '=' string Music {
904 Music * csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
906 csm->set_mus_property ("element", $5->self_scm ());
907 scm_gc_unprotect_object ($5->self_scm ());
909 csm->set_mus_property ("context-type", $2);
910 csm->set_mus_property ("context-id", $4);
921 int n = gh_scm2int (ly_car ($3)); int d = gh_scm2int (ly_cdr ($3));
923 $$= MY_MAKE_MUSIC("TimeScaledMusic");
924 $$->set_spot (THIS->pop_spot ());
927 $$->set_mus_property ("element", mp->self_scm ());
928 scm_gc_unprotect_object (mp->self_scm ());
929 $$->set_mus_property ("numerator", gh_int2scm (n));
930 $$->set_mus_property ("denominator", gh_int2scm (d));
931 $$->compress (Moment (Rational (n,d)));
934 | Repeated_music { $$ = $1; }
935 | Simultaneous_music { $$ = $1; }
936 | Sequential_music { $$ = $1; }
937 | TRANSPOSE pitch_also_in_chords pitch_also_in_chords Music {
938 $$ = MY_MAKE_MUSIC("TransposedMusic");
940 Pitch from = *unsmob_pitch ($2);
941 Pitch to = *unsmob_pitch ($3);
943 p->transpose (interval (from, to));
944 $$->set_mus_property ("element", p->self_scm ());
945 scm_gc_unprotect_object (p->self_scm ());
947 | APPLY embedded_scm Music {
948 SCM ret = gh_call1 ($2, $3->self_scm ());
949 Music *m = unsmob_music (ret);
951 THIS->parser_error ("\\apply must return a Music");
952 m = MY_MAKE_MUSIC("Music");
957 { THIS->lexer_->push_note_state (); }
960 THIS->lexer_->pop_state ();
963 { THIS->lexer_->push_figuredbass_state (); }
966 Music * chm = MY_MAKE_MUSIC("UntransposableMusic");
967 chm->set_mus_property ("element", $3->self_scm ());
969 scm_gc_unprotect_object ($3->self_scm());
971 THIS->lexer_->pop_state ();
974 { THIS->lexer_->push_chord_state (); }
977 Music * chm = MY_MAKE_MUSIC("UnrelativableMusic");
978 chm->set_mus_property ("element", $3->self_scm ());
979 scm_gc_unprotect_object ($3->self_scm());
982 THIS->lexer_->pop_state ();
985 { THIS->lexer_->push_lyric_state (); }
989 THIS->lexer_->pop_state ();
991 | relative_music { $$ = $1; }
992 | re_rhythmed_music { $$ = $1; }
993 | part_combined_music { $$ = $1; }
997 RELATIVE absolute_pitch Music {
999 Pitch pit = *unsmob_pitch ($2);
1000 $$ = MY_MAKE_MUSIC("RelativeOctaveMusic");
1002 $$->set_mus_property ("element", p->self_scm ());
1003 scm_gc_unprotect_object (p->self_scm ());
1005 $$->set_mus_property ("last-pitch", p->to_relative_octave (pit).smobbed_copy ());
1011 ADDLYRICS Music Music {
1012 Music*l =MY_MAKE_MUSIC("LyricCombineMusic");
1013 l->set_mus_property ("elements", gh_list ($2->self_scm (), $3->self_scm (), SCM_UNDEFINED));
1014 scm_gc_unprotect_object ($3->self_scm ());
1015 scm_gc_unprotect_object ($2->self_scm ());
1020 part_combined_music:
1021 PARTCOMBINE STRING Music Music {
1022 Music * p= MY_MAKE_MUSIC("PartCombineMusic");
1023 p->set_mus_property ("what", $2);
1024 p->set_mus_property ("elements", gh_list ($3->self_scm (),$4->self_scm (), SCM_UNDEFINED));
1026 scm_gc_unprotect_object ($3->self_scm ());
1027 scm_gc_unprotect_object ($4->self_scm ());
1034 TRANSLATOR STRING '=' STRING {
1035 Music*t= MY_MAKE_MUSIC("TranslatorChange");
1036 t-> set_mus_property ("change-to-type", $2);
1037 t-> set_mus_property ("change-to-id", $4);
1040 $$->set_spot (THIS->here_input ());
1046 | ONCE simple_property_def {
1048 SCM e = $2->get_mus_property ("element");
1049 unsmob_music (e)->set_mus_property ("once", SCM_BOOL_T);
1053 simple_property_def:
1054 PROPERTY STRING '.' STRING '=' scalar {
1055 Music *t = set_property_music (scm_string_to_symbol ($4), $6);
1056 Music *csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
1058 csm->set_mus_property ("element", t->self_scm ());
1059 scm_gc_unprotect_object (t->self_scm ());
1062 $$->set_spot (THIS->here_input ());
1064 csm-> set_mus_property ("context-type", $2);
1066 | PROPERTY STRING '.' STRING UNSET {
1068 Music *t = MY_MAKE_MUSIC("PropertyUnset");
1069 t->set_mus_property ("symbol", scm_string_to_symbol ($4));
1071 Music *csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
1072 csm->set_mus_property ("element", t->self_scm ());
1073 scm_gc_unprotect_object (t->self_scm ());
1076 $$->set_spot (THIS->here_input ());
1078 csm-> set_mus_property ("context-type", $2);
1080 | PROPERTY STRING '.' STRING SET embedded_scm '=' embedded_scm {
1082 = gh_equal_p ($4, scm_makfrom0str ("autoBeamSettings"));
1083 bool itc = internal_type_checking_global_b;
1084 Music *t = MY_MAKE_MUSIC("OverrideProperty");
1085 t->set_mus_property ("symbol", scm_string_to_symbol ($4));
1086 t->set_mus_property ("pop-first", SCM_BOOL_T);
1088 internal_type_checking_global_b = false;
1089 t->set_mus_property ("grob-property", $6);
1091 internal_type_checking_global_b = itc;
1092 t->set_mus_property ("grob-value", $8);
1094 Music *csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
1095 csm->set_mus_property ("element", t->self_scm ());
1096 scm_gc_unprotect_object (t->self_scm ());
1098 $$->set_spot (THIS->here_input ());
1100 csm-> set_mus_property ("context-type", $2);
1102 | PROPERTY STRING '.' STRING OVERRIDE
1103 embedded_scm '=' embedded_scm
1109 = gh_equal_p ($4, scm_makfrom0str ("autoBeamSettings"));
1110 bool itc = internal_type_checking_global_b;
1112 Music *t = MY_MAKE_MUSIC("OverrideProperty");
1113 t->set_mus_property ("symbol", scm_string_to_symbol ($4));
1115 internal_type_checking_global_b = false;
1116 t->set_mus_property ("grob-property", $6);
1117 t->set_mus_property ("grob-value", $8);
1119 internal_type_checking_global_b = itc;
1121 Music *csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
1122 csm->set_mus_property ("element", t->self_scm ());
1123 scm_gc_unprotect_object (t->self_scm ());
1126 $$->set_spot (THIS->here_input ());
1128 csm-> set_mus_property ("context-type", $2);
1131 | PROPERTY STRING '.' STRING REVERT embedded_scm {
1132 Music *t = MY_MAKE_MUSIC("RevertProperty");
1134 = gh_equal_p ($4, scm_makfrom0str ("autoBeamSettings"));
1135 bool itc = internal_type_checking_global_b;
1137 t->set_mus_property ("symbol", scm_string_to_symbol ($4));
1139 internal_type_checking_global_b = false;
1140 t->set_mus_property ("grob-property", $6);
1142 internal_type_checking_global_b = itc;
1144 Music *csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
1145 csm->set_mus_property ("element", t->self_scm ());
1146 scm_gc_unprotect_object (t->self_scm ());
1149 $$->set_spot (THIS->here_input ());
1151 csm-> set_mus_property ("context-type", $2);
1158 | bare_int { $$ = gh_int2scm ($1); }
1159 | embedded_scm { $$ = $1; }
1166 } /*cont */ simple_element post_events {
1167 SCM elts = $3-> get_mus_property ("elements");
1169 elts = gh_append3 (elts, scm_reverse_x ($1, SCM_EOL),
1170 scm_reverse_x ($4, SCM_EOL));
1172 $3-> set_mus_property ("elements", elts);
1176 | note_chord_element
1181 chord_body optional_notemode_duration post_events
1183 SCM dur = unsmob_duration ($2)->smobbed_copy();
1184 SCM es = $1->get_mus_property ("elements");
1185 SCM postevs = scm_reverse_x ($3, SCM_EOL);
1187 for (SCM s = es; gh_pair_p (s); s = gh_cdr (s))
1188 unsmob_music (gh_car(s))->set_mus_property ("duration", dur);
1189 es = gh_append2 (es, postevs);
1191 $1-> set_mus_property ("elements", es);
1197 CHORD_OPEN chord_body_elements CHORD_CLOSE
1199 $$ = MY_MAKE_MUSIC("EventChord");
1200 $$->set_mus_property ("elements",
1201 scm_reverse_x ($2, SCM_EOL));
1205 chord_body_elements:
1206 /* empty */ { $$ = SCM_EOL; }
1207 | chord_body_elements chord_body_element {
1208 $$ = gh_cons ($2->self_scm(), $1);
1209 scm_gc_unprotect_object ($2->self_scm());
1214 pitch exclamations questions post_events
1216 Music * n = MY_MAKE_MUSIC("NoteEvent");
1217 n->set_mus_property ("pitch", $1);
1219 n->set_mus_property ("cautionary", SCM_BOOL_T);
1220 if ($2 % 2 || $3 % 2)
1221 n->set_mus_property ("force-accidental", SCM_BOOL_T);
1223 SCM arts = scm_reverse_x ($4, SCM_EOL);
1224 n->set_mus_property ("articulations", arts);
1232 $$ = MY_MAKE_MUSIC("EventChord");
1233 $$->set_mus_property ("elements", scm_cons ($1->self_scm (), SCM_EOL));
1234 scm_gc_unprotect_object ($1->self_scm());
1236 $$-> set_spot (THIS->here_input ());
1237 $1-> set_spot (THIS->here_input ());
1240 Music *l = MY_MAKE_MUSIC("LigatureEvent");
1241 l->set_mus_property ("span-direction", gh_int2scm (START));
1242 l->set_spot (THIS->here_input ());
1244 $$ = MY_MAKE_MUSIC("EventChord");
1245 $$->set_mus_property ("elements", scm_cons (l->self_scm (), SCM_EOL));
1246 scm_gc_unprotect_object (l->self_scm());
1247 $$->set_spot (THIS->here_input ());
1250 Music *l = MY_MAKE_MUSIC("LigatureEvent");
1251 l->set_mus_property ("span-direction", gh_int2scm (STOP));
1252 l->set_spot (THIS->here_input ());
1254 $$ = MY_MAKE_MUSIC("EventChord");
1255 $$->set_mus_property ("elements", scm_cons (l->self_scm (), SCM_EOL));
1256 $$->set_spot (THIS->here_input ());
1257 scm_gc_unprotect_object (l->self_scm());
1260 $$ = MY_MAKE_MUSIC("VoiceSeparator");
1261 $$->set_spot (THIS->here_input ());
1265 $$ = MY_MAKE_MUSIC("BarCheck");
1266 $$->set_spot (THIS->here_input ());
1269 Music *t = set_property_music (ly_symbol2scm ("whichBar"), $2);
1271 Music *csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
1272 csm->set_mus_property ("element", t->self_scm ());
1273 scm_gc_unprotect_object (t->self_scm ());
1276 $$->set_spot (THIS->here_input ());
1278 csm->set_mus_property ("context-type", scm_makfrom0str ("Timing"));
1280 | PARTIAL duration_length {
1281 Moment m = - unsmob_duration ($2)->get_length ();
1282 Music * p = set_property_music (ly_symbol2scm ( "measurePosition"),m.smobbed_copy ());
1284 Music * sp = MY_MAKE_MUSIC("ContextSpeccedMusic");
1285 sp->set_mus_property ("element", p->self_scm ());
1286 scm_gc_unprotect_object (p->self_scm ());
1289 sp-> set_mus_property ("context-type", scm_makfrom0str ("Timing"));
1294 proc = scm_c_eval_string ("make-clef-set");
1296 SCM result = scm_call_1 (proc, $2);
1297 scm_gc_protect_object (result);
1298 $$ = unsmob_music (result);
1303 proc = scm_c_eval_string ("make-time-signature-set");
1305 SCM result = scm_apply_2 (proc, gh_car ($2), gh_cdr ($2), SCM_EOL);
1306 scm_gc_protect_object (result);
1307 $$ = unsmob_music (result);
1312 shorthand_command_req { $$ = $1; }
1313 | verbose_command_req { $$ = $1; }
1316 shorthand_command_req:
1324 $$ = MY_MAKE_MUSIC("TieEvent");
1327 Music *b= MY_MAKE_MUSIC("BeamEvent");
1328 b->set_mus_property ("span-direction", gh_int2scm (START));
1331 THIS->last_beam_start_ = b->self_scm ();
1334 Music *b= MY_MAKE_MUSIC("BeamEvent");
1335 b->set_mus_property ("span-direction", gh_int2scm (STOP));
1339 $$ = MY_MAKE_MUSIC("BreathingSignEvent");
1342 $$ = MY_MAKE_MUSIC("PorrectusEvent");
1346 verbose_command_req:
1348 Music * m = MY_MAKE_MUSIC("MarkEvent");
1352 Music *m = MY_MAKE_MUSIC("MarkEvent");
1353 m->set_mus_property ("label", $2);
1356 | SKIP duration_length {
1357 Music * skip = MY_MAKE_MUSIC("SkipEvent");
1358 skip->set_mus_property ("duration", $2);
1366 Music *key= MY_MAKE_MUSIC("KeyChangeEvent");
1369 | KEY NOTENAME_PITCH SCM_IDENTIFIER {
1370 Music *key= MY_MAKE_MUSIC("KeyChangeEvent");
1372 key->set_mus_property ("pitch-alist", $3);
1373 ((Music*)key)->transpose (* unsmob_pitch ($2));
1382 | post_events post_event {
1383 $2->set_spot (THIS->here_input ());
1384 $$ = gh_cons ($2->self_scm(), $$);
1385 scm_gc_unprotect_object ($2->self_scm());
1398 Music * s = MY_MAKE_MUSIC("StringNumberEvent");
1399 s->set_mus_property ("string-number", gh_int2scm($1));
1400 s->set_spot (THIS->here_input ());
1406 event_that_take_dir:
1412 Music * m = MY_MAKE_MUSIC ("NewBeamEvent");
1413 m->set_spot (THIS->here_input());
1414 m->set_mus_property ("span-direction" , gh_int2scm (START));
1418 Music * m = MY_MAKE_MUSIC ("NewBeamEvent");
1419 m->set_spot (THIS->here_input());
1420 m->set_mus_property ("span-direction" , gh_int2scm (STOP));
1424 Music * m = MY_MAKE_MUSIC ("NewTieEvent");
1425 m->set_spot (THIS->here_input());
1428 | script_abbreviation {
1429 SCM s = THIS->lexer_->lookup_identifier ("dash" + ly_scm2string ($1));
1430 Music *a = MY_MAKE_MUSIC("ArticulationEvent");
1431 if (gh_string_p (s))
1432 a->set_mus_property ("articulation-type", s);
1433 else THIS->parser_error (_ ("Expecting string as script definition"));
1439 script_dir event_that_take_dir {
1440 $2->set_mus_property ("direction", gh_int2scm ($1));
1447 $$ = unsmob_music ($1);
1450 Music * a = MY_MAKE_MUSIC("TremoloEvent");
1451 a->set_spot (THIS->here_input ());
1452 a->set_mus_property ("tremolo-type", gh_int2scm ($1));
1479 | NOTENAME_PITCH sup_quotes {
1480 Pitch p = *unsmob_pitch ($1);
1482 $$ = p.smobbed_copy ();
1484 | NOTENAME_PITCH sub_quotes {
1485 Pitch p =* unsmob_pitch ($1);
1488 $$ = p.smobbed_copy ();
1501 | TONICNAME_PITCH sup_quotes {
1502 Pitch p = *unsmob_pitch ($1);
1504 $$ = p.smobbed_copy ();
1506 | TONICNAME_PITCH sub_quotes {
1507 Pitch p =* unsmob_pitch ($1);
1510 $$ = p.smobbed_copy ();
1524 pitch_also_in_chords:
1530 PITCH embedded_scm {
1532 if (!unsmob_pitch ($2)) {
1533 THIS->parser_error (_f ("Expecting musical-pitch value", 3));
1534 $$ = Pitch ().smobbed_copy ();
1540 DURATION embedded_scm {
1542 if (!unsmob_duration ($2))
1544 THIS->parser_error (_ ("Must have duration object"));
1545 $$ = Duration ().smobbed_copy ();
1552 if (!THIS->lexer_->lyric_state_b ())
1553 THIS->parser_error (_ ("Have to be in Lyric mode for lyrics"));
1554 $$ = MY_MAKE_MUSIC("ExtenderEvent");
1560 if (!THIS->lexer_->lyric_state_b ())
1561 THIS->parser_error (_ ("Have to be in Lyric mode for lyrics"));
1562 $$ = MY_MAKE_MUSIC("HyphenEvent");
1567 close_event_parens {
1569 dynamic_cast<Music *> ($$)->set_mus_property ("span-direction", gh_int2scm (START))
1576 Music * s= MY_MAKE_MUSIC("SlurEvent");
1578 s->set_spot (THIS->here_input());
1581 Music * s= MY_MAKE_MUSIC("PhrasingSlurEvent");
1583 s->set_spot (THIS->here_input());
1586 Music *s =MY_MAKE_MUSIC("CrescendoEvent");
1588 s->set_spot (THIS->here_input());
1591 Music *s =MY_MAKE_MUSIC("DecrescendoEvent");
1593 s->set_spot (THIS->here_input());
1601 dynamic_cast<Music *> ($$)->set_mus_property ("span-direction", gh_int2scm (STOP))
1608 Music *s = MY_MAKE_MUSIC("CrescendoEvent");
1609 s->set_spot (THIS->here_input());
1614 Music * s= MY_MAKE_MUSIC("SlurEvent");
1616 s->set_spot (THIS->here_input());
1620 Music * s= MY_MAKE_MUSIC("PhrasingSlurEvent");
1622 s->set_mus_property ("span-type", scm_makfrom0str ( "phrasing-slur"));
1623 s->set_spot (THIS->here_input());
1629 Music *t = MY_MAKE_MUSIC("TextScriptEvent");
1630 t->set_mus_property ("text", $1);
1631 t->set_spot (THIS->here_input ());
1635 Music *t = MY_MAKE_MUSIC("TextScriptEvent");
1636 t->set_mus_property ("text", $1);
1637 t->set_spot (THIS->here_input ());
1641 Music *t = MY_MAKE_MUSIC("TextScriptEvent");
1642 t->set_mus_property ("text", $1);
1643 t->set_spot (THIS->here_input ());
1647 Music * t = MY_MAKE_MUSIC("FingerEvent");
1648 t->set_mus_property ("digit", gh_int2scm ($1));
1649 t->set_spot (THIS->here_input ());
1654 script_abbreviation:
1656 $$ = scm_makfrom0str ("Hat");
1659 $$ = scm_makfrom0str ("Plus");
1662 $$ = scm_makfrom0str ("Dash");
1665 $$ = scm_makfrom0str ("Bar");
1668 $$ = scm_makfrom0str ("Larger");
1671 $$ = scm_makfrom0str ("Dot");
1674 $$ = scm_makfrom0str ("Underscore");
1681 | '-' { $$ = CENTER; }
1688 | pre_events open_event {
1689 $$ = gh_cons ($2->self_scm(), $$);
1690 scm_gc_unprotect_object ($2->self_scm());
1701 multiplied_duration {
1704 | verbose_duration {
1709 optional_notemode_duration:
1711 Duration dd = THIS->default_duration_;
1712 $$ = dd.smobbed_copy ();
1714 THIS->beam_check ($$);
1716 | multiplied_duration {
1718 THIS->default_duration_ = *unsmob_duration ($$);
1720 THIS->beam_check ($$);
1722 | verbose_duration {
1724 THIS->default_duration_ = *unsmob_duration ($$);
1729 bare_unsigned dots {
1731 if (!is_duration_b ($1))
1732 THIS->parser_error (_f ("not a duration: %d", $1));
1736 $$ = Duration (l, $2).smobbed_copy ();
1738 | DURATION_IDENTIFIER dots {
1739 Duration *d =unsmob_duration ($1);
1740 Duration k (d->duration_log (),d->dot_count () + $2);
1750 multiplied_duration:
1754 | multiplied_duration '*' bare_unsigned {
1755 $$ = unsmob_duration ($$)->compressed ( $3) .smobbed_copy ();
1757 | multiplied_duration '*' FRACTION {
1758 Rational m (gh_scm2int (ly_car ($3)), gh_scm2int (ly_cdr ($3)));
1760 $$ = unsmob_duration ($$)->compressed (m).smobbed_copy ();
1765 FRACTION { $$ = $1; }
1766 | UNSIGNED '/' UNSIGNED {
1767 $$ = scm_cons (gh_int2scm ($1), gh_int2scm ($3));
1785 | ':' bare_unsigned {
1786 if (!is_duration_b ($2))
1787 THIS->parser_error (_f ("not a duration: %d", $2));
1794 /*****************************************************************
1796 *****************************************************************/
1810 Music *bfr = MY_MAKE_MUSIC("BassFigureEvent");
1811 $$ = bfr->self_scm();
1812 scm_gc_unprotect_object ($$);
1815 Music *bfr = MY_MAKE_MUSIC("BassFigureEvent");
1816 $$ = bfr->self_scm();
1818 bfr->set_mus_property ("figure", gh_int2scm ($1));
1820 scm_gc_unprotect_object ($$);
1822 | bass_figure bass_mod {
1823 Music *m = unsmob_music ($1);
1825 SCM salter =m->get_mus_property ("alteration");
1826 int alter = gh_number_p ( salter) ? gh_scm2int (salter) : 0;
1827 m->set_mus_property ("alteration",
1828 gh_int2scm (alter + $2));
1830 m->set_mus_property ("alteration", gh_int2scm (0));
1838 unsmob_music ($$)->set_mus_property ("bracket-start", SCM_BOOL_T);
1843 | br_bass_figure ']' {
1845 unsmob_music ($1)->set_mus_property ("bracket-stop", SCM_BOOL_T);
1853 | figure_list br_bass_figure {
1854 $$ = scm_cons ($2, $1);
1859 FIGURE_OPEN figure_list FIGURE_CLOSE {
1860 Music * m = MY_MAKE_MUSIC("EventChord");
1861 $2 = scm_reverse_x ($2, SCM_EOL);
1862 m->set_mus_property ("elements", $2);
1863 $$ = m->self_scm ();
1874 pitch exclamations questions optional_notemode_duration optional_rest {
1876 Input i = THIS->pop_spot ();
1877 if (!THIS->lexer_->note_state_b ())
1878 THIS->parser_error (_ ("Have to be in Note mode for notes"));
1882 n = MY_MAKE_MUSIC("RestEvent");
1884 n = MY_MAKE_MUSIC("NoteEvent");
1886 n->set_mus_property ("pitch", $1);
1887 n->set_mus_property ("duration", $4);
1891 n->set_mus_property ("cautionary", SCM_BOOL_T);
1892 if ($2 % 2 || $3 % 2)
1893 n->set_mus_property ("force-accidental", SCM_BOOL_T);
1895 Music *v = MY_MAKE_MUSIC("EventChord");
1896 v->set_mus_property ("elements", scm_list_n (n->self_scm (), SCM_UNDEFINED));
1897 scm_gc_unprotect_object (n->self_scm());
1903 | figure_spec optional_notemode_duration {
1904 Music * m = unsmob_music ($1);
1905 Input i = THIS->pop_spot ();
1907 for (SCM s = m->get_mus_property ("elements"); gh_pair_p (s); s = ly_cdr (s))
1909 unsmob_music (ly_car (s))->set_mus_property ("duration", $2);
1913 | RESTNAME optional_notemode_duration {
1915 Input i = THIS->pop_spot ();
1917 if (ly_scm2string ($1) =="s") {
1919 ev = MY_MAKE_MUSIC("SkipEvent");
1922 ev = MY_MAKE_MUSIC("RestEvent");
1925 ev->set_mus_property ("duration" ,$2);
1927 Music * velt = MY_MAKE_MUSIC("EventChord");
1928 velt->set_mus_property ("elements", scm_list_n (ev->self_scm (),SCM_UNDEFINED));
1933 | MULTI_MEASURE_REST optional_notemode_duration {
1938 proc = scm_c_eval_string ("make-multi-measure-rest");
1940 SCM mus = scm_call_2 (proc, $2,
1941 make_input (THIS->here_input()));
1942 scm_gc_protect_object (mus);
1943 $$ = unsmob_music (mus);
1945 | STRING optional_notemode_duration {
1946 Input i = THIS->pop_spot ();
1948 Music * lreq = MY_MAKE_MUSIC("LyricEvent");
1949 lreq->set_mus_property ("text", $1);
1950 lreq->set_mus_property ("duration",$2);
1952 Music * velt = MY_MAKE_MUSIC("EventChord");
1953 velt->set_mus_property ("elements", scm_list_n (lreq->self_scm (), SCM_UNDEFINED));
1960 if (!THIS->lexer_->chord_state_b ())
1961 THIS->parser_error (_ ("Have to be in Chord mode for chords"));
1968 steno_tonic_pitch optional_notemode_duration chord_additions chord_subtractions chord_inversion chord_bass {
1969 $$ = Chord::get_chord ($1, $3, $4, $5, $6, $2);
1970 $$->set_spot (THIS->here_input ());
1977 | CHORD_COLON chord_notes {
1986 | chord_notes '.' chord_step {
1987 $$ = gh_append2 ($$, $3);
1995 | CHORD_CARET chord_notes {
2005 | CHORD_SLASH steno_tonic_pitch {
2014 | CHORD_BASS steno_tonic_pitch {
2021 $$ = scm_cons ($1, SCM_EOL);
2023 | CHORDMODIFIER_PITCH {
2024 $$ = scm_cons (unsmob_pitch ($1)->smobbed_copy (), SCM_EOL);
2026 | CHORDMODIFIER_PITCH chord_note { /* Ugh. */
2027 $$ = scm_list_n (unsmob_pitch ($1)->smobbed_copy (),
2035 m.notename_ = ($1 - 1) % 7;
2036 m.octave_ = $1 > 7 ? 1 : 0;
2039 $$ = m.smobbed_copy ();
2041 | bare_unsigned '+' {
2043 m.notename_ = ($1 - 1) % 7;
2044 m.octave_ = $1 > 7 ? 1 : 0;
2048 $$ = m.smobbed_copy ();
2050 | bare_unsigned CHORD_MINUS {
2052 m.notename_ = ($1 - 1) % 7;
2053 m.octave_ = $1 > 7 ? 1 : 0;
2056 $$ = m.smobbed_copy ();
2064 number_expression '+' number_term {
2065 $$ = scm_sum ($1, $3);
2067 | number_expression '-' number_term {
2068 $$ = scm_difference ($1, $3);
2077 | number_factor '*' number_factor {
2078 $$ = scm_product ($1, $3);
2080 | number_factor '/' number_factor {
2081 $$ = scm_divide ($1, $3);
2086 '-' number_factor { /* %prec UNARY_MINUS */
2087 $$ = scm_difference ($2, SCM_UNDEFINED);
2095 $$ = gh_int2scm ($1);
2100 | NUMBER_IDENTIFIER {
2103 | REAL NUMBER_IDENTIFIER {
2104 $$ = gh_double2scm (gh_scm2double ($1) * gh_scm2double ($2));
2106 | UNSIGNED NUMBER_IDENTIFIER {
2107 $$ = gh_double2scm ($1 * gh_scm2double ($2));
2123 if (scm_integer_p ($1) == SCM_BOOL_T)
2125 int k = gh_scm2int ($1);
2129 THIS->parser_error (_ ("need integer number arg"));
2143 | STRING_IDENTIFIER {
2146 | string '+' string {
2147 $$ = scm_string_append (scm_list_n ($1, $3, SCM_UNDEFINED));
2154 | exclamations '!' { $$ ++; }
2159 | questions '?' { $$ ++; }
2166 { THIS->lexer_->push_markup_state (); }
2169 THIS->lexer_->pop_state ();
2177 simple = scm_c_eval_string ("simple-markup");
2179 $$ = scm_list_n (simple, $1, SCM_UNDEFINED);
2181 | MARKUP_HEAD_MARKUP0 markup {
2182 $$ = scm_list_n ($1, $2, SCM_UNDEFINED);
2184 | MARKUP_HEAD_SCM0_MARKUP1 SCM_T markup {
2185 $$ = scm_list_n ($1, $2, $3, SCM_UNDEFINED);
2190 | MARKUP_HEAD_LIST0 markup_list {
2191 $$ = scm_list_n ($1,$2, SCM_UNDEFINED);
2193 | MARKUP_HEAD_SCM0 embedded_scm {
2194 $$ = scm_list_n ($1, $2, SCM_UNDEFINED);
2196 | MARKUP_HEAD_SCM0_SCM1_MARKUP2 embedded_scm embedded_scm markup {
2197 $$ = scm_list_n ($1, $2, $3, $4, SCM_UNDEFINED);
2199 | MARKUP_IDENTIFIER {
2206 '<' markup_list_body '>' { $$ = scm_reverse_x ($2, SCM_EOL); }
2210 '{' markup_list_body '}' {
2213 line = scm_c_eval_string ("line-markup");
2215 $$ = scm_list_n (line, scm_reverse_x ($2, SCM_EOL), SCM_UNDEFINED);
2220 /**/ { $$ = SCM_EOL; }
2221 | markup_list_body markup {
2222 $$ = gh_cons ($2, $1) ;
2230 My_lily_parser::set_yydebug (bool )
2237 extern My_lily_parser * current_parser;
2240 My_lily_parser::do_yyparse ()
2242 current_parser = this;;
2243 yyparse ((void*)this);
2248 Should make this optional? It will also complain when you do
2252 which is entirely legitimate.
2254 Or we can scrap it. Barchecks should detect wrong durations, and
2255 skipTypesetting speeds it up a lot.
2259 My_lily_parser::beam_check (SCM dur)
2261 Duration *d = unsmob_duration (dur);
2262 if (unsmob_music (last_beam_start_) && d->duration_log () <= 2)
2264 Music * m = unsmob_music (last_beam_start_);
2265 m->origin ()->warning (_("Suspect duration found following this beam"));
2267 last_beam_start_ = SCM_EOL;
2275 return gh_pair_p (x)
2276 && SCM_BOOL_F != scm_object_property (gh_car (x), ly_symbol2scm ("markup-signature"));
2279 It is a little strange, to have this function in this file, but
2280 otherwise, we have to import music classes into the lexer.
2284 My_lily_lexer::try_special_identifiers (SCM * destination, SCM sid)
2286 if (gh_string_p (sid)) {
2288 return STRING_IDENTIFIER;
2289 } else if (gh_number_p (sid)) {
2291 return NUMBER_IDENTIFIER;
2292 } else if (unsmob_translator_def (sid)) {
2293 *destination = unsmob_translator_def (sid)->clone_scm();
2294 return TRANSLATOR_IDENTIFIER;
2295 } else if (unsmob_score (sid)) {
2296 Score *sc = new Score (*unsmob_score (sid));
2297 *destination =sc->self_scm ();
2298 return SCORE_IDENTIFIER;
2299 } else if (Music * mus =unsmob_music (sid)) {
2300 *destination = unsmob_music (sid)->clone ()->self_scm();
2301 unsmob_music (*destination)->
2302 set_mus_property ("origin", make_input (last_input_));
2303 return dynamic_cast<Event*> (mus)
2304 ? EVENT_IDENTIFIER : MUSIC_IDENTIFIER;
2305 } else if (unsmob_duration (sid)) {
2306 *destination = unsmob_duration (sid)->smobbed_copy();
2307 return DURATION_IDENTIFIER;
2308 } else if (unsmob_music_output_def (sid)) {
2309 Music_output_def *p = unsmob_music_output_def (sid);
2312 *destination = p->self_scm();
2313 return MUSIC_OUTPUT_DEF_IDENTIFIER;
2314 } else if (markup_p (sid)) {
2316 return MARKUP_IDENTIFIER;