1 %{ // -*-Fundamental-*-
4 parser.yy -- Bison/C++ parser for lilypond
6 source file of the GNU LilyPond music typesetter
8 (c) 1997--2001 Han-Wen Nienhuys <hanwen@cs.uu.nl>
9 Jan Nieuwenhuizen <janneke@gnu.org>
13 Two shift/reduce problems:
20 the rules for who is protecting what are very shady. TODO: uniformise
28 #include "translator-def.hh"
29 #include "lily-guile.hh"
31 #include "my-lily-lexer.hh"
32 #include "paper-def.hh"
33 #include "midi-def.hh"
35 #include "file-path.hh"
37 #include "dimensions.hh"
38 #include "my-lily-parser.hh"
40 #include "input-file-results.hh"
42 #include "lilypond-input-version.hh"
43 #include "scm-hash.hh"
44 #include "auto-change-iterator.hh"
46 #include "ly-modules.hh"
47 #include "music-sequence.hh"
48 #include "input-smob.hh"
52 regular_identifier_b (SCM id)
54 String str = ly_scm2string (id);
55 char const *s = str.to_str0 () ;
60 v = v && isalpha (*s);
71 return t && t == 1 << intlog2 (t);
75 set_music_properties (Music *p, SCM a)
77 for (SCM k = a; gh_pair_p (k); k = ly_cdr (k))
79 p->internal_set_mus_property (ly_caar (k), ly_cdar (k));
85 #define MY_MAKE_MUSIC(x) make_music_by_name (ly_symbol2scm (x))
88 set_property_music (SCM sym, SCM value)
90 Music * p = MY_MAKE_MUSIC("PropertySet");
91 p->set_mus_property ("symbol", sym);
92 p->set_mus_property ("value", value);
97 make_span_req (SCM name)
101 proc = scm_c_eval_string ("old-span-event->event");
102 SCM m = scm_call_1 (proc, name);
103 scm_gc_protect_object (m);
104 return unsmob_music (m);
107 // needed for bison.simple's malloc () and free ()
109 // #include <malloc.h>
114 #define YYERROR_VERBOSE 1
116 My_lily_parser* my_lily_parser;
117 #define YYPARSE_PARAM my_lily_parser
118 #define YYLEX_PARAM my_lily_parser
120 ((My_lily_parser *) my_lily_parser)
122 #define yyerror THIS->parser_error
126 /* We use SCMs to do strings, because it saves us the trouble of
127 deleting them. Let's hope that a stack overflow doesnt trigger a move
128 of the parse stack onto the heap. */
133 Link_array<Music> *reqvec;
135 String *string; // needed by the lexer as temporary scratch area.
138 Scheme_hash_table *scmhash;
139 Music_output_def * outputdef;
146 yylex (YYSTYPE *s, void * v)
148 My_lily_parser *pars = (My_lily_parser*) v;
149 My_lily_lexer * lex = pars->lexer_;
151 lex->lexval = (void*) s;
152 lex->prepare_for_next_token();
153 return lex->yylex ();
161 /* tokens which are not keywords */
170 %token CHORDMODIFIERS
178 %token GROBDESCRIPTIONS
184 %token FIGURES FIGURE_OPEN FIGURE_CLOSE
185 %token FIGURE_BRACKET_CLOSE FIGURE_BRACKET_OPEN
195 %token MULTI_MEASURE_REST
208 %token OVERRIDE SET REVERT
221 %token COMMANDSPANREQUEST
223 %token OUTPUTPROPERTY
234 %token E_CHAR E_EXCLAMATION E_SMALLER E_BIGGER E_OPEN E_CLOSE
235 %token E_LEFTSQUARE E_RIGHTSQUARE E_TILDE
237 %token <i> E_UNSIGNED
238 %token CHORD_BASS CHORD_COLON CHORD_MINUS CHORD_CARET CHORD_SLASH
241 %type <i> exclamations questions dots optional_rest
242 %type <i> bass_number bass_mod
243 %type <scm> br_bass_figure bass_figure figure_list figure_spec
245 %token <scm> NOTENAME_PITCH
246 %token <scm> TONICNAME_PITCH
247 %token <scm> CHORDMODIFIER_PITCH
248 %token <scm> DURATION_IDENTIFIER
249 %token <scm> FRACTION
250 %token <id> IDENTIFIER
253 %token <scm> SCORE_IDENTIFIER
254 %token <scm> MUSIC_OUTPUT_DEF_IDENTIFIER
256 %token <scm> NUMBER_IDENTIFIER
257 %token <scm> EVENT_IDENTIFIER
258 %token <scm> MUSIC_IDENTIFIER TRANSLATOR_IDENTIFIER
259 %token <scm> STRING_IDENTIFIER SCM_IDENTIFIER
260 %token <scm> RESTNAME
266 %type <outputdef> output_def
267 %type <scm> lilypond_header lilypond_header_body
268 %type <music> open_event_parens close_event_parens open_event close_event
269 %type <music> event_with_dir event_that_take_dir verbose_event
270 %type <i> sub_quotes sup_quotes
271 %type <music> simple_element event_chord command_element Simple_music Composite_music
272 %type <music> Repeated_music
273 %type <scm> Alternative_music
274 %type <i> tremolo_type
275 %type <i> bare_int bare_unsigned
277 %type <scm> identifier_init
279 %type <scm> steno_duration optional_notemode_duration multiplied_duration
280 %type <scm> verbose_duration
282 %type <reqvec> pre_events post_events
283 %type <music> gen_text_def
284 %type <scm> steno_pitch pitch absolute_pitch
285 %type <scm> explicit_pitch steno_tonic_pitch
287 %type <scm> chord_additions chord_subtractions chord_notes chord_step
289 %type <scm> chord_note chord_inversion chord_bass
290 %type <scm> duration_length fraction
292 %type <scm> embedded_scm scalar
293 %type <music> Music Sequential_music Simultaneous_music
294 %type <music> relative_music re_rhythmed_music part_combined_music
295 %type <music> property_def translator_change simple_property_def
296 %type <scm> Music_list
297 %type <outputdef> music_output_def_body
298 %type <music> shorthand_command_req
299 %type <music> post_event
300 %type <music> command_req verbose_command_req
301 %type <music> extender_req
302 %type <music> hyphen_req
303 %type <music> string_event
304 %type <scm> string bare_number number_expression number_term number_factor
306 %type <score> score_block score_body
308 %type <scm> translator_spec_block translator_spec_body
309 %type <music> tempo_event
310 %type <scm> notenames_body notenames_block chordmodifiers_block
311 %type <scm> script_abbreviation
317 /* We don't assign precedence to / and *, because we might need varied
318 prec levels in different prods */
324 lilypond: /* empty */
325 | lilypond toplevel_expression {}
326 | lilypond assignment { }
328 THIS->error_level_ = 1;
331 THIS->error_level_ = 1;
337 THIS->lexer_->pitchname_tab_ = $1;
339 | chordmodifiers_block {
340 THIS->lexer_->chordmodifier_tab_ = $1;
343 THIS->input_file_->header_ = $1;
346 THIS->input_file_->scores_.push ($1);
349 if (dynamic_cast<Paper_def*> ($1))
350 THIS->lexer_->set_identifier (scm_makfrom0str ("$defaultpaper"), $1->self_scm ());
351 else if (dynamic_cast<Midi_def*> ($1))
352 THIS->lexer_->set_identifier (scm_makfrom0str ("$defaultmidi"), $1->self_scm ());
362 chordmodifiers_block:
363 CHORDMODIFIERS notenames_body { $$ = $2; }
367 PITCHNAMES notenames_body { $$ = $2; }
372 int i = scm_ilength ($1);
374 SCM tab = scm_make_vector (gh_int2scm (i), SCM_EOL);
375 for (SCM s = $1; gh_pair_p (s); s = ly_cdr (s)) {
376 SCM pt = ly_cdar (s);
377 if (!unsmob_pitch (pt))
378 THIS->parser_error ("Need pitch object.");
380 scm_hashq_set_x (tab, ly_caar (s), pt);
387 lilypond_header_body:
389 $$ = ly_make_anonymous_module ();
390 THIS->lexer_->add_scope ($$);
392 | lilypond_header_body assignment {
398 HEADER '{' lilypond_header_body '}' {
399 $$ = THIS->lexer_-> remove_scope();
411 /* cont */ '=' identifier_init {
414 Should find generic way of associating input with objects.
416 Input ip = THIS->pop_spot ();
418 if (! regular_identifier_b ($1))
420 ip.warning (_ ("Identifier should have alphabetic characters only"));
423 THIS->lexer_->set_identifier ($1, $4);
426 TODO: devise standard for protection in parser.
428 The parser stack lives on the C-stack, which means that
429 all objects can be unprotected as soon as they're here.
440 $$ = $1->self_scm ();
441 scm_gc_unprotect_object ($$);
444 $$ = $1->self_scm ();
445 scm_gc_unprotect_object ($$);
447 | translator_spec_block {
451 $$ = $1->self_scm ();
452 scm_gc_unprotect_object ($$);
455 $$ = $1->self_scm ();
456 scm_gc_unprotect_object ($$);
461 | number_expression {
472 translator_spec_block:
473 TRANSLATOR '{' translator_spec_body '}'
479 translator_spec_body:
480 TRANSLATOR_IDENTIFIER {
482 unsmob_translator_def ($$)-> set_spot (THIS->here_input ());
485 $$ = Translator_def::make_scm ();
486 Translator_def*td = unsmob_translator_def ($$);
487 td->translator_group_type_ = $2;
488 td->set_spot (THIS->here_input ());
490 | translator_spec_body STRING '=' embedded_scm {
491 unsmob_translator_def ($$)->add_property_assign ($2, $4);
493 | translator_spec_body STRING OVERRIDE embedded_scm '=' embedded_scm {
494 unsmob_translator_def ($$)
495 ->add_push_property (scm_string_to_symbol ($2), $4, $6);
497 | translator_spec_body STRING SET embedded_scm '=' embedded_scm {
498 unsmob_translator_def ($$)
499 ->add_push_property (scm_string_to_symbol ($2), $4, $6);
501 | translator_spec_body STRING REVERT embedded_scm {
502 unsmob_translator_def ($$)->add_pop_property (
503 scm_string_to_symbol ($2), $4);
505 | translator_spec_body NAME STRING {
506 unsmob_translator_def ($$)->type_name_ = $3;
508 | translator_spec_body CONSISTS STRING {
509 unsmob_translator_def ($$)->add_element ($3);
511 | translator_spec_body ALIAS STRING {
512 Translator_def*td = unsmob_translator_def ($$);
513 td->type_aliases_ = scm_cons ($3, td->type_aliases_);
515 | translator_spec_body GROBDESCRIPTIONS embedded_scm {
516 Translator_def*td = unsmob_translator_def($$);
517 // td->add_property_assign (ly_symbol2scm ("allGrobDescriptions"), $3);
518 for (SCM p = $3; gh_pair_p (p); p = ly_cdr (p))
519 td->add_property_assign (scm_symbol_to_string (ly_caar (p)), ly_cdar (p));
521 | translator_spec_body CONSISTSEND STRING {
522 unsmob_translator_def ($$)->add_last_element ( $3);
524 | translator_spec_body ACCEPTS STRING {
525 unsmob_translator_def ($$)->set_acceptor ($3,true);
527 | translator_spec_body DENIES STRING {
528 unsmob_translator_def ($$)->set_acceptor ($3,false);
530 | translator_spec_body REMOVE STRING {
531 unsmob_translator_def ($$)->remove_element ($3);
542 /*cont*/ '{' score_body '}' {
545 if (!$$->defs_.size ())
547 Music_output_def *id =
548 unsmob_music_output_def (THIS->lexer_->lookup_identifier ("$defaultpaper"));
549 $$->add_output (id ? id->clone () : new Paper_def );
558 $$->set_spot (THIS->here_input ());
559 SCM m = $1->self_scm ();
560 scm_gc_unprotect_object (m);
565 SCM check_funcs = scm_c_eval_string ("toplevel-music-functions");
566 for (; gh_pair_p (check_funcs); check_funcs = gh_cdr (check_funcs))
567 m = gh_call1 (gh_car (check_funcs), m);
572 $$ = unsmob_score ($1);
573 $$->set_spot (THIS->here_input ());
575 | score_body lilypond_header {
578 | score_body output_def {
591 music_output_def_body '}' {
593 THIS-> lexer_-> remove_scope ();
597 music_output_def_body:
599 Music_output_def *id = unsmob_music_output_def (THIS->lexer_->lookup_identifier ("$defaultmidi"));
604 p = dynamic_cast<Midi_def*> (id->clone ());
609 THIS->lexer_->add_scope (p->scope_);
612 Music_output_def *id = unsmob_music_output_def (THIS->lexer_->lookup_identifier ("$defaultpaper"));
615 p = dynamic_cast<Paper_def*> (id->clone ());
619 THIS->lexer_->add_scope (p->scope_);
622 | PAPER '{' MUSIC_OUTPUT_DEF_IDENTIFIER {
623 Music_output_def * o = unsmob_music_output_def ($3);
626 THIS->lexer_->add_scope (o->scope_);
628 | MIDI '{' MUSIC_OUTPUT_DEF_IDENTIFIER {
629 Music_output_def * o = unsmob_music_output_def ($3);
632 THIS->lexer_->add_scope (o->scope_);
634 | music_output_def_body assignment {
637 | music_output_def_body translator_spec_block {
638 $$->assign_translator ($2);
640 | music_output_def_body tempo_event {
642 junk this ? there already is tempo stuff in
645 int m = gh_scm2int ( $2->get_mus_property ("metronome-count"));
646 Duration *d = unsmob_duration ($2->get_mus_property ("duration"));
647 Midi_def * md = dynamic_cast<Midi_def*> ($$);
649 md->set_tempo (d->get_length (), m);
651 | music_output_def_body error {
657 TEMPO steno_duration '=' bare_unsigned {
658 $$ = MY_MAKE_MUSIC("TempoEvent");
659 $$->set_mus_property ("duration", $2);
660 $$->set_mus_property ("metronome-count", gh_int2scm ( $4));
665 The representation of a list is the
669 to have efficient append.
671 Music_list: /* empty */ {
672 $$ = scm_cons (SCM_EOL, SCM_EOL);
676 SCM c = scm_cons ($2->self_scm (), SCM_EOL);
677 scm_gc_unprotect_object ($2->self_scm ()); /* UGH */
678 if (gh_pair_p (ly_cdr (s)))
679 gh_set_cdr_x (ly_cdr (s), c); /* append */
681 gh_set_car_x (s, c); /* set first cons */
682 gh_set_cdr_x (s, c) ; /* remember last cell */
698 | ALTERNATIVE '{' Music_list '}' {
704 REPEAT string bare_unsigned Music Alternative_music
708 SCM alts = gh_pair_p ($5) ? gh_car ($5) : SCM_EOL;
709 if (times < scm_ilength (alts)) {
710 unsmob_music (gh_car (alts))
711 ->origin ()->warning (
712 _("More alternatives than repeats. Junking excess alternatives."));
713 alts = ly_truncate_list (times, alts);
719 proc = scm_c_eval_string ("make-repeated-music");
721 SCM mus = scm_call_1 (proc, $2);
722 scm_gc_protect_object (mus); // UGH.
723 Music *r =unsmob_music (mus);
726 r-> set_mus_property ("element", beg->self_scm ());
727 scm_gc_unprotect_object (beg->self_scm ());
729 r->set_mus_property ("repeat-count", gh_int2scm (times >? 1));
731 r-> set_mus_property ("elements",alts);
732 if (gh_equal_p ($2, scm_makfrom0str ("tremolo")))
735 we can not get durations and other stuff correct down the line, so we have to
736 add to the duration log here.
738 SCM func = scm_primitive_eval (ly_symbol2scm ("shift-duration-log"));
740 gh_call3 (func, r->self_scm (), gh_int2scm(-intlog2 ($3*2/3)),gh_int2scm(1));
742 gh_call3 (func, r->self_scm (), gh_int2scm(-intlog2 ($3)), gh_int2scm(0));
744 r->set_spot (*$4->origin ());
751 SEQUENTIAL '{' Music_list '}' {
752 $$ = MY_MAKE_MUSIC("SequentialMusic");
753 $$->set_mus_property ("elements", ly_car ($3));
754 $$->set_spot(THIS->here_input());
756 | '{' Music_list '}' {
757 $$ = MY_MAKE_MUSIC("SequentialMusic");
758 $$->set_mus_property ("elements", ly_car ($2));
759 $$->set_spot(THIS->here_input());
764 SIMULTANEOUS '{' Music_list '}'{
765 $$ = MY_MAKE_MUSIC("SimultaneousMusic");
766 $$->set_mus_property ("elements", ly_car ($3));
767 $$->set_spot(THIS->here_input());
770 | '<' Music_list '>' {
771 $$ = MY_MAKE_MUSIC("SimultaneousMusic");
772 $$->set_mus_property ("elements", ly_car ($2));
773 $$->set_spot(THIS->here_input());
778 event_chord { $$ = $1; }
779 | OUTPUTPROPERTY embedded_scm embedded_scm '=' embedded_scm {
781 if (!gh_symbol_p ($3))
783 THIS->parser_error (_ ("Second argument must be a symbol"));
785 /* Should check # args */
786 if (!gh_procedure_p (pred))
788 THIS->parser_error (_ ("First argument must be a procedure taking one argument"));
791 Music*m = MY_MAKE_MUSIC("OutputPropertySetMusic");
792 m->set_mus_property ("predicate", pred);
793 m->set_mus_property ("grob-property", $3);
794 m->set_mus_property ("grob-value", $5);
799 $$ = unsmob_music ($1);
807 CONTEXT STRING Music {
808 Music*csm =MY_MAKE_MUSIC("ContextSpeccedMusic");
810 csm->set_mus_property ("element", $3->self_scm ());
811 scm_gc_unprotect_object ($3->self_scm ());
813 csm->set_mus_property ("context-type",$2);
814 csm->set_mus_property ("context-id", scm_makfrom0str (""));
818 | AUTOCHANGE STRING Music {
819 Music*chm = MY_MAKE_MUSIC("AutoChangeMusic");
820 chm->set_mus_property ("element", $3->self_scm ());
821 chm->set_mus_property ("iterator-ctor", Auto_change_iterator::constructor_proc);
823 scm_gc_unprotect_object ($3->self_scm ());
824 chm->set_mus_property ("what", $2);
827 chm->set_spot (*$3->origin ());
832 The other version is for easier debugging of
833 Sequential_music_iterator in combination with grace notes.
836 SCM start = THIS->lexer_->lookup_identifier ("startGraceMusic");
837 SCM stop = THIS->lexer_->lookup_identifier ("stopGraceMusic");
838 Music *startm = unsmob_music (start);
839 Music *stopm = unsmob_music (stop);
843 stopm = stopm->clone ();
844 ms = scm_cons (stopm->self_scm (), ms);
845 scm_gc_unprotect_object (stopm->self_scm ());
847 ms = scm_cons ($2->self_scm (), ms);
848 scm_gc_unprotect_object ($2->self_scm());
850 startm = startm->clone ();
851 ms = scm_cons (startm->self_scm () , ms);
852 scm_gc_unprotect_object (startm->self_scm ());
856 Music* seq = MY_MAKE_MUSIC("SequentialMusic");
857 seq->set_mus_property ("elements", ms);
860 $$ = MY_MAKE_MUSIC("GraceMusic");
861 $$->set_mus_property ("element", seq->self_scm ());
862 scm_gc_unprotect_object (seq->self_scm ());
864 $$ = MY_MAKE_MUSIC("GraceMusic");
865 $$->set_mus_property ("element", $2->self_scm ());
866 scm_gc_unprotect_object ($2->self_scm ());
869 | CONTEXT string '=' string Music {
870 Music * csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
872 csm->set_mus_property ("element", $5->self_scm ());
873 scm_gc_unprotect_object ($5->self_scm ());
875 csm->set_mus_property ("context-type", $2);
876 csm->set_mus_property ("context-id", $4);
887 int n = gh_scm2int (ly_car ($3)); int d = gh_scm2int (ly_cdr ($3));
889 $$= MY_MAKE_MUSIC("TimeScaledMusic");
890 $$->set_spot (THIS->pop_spot ());
893 $$->set_mus_property ("element", mp->self_scm ());
894 scm_gc_unprotect_object (mp->self_scm ());
895 $$->set_mus_property ("numerator", gh_int2scm (n));
896 $$->set_mus_property ("denominator", gh_int2scm (d));
897 $$->compress (Moment (Rational (n,d)));
900 | Repeated_music { $$ = $1; }
901 | Simultaneous_music { $$ = $1; }
902 | Sequential_music { $$ = $1; }
903 | TRANSPOSE pitch Music {
904 $$ = MY_MAKE_MUSIC("TransposedMusic");
906 Pitch pit = *unsmob_pitch ($2);
909 $$->set_mus_property ("element", p->self_scm ());
910 scm_gc_unprotect_object (p->self_scm ());
912 | TRANSPOSE steno_tonic_pitch Music {
913 $$ = MY_MAKE_MUSIC("TransposedMusic");
915 Pitch pit = *unsmob_pitch ($2);
918 $$->set_mus_property ("element", p->self_scm ());
919 scm_gc_unprotect_object (p->self_scm ());
922 | APPLY embedded_scm Music {
923 SCM ret = gh_call1 ($2, $3->self_scm ());
924 Music *m = unsmob_music (ret);
926 THIS->parser_error ("\\apply must return a Music");
927 m = MY_MAKE_MUSIC("Music");
932 { THIS->lexer_->push_note_state (); }
935 THIS->lexer_->pop_state ();
938 { THIS->lexer_->push_figuredbass_state (); }
941 Music * chm = MY_MAKE_MUSIC("UntransposableMusic");
942 chm->set_mus_property ("element", $3->self_scm ());
944 scm_gc_unprotect_object ($3->self_scm());
946 THIS->lexer_->pop_state ();
949 { THIS->lexer_->push_chord_state (); }
952 Music * chm = MY_MAKE_MUSIC("UnrelativableMusic");
953 chm->set_mus_property ("element", $3->self_scm ());
954 scm_gc_unprotect_object ($3->self_scm());
957 THIS->lexer_->pop_state ();
960 { THIS->lexer_->push_lyric_state (); }
964 THIS->lexer_->pop_state ();
966 | relative_music { $$ = $1; }
967 | re_rhythmed_music { $$ = $1; }
968 | part_combined_music { $$ = $1; }
972 RELATIVE absolute_pitch Music {
974 Pitch pit = *unsmob_pitch ($2);
975 $$ = MY_MAKE_MUSIC("RelativeOctaveMusic");
977 $$->set_mus_property ("element", p->self_scm ());
978 scm_gc_unprotect_object (p->self_scm ());
980 $$->set_mus_property ("last-pitch", p->to_relative_octave (pit).smobbed_copy ());
986 ADDLYRICS Music Music {
987 Music*l =MY_MAKE_MUSIC("LyricCombineMusic");
988 l->set_mus_property ("elements", gh_list ($2->self_scm (), $3->self_scm (), SCM_UNDEFINED));
989 scm_gc_unprotect_object ($3->self_scm ());
990 scm_gc_unprotect_object ($2->self_scm ());
996 PARTCOMBINE STRING Music Music {
997 Music * p= MY_MAKE_MUSIC("PartCombineMusic");
998 p->set_mus_property ("what", $2);
999 p->set_mus_property ("elements", gh_list ($3->self_scm (),$4->self_scm (), SCM_UNDEFINED));
1001 scm_gc_unprotect_object ($3->self_scm ());
1002 scm_gc_unprotect_object ($4->self_scm ());
1009 TRANSLATOR STRING '=' STRING {
1010 Music*t= MY_MAKE_MUSIC("TranslatorChange");
1011 t-> set_mus_property ("change-to-type", $2);
1012 t-> set_mus_property ("change-to-id", $4);
1015 $$->set_spot (THIS->here_input ());
1021 | ONCE simple_property_def {
1023 SCM e = $2->get_mus_property ("element");
1024 unsmob_music (e)->set_mus_property ("once", SCM_BOOL_T);
1028 simple_property_def:
1029 PROPERTY STRING '.' STRING '=' scalar {
1030 Music *t = set_property_music (scm_string_to_symbol ($4), $6);
1031 Music *csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
1033 csm->set_mus_property ("element", t->self_scm ());
1034 scm_gc_unprotect_object (t->self_scm ());
1037 $$->set_spot (THIS->here_input ());
1039 csm-> set_mus_property ("context-type", $2);
1041 | PROPERTY STRING '.' STRING UNSET {
1043 Music *t = MY_MAKE_MUSIC("PropertyUnset");
1044 t->set_mus_property ("symbol", scm_string_to_symbol ($4));
1046 Music *csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
1047 csm->set_mus_property ("element", t->self_scm ());
1048 scm_gc_unprotect_object (t->self_scm ());
1051 $$->set_spot (THIS->here_input ());
1053 csm-> set_mus_property ("context-type", $2);
1055 | PROPERTY STRING '.' STRING SET embedded_scm '=' embedded_scm {
1057 = gh_equal_p ($4, scm_makfrom0str ("autoBeamSettings"));
1058 bool itc = internal_type_checking_global_b;
1059 Music *t = MY_MAKE_MUSIC("OverrideProperty");
1060 t->set_mus_property ("symbol", scm_string_to_symbol ($4));
1061 t->set_mus_property ("pop-first", SCM_BOOL_T);
1063 internal_type_checking_global_b = false;
1064 t->set_mus_property ("grob-property", $6);
1066 internal_type_checking_global_b = itc;
1067 t->set_mus_property ("grob-value", $8);
1069 Music *csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
1070 csm->set_mus_property ("element", t->self_scm ());
1071 scm_gc_unprotect_object (t->self_scm ());
1073 $$->set_spot (THIS->here_input ());
1075 csm-> set_mus_property ("context-type", $2);
1077 | PROPERTY STRING '.' STRING OVERRIDE
1078 embedded_scm '=' embedded_scm
1084 = gh_equal_p ($4, scm_makfrom0str ("autoBeamSettings"));
1085 bool itc = internal_type_checking_global_b;
1087 Music *t = MY_MAKE_MUSIC("OverrideProperty");
1088 t->set_mus_property ("symbol", scm_string_to_symbol ($4));
1090 internal_type_checking_global_b = false;
1091 t->set_mus_property ("grob-property", $6);
1092 t->set_mus_property ("grob-value", $8);
1094 internal_type_checking_global_b = itc;
1096 Music *csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
1097 csm->set_mus_property ("element", t->self_scm ());
1098 scm_gc_unprotect_object (t->self_scm ());
1101 $$->set_spot (THIS->here_input ());
1103 csm-> set_mus_property ("context-type", $2);
1106 | PROPERTY STRING '.' STRING REVERT embedded_scm {
1107 Music *t = MY_MAKE_MUSIC("RevertProperty");
1109 = gh_equal_p ($4, scm_makfrom0str ("autoBeamSettings"));
1110 bool itc = internal_type_checking_global_b;
1112 t->set_mus_property ("symbol", scm_string_to_symbol ($4));
1114 internal_type_checking_global_b = false;
1115 t->set_mus_property ("grob-property", $6);
1117 internal_type_checking_global_b = itc;
1119 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);
1133 | bare_int { $$ = gh_int2scm ($1); }
1134 | embedded_scm { $$ = $1; }
1141 } /*cont */ simple_element post_events {
1142 Music_sequence *l = dynamic_cast<Music_sequence*> ($3);
1145 for (int i=0; i < $1->size (); i++) {
1146 Music * m = $1->elem (i);
1147 l->append_music (m);
1159 $$ = MY_MAKE_MUSIC("EventChord");
1160 $$->set_mus_property ("elements", scm_cons ($1->self_scm (), SCM_EOL));
1161 scm_gc_unprotect_object ($1->self_scm());
1163 $$-> set_spot (THIS->here_input ());
1164 $1-> set_spot (THIS->here_input ());
1167 Music *l = MY_MAKE_MUSIC("LigatureEvent");
1168 l->set_mus_property ("span-direction", gh_int2scm (START));
1169 l->set_spot (THIS->here_input ());
1171 $$ = MY_MAKE_MUSIC("EventChord");
1172 $$->set_mus_property ("elements", scm_cons (l->self_scm (), SCM_EOL));
1173 scm_gc_unprotect_object (l->self_scm());
1174 $$->set_spot (THIS->here_input ());
1177 Music *l = MY_MAKE_MUSIC("LigatureEvent");
1178 l->set_mus_property ("span-direction", gh_int2scm (STOP));
1179 l->set_spot (THIS->here_input ());
1181 $$ = MY_MAKE_MUSIC("EventChord");
1182 $$->set_mus_property ("elements", scm_cons (l->self_scm (), SCM_EOL));
1183 $$->set_spot (THIS->here_input ());
1184 scm_gc_unprotect_object (l->self_scm());
1188 $$ = MY_MAKE_MUSIC("VoiceSeparator");
1189 $$->set_spot (THIS->here_input ());
1193 $$ = MY_MAKE_MUSIC("BarCheck");
1194 $$->set_spot (THIS->here_input ());
1197 Music *t = set_property_music (ly_symbol2scm ("whichBar"), $2);
1199 Music *csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
1200 csm->set_mus_property ("element", t->self_scm ());
1201 scm_gc_unprotect_object (t->self_scm ());
1204 $$->set_spot (THIS->here_input ());
1206 csm->set_mus_property ("context-type", scm_makfrom0str ("Timing"));
1208 | PARTIAL duration_length {
1209 Moment m = - unsmob_duration ($2)->get_length ();
1210 Music * p = set_property_music (ly_symbol2scm ( "measurePosition"),m.smobbed_copy ());
1212 Music * sp = MY_MAKE_MUSIC("ContextSpeccedMusic");
1213 sp->set_mus_property ("element", p->self_scm ());
1214 scm_gc_unprotect_object (p->self_scm ());
1217 sp-> set_mus_property ("context-type", scm_makfrom0str ("Timing"));
1222 proc = scm_c_eval_string ("make-clef-set");
1224 SCM result = scm_call_1 (proc, $2);
1225 scm_gc_protect_object (result);
1226 $$ = unsmob_music (result);
1229 Music * p1 = set_property_music (ly_symbol2scm ( "timeSignatureFraction"), $2);
1231 int l = gh_scm2int (ly_car ($2));
1232 int o = gh_scm2int (ly_cdr ($2));
1234 Moment one_beat = Moment (1)/Moment (o);
1235 Moment len = Moment (l) * one_beat;
1238 Music *p2 = set_property_music (ly_symbol2scm ("measureLength"), len.smobbed_copy ());
1239 Music *p3 = set_property_music (ly_symbol2scm ("beatLength"), one_beat.smobbed_copy ());
1241 SCM list = scm_list_n (p1->self_scm (), p2->self_scm (), p3->self_scm(), SCM_UNDEFINED);
1242 Music *seq = MY_MAKE_MUSIC("SequentialMusic");
1243 seq->set_mus_property ("elements", list);
1246 Music * sp = MY_MAKE_MUSIC("ContextSpeccedMusic");
1247 sp->set_mus_property ("element", seq->self_scm ());
1249 scm_gc_unprotect_object (p3->self_scm ());
1250 scm_gc_unprotect_object (p2->self_scm ());
1251 scm_gc_unprotect_object (p1->self_scm ());
1252 scm_gc_unprotect_object (seq->self_scm ());
1256 sp-> set_mus_property ("context-type", scm_makfrom0str ( "Timing"));
1261 shorthand_command_req { $$ = $1; }
1262 | verbose_command_req { $$ = $1; }
1265 shorthand_command_req:
1273 $$ = MY_MAKE_MUSIC("TieEvent");
1276 Music *b= MY_MAKE_MUSIC("BeamEvent");
1277 b->set_mus_property ("span-direction", gh_int2scm (START))
1282 THIS->last_beam_start_ = b->self_scm ();
1285 Music *b= MY_MAKE_MUSIC("BeamEvent");
1286 b->set_mus_property ("span-direction", gh_int2scm (STOP));
1290 $$ = MY_MAKE_MUSIC("BreathingSignEvent");
1293 $$ = MY_MAKE_MUSIC("PorrectusEvent");
1297 verbose_command_req:
1298 COMMANDSPANREQUEST bare_int STRING {
1299 Music *sp = make_span_req ($3);
1300 sp->set_mus_property ("span-direction", gh_int2scm (Direction ($2)));
1301 sp->set_spot (THIS->here_input ());
1305 Music * m = MY_MAKE_MUSIC("MarkEvent");
1309 Music *m = MY_MAKE_MUSIC("MarkEvent");
1310 m->set_mus_property ("label", $2);
1314 Music * b = MY_MAKE_MUSIC("BreakEvent");
1316 if (!gh_number_p (s))
1319 b->set_mus_property ("penalty", s);
1320 b->set_spot (THIS->here_input ());
1323 | SKIP duration_length {
1324 Music * skip = MY_MAKE_MUSIC("SkipEvent");
1325 skip->set_mus_property ("duration", $2);
1333 Music *key= MY_MAKE_MUSIC("KeyChangeEvent");
1336 | KEY NOTENAME_PITCH SCM_IDENTIFIER {
1337 Music *key= MY_MAKE_MUSIC("KeyChangeEvent");
1339 key->set_mus_property ("pitch-alist", $3);
1340 ((Music*)key)->transpose (* unsmob_pitch ($2));
1347 $$ = new Link_array<Music>;
1349 | post_events post_event {
1350 $2->set_spot (THIS->here_input ());
1365 Music * s = MY_MAKE_MUSIC("StringNumberEvent");
1366 s->set_mus_property ("string-number", gh_int2scm($1));
1367 s->set_spot (THIS->here_input ());
1373 event_that_take_dir:
1378 | script_abbreviation {
1379 SCM s = THIS->lexer_->lookup_identifier ("dash" + ly_scm2string ($1));
1380 Music *a = MY_MAKE_MUSIC("ArticulationEvent");
1381 if (gh_string_p (s))
1382 a->set_mus_property ("articulation-type", s);
1383 else THIS->parser_error (_ ("Expecting string as script definition"));
1389 script_dir event_that_take_dir {
1390 $2->set_mus_property ("direction", gh_int2scm ($1));
1397 $$ = unsmob_music ($1);
1399 | SPANREQUEST bare_int STRING {
1400 Music * sp = make_span_req ($3);
1401 sp->set_mus_property ("span-direction", gh_int2scm ( $2));
1402 sp->set_spot (THIS->here_input ());
1406 Music * a = MY_MAKE_MUSIC("TremoloEvent");
1407 a->set_spot (THIS->here_input ());
1408 a->set_mus_property ("tremolo-type", gh_int2scm ($1));
1412 Music * a = MY_MAKE_MUSIC("ArticulationEvent");
1413 a->set_mus_property ("articulation-type", $2);
1414 a->set_spot (THIS->here_input ());
1419 duh, junk this syntax from the parser, if possible.
1422 Music *a = MY_MAKE_MUSIC("ArpeggioEvent");
1423 a->set_spot (THIS->here_input ());
1427 Music *g = MY_MAKE_MUSIC("GlissandoEvent");
1428 g->set_spot /* No pun intended */ (THIS->here_input ());
1455 | NOTENAME_PITCH sup_quotes {
1456 Pitch p = *unsmob_pitch ($1);
1458 $$ = p.smobbed_copy ();
1460 | NOTENAME_PITCH sub_quotes {
1461 Pitch p =* unsmob_pitch ($1);
1464 $$ = p.smobbed_copy ();
1477 | TONICNAME_PITCH sup_quotes {
1478 Pitch p = *unsmob_pitch ($1);
1480 $$ = p.smobbed_copy ();
1482 | TONICNAME_PITCH sub_quotes {
1483 Pitch p =* unsmob_pitch ($1);
1486 $$ = p.smobbed_copy ();
1501 PITCH embedded_scm {
1503 if (!unsmob_pitch ($2)) {
1504 THIS->parser_error (_f ("Expecting musical-pitch value", 3));
1505 $$ = Pitch ().smobbed_copy ();
1511 DURATION embedded_scm {
1513 if (!unsmob_duration ($2))
1515 THIS->parser_error (_ ("Must have duration object"));
1516 $$ = Duration ().smobbed_copy ();
1523 if (!THIS->lexer_->lyric_state_b ())
1524 THIS->parser_error (_ ("Have to be in Lyric mode for lyrics"));
1525 $$ = MY_MAKE_MUSIC("ExtenderEvent");
1531 if (!THIS->lexer_->lyric_state_b ())
1532 THIS->parser_error (_ ("Have to be in Lyric mode for lyrics"));
1533 $$ = MY_MAKE_MUSIC("HyphenEvent");
1538 close_event_parens {
1540 dynamic_cast<Music *> ($$)->set_mus_property ("span-direction", gh_int2scm (START))
1547 Music * s= MY_MAKE_MUSIC("SlurEvent");
1549 s->set_spot (THIS->here_input());
1552 Music * s= MY_MAKE_MUSIC("PhrasingSlurEvent");
1554 s->set_spot (THIS->here_input());
1557 Music *s =MY_MAKE_MUSIC("CrescendoEvent");
1559 s->set_spot (THIS->here_input());
1562 Music *s =MY_MAKE_MUSIC("DecrescendoEvent");
1564 s->set_spot (THIS->here_input());
1572 dynamic_cast<Music *> ($$)->set_mus_property ("span-direction", gh_int2scm (STOP))
1579 Music *s = MY_MAKE_MUSIC("CrescendoEvent");
1580 s->set_spot (THIS->here_input());
1585 Music * s= MY_MAKE_MUSIC("SlurEvent");
1587 s->set_spot (THIS->here_input());
1591 Music * s= MY_MAKE_MUSIC("PhrasingSlurEvent");
1593 s->set_mus_property ("span-type", scm_makfrom0str ( "phrasing-slur"));
1594 s->set_spot (THIS->here_input());
1600 Music *t = MY_MAKE_MUSIC("TextScriptEvent");
1601 t->set_mus_property ("text", $1);
1602 t->set_spot (THIS->here_input ());
1606 Music *t = MY_MAKE_MUSIC("TextScriptEvent");
1607 t->set_mus_property ("text", $1);
1608 t->set_spot (THIS->here_input ());
1612 String ds = to_string ($1);
1613 Music * t = MY_MAKE_MUSIC("TextScriptEvent");
1614 SCM finger = ly_symbol2scm ("finger");
1615 t->set_mus_property ("text", scm_makfrom0str (ds.to_str0 ()));
1616 t->set_mus_property ("text-type" , finger);
1617 t->set_spot (THIS->here_input ());
1622 script_abbreviation:
1624 $$ = scm_makfrom0str ("Hat");
1627 $$ = scm_makfrom0str ("Plus");
1630 $$ = scm_makfrom0str ("Dash");
1633 $$ = scm_makfrom0str ("Bar");
1636 $$ = scm_makfrom0str ("Larger");
1639 $$ = scm_makfrom0str ("Dot");
1642 $$ = scm_makfrom0str ("Underscore");
1649 | '-' { $$ = CENTER; }
1654 $$ = new Link_array<Music>;
1656 | pre_events open_event {
1668 multiplied_duration {
1671 | verbose_duration {
1676 optional_notemode_duration:
1678 Duration dd = THIS->default_duration_;
1679 $$ = dd.smobbed_copy ();
1681 THIS->beam_check ($$);
1683 | multiplied_duration {
1685 THIS->default_duration_ = *unsmob_duration ($$);
1687 THIS->beam_check ($$);
1689 | verbose_duration {
1691 THIS->default_duration_ = *unsmob_duration ($$);
1696 bare_unsigned dots {
1698 if (!is_duration_b ($1))
1699 THIS->parser_error (_f ("not a duration: %d", $1));
1703 $$ = Duration (l, $2).smobbed_copy ();
1705 | DURATION_IDENTIFIER dots {
1706 Duration *d =unsmob_duration ($1);
1707 Duration k (d->duration_log (),d->dot_count () + $2);
1717 multiplied_duration:
1721 | multiplied_duration '*' bare_unsigned {
1722 $$ = unsmob_duration ($$)->compressed ( $3) .smobbed_copy ();
1724 | multiplied_duration '*' FRACTION {
1725 Rational m (gh_scm2int (ly_car ($3)), gh_scm2int (ly_cdr ($3)));
1727 $$ = unsmob_duration ($$)->compressed (m).smobbed_copy ();
1732 FRACTION { $$ = $1; }
1733 | UNSIGNED '/' UNSIGNED {
1734 $$ = scm_cons (gh_int2scm ($1), gh_int2scm ($3));
1752 | ':' bare_unsigned {
1753 if (!is_duration_b ($2))
1754 THIS->parser_error (_f ("not a duration: %d", $2));
1773 Music *bfr = MY_MAKE_MUSIC("BassFigureEvent");
1774 $$ = bfr->self_scm();
1775 scm_gc_unprotect_object ($$);
1778 Music *bfr = MY_MAKE_MUSIC("BassFigureEvent");
1779 $$ = bfr->self_scm();
1781 bfr->set_mus_property ("figure", gh_int2scm ($1));
1783 scm_gc_unprotect_object ($$);
1785 | bass_figure bass_mod {
1786 Music *m = unsmob_music ($1);
1788 SCM salter =m->get_mus_property ("alteration");
1789 int alter = gh_number_p ( salter) ? gh_scm2int (salter) : 0;
1790 m->set_mus_property ("alteration",
1791 gh_int2scm (alter + $2));
1793 m->set_mus_property ("alteration", gh_int2scm (0));
1801 unsmob_music ($$)->set_mus_property ("bracket-start", SCM_BOOL_T);
1806 | br_bass_figure ']' {
1808 unsmob_music ($1)->set_mus_property ("bracket-stop", SCM_BOOL_T);
1816 | figure_list br_bass_figure {
1817 $$ = scm_cons ($2, $1);
1822 FIGURE_OPEN figure_list FIGURE_CLOSE {
1823 Music * m = MY_MAKE_MUSIC("EventChord");
1824 $2 = scm_reverse_x ($2, SCM_EOL);
1825 m->set_mus_property ("elements", $2);
1826 $$ = m->self_scm ();
1837 pitch exclamations questions optional_notemode_duration optional_rest {
1839 Input i = THIS->pop_spot ();
1840 if (!THIS->lexer_->note_state_b ())
1841 THIS->parser_error (_ ("Have to be in Note mode for notes"));
1845 n = MY_MAKE_MUSIC("RestEvent");
1847 n = MY_MAKE_MUSIC("NoteEvent");
1849 n->set_mus_property ("pitch", $1);
1850 n->set_mus_property ("duration", $4);
1854 n->set_mus_property ("cautionary", SCM_BOOL_T);
1855 if ($2 % 2 || $3 % 2)
1856 n->set_mus_property ("force-accidental", SCM_BOOL_T);
1858 Music *v = MY_MAKE_MUSIC("EventChord");
1859 v->set_mus_property ("elements", scm_list_n (n->self_scm (), SCM_UNDEFINED));
1860 scm_gc_unprotect_object (n->self_scm());
1866 | figure_spec optional_notemode_duration {
1867 Music * m = unsmob_music ($1);
1868 Input i = THIS->pop_spot ();
1870 for (SCM s = m->get_mus_property ("elements"); gh_pair_p (s); s = ly_cdr (s))
1872 unsmob_music (ly_car (s))->set_mus_property ("duration", $2);
1876 | RESTNAME optional_notemode_duration {
1878 Input i = THIS->pop_spot ();
1879 SCM e = SCM_UNDEFINED;
1880 if (ly_scm2string ($1) =="s") {
1882 Music * skip = MY_MAKE_MUSIC("SkipEvent");
1883 skip->set_mus_property ("duration" ,$2);
1885 e = skip->self_scm ();
1888 Music * rest_req = MY_MAKE_MUSIC("RestEvent");
1889 rest_req->set_mus_property ("duration", $2);
1890 rest_req->set_spot (i);
1891 e = rest_req->self_scm ();
1893 Music * velt = MY_MAKE_MUSIC("EventChord");
1894 velt-> set_mus_property ("elements", scm_list_n (e,SCM_UNDEFINED));
1899 | MULTI_MEASURE_REST optional_notemode_duration {
1904 proc = scm_c_eval_string ("make-multi-measure-rest");
1906 SCM mus = scm_call_2 (proc, $2,
1907 make_input (THIS->here_input()));
1908 scm_gc_protect_object (mus);
1909 $$ = unsmob_music (mus);
1911 | STRING optional_notemode_duration {
1912 Input i = THIS->pop_spot ();
1914 Music * lreq = MY_MAKE_MUSIC("LyricEvent");
1915 lreq->set_mus_property ("text", $1);
1916 lreq->set_mus_property ("duration",$2);
1918 Music * velt = MY_MAKE_MUSIC("EventChord");
1919 velt->set_mus_property ("elements", scm_list_n (lreq->self_scm (), SCM_UNDEFINED));
1926 if (!THIS->lexer_->chord_state_b ())
1927 THIS->parser_error (_ ("Have to be in Chord mode for chords"));
1934 steno_tonic_pitch optional_notemode_duration chord_additions chord_subtractions chord_inversion chord_bass {
1935 $$ = Chord::get_chord ($1, $3, $4, $5, $6, $2);
1936 $$->set_spot (THIS->here_input ());
1943 | CHORD_COLON chord_notes {
1952 | chord_notes '.' chord_step {
1953 $$ = gh_append2 ($$, $3);
1961 | CHORD_CARET chord_notes {
1971 | CHORD_SLASH steno_tonic_pitch {
1980 | CHORD_BASS steno_tonic_pitch {
1987 $$ = scm_cons ($1, SCM_EOL);
1989 | CHORDMODIFIER_PITCH {
1990 $$ = scm_cons (unsmob_pitch ($1)->smobbed_copy (), SCM_EOL);
1992 | CHORDMODIFIER_PITCH chord_note { /* Ugh. */
1993 $$ = scm_list_n (unsmob_pitch ($1)->smobbed_copy (),
2001 m.notename_ = ($1 - 1) % 7;
2002 m.octave_ = $1 > 7 ? 1 : 0;
2005 $$ = m.smobbed_copy ();
2007 | bare_unsigned '+' {
2009 m.notename_ = ($1 - 1) % 7;
2010 m.octave_ = $1 > 7 ? 1 : 0;
2014 $$ = m.smobbed_copy ();
2016 | bare_unsigned CHORD_MINUS {
2018 m.notename_ = ($1 - 1) % 7;
2019 m.octave_ = $1 > 7 ? 1 : 0;
2022 $$ = m.smobbed_copy ();
2030 number_expression '+' number_term {
2031 $$ = scm_sum ($1, $3);
2033 | number_expression '-' number_term {
2034 $$ = scm_difference ($1, $3);
2043 | number_factor '*' number_factor {
2044 $$ = scm_product ($1, $3);
2046 | number_factor '/' number_factor {
2047 $$ = scm_divide ($1, $3);
2052 '-' number_factor { /* %prec UNARY_MINUS */
2053 $$ = scm_difference ($2, SCM_UNDEFINED);
2061 $$ = gh_int2scm ($1);
2066 | NUMBER_IDENTIFIER {
2070 $$ = gh_double2scm (gh_scm2double ($1) CM );
2073 $$ = gh_double2scm (gh_scm2double ($1) PT);
2076 $$ = gh_double2scm (gh_scm2double ($1) INCH);
2079 $$ = gh_double2scm (gh_scm2double ($1) MM);
2082 $$ = gh_double2scm (gh_scm2double ($1) CHAR);
2098 if (scm_integer_p ($1) == SCM_BOOL_T)
2100 int k = gh_scm2int ($1);
2104 THIS->parser_error (_ ("need integer number arg"));
2118 | STRING_IDENTIFIER {
2121 | string '+' string {
2122 $$ = scm_string_append (scm_list_n ($1, $3, SCM_UNDEFINED));
2129 | exclamations '!' { $$ ++; }
2134 | questions '?' { $$ ++; }
2141 My_lily_parser::set_yydebug (bool )
2148 extern My_lily_parser * current_parser;
2151 My_lily_parser::do_yyparse ()
2153 current_parser = this;;
2154 yyparse ((void*)this);
2159 Should make this optional? It will also complain when you do
2163 which is entirely legitimate.
2165 Or we can scrap it. Barchecks should detect wrong durations, and
2166 skipTypesetting speeds it up a lot.
2169 My_lily_parser::beam_check (SCM dur)
2171 Duration *d = unsmob_duration (dur);
2172 if (unsmob_music (last_beam_start_) && d->duration_log () <= 2)
2174 Music * m = unsmob_music (last_beam_start_);
2175 m->origin ()->warning (_("Suspect duration found following this beam"));
2177 last_beam_start_ = SCM_EOL;
2182 It is a little strange, to have this function in this file, but
2183 otherwise, we have to import music classes into the lexer.
2187 My_lily_lexer::try_special_identifiers (SCM * destination, SCM sid)
2189 if (gh_string_p (sid)) {
2191 return STRING_IDENTIFIER;
2192 } else if (gh_number_p (sid)) {
2194 return NUMBER_IDENTIFIER;
2195 } else if (unsmob_translator_def (sid)) {
2196 *destination = unsmob_translator_def (sid)->clone_scm();
2197 return TRANSLATOR_IDENTIFIER;
2198 } else if (unsmob_score (sid)) {
2199 Score *sc = new Score (*unsmob_score (sid));
2200 *destination =sc->self_scm ();
2201 return SCORE_IDENTIFIER;
2202 } else if (Music * mus =unsmob_music (sid)) {
2203 *destination = unsmob_music (sid)->clone ()->self_scm();
2204 unsmob_music (*destination)->
2205 set_mus_property ("origin", make_input (last_input_));
2206 return dynamic_cast<Event*> (mus)
2207 ? EVENT_IDENTIFIER : MUSIC_IDENTIFIER;
2208 } else if (unsmob_duration (sid)) {
2209 *destination = unsmob_duration (sid)->smobbed_copy();
2210 return DURATION_IDENTIFIER;
2211 } else if (unsmob_music_output_def (sid)) {
2212 Music_output_def *p = unsmob_music_output_def (sid);
2215 *destination = p->self_scm();
2216 return MUSIC_OUTPUT_DEF_IDENTIFIER;