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 */
187 %token CHORDMODIFIERS
193 %token GROBDESCRIPTIONS
198 %token FIGURES FIGURE_OPEN FIGURE_CLOSE
199 %token FIGURE_BRACKET_CLOSE FIGURE_BRACKET_OPEN
207 %token MULTI_MEASURE_REST
218 %token OVERRIDE SET REVERT
228 %token COMMANDSPANREQUEST
230 %token OUTPUTPROPERTY
245 %token E_CHAR E_EXCLAMATION E_SMALLER E_BIGGER E_OPEN E_CLOSE
246 %token E_LEFTSQUARE E_RIGHTSQUARE E_TILDE
248 %token <i> E_UNSIGNED
249 %token CHORD_BASS CHORD_COLON CHORD_MINUS CHORD_CARET CHORD_SLASH
252 %type <i> exclamations questions dots optional_rest
253 %type <i> bass_number bass_mod
254 %type <scm> br_bass_figure bass_figure figure_list figure_spec
256 %token <scm> NOTENAME_PITCH
257 %token <scm> TONICNAME_PITCH
258 %token <scm> CHORDMODIFIER_PITCH
259 %token <scm> DURATION_IDENTIFIER
260 %token <scm> FRACTION
261 %token <id> IDENTIFIER
264 %token <scm> SCORE_IDENTIFIER
265 %token <scm> MUSIC_OUTPUT_DEF_IDENTIFIER
266 %token <scm> NUMBER_IDENTIFIER
267 %token <scm> EVENT_IDENTIFIER
268 %token <scm> MUSIC_IDENTIFIER TRANSLATOR_IDENTIFIER
269 %token <scm> STRING_IDENTIFIER SCM_IDENTIFIER
270 %token <scm> RESTNAME
276 %type <outputdef> output_def
277 %type <scm> lilypond_header lilypond_header_body
278 %type <music> open_event_parens close_event_parens open_event close_event
279 %type <music> event_with_dir event_that_take_dir verbose_event
280 %type <i> sub_quotes sup_quotes
281 %type <music> simple_element event_chord command_element Simple_music Composite_music
282 %type <music> Repeated_music
283 %type <scm> Alternative_music
284 %type <i> tremolo_type
285 %type <i> bare_int bare_unsigned
287 %type <scm> identifier_init
289 %type <music> note_chord_element chord_body chord_body_element
290 %type <scm> chord_body_elements
291 %type <scm> steno_duration optional_notemode_duration multiplied_duration
292 %type <scm> verbose_duration
294 %type <scm> pre_events post_events
295 %type <music> gen_text_def
296 %type <scm> steno_pitch pitch absolute_pitch pitch_also_in_chords
297 %type <scm> explicit_pitch steno_tonic_pitch
299 %type <scm> chord_additions chord_subtractions chord_notes chord_step
301 %type <scm> chord_note chord_inversion chord_bass
302 %type <scm> duration_length fraction
304 %type <scm> embedded_scm scalar
305 %type <music> Music Sequential_music Simultaneous_music
306 %type <music> relative_music re_rhythmed_music part_combined_music
307 %type <music> property_def translator_change simple_property_def
308 %type <scm> Music_list
309 %type <outputdef> music_output_def_body
310 %type <music> shorthand_command_req
311 %type <music> post_event
312 %type <music> command_req verbose_command_req
313 %type <music> extender_req
314 %type <music> hyphen_req
315 %type <music> string_event
316 %type <scm> string bare_number number_expression number_term number_factor
317 %type <score> score_block score_body
319 %type <scm> translator_spec_block translator_spec_body
320 %type <music> tempo_event
321 %type <scm> notenames_body notenames_block chordmodifiers_block
322 %type <scm> script_abbreviation
328 /* We don't assign precedence to / and *, because we might need varied
329 prec levels in different prods */
335 lilypond: /* empty */
336 | lilypond toplevel_expression {}
337 | lilypond assignment { }
339 THIS->error_level_ = 1;
342 THIS->error_level_ = 1;
348 THIS->lexer_->pitchname_tab_ = $1;
350 | chordmodifiers_block {
351 THIS->lexer_->chordmodifier_tab_ = $1;
354 THIS->input_file_->header_ = $1;
357 THIS->input_file_->scores_.push ($1);
360 if (dynamic_cast<Paper_def*> ($1))
361 THIS->lexer_->set_identifier (scm_makfrom0str ("$defaultpaper"), $1->self_scm ());
362 else if (dynamic_cast<Midi_def*> ($1))
363 THIS->lexer_->set_identifier (scm_makfrom0str ("$defaultmidi"), $1->self_scm ());
373 chordmodifiers_block:
374 CHORDMODIFIERS notenames_body { $$ = $2; }
378 PITCHNAMES notenames_body { $$ = $2; }
383 int i = scm_ilength ($1);
385 SCM tab = scm_make_vector (gh_int2scm (i), SCM_EOL);
386 for (SCM s = $1; gh_pair_p (s); s = ly_cdr (s)) {
387 SCM pt = ly_cdar (s);
388 if (!unsmob_pitch (pt))
389 THIS->parser_error ("Need pitch object.");
391 scm_hashq_set_x (tab, ly_caar (s), pt);
398 lilypond_header_body:
400 $$ = ly_make_anonymous_module ();
401 THIS->lexer_->add_scope ($$);
403 | lilypond_header_body assignment {
409 HEADER '{' lilypond_header_body '}' {
410 $$ = THIS->lexer_-> remove_scope();
422 /* cont */ '=' identifier_init {
425 Should find generic way of associating input with objects.
427 Input ip = THIS->pop_spot ();
429 if (! regular_identifier_b ($1))
431 ip.warning (_ ("Identifier should have alphabetic characters only"));
434 THIS->lexer_->set_identifier ($1, $4);
437 TODO: devise standard for protection in parser.
439 The parser stack lives on the C-stack, which means that
440 all objects can be unprotected as soon as they're here.
451 $$ = $1->self_scm ();
452 scm_gc_unprotect_object ($$);
455 $$ = $1->self_scm ();
456 scm_gc_unprotect_object ($$);
458 | translator_spec_block {
462 $$ = $1->self_scm ();
463 scm_gc_unprotect_object ($$);
466 $$ = $1->self_scm ();
467 scm_gc_unprotect_object ($$);
472 | number_expression {
483 translator_spec_block:
484 TRANSLATOR '{' translator_spec_body '}'
490 translator_spec_body:
491 TRANSLATOR_IDENTIFIER {
493 unsmob_translator_def ($$)-> set_spot (THIS->here_input ());
496 $$ = Translator_def::make_scm ();
497 Translator_def*td = unsmob_translator_def ($$);
498 td->translator_group_type_ = $2;
499 td->set_spot (THIS->here_input ());
501 | translator_spec_body STRING '=' embedded_scm {
502 unsmob_translator_def ($$)->add_property_assign ($2, $4);
504 | translator_spec_body STRING OVERRIDE embedded_scm '=' embedded_scm {
505 unsmob_translator_def ($$)
506 ->add_push_property (scm_string_to_symbol ($2), $4, $6);
508 | translator_spec_body STRING SET embedded_scm '=' embedded_scm {
509 unsmob_translator_def ($$)
510 ->add_push_property (scm_string_to_symbol ($2), $4, $6);
512 | translator_spec_body STRING REVERT embedded_scm {
513 unsmob_translator_def ($$)->add_pop_property (
514 scm_string_to_symbol ($2), $4);
516 | translator_spec_body NAME STRING {
517 unsmob_translator_def ($$)->type_name_ = $3;
519 | translator_spec_body CONSISTS STRING {
520 unsmob_translator_def ($$)->add_element ($3);
522 | translator_spec_body ALIAS STRING {
523 Translator_def*td = unsmob_translator_def ($$);
524 td->type_aliases_ = scm_cons ($3, td->type_aliases_);
526 | translator_spec_body GROBDESCRIPTIONS embedded_scm {
527 Translator_def*td = unsmob_translator_def($$);
528 // td->add_property_assign (ly_symbol2scm ("allGrobDescriptions"), $3);
529 for (SCM p = $3; gh_pair_p (p); p = ly_cdr (p))
530 td->add_property_assign (scm_symbol_to_string (ly_caar (p)), ly_cdar (p));
532 | translator_spec_body CONSISTSEND STRING {
533 unsmob_translator_def ($$)->add_last_element ( $3);
535 | translator_spec_body ACCEPTS STRING {
536 unsmob_translator_def ($$)->set_acceptor ($3,true);
538 | translator_spec_body DENIES STRING {
539 unsmob_translator_def ($$)->set_acceptor ($3,false);
541 | translator_spec_body REMOVE STRING {
542 unsmob_translator_def ($$)->remove_element ($3);
553 /*cont*/ '{' score_body '}' {
556 if (!$$->defs_.size ())
558 Music_output_def *id =
559 unsmob_music_output_def (THIS->lexer_->lookup_identifier ("$defaultpaper"));
560 $$->add_output (id ? id->clone () : new Paper_def );
569 $$->set_spot (THIS->here_input ());
570 SCM m = $1->self_scm ();
571 scm_gc_unprotect_object (m);
576 SCM check_funcs = scm_c_eval_string ("toplevel-music-functions");
577 for (; gh_pair_p (check_funcs); check_funcs = gh_cdr (check_funcs))
578 m = gh_call1 (gh_car (check_funcs), m);
583 $$ = unsmob_score ($1);
584 $$->set_spot (THIS->here_input ());
586 | score_body lilypond_header {
589 | score_body output_def {
602 music_output_def_body '}' {
604 THIS-> lexer_-> remove_scope ();
608 music_output_def_body:
610 Music_output_def *id = unsmob_music_output_def (THIS->lexer_->lookup_identifier ("$defaultmidi"));
615 p = dynamic_cast<Midi_def*> (id->clone ());
620 THIS->lexer_->add_scope (p->scope_);
623 Music_output_def *id = unsmob_music_output_def (THIS->lexer_->lookup_identifier ("$defaultpaper"));
626 p = dynamic_cast<Paper_def*> (id->clone ());
630 THIS->lexer_->add_scope (p->scope_);
633 | PAPER '{' MUSIC_OUTPUT_DEF_IDENTIFIER {
634 Music_output_def * o = unsmob_music_output_def ($3);
637 THIS->lexer_->add_scope (o->scope_);
639 | MIDI '{' MUSIC_OUTPUT_DEF_IDENTIFIER {
640 Music_output_def * o = unsmob_music_output_def ($3);
643 THIS->lexer_->add_scope (o->scope_);
645 | music_output_def_body assignment {
648 | music_output_def_body translator_spec_block {
649 $$->assign_translator ($2);
651 | music_output_def_body tempo_event {
653 junk this ? there already is tempo stuff in
656 int m = gh_scm2int ( $2->get_mus_property ("metronome-count"));
657 Duration *d = unsmob_duration ($2->get_mus_property ("duration"));
658 Midi_def * md = dynamic_cast<Midi_def*> ($$);
660 md->set_tempo (d->get_length (), m);
662 | music_output_def_body error {
668 TEMPO steno_duration '=' bare_unsigned {
669 $$ = MY_MAKE_MUSIC("TempoEvent");
670 $$->set_mus_property ("duration", $2);
671 $$->set_mus_property ("metronome-count", gh_int2scm ( $4));
676 The representation of a list is the
680 to have efficient append.
684 $$ = scm_cons (SCM_EOL, SCM_EOL);
688 SCM c = scm_cons ($2->self_scm (), SCM_EOL);
689 scm_gc_unprotect_object ($2->self_scm ()); /* UGH */
690 if (gh_pair_p (ly_cdr (s)))
691 gh_set_cdr_x (ly_cdr (s), c); /* append */
693 gh_set_car_x (s, c); /* set first cons */
694 gh_set_cdr_x (s, c) ; /* remember last cell */
710 | ALTERNATIVE '{' Music_list '}' {
716 REPEAT string bare_unsigned Music Alternative_music
720 SCM alts = gh_pair_p ($5) ? gh_car ($5) : SCM_EOL;
721 if (times < scm_ilength (alts)) {
722 unsmob_music (gh_car (alts))
723 ->origin ()->warning (
724 _("More alternatives than repeats. Junking excess alternatives."));
725 alts = ly_truncate_list (times, alts);
731 proc = scm_c_eval_string ("make-repeated-music");
733 SCM mus = scm_call_1 (proc, $2);
734 scm_gc_protect_object (mus); // UGH.
735 Music *r =unsmob_music (mus);
738 r-> set_mus_property ("element", beg->self_scm ());
739 scm_gc_unprotect_object (beg->self_scm ());
741 r->set_mus_property ("repeat-count", gh_int2scm (times >? 1));
743 r-> set_mus_property ("elements",alts);
744 if (gh_equal_p ($2, scm_makfrom0str ("tremolo")))
747 we can not get durations and other stuff correct down the line, so we have to
748 add to the duration log here.
750 SCM func = scm_primitive_eval (ly_symbol2scm ("shift-duration-log"));
752 gh_call3 (func, r->self_scm (), gh_int2scm(-intlog2 ($3*2/3)),gh_int2scm(1));
754 gh_call3 (func, r->self_scm (), gh_int2scm(-intlog2 ($3)), gh_int2scm(0));
756 r->set_spot (*$4->origin ());
763 SEQUENTIAL '{' Music_list '}' {
764 $$ = MY_MAKE_MUSIC("SequentialMusic");
765 $$->set_mus_property ("elements", ly_car ($3));
766 $$->set_spot(THIS->here_input());
768 | '{' Music_list '}' {
769 $$ = MY_MAKE_MUSIC("SequentialMusic");
770 $$->set_mus_property ("elements", ly_car ($2));
771 $$->set_spot(THIS->here_input());
776 SIMULTANEOUS '{' Music_list '}'{
777 $$ = MY_MAKE_MUSIC("SimultaneousMusic");
778 $$->set_mus_property ("elements", ly_car ($3));
779 $$->set_spot(THIS->here_input());
782 | '<' Music_list '>' {
783 $$ = MY_MAKE_MUSIC("SimultaneousMusic");
784 $$->set_mus_property ("elements", ly_car ($2));
785 $$->set_spot(THIS->here_input());
790 event_chord { $$ = $1; }
791 | OUTPUTPROPERTY embedded_scm embedded_scm '=' embedded_scm {
793 if (!gh_symbol_p ($3))
795 THIS->parser_error (_ ("Second argument must be a symbol"));
797 /* Should check # args */
798 if (!gh_procedure_p (pred))
800 THIS->parser_error (_ ("First argument must be a procedure taking one argument"));
803 Music*m = MY_MAKE_MUSIC("OutputPropertySetMusic");
804 m->set_mus_property ("predicate", pred);
805 m->set_mus_property ("grob-property", $3);
806 m->set_mus_property ("grob-value", $5);
811 $$ = unsmob_music ($1);
819 CONTEXT STRING Music {
820 Music*csm =MY_MAKE_MUSIC("ContextSpeccedMusic");
822 csm->set_mus_property ("element", $3->self_scm ());
823 scm_gc_unprotect_object ($3->self_scm ());
825 csm->set_mus_property ("context-type",$2);
826 csm->set_mus_property ("context-id", scm_makfrom0str (""));
830 | AUTOCHANGE STRING Music {
831 Music*chm = MY_MAKE_MUSIC("AutoChangeMusic");
832 chm->set_mus_property ("element", $3->self_scm ());
833 chm->set_mus_property ("iterator-ctor", Auto_change_iterator::constructor_proc);
835 scm_gc_unprotect_object ($3->self_scm ());
836 chm->set_mus_property ("what", $2);
839 chm->set_spot (*$3->origin ());
844 The other version is for easier debugging of
845 Sequential_music_iterator in combination with grace notes.
848 SCM start = THIS->lexer_->lookup_identifier ("startGraceMusic");
849 SCM stop = THIS->lexer_->lookup_identifier ("stopGraceMusic");
850 Music *startm = unsmob_music (start);
851 Music *stopm = unsmob_music (stop);
855 stopm = stopm->clone ();
856 ms = scm_cons (stopm->self_scm (), ms);
857 scm_gc_unprotect_object (stopm->self_scm ());
859 ms = scm_cons ($2->self_scm (), ms);
860 scm_gc_unprotect_object ($2->self_scm());
862 startm = startm->clone ();
863 ms = scm_cons (startm->self_scm () , ms);
864 scm_gc_unprotect_object (startm->self_scm ());
868 Music* seq = MY_MAKE_MUSIC("SequentialMusic");
869 seq->set_mus_property ("elements", ms);
872 $$ = MY_MAKE_MUSIC("GraceMusic");
873 $$->set_mus_property ("element", seq->self_scm ());
874 scm_gc_unprotect_object (seq->self_scm ());
876 $$ = MY_MAKE_MUSIC("GraceMusic");
877 $$->set_mus_property ("element", $2->self_scm ());
878 scm_gc_unprotect_object ($2->self_scm ());
881 | CONTEXT string '=' string Music {
882 Music * csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
884 csm->set_mus_property ("element", $5->self_scm ());
885 scm_gc_unprotect_object ($5->self_scm ());
887 csm->set_mus_property ("context-type", $2);
888 csm->set_mus_property ("context-id", $4);
899 int n = gh_scm2int (ly_car ($3)); int d = gh_scm2int (ly_cdr ($3));
901 $$= MY_MAKE_MUSIC("TimeScaledMusic");
902 $$->set_spot (THIS->pop_spot ());
905 $$->set_mus_property ("element", mp->self_scm ());
906 scm_gc_unprotect_object (mp->self_scm ());
907 $$->set_mus_property ("numerator", gh_int2scm (n));
908 $$->set_mus_property ("denominator", gh_int2scm (d));
909 $$->compress (Moment (Rational (n,d)));
912 | Repeated_music { $$ = $1; }
913 | Simultaneous_music { $$ = $1; }
914 | Sequential_music { $$ = $1; }
915 | TRANSPOSE pitch_also_in_chords pitch_also_in_chords Music {
916 $$ = MY_MAKE_MUSIC("TransposedMusic");
918 Pitch from = *unsmob_pitch ($2);
919 Pitch to = *unsmob_pitch ($3);
921 p->transpose (interval (from, to));
922 $$->set_mus_property ("element", p->self_scm ());
923 scm_gc_unprotect_object (p->self_scm ());
925 | APPLY embedded_scm Music {
926 SCM ret = gh_call1 ($2, $3->self_scm ());
927 Music *m = unsmob_music (ret);
929 THIS->parser_error ("\\apply must return a Music");
930 m = MY_MAKE_MUSIC("Music");
935 { THIS->lexer_->push_note_state (); }
938 THIS->lexer_->pop_state ();
941 { THIS->lexer_->push_figuredbass_state (); }
944 Music * chm = MY_MAKE_MUSIC("UntransposableMusic");
945 chm->set_mus_property ("element", $3->self_scm ());
947 scm_gc_unprotect_object ($3->self_scm());
949 THIS->lexer_->pop_state ();
952 { THIS->lexer_->push_chord_state (); }
955 Music * chm = MY_MAKE_MUSIC("UnrelativableMusic");
956 chm->set_mus_property ("element", $3->self_scm ());
957 scm_gc_unprotect_object ($3->self_scm());
960 THIS->lexer_->pop_state ();
963 { THIS->lexer_->push_lyric_state (); }
967 THIS->lexer_->pop_state ();
969 | relative_music { $$ = $1; }
970 | re_rhythmed_music { $$ = $1; }
971 | part_combined_music { $$ = $1; }
975 RELATIVE absolute_pitch Music {
977 Pitch pit = *unsmob_pitch ($2);
978 $$ = MY_MAKE_MUSIC("RelativeOctaveMusic");
980 $$->set_mus_property ("element", p->self_scm ());
981 scm_gc_unprotect_object (p->self_scm ());
983 $$->set_mus_property ("last-pitch", p->to_relative_octave (pit).smobbed_copy ());
989 ADDLYRICS Music Music {
990 Music*l =MY_MAKE_MUSIC("LyricCombineMusic");
991 l->set_mus_property ("elements", gh_list ($2->self_scm (), $3->self_scm (), SCM_UNDEFINED));
992 scm_gc_unprotect_object ($3->self_scm ());
993 scm_gc_unprotect_object ($2->self_scm ());
999 PARTCOMBINE STRING Music Music {
1000 Music * p= MY_MAKE_MUSIC("PartCombineMusic");
1001 p->set_mus_property ("what", $2);
1002 p->set_mus_property ("elements", gh_list ($3->self_scm (),$4->self_scm (), SCM_UNDEFINED));
1004 scm_gc_unprotect_object ($3->self_scm ());
1005 scm_gc_unprotect_object ($4->self_scm ());
1012 TRANSLATOR STRING '=' STRING {
1013 Music*t= MY_MAKE_MUSIC("TranslatorChange");
1014 t-> set_mus_property ("change-to-type", $2);
1015 t-> set_mus_property ("change-to-id", $4);
1018 $$->set_spot (THIS->here_input ());
1024 | ONCE simple_property_def {
1026 SCM e = $2->get_mus_property ("element");
1027 unsmob_music (e)->set_mus_property ("once", SCM_BOOL_T);
1031 simple_property_def:
1032 PROPERTY STRING '.' STRING '=' scalar {
1033 Music *t = set_property_music (scm_string_to_symbol ($4), $6);
1034 Music *csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
1036 csm->set_mus_property ("element", t->self_scm ());
1037 scm_gc_unprotect_object (t->self_scm ());
1040 $$->set_spot (THIS->here_input ());
1042 csm-> set_mus_property ("context-type", $2);
1044 | PROPERTY STRING '.' STRING UNSET {
1046 Music *t = MY_MAKE_MUSIC("PropertyUnset");
1047 t->set_mus_property ("symbol", scm_string_to_symbol ($4));
1049 Music *csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
1050 csm->set_mus_property ("element", t->self_scm ());
1051 scm_gc_unprotect_object (t->self_scm ());
1054 $$->set_spot (THIS->here_input ());
1056 csm-> set_mus_property ("context-type", $2);
1058 | PROPERTY STRING '.' STRING SET embedded_scm '=' embedded_scm {
1060 = gh_equal_p ($4, scm_makfrom0str ("autoBeamSettings"));
1061 bool itc = internal_type_checking_global_b;
1062 Music *t = MY_MAKE_MUSIC("OverrideProperty");
1063 t->set_mus_property ("symbol", scm_string_to_symbol ($4));
1064 t->set_mus_property ("pop-first", SCM_BOOL_T);
1066 internal_type_checking_global_b = false;
1067 t->set_mus_property ("grob-property", $6);
1069 internal_type_checking_global_b = itc;
1070 t->set_mus_property ("grob-value", $8);
1072 Music *csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
1073 csm->set_mus_property ("element", t->self_scm ());
1074 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 OVERRIDE
1081 embedded_scm '=' embedded_scm
1087 = gh_equal_p ($4, scm_makfrom0str ("autoBeamSettings"));
1088 bool itc = internal_type_checking_global_b;
1090 Music *t = MY_MAKE_MUSIC("OverrideProperty");
1091 t->set_mus_property ("symbol", scm_string_to_symbol ($4));
1093 internal_type_checking_global_b = false;
1094 t->set_mus_property ("grob-property", $6);
1095 t->set_mus_property ("grob-value", $8);
1097 internal_type_checking_global_b = itc;
1099 Music *csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
1100 csm->set_mus_property ("element", t->self_scm ());
1101 scm_gc_unprotect_object (t->self_scm ());
1104 $$->set_spot (THIS->here_input ());
1106 csm-> set_mus_property ("context-type", $2);
1109 | PROPERTY STRING '.' STRING REVERT embedded_scm {
1110 Music *t = MY_MAKE_MUSIC("RevertProperty");
1112 = gh_equal_p ($4, scm_makfrom0str ("autoBeamSettings"));
1113 bool itc = internal_type_checking_global_b;
1115 t->set_mus_property ("symbol", scm_string_to_symbol ($4));
1117 internal_type_checking_global_b = false;
1118 t->set_mus_property ("grob-property", $6);
1120 internal_type_checking_global_b = itc;
1122 Music *csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
1123 csm->set_mus_property ("element", t->self_scm ());
1124 scm_gc_unprotect_object (t->self_scm ());
1127 $$->set_spot (THIS->here_input ());
1129 csm-> set_mus_property ("context-type", $2);
1136 | bare_int { $$ = gh_int2scm ($1); }
1137 | embedded_scm { $$ = $1; }
1144 } /*cont */ simple_element post_events {
1145 SCM elts = $3-> get_mus_property ("elements");
1147 elts = gh_append3 (elts, scm_reverse_x ($1, SCM_EOL),
1148 scm_reverse_x ($4, SCM_EOL));
1150 $3-> set_mus_property ("elements", elts);
1154 | note_chord_element
1159 chord_body optional_notemode_duration post_events
1161 SCM dur = unsmob_duration ($2)->smobbed_copy();
1162 SCM es = $1->get_mus_property ("elements");
1163 SCM postevs = scm_reverse_x ($3, SCM_EOL);
1165 for (SCM s = es; gh_pair_p (s); s = gh_cdr (s))
1166 unsmob_music (gh_car(s))->set_mus_property ("duration", dur);
1167 es = gh_append2 (es, postevs);
1169 $1-> set_mus_property ("elements", es);
1175 CHORD_OPEN chord_body_elements CHORD_CLOSE
1177 $$ = MY_MAKE_MUSIC("EventChord");
1178 $$->set_mus_property ("elements",
1179 scm_reverse_x ($2, SCM_EOL));
1183 chord_body_elements:
1184 /* empty */ { $$ = SCM_EOL; }
1185 | chord_body_elements chord_body_element {
1186 $$ = gh_cons ($2->self_scm(), $1);
1187 scm_gc_unprotect_object ($2->self_scm());
1192 pitch exclamations questions post_events
1194 Music * n = MY_MAKE_MUSIC("NoteEvent");
1195 n->set_mus_property ("pitch", $1);
1197 n->set_mus_property ("cautionary", SCM_BOOL_T);
1198 if ($2 % 2 || $3 % 2)
1199 n->set_mus_property ("force-accidental", SCM_BOOL_T);
1201 SCM arts = scm_reverse_x ($4, SCM_EOL);
1202 n->set_mus_property ("articulations", arts);
1210 $$ = MY_MAKE_MUSIC("EventChord");
1211 $$->set_mus_property ("elements", scm_cons ($1->self_scm (), SCM_EOL));
1212 scm_gc_unprotect_object ($1->self_scm());
1214 $$-> set_spot (THIS->here_input ());
1215 $1-> set_spot (THIS->here_input ());
1218 Music *l = MY_MAKE_MUSIC("LigatureEvent");
1219 l->set_mus_property ("span-direction", gh_int2scm (START));
1220 l->set_spot (THIS->here_input ());
1222 $$ = MY_MAKE_MUSIC("EventChord");
1223 $$->set_mus_property ("elements", scm_cons (l->self_scm (), SCM_EOL));
1224 scm_gc_unprotect_object (l->self_scm());
1225 $$->set_spot (THIS->here_input ());
1228 Music *l = MY_MAKE_MUSIC("LigatureEvent");
1229 l->set_mus_property ("span-direction", gh_int2scm (STOP));
1230 l->set_spot (THIS->here_input ());
1232 $$ = MY_MAKE_MUSIC("EventChord");
1233 $$->set_mus_property ("elements", scm_cons (l->self_scm (), SCM_EOL));
1234 $$->set_spot (THIS->here_input ());
1235 scm_gc_unprotect_object (l->self_scm());
1239 $$ = MY_MAKE_MUSIC("VoiceSeparator");
1240 $$->set_spot (THIS->here_input ());
1244 $$ = MY_MAKE_MUSIC("BarCheck");
1245 $$->set_spot (THIS->here_input ());
1248 Music *t = set_property_music (ly_symbol2scm ("whichBar"), $2);
1250 Music *csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
1251 csm->set_mus_property ("element", t->self_scm ());
1252 scm_gc_unprotect_object (t->self_scm ());
1255 $$->set_spot (THIS->here_input ());
1257 csm->set_mus_property ("context-type", scm_makfrom0str ("Timing"));
1259 | PARTIAL duration_length {
1260 Moment m = - unsmob_duration ($2)->get_length ();
1261 Music * p = set_property_music (ly_symbol2scm ( "measurePosition"),m.smobbed_copy ());
1263 Music * sp = MY_MAKE_MUSIC("ContextSpeccedMusic");
1264 sp->set_mus_property ("element", p->self_scm ());
1265 scm_gc_unprotect_object (p->self_scm ());
1268 sp-> set_mus_property ("context-type", scm_makfrom0str ("Timing"));
1273 proc = scm_c_eval_string ("make-clef-set");
1275 SCM result = scm_call_1 (proc, $2);
1276 scm_gc_protect_object (result);
1277 $$ = unsmob_music (result);
1280 Music * p1 = set_property_music (ly_symbol2scm ( "timeSignatureFraction"), $2);
1282 int l = gh_scm2int (ly_car ($2));
1283 int o = gh_scm2int (ly_cdr ($2));
1285 Moment one_beat = Moment (1)/Moment (o);
1286 Moment len = Moment (l) * one_beat;
1289 Music *p2 = set_property_music (ly_symbol2scm ("measureLength"), len.smobbed_copy ());
1290 Music *p3 = set_property_music (ly_symbol2scm ("beatLength"), one_beat.smobbed_copy ());
1292 SCM list = scm_list_n (p1->self_scm (), p2->self_scm (), p3->self_scm(), SCM_UNDEFINED);
1293 Music *seq = MY_MAKE_MUSIC("SequentialMusic");
1294 seq->set_mus_property ("elements", list);
1297 Music * sp = MY_MAKE_MUSIC("ContextSpeccedMusic");
1298 sp->set_mus_property ("element", seq->self_scm ());
1300 scm_gc_unprotect_object (p3->self_scm ());
1301 scm_gc_unprotect_object (p2->self_scm ());
1302 scm_gc_unprotect_object (p1->self_scm ());
1303 scm_gc_unprotect_object (seq->self_scm ());
1307 sp-> set_mus_property ("context-type", scm_makfrom0str ( "Timing"));
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("FingerEvent");
1642 t->set_mus_property ("digit", gh_int2scm ($1));
1643 t->set_spot (THIS->here_input ());
1648 script_abbreviation:
1650 $$ = scm_makfrom0str ("Hat");
1653 $$ = scm_makfrom0str ("Plus");
1656 $$ = scm_makfrom0str ("Dash");
1659 $$ = scm_makfrom0str ("Bar");
1662 $$ = scm_makfrom0str ("Larger");
1665 $$ = scm_makfrom0str ("Dot");
1668 $$ = scm_makfrom0str ("Underscore");
1675 | '-' { $$ = CENTER; }
1682 | pre_events open_event {
1683 $$ = gh_cons ($2->self_scm(), $$);
1684 scm_gc_unprotect_object ($2->self_scm());
1695 multiplied_duration {
1698 | verbose_duration {
1703 optional_notemode_duration:
1705 Duration dd = THIS->default_duration_;
1706 $$ = dd.smobbed_copy ();
1708 THIS->beam_check ($$);
1710 | multiplied_duration {
1712 THIS->default_duration_ = *unsmob_duration ($$);
1714 THIS->beam_check ($$);
1716 | verbose_duration {
1718 THIS->default_duration_ = *unsmob_duration ($$);
1723 bare_unsigned dots {
1725 if (!is_duration_b ($1))
1726 THIS->parser_error (_f ("not a duration: %d", $1));
1730 $$ = Duration (l, $2).smobbed_copy ();
1732 | DURATION_IDENTIFIER dots {
1733 Duration *d =unsmob_duration ($1);
1734 Duration k (d->duration_log (),d->dot_count () + $2);
1744 multiplied_duration:
1748 | multiplied_duration '*' bare_unsigned {
1749 $$ = unsmob_duration ($$)->compressed ( $3) .smobbed_copy ();
1751 | multiplied_duration '*' FRACTION {
1752 Rational m (gh_scm2int (ly_car ($3)), gh_scm2int (ly_cdr ($3)));
1754 $$ = unsmob_duration ($$)->compressed (m).smobbed_copy ();
1759 FRACTION { $$ = $1; }
1760 | UNSIGNED '/' UNSIGNED {
1761 $$ = scm_cons (gh_int2scm ($1), gh_int2scm ($3));
1779 | ':' bare_unsigned {
1780 if (!is_duration_b ($2))
1781 THIS->parser_error (_f ("not a duration: %d", $2));
1788 /*****************************************************************
1790 *****************************************************************/
1804 Music *bfr = MY_MAKE_MUSIC("BassFigureEvent");
1805 $$ = bfr->self_scm();
1806 scm_gc_unprotect_object ($$);
1809 Music *bfr = MY_MAKE_MUSIC("BassFigureEvent");
1810 $$ = bfr->self_scm();
1812 bfr->set_mus_property ("figure", gh_int2scm ($1));
1814 scm_gc_unprotect_object ($$);
1816 | bass_figure bass_mod {
1817 Music *m = unsmob_music ($1);
1819 SCM salter =m->get_mus_property ("alteration");
1820 int alter = gh_number_p ( salter) ? gh_scm2int (salter) : 0;
1821 m->set_mus_property ("alteration",
1822 gh_int2scm (alter + $2));
1824 m->set_mus_property ("alteration", gh_int2scm (0));
1832 unsmob_music ($$)->set_mus_property ("bracket-start", SCM_BOOL_T);
1837 | br_bass_figure ']' {
1839 unsmob_music ($1)->set_mus_property ("bracket-stop", SCM_BOOL_T);
1847 | figure_list br_bass_figure {
1848 $$ = scm_cons ($2, $1);
1853 FIGURE_OPEN figure_list FIGURE_CLOSE {
1854 Music * m = MY_MAKE_MUSIC("EventChord");
1855 $2 = scm_reverse_x ($2, SCM_EOL);
1856 m->set_mus_property ("elements", $2);
1857 $$ = m->self_scm ();
1868 pitch exclamations questions optional_notemode_duration optional_rest {
1870 Input i = THIS->pop_spot ();
1871 if (!THIS->lexer_->note_state_b ())
1872 THIS->parser_error (_ ("Have to be in Note mode for notes"));
1876 n = MY_MAKE_MUSIC("RestEvent");
1878 n = MY_MAKE_MUSIC("NoteEvent");
1880 n->set_mus_property ("pitch", $1);
1881 n->set_mus_property ("duration", $4);
1885 n->set_mus_property ("cautionary", SCM_BOOL_T);
1886 if ($2 % 2 || $3 % 2)
1887 n->set_mus_property ("force-accidental", SCM_BOOL_T);
1889 Music *v = MY_MAKE_MUSIC("EventChord");
1890 v->set_mus_property ("elements", scm_list_n (n->self_scm (), SCM_UNDEFINED));
1891 scm_gc_unprotect_object (n->self_scm());
1897 | figure_spec optional_notemode_duration {
1898 Music * m = unsmob_music ($1);
1899 Input i = THIS->pop_spot ();
1901 for (SCM s = m->get_mus_property ("elements"); gh_pair_p (s); s = ly_cdr (s))
1903 unsmob_music (ly_car (s))->set_mus_property ("duration", $2);
1907 | RESTNAME optional_notemode_duration {
1909 Input i = THIS->pop_spot ();
1911 if (ly_scm2string ($1) =="s") {
1913 ev = MY_MAKE_MUSIC("SkipEvent");
1916 ev = MY_MAKE_MUSIC("RestEvent");
1919 ev->set_mus_property ("duration" ,$2);
1921 Music * velt = MY_MAKE_MUSIC("EventChord");
1922 velt->set_mus_property ("elements", scm_list_n (ev->self_scm (),SCM_UNDEFINED));
1927 | MULTI_MEASURE_REST optional_notemode_duration {
1932 proc = scm_c_eval_string ("make-multi-measure-rest");
1934 SCM mus = scm_call_2 (proc, $2,
1935 make_input (THIS->here_input()));
1936 scm_gc_protect_object (mus);
1937 $$ = unsmob_music (mus);
1939 | STRING optional_notemode_duration {
1940 Input i = THIS->pop_spot ();
1942 Music * lreq = MY_MAKE_MUSIC("LyricEvent");
1943 lreq->set_mus_property ("text", $1);
1944 lreq->set_mus_property ("duration",$2);
1946 Music * velt = MY_MAKE_MUSIC("EventChord");
1947 velt->set_mus_property ("elements", scm_list_n (lreq->self_scm (), SCM_UNDEFINED));
1954 if (!THIS->lexer_->chord_state_b ())
1955 THIS->parser_error (_ ("Have to be in Chord mode for chords"));
1962 steno_tonic_pitch optional_notemode_duration chord_additions chord_subtractions chord_inversion chord_bass {
1963 $$ = Chord::get_chord ($1, $3, $4, $5, $6, $2);
1964 $$->set_spot (THIS->here_input ());
1971 | CHORD_COLON chord_notes {
1980 | chord_notes '.' chord_step {
1981 $$ = gh_append2 ($$, $3);
1989 | CHORD_CARET chord_notes {
1999 | CHORD_SLASH steno_tonic_pitch {
2008 | CHORD_BASS steno_tonic_pitch {
2015 $$ = scm_cons ($1, SCM_EOL);
2017 | CHORDMODIFIER_PITCH {
2018 $$ = scm_cons (unsmob_pitch ($1)->smobbed_copy (), SCM_EOL);
2020 | CHORDMODIFIER_PITCH chord_note { /* Ugh. */
2021 $$ = scm_list_n (unsmob_pitch ($1)->smobbed_copy (),
2029 m.notename_ = ($1 - 1) % 7;
2030 m.octave_ = $1 > 7 ? 1 : 0;
2033 $$ = m.smobbed_copy ();
2035 | bare_unsigned '+' {
2037 m.notename_ = ($1 - 1) % 7;
2038 m.octave_ = $1 > 7 ? 1 : 0;
2042 $$ = m.smobbed_copy ();
2044 | bare_unsigned CHORD_MINUS {
2046 m.notename_ = ($1 - 1) % 7;
2047 m.octave_ = $1 > 7 ? 1 : 0;
2050 $$ = m.smobbed_copy ();
2058 number_expression '+' number_term {
2059 $$ = scm_sum ($1, $3);
2061 | number_expression '-' number_term {
2062 $$ = scm_difference ($1, $3);
2071 | number_factor '*' number_factor {
2072 $$ = scm_product ($1, $3);
2074 | number_factor '/' number_factor {
2075 $$ = scm_divide ($1, $3);
2080 '-' number_factor { /* %prec UNARY_MINUS */
2081 $$ = scm_difference ($2, SCM_UNDEFINED);
2089 $$ = gh_int2scm ($1);
2094 | NUMBER_IDENTIFIER {
2097 | REAL NUMBER_IDENTIFIER {
2098 $$ = gh_double2scm (gh_scm2double ($1) * gh_scm2double ($2));
2100 | UNSIGNED NUMBER_IDENTIFIER {
2101 $$ = gh_double2scm ($1 * gh_scm2double ($2));
2117 if (scm_integer_p ($1) == SCM_BOOL_T)
2119 int k = gh_scm2int ($1);
2123 THIS->parser_error (_ ("need integer number arg"));
2137 | STRING_IDENTIFIER {
2140 | string '+' string {
2141 $$ = scm_string_append (scm_list_n ($1, $3, SCM_UNDEFINED));
2148 | exclamations '!' { $$ ++; }
2153 | questions '?' { $$ ++; }
2160 My_lily_parser::set_yydebug (bool )
2167 extern My_lily_parser * current_parser;
2170 My_lily_parser::do_yyparse ()
2172 current_parser = this;;
2173 yyparse ((void*)this);
2178 Should make this optional? It will also complain when you do
2182 which is entirely legitimate.
2184 Or we can scrap it. Barchecks should detect wrong durations, and
2185 skipTypesetting speeds it up a lot.
2189 My_lily_parser::beam_check (SCM dur)
2191 Duration *d = unsmob_duration (dur);
2192 if (unsmob_music (last_beam_start_) && d->duration_log () <= 2)
2194 Music * m = unsmob_music (last_beam_start_);
2195 m->origin ()->warning (_("Suspect duration found following this beam"));
2197 last_beam_start_ = SCM_EOL;
2202 It is a little strange, to have this function in this file, but
2203 otherwise, we have to import music classes into the lexer.
2207 My_lily_lexer::try_special_identifiers (SCM * destination, SCM sid)
2209 if (gh_string_p (sid)) {
2211 return STRING_IDENTIFIER;
2212 } else if (gh_number_p (sid)) {
2214 return NUMBER_IDENTIFIER;
2215 } else if (unsmob_translator_def (sid)) {
2216 *destination = unsmob_translator_def (sid)->clone_scm();
2217 return TRANSLATOR_IDENTIFIER;
2218 } else if (unsmob_score (sid)) {
2219 Score *sc = new Score (*unsmob_score (sid));
2220 *destination =sc->self_scm ();
2221 return SCORE_IDENTIFIER;
2222 } else if (Music * mus =unsmob_music (sid)) {
2223 *destination = unsmob_music (sid)->clone ()->self_scm();
2224 unsmob_music (*destination)->
2225 set_mus_property ("origin", make_input (last_input_));
2226 return dynamic_cast<Event*> (mus)
2227 ? EVENT_IDENTIFIER : MUSIC_IDENTIFIER;
2228 } else if (unsmob_duration (sid)) {
2229 *destination = unsmob_duration (sid)->smobbed_copy();
2230 return DURATION_IDENTIFIER;
2231 } else if (unsmob_music_output_def (sid)) {
2232 Music_output_def *p = unsmob_music_output_def (sid);
2235 *destination = p->self_scm();
2236 return MUSIC_OUTPUT_DEF_IDENTIFIER;