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 ());
365 chordmodifiers_block:
366 CHORDMODIFIERS notenames_body { $$ = $2; }
370 PITCHNAMES notenames_body { $$ = $2; }
375 int i = scm_ilength ($1);
377 SCM tab = scm_make_vector (gh_int2scm (i), SCM_EOL);
378 for (SCM s = $1; gh_pair_p (s); s = ly_cdr (s)) {
379 SCM pt = ly_cdar (s);
380 if (!unsmob_pitch (pt))
381 THIS->parser_error ("Need pitch object.");
383 scm_hashq_set_x (tab, ly_caar (s), pt);
390 lilypond_header_body:
392 $$ = ly_make_anonymous_module ();
393 THIS->lexer_->add_scope ($$);
395 | lilypond_header_body assignment {
401 HEADER '{' lilypond_header_body '}' {
402 $$ = THIS->lexer_-> remove_scope();
414 /* cont */ '=' identifier_init {
417 Should find generic way of associating input with objects.
419 Input ip = THIS->pop_spot ();
421 if (! regular_identifier_b ($1))
423 ip.warning (_ ("Identifier should have alphabetic characters only"));
426 THIS->lexer_->set_identifier ($1, $4);
429 TODO: devise standard for protection in parser.
431 The parser stack lives on the C-stack, which means that
432 all objects can be unprotected as soon as they're here.
442 $$ = $1->self_scm ();
443 scm_gc_unprotect_object ($$);
446 $$ = $1->self_scm ();
447 scm_gc_unprotect_object ($$);
449 | translator_spec_block {
453 $$ = $1->self_scm ();
454 scm_gc_unprotect_object ($$);
457 $$ = $1->self_scm ();
458 scm_gc_unprotect_object ($$);
463 | number_expression {
474 translator_spec_block:
475 TRANSLATOR '{' translator_spec_body '}'
481 translator_spec_body:
482 TRANSLATOR_IDENTIFIER {
484 unsmob_translator_def ($$)-> set_spot (THIS->here_input ());
487 $$ = Translator_def::make_scm ();
488 Translator_def*td = unsmob_translator_def ($$);
489 td->translator_group_type_ = $2;
490 td->set_spot (THIS->here_input ());
492 | translator_spec_body STRING '=' embedded_scm {
493 unsmob_translator_def ($$)->add_property_assign ($2, $4);
495 | translator_spec_body STRING OVERRIDE embedded_scm '=' embedded_scm {
496 unsmob_translator_def ($$)
497 ->add_push_property (scm_string_to_symbol ($2), $4, $6);
499 | translator_spec_body STRING SET embedded_scm '=' embedded_scm {
500 unsmob_translator_def ($$)
501 ->add_push_property (scm_string_to_symbol ($2), $4, $6);
503 | translator_spec_body STRING REVERT embedded_scm {
504 unsmob_translator_def ($$)->add_pop_property (
505 scm_string_to_symbol ($2), $4);
507 | translator_spec_body NAME STRING {
508 unsmob_translator_def ($$)->type_name_ = $3;
510 | translator_spec_body CONSISTS STRING {
511 unsmob_translator_def ($$)->add_element ($3);
513 | translator_spec_body ALIAS STRING {
514 Translator_def*td = unsmob_translator_def ($$);
515 td->type_aliases_ = scm_cons ($3, td->type_aliases_);
517 | translator_spec_body GROBDESCRIPTIONS embedded_scm {
518 Translator_def*td = unsmob_translator_def($$);
519 // td->add_property_assign (ly_symbol2scm ("allGrobDescriptions"), $3);
520 for (SCM p = $3; gh_pair_p (p); p = ly_cdr (p))
521 td->add_property_assign (scm_symbol_to_string (ly_caar (p)), ly_cdar (p));
523 | translator_spec_body CONSISTSEND STRING {
524 unsmob_translator_def ($$)->add_last_element ( $3);
526 | translator_spec_body ACCEPTS STRING {
527 unsmob_translator_def ($$)->set_acceptor ($3,true);
529 | translator_spec_body DENIES STRING {
530 unsmob_translator_def ($$)->set_acceptor ($3,false);
532 | translator_spec_body REMOVE STRING {
533 unsmob_translator_def ($$)->remove_element ($3);
544 /*cont*/ '{' score_body '}' {
547 if (!$$->defs_.size ())
549 Music_output_def *id =
550 unsmob_music_output_def (THIS->lexer_->lookup_identifier ("$defaultpaper"));
551 $$->add_output (id ? id->clone () : new Paper_def );
560 $$->set_spot (THIS->here_input ());
561 SCM m = $1->self_scm ();
562 scm_gc_unprotect_object (m);
567 SCM check_funcs = scm_c_eval_string ("toplevel-music-functions");
568 for (; gh_pair_p (check_funcs); check_funcs = gh_cdr (check_funcs))
569 m = gh_call1 (gh_car (check_funcs), m);
574 $$ = unsmob_score ($1);
575 $$->set_spot (THIS->here_input ());
577 | score_body lilypond_header {
580 | score_body output_def {
593 music_output_def_body '}' {
595 THIS-> lexer_-> remove_scope ();
599 music_output_def_body:
601 Music_output_def *id = unsmob_music_output_def (THIS->lexer_->lookup_identifier ("$defaultmidi"));
606 p = dynamic_cast<Midi_def*> (id->clone ());
611 THIS->lexer_->add_scope (p->scope_);
614 Music_output_def *id = unsmob_music_output_def (THIS->lexer_->lookup_identifier ("$defaultpaper"));
617 p = dynamic_cast<Paper_def*> (id->clone ());
621 THIS->lexer_->add_scope (p->scope_);
624 | PAPER '{' MUSIC_OUTPUT_DEF_IDENTIFIER {
625 Music_output_def * o = unsmob_music_output_def ($3);
628 THIS->lexer_->add_scope (o->scope_);
630 | MIDI '{' MUSIC_OUTPUT_DEF_IDENTIFIER {
631 Music_output_def * o = unsmob_music_output_def ($3);
634 THIS->lexer_->add_scope (o->scope_);
636 | music_output_def_body assignment {
639 | music_output_def_body translator_spec_block {
640 $$->assign_translator ($2);
642 | music_output_def_body STYLESHEET embedded_scm {
643 dynamic_cast<Paper_def*> ($$)-> style_sheet_ = $3;
645 | music_output_def_body tempo_event {
647 junk this ? there already is tempo stuff in
650 int m = gh_scm2int ( $2->get_mus_property ("metronome-count"));
651 Duration *d = unsmob_duration ($2->get_mus_property ("duration"));
652 Midi_def * md = dynamic_cast<Midi_def*> ($$);
654 md->set_tempo (d->get_length (), m);
656 | music_output_def_body error {
662 TEMPO steno_duration '=' bare_unsigned {
663 $$ = MY_MAKE_MUSIC("TempoEvent");
664 $$->set_mus_property ("duration", $2);
665 $$->set_mus_property ("metronome-count", gh_int2scm ( $4));
670 The representation of a list is the
674 to have efficient append.
676 Music_list: /* empty */ {
677 $$ = scm_cons (SCM_EOL, SCM_EOL);
681 SCM c = scm_cons ($2->self_scm (), SCM_EOL);
682 scm_gc_unprotect_object ($2->self_scm ()); /* UGH */
683 if (gh_pair_p (ly_cdr (s)))
684 gh_set_cdr_x (ly_cdr (s), c); /* append */
686 gh_set_car_x (s, c); /* set first cons */
687 gh_set_cdr_x (s, c) ; /* remember last cell */
703 | ALTERNATIVE '{' Music_list '}' {
709 REPEAT string bare_unsigned Music Alternative_music
713 SCM alts = gh_pair_p ($5) ? gh_car ($5) : SCM_EOL;
714 if (times < scm_ilength (alts)) {
715 unsmob_music (gh_car (alts))
716 ->origin ()->warning (
717 _("More alternatives than repeats. Junking excess alternatives."));
718 alts = ly_truncate_list (times, alts);
724 proc = scm_c_eval_string ("make-repeated-music");
726 SCM mus = scm_call_1 (proc, $2);
727 scm_gc_protect_object (mus); // UGH.
728 Music *r =unsmob_music (mus);
731 r-> set_mus_property ("element", beg->self_scm ());
732 scm_gc_unprotect_object (beg->self_scm ());
734 r->set_mus_property ("repeat-count", gh_int2scm (times >? 1));
736 r-> set_mus_property ("elements",alts);
737 if (gh_equal_p ($2, scm_makfrom0str ("tremolo")))
740 we can not get durations and other stuff correct down the line, so we have to
741 add to the duration log here.
743 SCM func = scm_primitive_eval (ly_symbol2scm ("shift-duration-log"));
745 gh_call3 (func, r->self_scm (), gh_int2scm(-intlog2 ($3*2/3)),gh_int2scm(1));
747 gh_call3 (func, r->self_scm (), gh_int2scm(-intlog2 ($3)), gh_int2scm(0));
749 r->set_spot (*$4->origin ());
756 SEQUENTIAL '{' Music_list '}' {
757 $$ = MY_MAKE_MUSIC("SequentialMusic");
758 $$->set_mus_property ("elements", ly_car ($3));
759 $$->set_spot(THIS->here_input());
761 | '{' Music_list '}' {
762 $$ = MY_MAKE_MUSIC("SequentialMusic");
763 $$->set_mus_property ("elements", ly_car ($2));
764 $$->set_spot(THIS->here_input());
769 SIMULTANEOUS '{' Music_list '}'{
770 $$ = MY_MAKE_MUSIC("SimultaneousMusic");
771 $$->set_mus_property ("elements", ly_car ($3));
772 $$->set_spot(THIS->here_input());
775 | '<' Music_list '>' {
776 $$ = MY_MAKE_MUSIC("SimultaneousMusic");
777 $$->set_mus_property ("elements", ly_car ($2));
778 $$->set_spot(THIS->here_input());
783 event_chord { $$ = $1; }
784 | OUTPUTPROPERTY embedded_scm embedded_scm '=' embedded_scm {
786 if (!gh_symbol_p ($3))
788 THIS->parser_error (_ ("Second argument must be a symbol"));
790 /* Should check # args */
791 if (!gh_procedure_p (pred))
793 THIS->parser_error (_ ("First argument must be a procedure taking one argument"));
796 Music*m = MY_MAKE_MUSIC("OutputPropertySetMusic");
797 m->set_mus_property ("predicate", pred);
798 m->set_mus_property ("grob-property", $3);
799 m->set_mus_property ("grob-value", $5);
804 $$ = unsmob_music ($1);
812 CONTEXT STRING Music {
813 Music*csm =MY_MAKE_MUSIC("ContextSpeccedMusic");
815 csm->set_mus_property ("element", $3->self_scm ());
816 scm_gc_unprotect_object ($3->self_scm ());
818 csm->set_mus_property ("context-type",$2);
819 csm->set_mus_property ("context-id", scm_makfrom0str (""));
823 | AUTOCHANGE STRING Music {
824 Music*chm = MY_MAKE_MUSIC("AutoChangeMusic");
825 chm->set_mus_property ("element", $3->self_scm ());
826 chm->set_mus_property ("iterator-ctor", Auto_change_iterator::constructor_proc);
828 scm_gc_unprotect_object ($3->self_scm ());
829 chm->set_mus_property ("what", $2);
832 chm->set_spot (*$3->origin ());
837 The other version is for easier debugging of
838 Sequential_music_iterator in combination with grace notes.
841 SCM start = THIS->lexer_->lookup_identifier ("startGraceMusic");
842 SCM stop = THIS->lexer_->lookup_identifier ("stopGraceMusic");
843 Music *startm = unsmob_music (start);
844 Music *stopm = unsmob_music (stop);
848 stopm = stopm->clone ();
849 ms = scm_cons (stopm->self_scm (), ms);
850 scm_gc_unprotect_object (stopm->self_scm ());
852 ms = scm_cons ($2->self_scm (), ms);
853 scm_gc_unprotect_object ($2->self_scm());
855 startm = startm->clone ();
856 ms = scm_cons (startm->self_scm () , ms);
857 scm_gc_unprotect_object (startm->self_scm ());
861 Music* seq = MY_MAKE_MUSIC("SequentialMusic");
862 seq->set_mus_property ("elements", ms);
865 $$ = MY_MAKE_MUSIC("GraceMusic");
866 $$->set_mus_property ("element", seq->self_scm ());
867 scm_gc_unprotect_object (seq->self_scm ());
869 $$ = MY_MAKE_MUSIC("GraceMusic");
870 $$->set_mus_property ("element", $2->self_scm ());
871 scm_gc_unprotect_object ($2->self_scm ());
874 | CONTEXT string '=' string Music {
875 Music * csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
877 csm->set_mus_property ("element", $5->self_scm ());
878 scm_gc_unprotect_object ($5->self_scm ());
880 csm->set_mus_property ("context-type", $2);
881 csm->set_mus_property ("context-id", $4);
892 int n = gh_scm2int (ly_car ($3)); int d = gh_scm2int (ly_cdr ($3));
894 $$= MY_MAKE_MUSIC("TimeScaledMusic");
895 $$->set_spot (THIS->pop_spot ());
898 $$->set_mus_property ("element", mp->self_scm ());
899 scm_gc_unprotect_object (mp->self_scm ());
900 $$->set_mus_property ("numerator", gh_int2scm (n));
901 $$->set_mus_property ("denominator", gh_int2scm (d));
902 $$->compress (Moment (Rational (n,d)));
905 | Repeated_music { $$ = $1; }
906 | Simultaneous_music { $$ = $1; }
907 | Sequential_music { $$ = $1; }
908 | TRANSPOSE pitch Music {
909 $$ = MY_MAKE_MUSIC("TransposedMusic");
911 Pitch pit = *unsmob_pitch ($2);
914 $$->set_mus_property ("element", p->self_scm ());
915 scm_gc_unprotect_object (p->self_scm ());
917 | TRANSPOSE steno_tonic_pitch Music {
918 $$ = MY_MAKE_MUSIC("TransposedMusic");
920 Pitch pit = *unsmob_pitch ($2);
923 $$->set_mus_property ("element", p->self_scm ());
924 scm_gc_unprotect_object (p->self_scm ());
927 | APPLY embedded_scm Music {
928 SCM ret = gh_call1 ($2, $3->self_scm ());
929 Music *m = unsmob_music (ret);
931 THIS->parser_error ("\\apply must return a Music");
932 m = MY_MAKE_MUSIC("Music");
937 { THIS->lexer_->push_note_state (); }
940 THIS->lexer_->pop_state ();
943 { THIS->lexer_->push_figuredbass_state (); }
946 Music * chm = MY_MAKE_MUSIC("UntransposableMusic");
947 chm->set_mus_property ("element", $3->self_scm ());
949 scm_gc_unprotect_object ($3->self_scm());
951 THIS->lexer_->pop_state ();
954 { THIS->lexer_->push_chord_state (); }
957 Music * chm = MY_MAKE_MUSIC("UnrelativableMusic");
958 chm->set_mus_property ("element", $3->self_scm ());
959 scm_gc_unprotect_object ($3->self_scm());
962 THIS->lexer_->pop_state ();
965 { THIS->lexer_->push_lyric_state (); }
969 THIS->lexer_->pop_state ();
971 | relative_music { $$ = $1; }
972 | re_rhythmed_music { $$ = $1; }
973 | part_combined_music { $$ = $1; }
977 RELATIVE absolute_pitch Music {
979 Pitch pit = *unsmob_pitch ($2);
980 $$ = MY_MAKE_MUSIC("RelativeOctaveMusic");
982 $$->set_mus_property ("element", p->self_scm ());
983 scm_gc_unprotect_object (p->self_scm ());
985 $$->set_mus_property ("last-pitch", p->to_relative_octave (pit).smobbed_copy ());
991 ADDLYRICS Music Music {
992 Music*l =MY_MAKE_MUSIC("LyricCombineMusic");
993 l->set_mus_property ("elements", gh_list ($2->self_scm (), $3->self_scm (), SCM_UNDEFINED));
994 scm_gc_unprotect_object ($3->self_scm ());
995 scm_gc_unprotect_object ($2->self_scm ());
1000 part_combined_music:
1001 PARTCOMBINE STRING Music Music {
1002 Music * p= MY_MAKE_MUSIC("PartCombineMusic");
1003 p->set_mus_property ("what", $2);
1004 p->set_mus_property ("elements", gh_list ($3->self_scm (),$4->self_scm (), SCM_UNDEFINED));
1006 scm_gc_unprotect_object ($3->self_scm ());
1007 scm_gc_unprotect_object ($4->self_scm ());
1014 TRANSLATOR STRING '=' STRING {
1015 Music*t= MY_MAKE_MUSIC("TranslatorChange");
1016 t-> set_mus_property ("change-to-type", $2);
1017 t-> set_mus_property ("change-to-id", $4);
1020 $$->set_spot (THIS->here_input ());
1026 | ONCE simple_property_def {
1028 SCM e = $2->get_mus_property ("element");
1029 unsmob_music (e)->set_mus_property ("once", SCM_BOOL_T);
1033 simple_property_def:
1034 PROPERTY STRING '.' STRING '=' scalar {
1035 Music *t = set_property_music (scm_string_to_symbol ($4), $6);
1036 Music *csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
1038 csm->set_mus_property ("element", t->self_scm ());
1039 scm_gc_unprotect_object (t->self_scm ());
1042 $$->set_spot (THIS->here_input ());
1044 csm-> set_mus_property ("context-type", $2);
1046 | PROPERTY STRING '.' STRING UNSET {
1048 Music *t = MY_MAKE_MUSIC("PropertyUnset");
1049 t->set_mus_property ("symbol", scm_string_to_symbol ($4));
1051 Music *csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
1052 csm->set_mus_property ("element", t->self_scm ());
1053 scm_gc_unprotect_object (t->self_scm ());
1056 $$->set_spot (THIS->here_input ());
1058 csm-> set_mus_property ("context-type", $2);
1060 | PROPERTY STRING '.' STRING SET embedded_scm '=' embedded_scm {
1062 = gh_equal_p ($4, scm_makfrom0str ("autoBeamSettings"));
1063 bool itc = internal_type_checking_global_b;
1064 Music *t = MY_MAKE_MUSIC("OverrideProperty");
1065 t->set_mus_property ("symbol", scm_string_to_symbol ($4));
1066 t->set_mus_property ("pop-first", SCM_BOOL_T);
1068 internal_type_checking_global_b = false;
1069 t->set_mus_property ("grob-property", $6);
1071 internal_type_checking_global_b = itc;
1072 t->set_mus_property ("grob-value", $8);
1074 Music *csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
1075 csm->set_mus_property ("element", t->self_scm ());
1076 scm_gc_unprotect_object (t->self_scm ());
1078 $$->set_spot (THIS->here_input ());
1080 csm-> set_mus_property ("context-type", $2);
1082 | PROPERTY STRING '.' STRING OVERRIDE
1083 embedded_scm '=' embedded_scm
1089 = gh_equal_p ($4, scm_makfrom0str ("autoBeamSettings"));
1090 bool itc = internal_type_checking_global_b;
1092 Music *t = MY_MAKE_MUSIC("OverrideProperty");
1093 t->set_mus_property ("symbol", scm_string_to_symbol ($4));
1095 internal_type_checking_global_b = false;
1096 t->set_mus_property ("grob-property", $6);
1097 t->set_mus_property ("grob-value", $8);
1099 internal_type_checking_global_b = itc;
1101 Music *csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
1102 csm->set_mus_property ("element", t->self_scm ());
1103 scm_gc_unprotect_object (t->self_scm ());
1106 $$->set_spot (THIS->here_input ());
1108 csm-> set_mus_property ("context-type", $2);
1111 | PROPERTY STRING '.' STRING REVERT embedded_scm {
1112 Music *t = MY_MAKE_MUSIC("RevertProperty");
1114 = gh_equal_p ($4, scm_makfrom0str ("autoBeamSettings"));
1115 bool itc = internal_type_checking_global_b;
1117 t->set_mus_property ("symbol", scm_string_to_symbol ($4));
1119 internal_type_checking_global_b = false;
1120 t->set_mus_property ("grob-property", $6);
1122 internal_type_checking_global_b = itc;
1124 Music *csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
1125 csm->set_mus_property ("element", t->self_scm ());
1126 scm_gc_unprotect_object (t->self_scm ());
1129 $$->set_spot (THIS->here_input ());
1131 csm-> set_mus_property ("context-type", $2);
1138 | bare_int { $$ = gh_int2scm ($1); }
1139 | embedded_scm { $$ = $1; }
1146 } /*cont */ simple_element post_events {
1147 Music_sequence *l = dynamic_cast<Music_sequence*> ($3);
1150 for (int i=0; i < $1->size (); i++) {
1151 Music * m = $1->elem (i);
1152 l->append_music (m);
1164 $$ = MY_MAKE_MUSIC("EventChord");
1165 $$->set_mus_property ("elements", scm_cons ($1->self_scm (), SCM_EOL));
1166 scm_gc_unprotect_object ($1->self_scm());
1168 $$-> set_spot (THIS->here_input ());
1169 $1-> set_spot (THIS->here_input ());
1172 Music *l = MY_MAKE_MUSIC("LigatureEvent");
1173 l->set_mus_property ("span-direction", gh_int2scm (START));
1174 l->set_spot (THIS->here_input ());
1176 $$ = MY_MAKE_MUSIC("EventChord");
1177 $$->set_mus_property ("elements", scm_cons (l->self_scm (), SCM_EOL));
1178 scm_gc_unprotect_object (l->self_scm());
1179 $$->set_spot (THIS->here_input ());
1182 Music *l = MY_MAKE_MUSIC("LigatureEvent");
1183 l->set_mus_property ("span-direction", gh_int2scm (STOP));
1184 l->set_spot (THIS->here_input ());
1186 $$ = MY_MAKE_MUSIC("EventChord");
1187 $$->set_mus_property ("elements", scm_cons (l->self_scm (), SCM_EOL));
1188 $$->set_spot (THIS->here_input ());
1189 scm_gc_unprotect_object (l->self_scm());
1193 $$ = MY_MAKE_MUSIC("VoiceSeparator");
1194 $$->set_spot (THIS->here_input ());
1198 $$ = MY_MAKE_MUSIC("BarCheck");
1199 $$->set_spot (THIS->here_input ());
1202 Music *t = set_property_music (ly_symbol2scm ("whichBar"), $2);
1204 Music *csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
1205 csm->set_mus_property ("element", t->self_scm ());
1206 scm_gc_unprotect_object (t->self_scm ());
1209 $$->set_spot (THIS->here_input ());
1211 csm->set_mus_property ("context-type", scm_makfrom0str ("Timing"));
1213 | PARTIAL duration_length {
1214 Moment m = - unsmob_duration ($2)->get_length ();
1215 Music * p = set_property_music (ly_symbol2scm ( "measurePosition"),m.smobbed_copy ());
1217 Music * sp = MY_MAKE_MUSIC("ContextSpeccedMusic");
1218 sp->set_mus_property ("element", p->self_scm ());
1219 scm_gc_unprotect_object (p->self_scm ());
1222 sp-> set_mus_property ("context-type", scm_makfrom0str ("Timing"));
1227 proc = scm_c_eval_string ("make-clef-set");
1229 SCM result = scm_call_1 (proc, $2);
1230 scm_gc_protect_object (result);
1231 $$ = unsmob_music (result);
1234 Music * p1 = set_property_music (ly_symbol2scm ( "timeSignatureFraction"), $2);
1236 int l = gh_scm2int (ly_car ($2));
1237 int o = gh_scm2int (ly_cdr ($2));
1239 Moment one_beat = Moment (1)/Moment (o);
1240 Moment len = Moment (l) * one_beat;
1243 Music *p2 = set_property_music (ly_symbol2scm ("measureLength"), len.smobbed_copy ());
1244 Music *p3 = set_property_music (ly_symbol2scm ("beatLength"), one_beat.smobbed_copy ());
1246 SCM list = scm_list_n (p1->self_scm (), p2->self_scm (), p3->self_scm(), SCM_UNDEFINED);
1247 Music *seq = MY_MAKE_MUSIC("SequentialMusic");
1248 seq->set_mus_property ("elements", list);
1251 Music * sp = MY_MAKE_MUSIC("ContextSpeccedMusic");
1252 sp->set_mus_property ("element", seq->self_scm ());
1254 scm_gc_unprotect_object (p3->self_scm ());
1255 scm_gc_unprotect_object (p2->self_scm ());
1256 scm_gc_unprotect_object (p1->self_scm ());
1257 scm_gc_unprotect_object (seq->self_scm ());
1261 sp-> set_mus_property ("context-type", scm_makfrom0str ( "Timing"));
1266 shorthand_command_req { $$ = $1; }
1267 | verbose_command_req { $$ = $1; }
1270 shorthand_command_req:
1278 $$ = MY_MAKE_MUSIC("TieEvent");
1281 Music *b= MY_MAKE_MUSIC("BeamEvent");
1282 b->set_mus_property ("span-direction", gh_int2scm (START))
1287 THIS->last_beam_start_ = b->self_scm ();
1290 Music *b= MY_MAKE_MUSIC("BeamEvent");
1291 b->set_mus_property ("span-direction", gh_int2scm (STOP));
1295 $$ = MY_MAKE_MUSIC("BreathingSignEvent");
1298 $$ = MY_MAKE_MUSIC("PorrectusEvent");
1302 verbose_command_req:
1303 COMMANDSPANREQUEST bare_int STRING {
1304 Music *sp = make_span_req ($3);
1305 sp->set_mus_property ("span-direction", gh_int2scm (Direction ($2)));
1306 sp->set_spot (THIS->here_input ());
1310 Music * m = MY_MAKE_MUSIC("MarkEvent");
1314 Music *m = MY_MAKE_MUSIC("MarkEvent");
1315 m->set_mus_property ("label", $2);
1319 Music * b = MY_MAKE_MUSIC("BreakEvent");
1321 if (!gh_number_p (s))
1324 b->set_mus_property ("penalty", s);
1325 b->set_spot (THIS->here_input ());
1328 | SKIP duration_length {
1329 Music * skip = MY_MAKE_MUSIC("SkipEvent");
1330 skip->set_mus_property ("duration", $2);
1338 Music *key= MY_MAKE_MUSIC("KeyChangeEvent");
1341 | KEY NOTENAME_PITCH SCM_IDENTIFIER {
1342 Music *key= MY_MAKE_MUSIC("KeyChangeEvent");
1344 key->set_mus_property ("pitch-alist", $3);
1345 ((Music*)key)->transpose (* unsmob_pitch ($2));
1352 $$ = new Link_array<Music>;
1354 | post_events post_event {
1355 $2->set_spot (THIS->here_input ());
1370 Music * s = MY_MAKE_MUSIC("StringNumberEvent");
1371 s->set_mus_property ("string-number", gh_int2scm($1));
1372 s->set_spot (THIS->here_input ());
1378 event_that_take_dir:
1383 | script_abbreviation {
1384 SCM s = THIS->lexer_->lookup_identifier ("dash" + ly_scm2string ($1));
1385 Music *a = MY_MAKE_MUSIC("ArticulationEvent");
1386 if (gh_string_p (s))
1387 a->set_mus_property ("articulation-type", s);
1388 else THIS->parser_error (_ ("Expecting string as script definition"));
1394 script_dir event_that_take_dir {
1395 $2->set_mus_property ("direction", gh_int2scm ($1));
1402 $$ = unsmob_music ($1);
1404 | SPANREQUEST bare_int STRING {
1405 Music * sp = make_span_req ($3);
1406 sp->set_mus_property ("span-direction", gh_int2scm ( $2));
1407 sp->set_spot (THIS->here_input ());
1411 Music * a = MY_MAKE_MUSIC("TremoloEvent");
1412 a->set_spot (THIS->here_input ());
1413 a->set_mus_property ("tremolo-type", gh_int2scm ($1));
1417 Music * a = MY_MAKE_MUSIC("ArticulationEvent");
1418 a->set_mus_property ("articulation-type", $2);
1419 a->set_spot (THIS->here_input ());
1424 duh, junk this syntax from the parser, if possible.
1427 Music *a = MY_MAKE_MUSIC("ArpeggioEvent");
1428 a->set_spot (THIS->here_input ());
1432 Music *g = MY_MAKE_MUSIC("GlissandoEvent");
1433 g->set_spot /* No pun intended */ (THIS->here_input ());
1460 | NOTENAME_PITCH sup_quotes {
1461 Pitch p = *unsmob_pitch ($1);
1463 $$ = p.smobbed_copy ();
1465 | NOTENAME_PITCH sub_quotes {
1466 Pitch p =* unsmob_pitch ($1);
1469 $$ = p.smobbed_copy ();
1482 | TONICNAME_PITCH sup_quotes {
1483 Pitch p = *unsmob_pitch ($1);
1485 $$ = p.smobbed_copy ();
1487 | TONICNAME_PITCH sub_quotes {
1488 Pitch p =* unsmob_pitch ($1);
1491 $$ = p.smobbed_copy ();
1506 PITCH embedded_scm {
1508 if (!unsmob_pitch ($2)) {
1509 THIS->parser_error (_f ("Expecting musical-pitch value", 3));
1510 $$ = Pitch ().smobbed_copy ();
1516 DURATION embedded_scm {
1518 if (!unsmob_duration ($2))
1520 THIS->parser_error (_ ("Must have duration object"));
1521 $$ = Duration ().smobbed_copy ();
1528 if (!THIS->lexer_->lyric_state_b ())
1529 THIS->parser_error (_ ("Have to be in Lyric mode for lyrics"));
1530 $$ = MY_MAKE_MUSIC("ExtenderEvent");
1536 if (!THIS->lexer_->lyric_state_b ())
1537 THIS->parser_error (_ ("Have to be in Lyric mode for lyrics"));
1538 $$ = MY_MAKE_MUSIC("HyphenEvent");
1543 close_event_parens {
1545 dynamic_cast<Music *> ($$)->set_mus_property ("span-direction", gh_int2scm (START))
1552 Music * s= MY_MAKE_MUSIC("SlurEvent");
1554 s->set_spot (THIS->here_input());
1557 Music * s= MY_MAKE_MUSIC("PhrasingSlurEvent");
1559 s->set_spot (THIS->here_input());
1562 Music *s =MY_MAKE_MUSIC("CrescendoEvent");
1564 s->set_spot (THIS->here_input());
1567 Music *s =MY_MAKE_MUSIC("DecrescendoEvent");
1569 s->set_spot (THIS->here_input());
1577 dynamic_cast<Music *> ($$)->set_mus_property ("span-direction", gh_int2scm (STOP))
1584 Music *s = MY_MAKE_MUSIC("CrescendoEvent");
1585 s->set_spot (THIS->here_input());
1590 Music * s= MY_MAKE_MUSIC("SlurEvent");
1592 s->set_spot (THIS->here_input());
1596 Music * s= MY_MAKE_MUSIC("PhrasingSlurEvent");
1598 s->set_mus_property ("span-type", scm_makfrom0str ( "phrasing-slur"));
1599 s->set_spot (THIS->here_input());
1605 Music *t = MY_MAKE_MUSIC("TextScriptEvent");
1606 t->set_mus_property ("text", $1);
1607 t->set_spot (THIS->here_input ());
1611 Music *t = MY_MAKE_MUSIC("TextScriptEvent");
1612 t->set_mus_property ("text", $1);
1613 t->set_spot (THIS->here_input ());
1617 String ds = to_string ($1);
1618 Music * t = MY_MAKE_MUSIC("TextScriptEvent");
1619 SCM finger = ly_symbol2scm ("finger");
1620 t->set_mus_property ("text", scm_makfrom0str (ds.to_str0 ()));
1621 t->set_mus_property ("text-type" , finger);
1622 t->set_spot (THIS->here_input ());
1627 script_abbreviation:
1629 $$ = scm_makfrom0str ("Hat");
1632 $$ = scm_makfrom0str ("Plus");
1635 $$ = scm_makfrom0str ("Dash");
1638 $$ = scm_makfrom0str ("Bar");
1641 $$ = scm_makfrom0str ("Larger");
1644 $$ = scm_makfrom0str ("Dot");
1647 $$ = scm_makfrom0str ("Underscore");
1654 | '-' { $$ = CENTER; }
1659 $$ = new Link_array<Music>;
1661 | pre_events open_event {
1673 multiplied_duration {
1676 | verbose_duration {
1681 optional_notemode_duration:
1683 Duration dd = THIS->default_duration_;
1684 $$ = dd.smobbed_copy ();
1686 THIS->beam_check ($$);
1688 | multiplied_duration {
1690 THIS->default_duration_ = *unsmob_duration ($$);
1692 THIS->beam_check ($$);
1694 | verbose_duration {
1696 THIS->default_duration_ = *unsmob_duration ($$);
1701 bare_unsigned dots {
1703 if (!is_duration_b ($1))
1704 THIS->parser_error (_f ("not a duration: %d", $1));
1708 $$ = Duration (l, $2).smobbed_copy ();
1710 | DURATION_IDENTIFIER dots {
1711 Duration *d =unsmob_duration ($1);
1712 Duration k (d->duration_log (),d->dot_count () + $2);
1722 multiplied_duration:
1726 | multiplied_duration '*' bare_unsigned {
1727 $$ = unsmob_duration ($$)->compressed ( $3) .smobbed_copy ();
1729 | multiplied_duration '*' FRACTION {
1730 Rational m (gh_scm2int (ly_car ($3)), gh_scm2int (ly_cdr ($3)));
1732 $$ = unsmob_duration ($$)->compressed (m).smobbed_copy ();
1737 FRACTION { $$ = $1; }
1738 | UNSIGNED '/' UNSIGNED {
1739 $$ = scm_cons (gh_int2scm ($1), gh_int2scm ($3));
1757 | ':' bare_unsigned {
1758 if (!is_duration_b ($2))
1759 THIS->parser_error (_f ("not a duration: %d", $2));
1778 Music *bfr = MY_MAKE_MUSIC("BassFigureEvent");
1779 $$ = bfr->self_scm();
1780 scm_gc_unprotect_object ($$);
1783 Music *bfr = MY_MAKE_MUSIC("BassFigureEvent");
1784 $$ = bfr->self_scm();
1786 bfr->set_mus_property ("figure", gh_int2scm ($1));
1788 scm_gc_unprotect_object ($$);
1790 | bass_figure bass_mod {
1791 Music *m = unsmob_music ($1);
1793 SCM salter =m->get_mus_property ("alteration");
1794 int alter = gh_number_p ( salter) ? gh_scm2int (salter) : 0;
1795 m->set_mus_property ("alteration",
1796 gh_int2scm (alter + $2));
1798 m->set_mus_property ("alteration", gh_int2scm (0));
1806 unsmob_music ($$)->set_mus_property ("bracket-start", SCM_BOOL_T);
1811 | br_bass_figure ']' {
1813 unsmob_music ($1)->set_mus_property ("bracket-stop", SCM_BOOL_T);
1821 | figure_list br_bass_figure {
1822 $$ = scm_cons ($2, $1);
1827 FIGURE_OPEN figure_list FIGURE_CLOSE {
1828 Music * m = MY_MAKE_MUSIC("EventChord");
1829 $2 = scm_reverse_x ($2, SCM_EOL);
1830 m->set_mus_property ("elements", $2);
1831 $$ = m->self_scm ();
1842 pitch exclamations questions optional_notemode_duration optional_rest {
1844 Input i = THIS->pop_spot ();
1845 if (!THIS->lexer_->note_state_b ())
1846 THIS->parser_error (_ ("Have to be in Note mode for notes"));
1850 n = MY_MAKE_MUSIC("RestEvent");
1852 n = MY_MAKE_MUSIC("NoteEvent");
1854 n->set_mus_property ("pitch", $1);
1855 n->set_mus_property ("duration", $4);
1859 n->set_mus_property ("cautionary", SCM_BOOL_T);
1860 if ($2 % 2 || $3 % 2)
1861 n->set_mus_property ("force-accidental", SCM_BOOL_T);
1863 Music *v = MY_MAKE_MUSIC("EventChord");
1864 v->set_mus_property ("elements", scm_list_n (n->self_scm (), SCM_UNDEFINED));
1865 scm_gc_unprotect_object (n->self_scm());
1871 | figure_spec optional_notemode_duration {
1872 Music * m = unsmob_music ($1);
1873 Input i = THIS->pop_spot ();
1875 for (SCM s = m->get_mus_property ("elements"); gh_pair_p (s); s = ly_cdr (s))
1877 unsmob_music (ly_car (s))->set_mus_property ("duration", $2);
1881 | RESTNAME optional_notemode_duration {
1883 Input i = THIS->pop_spot ();
1884 SCM e = SCM_UNDEFINED;
1885 if (ly_scm2string ($1) =="s") {
1887 Music * skip = MY_MAKE_MUSIC("SkipEvent");
1888 skip->set_mus_property ("duration" ,$2);
1890 e = skip->self_scm ();
1893 Music * rest_req = MY_MAKE_MUSIC("RestEvent");
1894 rest_req->set_mus_property ("duration", $2);
1895 rest_req->set_spot (i);
1896 e = rest_req->self_scm ();
1898 Music * velt = MY_MAKE_MUSIC("EventChord");
1899 velt-> set_mus_property ("elements", scm_list_n (e,SCM_UNDEFINED));
1904 | MULTI_MEASURE_REST optional_notemode_duration {
1909 proc = scm_c_eval_string ("make-multi-measure-rest");
1911 SCM mus = scm_call_2 (proc, $2,
1912 make_input (THIS->here_input()));
1913 scm_gc_protect_object (mus);
1914 $$ = unsmob_music (mus);
1916 | STRING optional_notemode_duration {
1917 Input i = THIS->pop_spot ();
1919 Music * lreq = MY_MAKE_MUSIC("LyricEvent");
1920 lreq->set_mus_property ("text", $1);
1921 lreq->set_mus_property ("duration",$2);
1923 Music * velt = MY_MAKE_MUSIC("EventChord");
1924 velt->set_mus_property ("elements", scm_list_n (lreq->self_scm (), SCM_UNDEFINED));
1931 if (!THIS->lexer_->chord_state_b ())
1932 THIS->parser_error (_ ("Have to be in Chord mode for chords"));
1939 steno_tonic_pitch optional_notemode_duration chord_additions chord_subtractions chord_inversion chord_bass {
1940 $$ = Chord::get_chord ($1, $3, $4, $5, $6, $2);
1941 $$->set_spot (THIS->here_input ());
1948 | CHORD_COLON chord_notes {
1957 | chord_notes '.' chord_step {
1958 $$ = gh_append2 ($$, $3);
1966 | CHORD_CARET chord_notes {
1976 | CHORD_SLASH steno_tonic_pitch {
1985 | CHORD_BASS steno_tonic_pitch {
1992 $$ = scm_cons ($1, SCM_EOL);
1994 | CHORDMODIFIER_PITCH {
1995 $$ = scm_cons (unsmob_pitch ($1)->smobbed_copy (), SCM_EOL);
1997 | CHORDMODIFIER_PITCH chord_note { /* Ugh. */
1998 $$ = scm_list_n (unsmob_pitch ($1)->smobbed_copy (),
2006 m.notename_ = ($1 - 1) % 7;
2007 m.octave_ = $1 > 7 ? 1 : 0;
2010 $$ = m.smobbed_copy ();
2012 | bare_unsigned '+' {
2014 m.notename_ = ($1 - 1) % 7;
2015 m.octave_ = $1 > 7 ? 1 : 0;
2019 $$ = m.smobbed_copy ();
2021 | bare_unsigned CHORD_MINUS {
2023 m.notename_ = ($1 - 1) % 7;
2024 m.octave_ = $1 > 7 ? 1 : 0;
2027 $$ = m.smobbed_copy ();
2035 number_expression '+' number_term {
2036 $$ = scm_sum ($1, $3);
2038 | number_expression '-' number_term {
2039 $$ = scm_difference ($1, $3);
2048 | number_factor '*' number_factor {
2049 $$ = scm_product ($1, $3);
2051 | number_factor '/' number_factor {
2052 $$ = scm_divide ($1, $3);
2057 '-' number_factor { /* %prec UNARY_MINUS */
2058 $$ = scm_difference ($2, SCM_UNDEFINED);
2066 $$ = gh_int2scm ($1);
2071 | NUMBER_IDENTIFIER {
2075 $$ = gh_double2scm (gh_scm2double ($1) CM );
2078 $$ = gh_double2scm (gh_scm2double ($1) PT);
2081 $$ = gh_double2scm (gh_scm2double ($1) INCH);
2084 $$ = gh_double2scm (gh_scm2double ($1) MM);
2087 $$ = gh_double2scm (gh_scm2double ($1) CHAR);
2103 if (scm_integer_p ($1) == SCM_BOOL_T)
2105 int k = gh_scm2int ($1);
2109 THIS->parser_error (_ ("need integer number arg"));
2123 | STRING_IDENTIFIER {
2126 | string '+' string {
2127 $$ = scm_string_append (scm_list_n ($1, $3, SCM_UNDEFINED));
2134 | exclamations '!' { $$ ++; }
2139 | questions '?' { $$ ++; }
2146 My_lily_parser::set_yydebug (bool )
2153 extern My_lily_parser * current_parser;
2156 My_lily_parser::do_yyparse ()
2159 current_parser = this;;
2160 yyparse ((void*)this);
2165 Should make this optional? It will also complain when you do
2169 which is entirely legitimate.
2171 Or we can scrap it. Barchecks should detect wrong durations, and
2172 skipTypesetting speeds it up a lot.
2175 My_lily_parser::beam_check (SCM dur)
2177 Duration *d = unsmob_duration (dur);
2178 if (unsmob_music (last_beam_start_) && d->duration_log () <= 2)
2180 Music * m = unsmob_music (last_beam_start_);
2181 m->origin ()->warning (_("Suspect duration found following this beam"));
2183 last_beam_start_ = SCM_EOL;
2188 It is a little strange, to have this function in this file, but
2189 otherwise, we have to import music classes into the lexer.
2193 My_lily_lexer::try_special_identifiers (SCM * destination, SCM sid)
2195 if (gh_string_p (sid)) {
2197 return STRING_IDENTIFIER;
2198 } else if (gh_number_p (sid)) {
2200 return NUMBER_IDENTIFIER;
2201 } else if (unsmob_translator_def (sid)) {
2202 *destination = unsmob_translator_def (sid)->clone_scm();
2203 return TRANSLATOR_IDENTIFIER;
2204 } else if (unsmob_score (sid)) {
2205 Score *sc = new Score (*unsmob_score (sid));
2206 *destination =sc->self_scm ();
2207 return SCORE_IDENTIFIER;
2208 } else if (Music * mus =unsmob_music (sid)) {
2209 *destination = unsmob_music (sid)->clone ()->self_scm();
2210 unsmob_music (*destination)->
2211 set_mus_property ("origin", make_input (last_input_));
2212 return dynamic_cast<Event*> (mus)
2213 ? EVENT_IDENTIFIER : MUSIC_IDENTIFIER;
2214 } else if (unsmob_duration (sid)) {
2215 *destination = unsmob_duration (sid)->smobbed_copy();
2216 return DURATION_IDENTIFIER;
2217 } else if (unsmob_music_output_def (sid)) {
2218 Music_output_def *p = unsmob_music_output_def (sid);
2221 *destination = p->self_scm();
2222 return MUSIC_OUTPUT_DEF_IDENTIFIER;