1 %{ // -*-Fundamental-*-
4 parser.yy -- Bison/C++ parser for lilypond
6 source file of the GNU LilyPond music typesetter
8 (c) 1997--2003 Han-Wen Nienhuys <hanwen@cs.uu.nl>
9 Jan Nieuwenhuizen <janneke@gnu.org>
13 Two shift/reduce problems:
17 "bar" -> String -> Lyric -> Music -> music-assignment
19 "bar" -> String -> string-assignment
23 \repeat .. \alternative
26 \repeat { \repeat .. \alternative }
30 \repeat { \repeat } \alternative
42 * The rules for who is protecting what are very shady. Uniformise
45 * There are too many lexical modes?
52 #include "translator-def.hh"
53 #include "lily-guile.hh"
55 #include "my-lily-lexer.hh"
56 #include "paper-def.hh"
57 #include "midi-def.hh"
59 #include "file-path.hh"
61 #include "dimensions.hh"
62 #include "my-lily-parser.hh"
64 #include "input-file-results.hh"
66 #include "lilypond-input-version.hh"
67 #include "scm-hash.hh"
68 #include "auto-change-iterator.hh"
69 #include "ly-modules.hh"
70 #include "music-sequence.hh"
71 #include "input-smob.hh"
73 #include "text-item.hh"
77 #define MY_MAKE_MUSIC(x) make_music_by_name (ly_symbol2scm (x))
81 #define YYERROR_VERBOSE 1
83 My_lily_parser* my_lily_parser;
84 #define YYPARSE_PARAM my_lily_parser
85 #define YYLEX_PARAM my_lily_parser
87 ((My_lily_parser *) my_lily_parser)
89 #define yyerror THIS->parser_error
96 regular_identifier_b (SCM id)
98 String str = ly_scm2string (id);
99 char const *s = str.to_str0 () ;
104 v = v && isalpha (*s);
111 make_simple_markup (SCM a)
115 simple = scm_c_eval_string ("simple-markup");
117 return scm_list_n (simple, a, SCM_UNDEFINED);
122 is_duration_b (int t)
124 return t && t == 1 << intlog2 (t);
128 set_music_properties (Music *p, SCM a)
130 for (SCM k = a; gh_pair_p (k); k = ly_cdr (k))
132 p->internal_set_mus_property (ly_caar (k), ly_cdar (k));
138 make_chord_step (int step, int alter)
143 /* ugh: fucks up above 13 */
144 Pitch m(step > 7 ? 1 : 0,(step - 1) % 7, alter);
145 return m.smobbed_copy ();
150 make_chord (SCM pitch, SCM dur, SCM modification_list)
152 static SCM chord_ctor;
154 chord_ctor= scm_c_eval_string ("construct-chord");
155 SCM ch= scm_call_3 (chord_ctor, pitch, dur, modification_list);
156 scm_gc_protect_object (ch);
163 set_property_music (SCM sym, SCM value)
165 Music * p = MY_MAKE_MUSIC("PropertySet");
166 p->set_mus_property ("symbol", sym);
167 p->set_mus_property ("value", value);
173 /* We use SCMs to do strings, because it saves us the trouble of
174 deleting them. Let's hope that a stack overflow doesnt trigger a move
175 of the parse stack onto the heap. */
182 Music_output_def * outputdef;
189 yylex (YYSTYPE *s, void * v)
191 My_lily_parser *pars = (My_lily_parser*) v;
192 My_lily_lexer * lex = pars->lexer_;
194 lex->lexval = (void*) s;
195 lex->prepare_for_next_token();
196 return lex->yylex ();
204 /* tokens which are not keywords */
213 %token CHORDMODIFIERS
219 %token GROBDESCRIPTIONS
224 %token FIGURES FIGURE_OPEN FIGURE_CLOSE
225 %token FIGURE_BRACKET_CLOSE FIGURE_BRACKET_OPEN
233 %token MULTI_MEASURE_REST
244 %token OVERRIDE SET REVERT
254 %token COMMANDSPANREQUEST
256 %token OUTPUTPROPERTY
271 %token E_CHAR E_EXCLAMATION E_SMALLER E_BIGGER E_OPEN E_CLOSE
272 %token E_LEFTSQUARE E_RIGHTSQUARE E_TILDE
274 %token <i> E_UNSIGNED
275 %token CHORD_BASS CHORD_COLON CHORD_MINUS CHORD_CARET CHORD_SLASH
278 %type <i> exclamations questions dots optional_rest
279 %type <i> bass_number bass_mod
280 %type <scm> br_bass_figure bass_figure figure_list figure_spec
282 %token <scm> NOTENAME_PITCH
283 %token <scm> TONICNAME_PITCH
284 %token <scm> CHORDMODIFIER_PITCH
285 %token <scm> DURATION_IDENTIFIER
286 %token <scm> FRACTION
287 %token <id> IDENTIFIER
288 %token <scm> CHORDNAMES CHORDNAMES_IDENTIFIER
290 %token <scm> CHORD_MODIFIER
292 %token <scm> SCORE_IDENTIFIER
293 %token <scm> MUSIC_OUTPUT_DEF_IDENTIFIER
294 %token <scm> NUMBER_IDENTIFIER
295 %token <scm> EVENT_IDENTIFIER
296 %token <scm> MUSIC_IDENTIFIER TRANSLATOR_IDENTIFIER
297 %token <scm> STRING_IDENTIFIER SCM_IDENTIFIER
298 %token <scm> RESTNAME
305 %token <scm> MARKUP_HEAD_MARKUP0
306 %token <scm> MARKUP_HEAD_MARKUP0_MARKUP1
307 %token <scm> MARKUP_HEAD_SCM0
308 %token <scm> MARKUP_HEAD_SCM0_MARKUP1
309 %token <scm> MARKUP_HEAD_SCM0_SCM1
310 %token <scm> MARKUP_HEAD_SCM0_SCM1_MARKUP2
312 %token <scm> MARKUP_IDENTIFIER MARKUP_HEAD_LIST0
313 %type <scm> markup markup_line markup_list markup_list_body full_markup
315 %type <outputdef> output_def
316 %type <scm> lilypond_header lilypond_header_body
317 %type <music> open_event_parens close_event_parens open_event close_event
318 %type <music> event_with_dir event_that_take_dir verbose_event
319 %type <i> sub_quotes sup_quotes
320 %type <music> simple_element event_chord command_element Simple_music Composite_music
321 %type <music> Repeated_music
322 %type <scm> Alternative_music
323 %type <i> tremolo_type
324 %type <i> bare_int bare_unsigned
326 %type <scm> identifier_init
328 %type <music> note_chord_element chord_body chord_body_element
329 %type <scm> chord_body_elements
330 %type <scm> steno_duration optional_notemode_duration multiplied_duration
331 %type <scm> verbose_duration
333 %type <scm> pre_events post_events
334 %type <music> gen_text_def
335 %type <scm> steno_pitch pitch absolute_pitch pitch_also_in_chords
336 %type <scm> explicit_pitch steno_tonic_pitch
338 /* %type <scm> chord_additions chord_subtractions chord_notes chord_step */
339 /* %type <music> chord */
340 /* %type <scm> chord_note chord_inversion chord_bass */
341 %type <scm> duration_length fraction
343 %type <scm> new_chord step_number chord_items chord_item chord_separator step_numbers
345 %type <scm> embedded_scm scalar
346 %type <music> Music Sequential_music Simultaneous_music
347 %type <music> relative_music re_rhythmed_music part_combined_music
348 %type <music> property_def translator_change simple_property_def
349 %type <scm> Music_list
350 %type <outputdef> music_output_def_body
351 %type <music> shorthand_command_req
352 %type <music> post_event
353 %type <music> command_req verbose_command_req
354 %type <music> extender_req
355 %type <music> hyphen_req
356 %type <music> string_event
357 %type <scm> string bare_number number_expression number_term number_factor
358 %type <score> score_block score_body
360 %type <scm> translator_spec_block translator_spec_body
361 %type <music> tempo_event
362 %type <scm> notenames_body notenames_block chordmodifiers_block
363 %type <scm> script_abbreviation
369 /* We don't assign precedence to / and *, because we might need varied
370 prec levels in different prods */
376 lilypond: /* empty */
377 | lilypond toplevel_expression {}
378 | lilypond assignment { }
380 THIS->error_level_ = 1;
383 THIS->error_level_ = 1;
389 THIS->lexer_->pitchname_tab_ = $1;
391 | chordmodifiers_block {
392 THIS->lexer_->chordmodifier_tab_ = $1;
395 THIS->input_file_->header_ = $1;
398 THIS->input_file_->scores_.push ($1);
401 if (dynamic_cast<Paper_def*> ($1))
402 THIS->lexer_->set_identifier (scm_makfrom0str ("$defaultpaper"), $1->self_scm ());
403 else if (dynamic_cast<Midi_def*> ($1))
404 THIS->lexer_->set_identifier (scm_makfrom0str ("$defaultmidi"), $1->self_scm ());
414 chordmodifiers_block:
415 CHORDMODIFIERS notenames_body { $$ = $2; }
419 PITCHNAMES notenames_body { $$ = $2; }
424 int i = scm_ilength ($1);
426 SCM tab = scm_make_vector (gh_int2scm (i), SCM_EOL);
427 for (SCM s = $1; gh_pair_p (s); s = ly_cdr (s)) {
428 SCM pt = ly_cdar (s);
429 scm_hashq_set_x (tab, ly_caar (s), pt);
435 lilypond_header_body:
437 $$ = ly_make_anonymous_module ();
438 THIS->lexer_->add_scope ($$);
440 | lilypond_header_body assignment {
446 HEADER '{' lilypond_header_body '}' {
447 $$ = THIS->lexer_-> remove_scope();
459 /* cont */ '=' identifier_init {
462 Should find generic way of associating input with objects.
464 Input ip = THIS->pop_spot ();
466 if (! regular_identifier_b ($1))
468 ip.warning (_ ("Identifier should have alphabetic characters only"));
471 THIS->lexer_->set_identifier ($1, $4);
474 TODO: devise standard for protection in parser.
476 The parser stack lives on the C-stack, which means that
477 all objects can be unprotected as soon as they're here.
488 $$ = $1->self_scm ();
489 scm_gc_unprotect_object ($$);
495 $$ = $1->self_scm ();
496 scm_gc_unprotect_object ($$);
498 | translator_spec_block {
502 $$ = $1->self_scm ();
503 scm_gc_unprotect_object ($$);
506 $$ = $1->self_scm ();
507 scm_gc_unprotect_object ($$);
512 | number_expression {
523 translator_spec_block:
524 TRANSLATOR '{' translator_spec_body '}'
530 translator_spec_body:
531 TRANSLATOR_IDENTIFIER {
533 unsmob_translator_def ($$)-> set_spot (THIS->here_input ());
536 $$ = Translator_def::make_scm ();
537 Translator_def*td = unsmob_translator_def ($$);
538 td->translator_group_type_ = $2;
539 td->set_spot (THIS->here_input ());
541 | translator_spec_body STRING '=' embedded_scm {
542 unsmob_translator_def ($$)->add_property_assign ($2, $4);
544 | translator_spec_body STRING OVERRIDE embedded_scm '=' embedded_scm {
545 unsmob_translator_def ($$)
546 ->add_push_property (scm_string_to_symbol ($2), $4, $6);
548 | translator_spec_body STRING SET embedded_scm '=' embedded_scm {
549 unsmob_translator_def ($$)
550 ->add_push_property (scm_string_to_symbol ($2), $4, $6);
552 | translator_spec_body STRING REVERT embedded_scm {
553 unsmob_translator_def ($$)->add_pop_property (
554 scm_string_to_symbol ($2), $4);
556 | translator_spec_body NAME STRING {
557 unsmob_translator_def ($$)->type_name_ = $3;
559 | translator_spec_body CONSISTS STRING {
560 unsmob_translator_def ($$)->add_element ($3);
562 | translator_spec_body ALIAS STRING {
563 Translator_def*td = unsmob_translator_def ($$);
564 td->type_aliases_ = scm_cons ($3, td->type_aliases_);
566 | translator_spec_body GROBDESCRIPTIONS embedded_scm {
567 Translator_def*td = unsmob_translator_def($$);
568 // td->add_property_assign (ly_symbol2scm ("allGrobDescriptions"), $3);
569 for (SCM p = $3; gh_pair_p (p); p = ly_cdr (p))
570 td->add_property_assign (scm_symbol_to_string (ly_caar (p)), ly_cdar (p));
572 | translator_spec_body CONSISTSEND STRING {
573 unsmob_translator_def ($$)->add_last_element ( $3);
575 | translator_spec_body ACCEPTS STRING {
576 unsmob_translator_def ($$)->set_acceptor ($3,true);
578 | translator_spec_body DENIES STRING {
579 unsmob_translator_def ($$)->set_acceptor ($3,false);
581 | translator_spec_body REMOVE STRING {
582 unsmob_translator_def ($$)->remove_element ($3);
593 /*cont*/ '{' score_body '}' {
596 if (!$$->defs_.size ())
598 Music_output_def *id =
599 unsmob_music_output_def (THIS->lexer_->lookup_identifier ("$defaultpaper"));
600 $$->add_output (id ? id->clone () : new Paper_def );
609 $$->set_spot (THIS->here_input ());
610 SCM m = $1->self_scm ();
611 scm_gc_unprotect_object (m);
616 SCM check_funcs = scm_c_eval_string ("toplevel-music-functions");
617 for (; gh_pair_p (check_funcs); check_funcs = gh_cdr (check_funcs))
618 m = gh_call1 (gh_car (check_funcs), m);
623 $$ = unsmob_score ($1);
624 $$->set_spot (THIS->here_input ());
626 | score_body lilypond_header {
629 | score_body output_def {
642 music_output_def_body '}' {
644 THIS-> lexer_-> remove_scope ();
648 music_output_def_body:
650 Music_output_def *id = unsmob_music_output_def (THIS->lexer_->lookup_identifier ("$defaultmidi"));
655 p = dynamic_cast<Midi_def*> (id->clone ());
660 THIS->lexer_->add_scope (p->scope_);
663 Music_output_def *id = unsmob_music_output_def (THIS->lexer_->lookup_identifier ("$defaultpaper"));
666 p = dynamic_cast<Paper_def*> (id->clone ());
670 THIS->lexer_->add_scope (p->scope_);
673 | PAPER '{' MUSIC_OUTPUT_DEF_IDENTIFIER {
674 Music_output_def * o = unsmob_music_output_def ($3);
677 THIS->lexer_->add_scope (o->scope_);
679 | MIDI '{' MUSIC_OUTPUT_DEF_IDENTIFIER {
680 Music_output_def * o = unsmob_music_output_def ($3);
683 THIS->lexer_->add_scope (o->scope_);
685 | music_output_def_body assignment {
688 | music_output_def_body translator_spec_block {
689 $$->assign_translator ($2);
691 | music_output_def_body tempo_event {
693 junk this ? there already is tempo stuff in
696 int m = gh_scm2int ( $2->get_mus_property ("metronome-count"));
697 Duration *d = unsmob_duration ($2->get_mus_property ("tempo-unit"));
698 Midi_def * md = dynamic_cast<Midi_def*> ($$);
700 md->set_tempo (d->get_length (), m);
702 | music_output_def_body error {
708 TEMPO steno_duration '=' bare_unsigned {
709 $$ = MY_MAKE_MUSIC("TempoEvent");
710 $$->set_mus_property ("tempo-unit", $2);
711 $$->set_mus_property ("metronome-count", gh_int2scm ( $4));
716 The representation of a list is the
720 to have efficient append.
724 $$ = scm_cons (SCM_EOL, SCM_EOL);
728 SCM c = scm_cons ($2->self_scm (), SCM_EOL);
729 scm_gc_unprotect_object ($2->self_scm ()); /* UGH */
730 if (gh_pair_p (ly_cdr (s)))
731 gh_set_cdr_x (ly_cdr (s), c); /* append */
733 gh_set_car_x (s, c); /* set first cons */
734 gh_set_cdr_x (s, c) ; /* remember last cell */
750 | ALTERNATIVE '{' Music_list '}' {
756 REPEAT string bare_unsigned Music Alternative_music
760 SCM alts = gh_pair_p ($5) ? gh_car ($5) : SCM_EOL;
761 if (times < scm_ilength (alts)) {
762 unsmob_music (gh_car (alts))
763 ->origin ()->warning (
764 _("More alternatives than repeats. Junking excess alternatives."));
765 alts = ly_truncate_list (times, alts);
771 proc = scm_c_eval_string ("make-repeated-music");
773 SCM mus = scm_call_1 (proc, $2);
774 scm_gc_protect_object (mus); // UGH.
775 Music *r =unsmob_music (mus);
778 r-> set_mus_property ("element", beg->self_scm ());
779 scm_gc_unprotect_object (beg->self_scm ());
781 r->set_mus_property ("repeat-count", gh_int2scm (times >? 1));
783 r-> set_mus_property ("elements",alts);
784 if (gh_equal_p ($2, scm_makfrom0str ("tremolo")))
787 we can not get durations and other stuff correct down the line, so we have to
788 add to the duration log here.
790 SCM func = scm_primitive_eval (ly_symbol2scm ("shift-duration-log"));
792 gh_call3 (func, r->self_scm (), gh_int2scm(-intlog2 ($3*2/3)),gh_int2scm(1));
794 gh_call3 (func, r->self_scm (), gh_int2scm(-intlog2 ($3)), gh_int2scm(0));
796 r->set_spot (*$4->origin ());
803 SEQUENTIAL '{' Music_list '}' {
804 $$ = MY_MAKE_MUSIC("SequentialMusic");
805 $$->set_mus_property ("elements", ly_car ($3));
806 $$->set_spot(THIS->here_input());
808 | '{' Music_list '}' {
809 $$ = MY_MAKE_MUSIC("SequentialMusic");
810 $$->set_mus_property ("elements", ly_car ($2));
811 $$->set_spot(THIS->here_input());
816 SIMULTANEOUS '{' Music_list '}'{
817 $$ = MY_MAKE_MUSIC("SimultaneousMusic");
818 $$->set_mus_property ("elements", ly_car ($3));
819 $$->set_spot(THIS->here_input());
822 | '<' Music_list '>' {
823 $$ = MY_MAKE_MUSIC("SimultaneousMusic");
824 $$->set_mus_property ("elements", ly_car ($2));
825 $$->set_spot(THIS->here_input());
830 event_chord { $$ = $1; }
831 | APPLYCONTEXT embedded_scm {
832 if (!gh_procedure_p ($2))
833 THIS->parser_error (_ ("\applycontext takes function argument"));
834 $$ = MY_MAKE_MUSIC ("ApplyContext");
835 $$->set_mus_property ("procedure", $2);
836 $$->set_spot (THIS->here_input());
838 | OUTPUTPROPERTY embedded_scm embedded_scm '=' embedded_scm {
840 if (!gh_symbol_p ($3))
842 THIS->parser_error (_ ("Second argument must be a symbol"));
844 /* Should check # args */
845 if (!gh_procedure_p (pred))
847 THIS->parser_error (_ ("First argument must be a procedure taking one argument"));
850 Music*m = MY_MAKE_MUSIC("OutputPropertySetMusic");
851 m->set_mus_property ("predicate", pred);
852 m->set_mus_property ("grob-property", $3);
853 m->set_mus_property ("grob-value", $5);
858 $$ = unsmob_music ($1);
866 CONTEXT STRING Music {
867 Music*csm =MY_MAKE_MUSIC("ContextSpeccedMusic");
869 csm->set_mus_property ("element", $3->self_scm ());
870 scm_gc_unprotect_object ($3->self_scm ());
872 csm->set_mus_property ("context-type",$2);
873 csm->set_mus_property ("context-id", scm_makfrom0str (""));
877 | AUTOCHANGE STRING Music {
878 Music*chm = MY_MAKE_MUSIC("AutoChangeMusic");
879 chm->set_mus_property ("element", $3->self_scm ());
880 chm->set_mus_property ("iterator-ctor", Auto_change_iterator::constructor_proc);
882 scm_gc_unprotect_object ($3->self_scm ());
883 chm->set_mus_property ("what", $2);
886 chm->set_spot (*$3->origin ());
891 The other version is for easier debugging of
892 Sequential_music_iterator in combination with grace notes.
895 SCM start = THIS->lexer_->lookup_identifier ("startGraceMusic");
896 SCM stop = THIS->lexer_->lookup_identifier ("stopGraceMusic");
897 Music *startm = unsmob_music (start);
898 Music *stopm = unsmob_music (stop);
902 stopm = stopm->clone ();
903 ms = scm_cons (stopm->self_scm (), ms);
904 scm_gc_unprotect_object (stopm->self_scm ());
906 ms = scm_cons ($2->self_scm (), ms);
907 scm_gc_unprotect_object ($2->self_scm());
909 startm = startm->clone ();
910 ms = scm_cons (startm->self_scm () , ms);
911 scm_gc_unprotect_object (startm->self_scm ());
915 Music* seq = MY_MAKE_MUSIC("SequentialMusic");
916 seq->set_mus_property ("elements", ms);
919 $$ = MY_MAKE_MUSIC("GraceMusic");
920 $$->set_mus_property ("element", seq->self_scm ());
921 scm_gc_unprotect_object (seq->self_scm ());
923 $$ = MY_MAKE_MUSIC("GraceMusic");
924 $$->set_mus_property ("element", $2->self_scm ());
925 scm_gc_unprotect_object ($2->self_scm ());
928 | CONTEXT string '=' string Music {
929 Music * csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
931 csm->set_mus_property ("element", $5->self_scm ());
932 scm_gc_unprotect_object ($5->self_scm ());
934 csm->set_mus_property ("context-type", $2);
935 csm->set_mus_property ("context-id", $4);
946 int n = gh_scm2int (ly_car ($3)); int d = gh_scm2int (ly_cdr ($3));
948 $$= MY_MAKE_MUSIC("TimeScaledMusic");
949 $$->set_spot (THIS->pop_spot ());
952 $$->set_mus_property ("element", mp->self_scm ());
953 scm_gc_unprotect_object (mp->self_scm ());
954 $$->set_mus_property ("numerator", gh_int2scm (n));
955 $$->set_mus_property ("denominator", gh_int2scm (d));
956 $$->compress (Moment (Rational (n,d)));
959 | Repeated_music { $$ = $1; }
960 | Simultaneous_music { $$ = $1; }
961 | Sequential_music { $$ = $1; }
962 | TRANSPOSE pitch_also_in_chords pitch_also_in_chords Music {
963 $$ = MY_MAKE_MUSIC("TransposedMusic");
965 Pitch from = *unsmob_pitch ($2);
966 Pitch to = *unsmob_pitch ($3);
968 p->transpose (interval (from, to));
969 $$->set_mus_property ("element", p->self_scm ());
970 scm_gc_unprotect_object (p->self_scm ());
972 | APPLY embedded_scm Music {
973 SCM ret = gh_call1 ($2, $3->self_scm ());
974 Music *m = unsmob_music (ret);
976 THIS->parser_error ("\\apply must return a Music");
977 m = MY_MAKE_MUSIC("Music");
982 { THIS->lexer_->push_note_state (); }
985 THIS->lexer_->pop_state ();
988 { THIS->lexer_->push_figuredbass_state (); }
991 Music * chm = MY_MAKE_MUSIC("UntransposableMusic");
992 chm->set_mus_property ("element", $3->self_scm ());
994 scm_gc_unprotect_object ($3->self_scm());
996 THIS->lexer_->pop_state ();
999 { THIS->lexer_->push_chord_state (); }
1002 Music * chm = MY_MAKE_MUSIC("UnrelativableMusic");
1003 chm->set_mus_property ("element", $3->self_scm ());
1004 scm_gc_unprotect_object ($3->self_scm());
1007 THIS->lexer_->pop_state ();
1010 { THIS->lexer_->push_lyric_state (); }
1014 THIS->lexer_->pop_state ();
1016 | relative_music { $$ = $1; }
1017 | re_rhythmed_music { $$ = $1; }
1018 | part_combined_music { $$ = $1; }
1022 RELATIVE absolute_pitch Music {
1024 Pitch pit = *unsmob_pitch ($2);
1025 $$ = MY_MAKE_MUSIC("RelativeOctaveMusic");
1027 $$->set_mus_property ("element", p->self_scm ());
1028 scm_gc_unprotect_object (p->self_scm ());
1031 $$->set_mus_property ("last-pitch", p->to_relative_octave (pit).smobbed_copy ());
1037 ADDLYRICS Music Music {
1038 Music*l =MY_MAKE_MUSIC("LyricCombineMusic");
1039 l->set_mus_property ("elements", gh_list ($2->self_scm (), $3->self_scm (), SCM_UNDEFINED));
1040 scm_gc_unprotect_object ($3->self_scm ());
1041 scm_gc_unprotect_object ($2->self_scm ());
1046 part_combined_music:
1047 PARTCOMBINE STRING Music Music {
1048 Music * p= MY_MAKE_MUSIC("PartCombineMusic");
1049 p->set_mus_property ("what", $2);
1050 p->set_mus_property ("elements", gh_list ($3->self_scm (),$4->self_scm (), SCM_UNDEFINED));
1052 scm_gc_unprotect_object ($3->self_scm ());
1053 scm_gc_unprotect_object ($4->self_scm ());
1060 TRANSLATOR STRING '=' STRING {
1061 Music*t= MY_MAKE_MUSIC("TranslatorChange");
1062 t-> set_mus_property ("change-to-type", $2);
1063 t-> set_mus_property ("change-to-id", $4);
1066 $$->set_spot (THIS->here_input ());
1072 | ONCE simple_property_def {
1074 SCM e = $2->get_mus_property ("element");
1075 unsmob_music (e)->set_mus_property ("once", SCM_BOOL_T);
1079 simple_property_def:
1080 PROPERTY STRING '.' STRING '=' scalar {
1081 Music *t = set_property_music (scm_string_to_symbol ($4), $6);
1082 Music *csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
1084 csm->set_mus_property ("element", t->self_scm ());
1085 scm_gc_unprotect_object (t->self_scm ());
1088 $$->set_spot (THIS->here_input ());
1090 csm-> set_mus_property ("context-type", $2);
1092 | PROPERTY STRING '.' STRING UNSET {
1094 Music *t = MY_MAKE_MUSIC("PropertyUnset");
1095 t->set_mus_property ("symbol", scm_string_to_symbol ($4));
1097 Music *csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
1098 csm->set_mus_property ("element", t->self_scm ());
1099 scm_gc_unprotect_object (t->self_scm ());
1102 $$->set_spot (THIS->here_input ());
1104 csm-> set_mus_property ("context-type", $2);
1106 | PROPERTY STRING '.' STRING SET embedded_scm '=' embedded_scm {
1108 = gh_equal_p ($4, scm_makfrom0str ("autoBeamSettings"));
1109 bool itc = internal_type_checking_global_b;
1110 Music *t = MY_MAKE_MUSIC("OverrideProperty");
1111 t->set_mus_property ("symbol", scm_string_to_symbol ($4));
1112 t->set_mus_property ("pop-first", SCM_BOOL_T);
1114 internal_type_checking_global_b = false;
1115 t->set_mus_property ("grob-property", $6);
1117 internal_type_checking_global_b = itc;
1118 t->set_mus_property ("grob-value", $8);
1120 Music *csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
1121 csm->set_mus_property ("element", t->self_scm ());
1122 scm_gc_unprotect_object (t->self_scm ());
1124 $$->set_spot (THIS->here_input ());
1126 csm-> set_mus_property ("context-type", $2);
1128 | PROPERTY STRING '.' STRING OVERRIDE
1129 embedded_scm '=' embedded_scm
1135 = gh_equal_p ($4, scm_makfrom0str ("autoBeamSettings"));
1136 bool itc = internal_type_checking_global_b;
1138 Music *t = MY_MAKE_MUSIC("OverrideProperty");
1139 t->set_mus_property ("symbol", scm_string_to_symbol ($4));
1141 internal_type_checking_global_b = false;
1142 t->set_mus_property ("grob-property", $6);
1143 t->set_mus_property ("grob-value", $8);
1145 internal_type_checking_global_b = itc;
1147 Music *csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
1148 csm->set_mus_property ("element", t->self_scm ());
1149 scm_gc_unprotect_object (t->self_scm ());
1152 $$->set_spot (THIS->here_input ());
1154 csm-> set_mus_property ("context-type", $2);
1157 | PROPERTY STRING '.' STRING REVERT embedded_scm {
1158 Music *t = MY_MAKE_MUSIC("RevertProperty");
1160 = gh_equal_p ($4, scm_makfrom0str ("autoBeamSettings"));
1161 bool itc = internal_type_checking_global_b;
1163 t->set_mus_property ("symbol", scm_string_to_symbol ($4));
1165 internal_type_checking_global_b = false;
1166 t->set_mus_property ("grob-property", $6);
1168 internal_type_checking_global_b = itc;
1170 Music *csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
1171 csm->set_mus_property ("element", t->self_scm ());
1172 scm_gc_unprotect_object (t->self_scm ());
1175 $$->set_spot (THIS->here_input ());
1177 csm-> set_mus_property ("context-type", $2);
1184 | bare_int { $$ = gh_int2scm ($1); }
1185 | embedded_scm { $$ = $1; }
1186 | full_markup { $$ = $1; }
1187 | DIGIT { $$ = gh_int2scm ($1); }
1194 } /*cont */ simple_element post_events {
1195 SCM elts = $3-> get_mus_property ("elements");
1197 elts = gh_append3 (elts, scm_reverse_x ($1, SCM_EOL),
1198 scm_reverse_x ($4, SCM_EOL));
1200 $3-> set_mus_property ("elements", elts);
1204 | note_chord_element
1209 chord_body optional_notemode_duration post_events
1211 SCM dur = unsmob_duration ($2)->smobbed_copy();
1212 SCM es = $1->get_mus_property ("elements");
1213 SCM postevs = scm_reverse_x ($3, SCM_EOL);
1215 for (SCM s = es; gh_pair_p (s); s = gh_cdr (s))
1216 unsmob_music (gh_car(s))->set_mus_property ("duration", dur);
1217 es = gh_append2 (es, postevs);
1219 $1-> set_mus_property ("elements", es);
1225 CHORD_OPEN chord_body_elements CHORD_CLOSE
1227 $$ = MY_MAKE_MUSIC("EventChord");
1228 $$->set_mus_property ("elements",
1229 scm_reverse_x ($2, SCM_EOL));
1233 chord_body_elements:
1234 /* empty */ { $$ = SCM_EOL; }
1235 | chord_body_elements chord_body_element {
1236 $$ = gh_cons ($2->self_scm(), $1);
1237 scm_gc_unprotect_object ($2->self_scm());
1242 pitch exclamations questions post_events
1244 Music * n = MY_MAKE_MUSIC("NoteEvent");
1245 n->set_mus_property ("pitch", $1);
1247 n->set_mus_property ("cautionary", SCM_BOOL_T);
1248 if ($2 % 2 || $3 % 2)
1249 n->set_mus_property ("force-accidental", SCM_BOOL_T);
1251 SCM arts = scm_reverse_x ($4, SCM_EOL);
1252 n->set_mus_property ("articulations", arts);
1260 $$ = MY_MAKE_MUSIC("EventChord");
1261 $$->set_mus_property ("elements", scm_cons ($1->self_scm (), SCM_EOL));
1262 scm_gc_unprotect_object ($1->self_scm());
1264 $$-> set_spot (THIS->here_input ());
1265 $1-> set_spot (THIS->here_input ());
1268 Music *l = MY_MAKE_MUSIC("LigatureEvent");
1269 l->set_mus_property ("span-direction", gh_int2scm (START));
1270 l->set_spot (THIS->here_input ());
1272 $$ = MY_MAKE_MUSIC("EventChord");
1273 $$->set_mus_property ("elements", scm_cons (l->self_scm (), SCM_EOL));
1274 scm_gc_unprotect_object (l->self_scm());
1275 $$->set_spot (THIS->here_input ());
1278 Music *l = MY_MAKE_MUSIC("LigatureEvent");
1279 l->set_mus_property ("span-direction", gh_int2scm (STOP));
1280 l->set_spot (THIS->here_input ());
1282 $$ = MY_MAKE_MUSIC("EventChord");
1283 $$->set_mus_property ("elements", scm_cons (l->self_scm (), SCM_EOL));
1284 $$->set_spot (THIS->here_input ());
1285 scm_gc_unprotect_object (l->self_scm());
1288 $$ = MY_MAKE_MUSIC("VoiceSeparator");
1289 $$->set_spot (THIS->here_input ());
1293 $$ = MY_MAKE_MUSIC("BarCheck");
1294 $$->set_spot (THIS->here_input ());
1297 Music *t = set_property_music (ly_symbol2scm ("whichBar"), $2);
1299 Music *csm = MY_MAKE_MUSIC("ContextSpeccedMusic");
1300 csm->set_mus_property ("element", t->self_scm ());
1301 scm_gc_unprotect_object (t->self_scm ());
1304 $$->set_spot (THIS->here_input ());
1306 csm->set_mus_property ("context-type", scm_makfrom0str ("Timing"));
1308 | PARTIAL duration_length {
1309 Moment m = - unsmob_duration ($2)->get_length ();
1310 Music * p = set_property_music (ly_symbol2scm ( "measurePosition"),m.smobbed_copy ());
1312 Music * sp = MY_MAKE_MUSIC("ContextSpeccedMusic");
1313 sp->set_mus_property ("element", p->self_scm ());
1314 scm_gc_unprotect_object (p->self_scm ());
1317 sp-> set_mus_property ("context-type", scm_makfrom0str ("Timing"));
1322 proc = scm_c_eval_string ("make-clef-set");
1324 SCM result = scm_call_1 (proc, $2);
1325 scm_gc_protect_object (result);
1326 $$ = unsmob_music (result);
1331 proc = scm_c_eval_string ("make-time-signature-set");
1333 SCM result = scm_apply_2 (proc, gh_car ($2), gh_cdr ($2), SCM_EOL);
1334 scm_gc_protect_object (result);
1335 $$ = unsmob_music (result);
1340 shorthand_command_req { $$ = $1; }
1341 | verbose_command_req { $$ = $1; }
1344 shorthand_command_req:
1352 $$ = MY_MAKE_MUSIC("TieEvent");
1355 Music *b= MY_MAKE_MUSIC("BeamEvent");
1356 b->set_mus_property ("span-direction", gh_int2scm (START));
1359 THIS->last_beam_start_ = b->self_scm ();
1362 Music *b= MY_MAKE_MUSIC("BeamEvent");
1363 b->set_mus_property ("span-direction", gh_int2scm (STOP));
1367 $$ = MY_MAKE_MUSIC("BreathingSignEvent");
1370 $$ = MY_MAKE_MUSIC("PorrectusEvent");
1374 verbose_command_req:
1376 Music * m = MY_MAKE_MUSIC("MarkEvent");
1380 Music *m = MY_MAKE_MUSIC("MarkEvent");
1381 m->set_mus_property ("label", $2);
1384 | SKIP duration_length {
1385 Music * skip = MY_MAKE_MUSIC("SkipEvent");
1386 skip->set_mus_property ("duration", $2);
1394 Music *key= MY_MAKE_MUSIC("KeyChangeEvent");
1397 | KEY NOTENAME_PITCH SCM_IDENTIFIER {
1398 Music *key= MY_MAKE_MUSIC("KeyChangeEvent");
1400 key->set_mus_property ("pitch-alist", $3);
1401 key->set_mus_property ("tonic", Pitch (0,0,0).smobbed_copy());
1402 ((Music*)key)->transpose (* unsmob_pitch ($2));
1412 | post_events post_event {
1413 $2->set_spot (THIS->here_input ());
1414 $$ = gh_cons ($2->self_scm(), $$);
1415 scm_gc_unprotect_object ($2->self_scm());
1428 Music * s = MY_MAKE_MUSIC("StringNumberEvent");
1429 s->set_mus_property ("string-number", gh_int2scm($1));
1430 s->set_spot (THIS->here_input ());
1436 event_that_take_dir:
1442 Music * m = MY_MAKE_MUSIC ("NewBeamEvent");
1443 m->set_spot (THIS->here_input());
1444 m->set_mus_property ("span-direction" , gh_int2scm (START));
1448 Music * m = MY_MAKE_MUSIC ("NewBeamEvent");
1449 m->set_spot (THIS->here_input());
1450 m->set_mus_property ("span-direction" , gh_int2scm (STOP));
1454 Music * m = MY_MAKE_MUSIC ("NewTieEvent");
1455 m->set_spot (THIS->here_input());
1458 | script_abbreviation {
1459 SCM s = THIS->lexer_->lookup_identifier ("dash" + ly_scm2string ($1));
1460 Music *a = MY_MAKE_MUSIC("ArticulationEvent");
1461 if (gh_string_p (s))
1462 a->set_mus_property ("articulation-type", s);
1463 else THIS->parser_error (_ ("Expecting string as script definition"));
1469 script_dir event_that_take_dir {
1470 $2->set_mus_property ("direction", gh_int2scm ($1));
1477 $$ = unsmob_music ($1);
1480 Music * a = MY_MAKE_MUSIC("TremoloEvent");
1481 a->set_spot (THIS->here_input ());
1482 a->set_mus_property ("tremolo-type", gh_int2scm ($1));
1509 | NOTENAME_PITCH sup_quotes {
1510 Pitch p = *unsmob_pitch ($1);
1511 p = p.transposed (Pitch ($2,0,0));
1512 $$ = p.smobbed_copy ();
1514 | NOTENAME_PITCH sub_quotes {
1515 Pitch p =* unsmob_pitch ($1);
1516 p = p.transposed (Pitch (-$2,0,0));
1517 $$ = p.smobbed_copy ();
1529 | TONICNAME_PITCH sup_quotes {
1530 Pitch p = *unsmob_pitch ($1);
1531 p = p.transposed (Pitch ($2,0,0));
1532 $$ = p.smobbed_copy ();
1534 | TONICNAME_PITCH sub_quotes {
1535 Pitch p =* unsmob_pitch ($1);
1537 p = p.transposed (Pitch (-$2,0,0));
1538 $$ = p.smobbed_copy ();
1551 pitch_also_in_chords:
1557 PITCH embedded_scm {
1559 if (!unsmob_pitch ($2)) {
1560 THIS->parser_error (_f ("Expecting musical-pitch value", 3));
1561 $$ = Pitch ().smobbed_copy ();
1567 DURATION embedded_scm {
1569 if (!unsmob_duration ($2))
1571 THIS->parser_error (_ ("Must have duration object"));
1572 $$ = Duration ().smobbed_copy ();
1579 if (!THIS->lexer_->lyric_state_b ())
1580 THIS->parser_error (_ ("Have to be in Lyric mode for lyrics"));
1581 $$ = MY_MAKE_MUSIC("ExtenderEvent");
1587 if (!THIS->lexer_->lyric_state_b ())
1588 THIS->parser_error (_ ("Have to be in Lyric mode for lyrics"));
1589 $$ = MY_MAKE_MUSIC("HyphenEvent");
1594 close_event_parens {
1596 dynamic_cast<Music *> ($$)->set_mus_property ("span-direction", gh_int2scm (START))
1603 Music * s= MY_MAKE_MUSIC("SlurEvent");
1605 s->set_spot (THIS->here_input());
1608 Music * s= MY_MAKE_MUSIC("PhrasingSlurEvent");
1610 s->set_spot (THIS->here_input());
1613 Music *s =MY_MAKE_MUSIC("CrescendoEvent");
1615 s->set_spot (THIS->here_input());
1618 Music *s =MY_MAKE_MUSIC("DecrescendoEvent");
1620 s->set_spot (THIS->here_input());
1628 dynamic_cast<Music *> ($$)->set_mus_property ("span-direction", gh_int2scm (STOP))
1635 Music *s = MY_MAKE_MUSIC("CrescendoEvent");
1636 s->set_spot (THIS->here_input());
1641 Music * s= MY_MAKE_MUSIC("SlurEvent");
1643 s->set_spot (THIS->here_input());
1647 Music * s= MY_MAKE_MUSIC("PhrasingSlurEvent");
1649 s->set_mus_property ("span-type", scm_makfrom0str ( "phrasing-slur"));
1650 s->set_spot (THIS->here_input());
1656 Music *t = MY_MAKE_MUSIC("TextScriptEvent");
1657 t->set_mus_property ("text", $1);
1658 t->set_spot (THIS->here_input ());
1662 Music *t = MY_MAKE_MUSIC("TextScriptEvent");
1663 t->set_mus_property ("text", $1);
1664 t->set_spot (THIS->here_input ());
1668 Music *t = MY_MAKE_MUSIC("TextScriptEvent");
1669 t->set_mus_property ("text", make_simple_markup ($1));
1670 t->set_spot (THIS->here_input ());
1675 Music * t = MY_MAKE_MUSIC("FingerEvent");
1676 t->set_mus_property ("digit", gh_int2scm ($1));
1677 t->set_spot (THIS->here_input ());
1682 script_abbreviation:
1684 $$ = scm_makfrom0str ("Hat");
1687 $$ = scm_makfrom0str ("Plus");
1690 $$ = scm_makfrom0str ("Dash");
1693 $$ = scm_makfrom0str ("Bar");
1696 $$ = scm_makfrom0str ("Larger");
1699 $$ = scm_makfrom0str ("Dot");
1702 $$ = scm_makfrom0str ("Underscore");
1709 | '-' { $$ = CENTER; }
1716 | pre_events open_event {
1717 $$ = gh_cons ($2->self_scm(), $$);
1718 scm_gc_unprotect_object ($2->self_scm());
1729 multiplied_duration {
1732 | verbose_duration {
1737 optional_notemode_duration:
1739 Duration dd = THIS->default_duration_;
1740 $$ = dd.smobbed_copy ();
1742 THIS->beam_check ($$);
1744 | multiplied_duration {
1746 THIS->default_duration_ = *unsmob_duration ($$);
1748 THIS->beam_check ($$);
1750 | verbose_duration {
1752 THIS->default_duration_ = *unsmob_duration ($$);
1757 bare_unsigned dots {
1759 if (!is_duration_b ($1))
1760 THIS->parser_error (_f ("not a duration: %d", $1));
1764 $$ = Duration (l, $2).smobbed_copy ();
1766 | DURATION_IDENTIFIER dots {
1767 Duration *d =unsmob_duration ($1);
1768 Duration k (d->duration_log (),d->dot_count () + $2);
1778 multiplied_duration:
1782 | multiplied_duration '*' bare_unsigned {
1783 $$ = unsmob_duration ($$)->compressed ( $3) .smobbed_copy ();
1785 | multiplied_duration '*' FRACTION {
1786 Rational m (gh_scm2int (ly_car ($3)), gh_scm2int (ly_cdr ($3)));
1788 $$ = unsmob_duration ($$)->compressed (m).smobbed_copy ();
1793 FRACTION { $$ = $1; }
1794 | UNSIGNED '/' UNSIGNED {
1795 $$ = scm_cons (gh_int2scm ($1), gh_int2scm ($3));
1813 | ':' bare_unsigned {
1814 if (!is_duration_b ($2))
1815 THIS->parser_error (_f ("not a duration: %d", $2));
1822 /*****************************************************************
1824 *****************************************************************/
1838 Music *bfr = MY_MAKE_MUSIC("BassFigureEvent");
1839 $$ = bfr->self_scm();
1840 scm_gc_unprotect_object ($$);
1843 Music *bfr = MY_MAKE_MUSIC("BassFigureEvent");
1844 $$ = bfr->self_scm();
1846 bfr->set_mus_property ("figure", gh_int2scm ($1));
1848 scm_gc_unprotect_object ($$);
1850 | bass_figure bass_mod {
1851 Music *m = unsmob_music ($1);
1853 SCM salter =m->get_mus_property ("alteration");
1854 int alter = gh_number_p ( salter) ? gh_scm2int (salter) : 0;
1855 m->set_mus_property ("alteration",
1856 gh_int2scm (alter + $2));
1858 m->set_mus_property ("alteration", gh_int2scm (0));
1866 unsmob_music ($$)->set_mus_property ("bracket-start", SCM_BOOL_T);
1871 | br_bass_figure ']' {
1873 unsmob_music ($1)->set_mus_property ("bracket-stop", SCM_BOOL_T);
1881 | figure_list br_bass_figure {
1882 $$ = scm_cons ($2, $1);
1887 FIGURE_OPEN figure_list FIGURE_CLOSE {
1888 Music * m = MY_MAKE_MUSIC("EventChord");
1889 $2 = scm_reverse_x ($2, SCM_EOL);
1890 m->set_mus_property ("elements", $2);
1891 $$ = m->self_scm ();
1902 pitch exclamations questions optional_notemode_duration optional_rest {
1904 Input i = THIS->pop_spot ();
1905 if (!THIS->lexer_->note_state_b ())
1906 THIS->parser_error (_ ("Have to be in Note mode for notes"));
1910 n = MY_MAKE_MUSIC("RestEvent");
1912 n = MY_MAKE_MUSIC("NoteEvent");
1914 n->set_mus_property ("pitch", $1);
1915 n->set_mus_property ("duration", $4);
1919 n->set_mus_property ("cautionary", SCM_BOOL_T);
1920 if ($2 % 2 || $3 % 2)
1921 n->set_mus_property ("force-accidental", SCM_BOOL_T);
1923 Music *v = MY_MAKE_MUSIC("EventChord");
1924 v->set_mus_property ("elements", scm_list_n (n->self_scm (), SCM_UNDEFINED));
1925 scm_gc_unprotect_object (n->self_scm());
1931 | figure_spec optional_notemode_duration {
1932 Music * m = unsmob_music ($1);
1933 Input i = THIS->pop_spot ();
1935 for (SCM s = m->get_mus_property ("elements"); gh_pair_p (s); s = ly_cdr (s))
1937 unsmob_music (ly_car (s))->set_mus_property ("duration", $2);
1941 | RESTNAME optional_notemode_duration {
1943 Input i = THIS->pop_spot ();
1945 if (ly_scm2string ($1) =="s") {
1947 ev = MY_MAKE_MUSIC("SkipEvent");
1950 ev = MY_MAKE_MUSIC("RestEvent");
1953 ev->set_mus_property ("duration" ,$2);
1955 Music * velt = MY_MAKE_MUSIC("EventChord");
1956 velt->set_mus_property ("elements", scm_list_n (ev->self_scm (),SCM_UNDEFINED));
1961 | MULTI_MEASURE_REST optional_notemode_duration {
1966 proc = scm_c_eval_string ("make-multi-measure-rest");
1968 SCM mus = scm_call_2 (proc, $2,
1969 make_input (THIS->here_input()));
1970 scm_gc_protect_object (mus);
1971 $$ = unsmob_music (mus);
1973 | STRING optional_notemode_duration {
1974 Input i = THIS->pop_spot ();
1976 Music * lreq = MY_MAKE_MUSIC("LyricEvent");
1977 lreq->set_mus_property ("text", $1);
1978 lreq->set_mus_property ("duration",$2);
1980 Music * velt = MY_MAKE_MUSIC("EventChord");
1981 velt->set_mus_property ("elements", scm_list_n (lreq->self_scm (), SCM_UNDEFINED));
1988 if (!THIS->lexer_->chord_state_b ())
1989 THIS->parser_error (_ ("Have to be in Chord mode for chords"));
1990 $$ = unsmob_music ($1);
1995 steno_tonic_pitch optional_notemode_duration {
1996 $$ = make_chord ($1, $2, SCM_EOL);
1998 | steno_tonic_pitch optional_notemode_duration chord_separator chord_items {
1999 SCM its = scm_reverse_x ($4, SCM_EOL);
2000 $$ = make_chord ($1, $2, gh_cons ($3, its));
2008 | chord_items chord_item {
2009 $$ = gh_cons ($2, $$);
2015 $$ = ly_symbol2scm ("chord-colon");
2018 $$ = ly_symbol2scm ("chord-caret");
2020 | CHORD_SLASH steno_tonic_pitch {
2021 $$ = scm_list_n (ly_symbol2scm ("chord-slash"), $2, SCM_UNDEFINED);
2023 | CHORD_BASS steno_tonic_pitch {
2024 $$ = scm_list_n (ly_symbol2scm ("chord-bass"), $2, SCM_UNDEFINED);
2033 $$ = scm_reverse_x ($1, SCM_EOL);
2041 step_number { $$ = gh_cons ($1, SCM_EOL); }
2042 | step_numbers '.' step_number {
2043 $$ = gh_cons ($3, $$);
2049 $$ = make_chord_step ($1, 0);
2051 | bare_unsigned '+' {
2052 $$ = make_chord_step ($1, 1);
2054 | bare_unsigned CHORD_MINUS {
2055 $$ = make_chord_step ($1,-1);
2063 number_expression '+' number_term {
2064 $$ = scm_sum ($1, $3);
2066 | number_expression '-' number_term {
2067 $$ = scm_difference ($1, $3);
2076 | number_factor '*' number_factor {
2077 $$ = scm_product ($1, $3);
2079 | number_factor '/' number_factor {
2080 $$ = scm_divide ($1, $3);
2085 '-' number_factor { /* %prec UNARY_MINUS */
2086 $$ = scm_difference ($2, SCM_UNDEFINED);
2094 $$ = gh_int2scm ($1);
2099 | NUMBER_IDENTIFIER {
2102 | REAL NUMBER_IDENTIFIER {
2103 $$ = gh_double2scm (gh_scm2double ($1) * gh_scm2double ($2));
2105 | UNSIGNED NUMBER_IDENTIFIER {
2106 $$ = gh_double2scm ($1 * gh_scm2double ($2));
2122 if (scm_integer_p ($1) == SCM_BOOL_T)
2124 int k = gh_scm2int ($1);
2128 THIS->parser_error (_ ("need integer number arg"));
2142 | STRING_IDENTIFIER {
2145 | string '+' string {
2146 $$ = scm_string_append (scm_list_n ($1, $3, SCM_UNDEFINED));
2153 | exclamations '!' { $$ ++; }
2158 | questions '?' { $$ ++; }
2168 { THIS->lexer_->push_markup_state (); }
2171 THIS->lexer_->pop_state ();
2177 $$ = make_simple_markup ($1);
2179 | MARKUP_HEAD_MARKUP0 markup {
2180 $$ = scm_list_n ($1, $2, SCM_UNDEFINED);
2182 | MARKUP_HEAD_MARKUP0_MARKUP1 markup markup {
2183 $$ = scm_list_n ($1, $2, $3, SCM_UNDEFINED);
2185 | MARKUP_HEAD_SCM0_MARKUP1 SCM_T markup {
2186 $$ = scm_list_n ($1, $2, $3, SCM_UNDEFINED);
2191 | MARKUP_HEAD_LIST0 markup_list {
2192 $$ = scm_list_n ($1,$2, SCM_UNDEFINED);
2194 | MARKUP_HEAD_SCM0 embedded_scm {
2195 $$ = scm_list_n ($1, $2, SCM_UNDEFINED);
2197 | MARKUP_HEAD_SCM0_SCM1_MARKUP2 embedded_scm embedded_scm markup {
2198 $$ = scm_list_n ($1, $2, $3, $4, SCM_UNDEFINED);
2200 | MARKUP_IDENTIFIER {
2207 CHORD_OPEN markup_list_body CHORD_CLOSE { $$ = scm_reverse_x ($2, SCM_EOL); }
2211 '{' markup_list_body '}' {
2214 line = scm_c_eval_string ("line-markup");
2216 $$ = scm_list_n (line, scm_reverse_x ($2, SCM_EOL), SCM_UNDEFINED);
2221 /**/ { $$ = SCM_EOL; }
2222 | markup_list_body markup {
2223 $$ = gh_cons ($2, $1) ;
2231 My_lily_parser::set_yydebug (bool )
2238 extern My_lily_parser * current_parser;
2241 My_lily_parser::do_yyparse ()
2243 current_parser = this;;
2244 yyparse ((void*)this);
2249 Should make this optional? It will also complain when you do
2253 which is entirely legitimate.
2255 Or we can scrap it. Barchecks should detect wrong durations, and
2256 skipTypesetting speeds it up a lot.
2260 My_lily_parser::beam_check (SCM dur)
2262 Duration *d = unsmob_duration (dur);
2263 if (unsmob_music (last_beam_start_) && d->duration_log () <= 2)
2265 Music * m = unsmob_music (last_beam_start_);
2266 m->origin ()->warning (_("Suspect duration found following this beam"));
2268 last_beam_start_ = SCM_EOL;
2276 return gh_pair_p (x)
2277 && SCM_BOOL_F != scm_object_property (gh_car (x), ly_symbol2scm ("markup-signature"));
2280 It is a little strange, to have this function in this file, but
2281 otherwise, we have to import music classes into the lexer.
2285 My_lily_lexer::try_special_identifiers (SCM * destination, SCM sid)
2287 if (gh_string_p (sid)) {
2289 return STRING_IDENTIFIER;
2290 } else if (gh_number_p (sid)) {
2292 return NUMBER_IDENTIFIER;
2293 } else if (unsmob_translator_def (sid)) {
2294 *destination = unsmob_translator_def (sid)->clone_scm();
2295 return TRANSLATOR_IDENTIFIER;
2296 } else if (unsmob_score (sid)) {
2297 Score *sc = new Score (*unsmob_score (sid));
2298 *destination =sc->self_scm ();
2299 return SCORE_IDENTIFIER;
2300 } else if (Music * mus =unsmob_music (sid)) {
2301 *destination = unsmob_music (sid)->clone ()->self_scm();
2302 unsmob_music (*destination)->
2303 set_mus_property ("origin", make_input (last_input_));
2304 return dynamic_cast<Event*> (mus)
2305 ? EVENT_IDENTIFIER : MUSIC_IDENTIFIER;
2306 } else if (unsmob_duration (sid)) {
2307 *destination = unsmob_duration (sid)->smobbed_copy();
2308 return DURATION_IDENTIFIER;
2309 } else if (unsmob_music_output_def (sid)) {
2310 Music_output_def *p = unsmob_music_output_def (sid);
2313 *destination = p->self_scm();
2314 return MUSIC_OUTPUT_DEF_IDENTIFIER;
2315 } else if (new_markup_p (sid)) {
2317 return MARKUP_IDENTIFIER;