2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 1997--2011 Han-Wen Nienhuys <hanwen@xs4all.nl>
5 Jan Nieuwenhuizen <janneke@gnu.org>
7 LilyPond is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
12 LilyPond is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
24 #define YYERROR_VERBOSE 1
25 #define YYPARSE_PARAM my_lily_parser
26 #define YYLEX_PARAM my_lily_parser
27 #define PARSER ((Lily_parser *) my_lily_parser)
29 #define yyerror PARSER->parser_error
31 /* We use custom location type: Input objects */
33 #define YYLLOC_DEFAULT(Current,Rhs,N) \
34 ((Current).set_location ((Rhs)[1], (Rhs)[N]))
39 /* We use SCMs to do strings, because it saves us the trouble of
40 deleting them. Let's hope that a stack overflow doesnt trigger a move
41 of the parse stack onto the heap. */
47 /* The above precedences tackle the shift/reduce problem
50 \repeat .. \alternative
52 \repeat { \repeat .. \alternative }
56 \repeat { \repeat } \alternative
59 %right FUNCTION_ARGUMENTS
60 MARKUP LYRICS_STRING MARKUP_IDENTIFIER STRING STRING_IDENTIFIER
61 MARKUPLINES WITH CONTEXT_MOD_IDENTIFIER MARKUPLINES_IDENTIFIER
62 SCORE BOOK BOOKPART PAPER LAYOUT MIDI
63 SEQUENTIAL SIMULTANEOUS DOUBLE_ANGLE_OPEN MUSIC_IDENTIFIER '{'
64 PITCH_IDENTIFIER NOTENAME_PITCH TONICNAME_PITCH
65 SCM_FUNCTION SCM_IDENTIFIER SCM_TOKEN
66 UNSIGNED DURATION_IDENTIFIER
67 CHORDMODE CHORDS DRUMMODE DRUMS FIGUREMODE FIGURES LYRICMODE LYRICS
69 CONTEXT TIMES NEWCONTEXT
71 /* The above are the symbols that can start function arguments */
84 %{ // -*-Fundamental-*-
89 * The rules for who is protecting what are very shady. Uniformise
92 * There are too many lexical modes?
103 #include "context-def.hh"
104 #include "context-mod.hh"
105 #include "dimensions.hh"
106 #include "file-path.hh"
108 #include "international.hh"
109 #include "lily-guile.hh"
110 #include "lily-lexer.hh"
111 #include "lily-parser.hh"
115 #include "output-def.hh"
116 #include "paper-book.hh"
117 #include "scm-hash.hh"
119 #include "text-interface.hh"
122 #define MYBACKUP(Token, Value, Location) \
124 if (yychar == YYEMPTY) \
125 PARSER->lexer_->push_extra_token (Token, Value); \
127 PARSER->parser_error \
128 (Location, _("cannot backup token")); \
136 Output_def *outputdef;
146 #define MY_MAKE_MUSIC(x, spot) make_music_with_input (ly_symbol2scm (x), spot)
149 - Don't use lily module, create a new module instead.
150 - delay application of the function
152 #define LOWLEVEL_MAKE_SYNTAX(proc, args) \
153 scm_apply_0 (proc, args)
154 /* Syntactic Sugar. */
155 #define MAKE_SYNTAX(name, location, ...) \
156 LOWLEVEL_MAKE_SYNTAX (ly_lily_module_constant (name), scm_list_n (PARSER->self_scm (), make_input (location), ##__VA_ARGS__, SCM_UNDEFINED));
157 #define START_MAKE_SYNTAX(name, ...) \
158 scm_list_n (ly_lily_module_constant (name), ##__VA_ARGS__, SCM_UNDEFINED)
159 #define FINISH_MAKE_SYNTAX(start, location, ...) \
160 LOWLEVEL_MAKE_SYNTAX (scm_car (start), scm_cons2 (PARSER->self_scm (), make_input (location), scm_append_x (scm_list_2 (scm_cdr (start), scm_list_n (__VA_ARGS__, SCM_UNDEFINED)))))
162 SCM get_next_unique_context_id ();
163 SCM get_next_unique_lyrics_context_id ();
170 #define _(x) gettext (x)
174 static Music *make_music_with_input (SCM name, Input where);
175 SCM check_scheme_arg (Lily_parser *parser, Input loc, SCM fallback,
176 SCM arg, SCM args, SCM pred);
177 SCM loc_on_music (Input loc, SCM arg);
178 SCM get_first_context_id (SCM type, Music *m);
179 SCM make_chord_elements (SCM pitch, SCM dur, SCM modification_list);
180 SCM make_chord_step (int step, Rational alter);
181 SCM make_simple_markup (SCM a);
182 bool is_duration (int t);
183 bool is_regular_identifier (SCM id);
184 bool ly_input_procedure_p (SCM x);
185 int yylex (YYSTYPE *s, YYLTYPE *loc, void *v);
186 void set_music_properties (Music *p, SCM a);
190 /* The third option is an alias that will be used to display the
191 syntax error. Bison CVS now correctly handles backslash escapes.
193 FIXME: Bison needs to translate some of these, eg, STRING.
197 /* Keyword tokens with plain escaped name. */
198 %token ACCEPTS "\\accepts"
199 %token ADDLYRICS "\\addlyrics"
200 %token ALIAS "\\alias"
201 %token ALTERNATIVE "\\alternative"
203 %token BOOKPART "\\bookpart"
204 %token CHANGE "\\change"
205 %token CHORDMODE "\\chordmode"
206 %token CHORDS "\\chords"
207 %token CONSISTS "\\consists"
208 %token CONTEXT "\\context"
209 %token DEFAULT "\\default"
210 %token DEFAULTCHILD "\\defaultchild"
211 %token DENIES "\\denies"
212 %token DESCRIPTION "\\description"
213 %token DRUMMODE "\\drummode"
214 %token DRUMS "\\drums"
215 %token FIGUREMODE "\\figuremode"
216 %token FIGURES "\\figures"
217 %token GROBDESCRIPTIONS "\\grobdescriptions"
218 %token HEADER "\\header"
219 %token INVALID "\\version-error"
221 %token LAYOUT "\\layout"
222 %token LYRICMODE "\\lyricmode"
223 %token LYRICS "\\lyrics"
224 %token LYRICSTO "\\lyricsto"
226 %token MARKUP "\\markup"
227 %token MARKUPLINES "\\markuplines"
230 %token NOTEMODE "\\notemode"
232 %token OVERRIDE "\\override"
233 %token PAPER "\\paper"
234 %token REMOVE "\\remove"
235 %token REPEAT "\\repeat"
237 %token REVERT "\\revert"
238 %token SCORE "\\score"
239 %token SEQUENTIAL "\\sequential"
241 %token SIMULTANEOUS "\\simultaneous"
242 %token TEMPO "\\tempo"
243 %token TIMES "\\times"
245 %token UNSET "\\unset"
248 /* Keyword token exceptions. */
249 %token TIME_T "\\time"
250 %token NEWCONTEXT "\\new"
253 /* Other string tokens. */
255 %token CHORD_BASS "/+"
256 %token CHORD_CARET "^"
257 %token CHORD_COLON ":"
258 %token CHORD_MINUS "-"
259 %token CHORD_SLASH "/"
260 %token ANGLE_OPEN "<"
261 %token ANGLE_CLOSE ">"
262 %token DOUBLE_ANGLE_OPEN "<<"
263 %token DOUBLE_ANGLE_CLOSE ">>"
264 %token E_BACKSLASH "\\"
265 %token E_ANGLE_CLOSE "\\>"
266 %token E_CHAR "\\C[haracter]"
268 %token E_EXCLAMATION "\\!"
269 %token E_BRACKET_OPEN "\\["
271 %token E_BRACKET_CLOSE "\\]"
272 %token E_ANGLE_OPEN "\\<"
278 If we give names, Bison complains.
280 %token FIGURE_CLOSE /* "\\>" */
281 %token FIGURE_OPEN /* "\\<" */
282 %token FIGURE_SPACE "_"
285 %token CHORDMODIFIERS
287 %token MULTI_MEASURE_REST
290 %token <i> E_UNSIGNED
293 /* Artificial tokens, for more generic function syntax */
294 %token <i> EXPECT_MARKUP "markup?"
295 %token <i> EXPECT_MUSIC "ly:music?"
296 %token <i> EXPECT_PITCH "ly:pitch?"
297 %token <i> EXPECT_DURATION "ly:duration?"
298 %token <scm> EXPECT_SCM "scheme?"
299 %token <scm> SKIPPED_SCM "(scheme?)"
300 %token <i> EXPECT_MARKUP_LIST "markup-list?"
301 %token <scm> EXPECT_OPTIONAL "optional?"
302 /* After the last argument. */
303 %token <i> EXPECT_NO_MORE_ARGS;
305 /* An artificial token for parsing embedded Lilypond */
306 %token <i> EMBEDDED_LILY "#{"
308 %token <scm> BOOK_IDENTIFIER
309 %token <scm> CHORDMODIFIER_PITCH
310 %token <scm> CHORD_MODIFIER
311 %token <scm> CHORD_REPETITION
312 %token <scm> CONTEXT_DEF_IDENTIFIER
313 %token <scm> CONTEXT_MOD_IDENTIFIER
314 %token <scm> DRUM_PITCH
315 %token <scm> PITCH_IDENTIFIER
316 %token <scm> DURATION_IDENTIFIER
317 %token <scm> EVENT_IDENTIFIER
318 %token <scm> EVENT_FUNCTION
319 %token <scm> FRACTION
320 %token <scm> LYRICS_STRING
321 %token <scm> LYRIC_MARKUP_IDENTIFIER
322 %token <scm> MARKUP_FUNCTION
323 %token <scm> MARKUP_LIST_FUNCTION
324 %token <scm> MARKUP_IDENTIFIER
325 %token <scm> MARKUPLINES_IDENTIFIER
326 %token <scm> MUSIC_FUNCTION
327 %token <scm> MUSIC_IDENTIFIER
328 %token <scm> NOTENAME_PITCH
329 %token <scm> NUMBER_IDENTIFIER
330 %token <scm> OUTPUT_DEF_IDENTIFIER
332 %token <scm> RESTNAME
333 %token <scm> SCM_FUNCTION
334 %token <scm> SCM_IDENTIFIER
335 %token <scm> SCM_TOKEN
336 %token <scm> SCORE_IDENTIFIER
338 %token <scm> STRING_IDENTIFIER
339 %token <scm> TONICNAME_PITCH
342 %type <book> book_block
343 %type <book> book_body
344 %type <book> bookpart_block
345 %type <book> bookpart_body
347 %type <i> bare_unsigned
348 %type <scm> figured_bass_alteration
350 %type <i> exclamations
351 %type <i> optional_rest
356 %type <i> tremolo_type
359 %type <scm> composite_music
360 %type <scm> grouped_music_list
361 %type <scm> braced_music_list
362 %type <scm> closed_music
364 %type <scm> music_bare
365 %type <scm> complex_music
366 %type <scm> complex_music_prefix
367 %type <scm> mode_changed_music
368 %type <scm> repeated_music
369 %type <scm> sequential_music
370 %type <scm> simple_music
371 %type <scm> simultaneous_music
372 %type <scm> chord_body
373 %type <scm> chord_body_element
374 %type <scm> command_element
375 %type <scm> command_event
376 %type <scm> context_modification
377 %type <scm> context_change
378 %type <scm> direction_less_event
379 %type <scm> direction_reqd_event
380 %type <scm> embedded_lilypond
381 %type <scm> event_chord
382 %type <scm> fingering
383 %type <scm> gen_text_def
384 %type <scm> music_property_def
385 %type <scm> note_chord_element
386 %type <scm> post_event
387 %type <scm> post_event_nofinger
388 %type <scm> re_rhythmed_music
389 %type <scm> simple_element
390 %type <scm> simple_music_property_def
391 %type <scm> start_symbol
392 %type <scm> string_number_event
393 %type <scm> tempo_event
395 %type <outputdef> output_def_body
396 %type <outputdef> output_def_head
397 %type <outputdef> output_def_head_with_mode_switch
398 %type <outputdef> output_def
399 %type <outputdef> paper_block
401 %type <scm> music_function_call
402 %type <scm> music_list
403 %type <scm> assignment_id
404 %type <scm> bare_number
405 %type <scm> unsigned_number
406 %type <scm> bass_figure
407 %type <scm> figured_bass_modification
408 %type <scm> br_bass_figure
409 %type <scm> bass_number
410 %type <scm> chord_body_elements
411 %type <scm> chord_item
412 %type <scm> chord_items
413 %type <scm> chord_separator
414 %type <scm> context_def_mod
415 %type <scm> context_def_spec_block
416 %type <scm> context_def_spec_body
417 %type <scm> context_mod
418 %type <scm> context_mod_list
419 %type <scm> context_prop_spec
420 %type <scm> direction_less_char
421 %type <scm> duration_length
422 %type <scm> embedded_scm
423 %type <scm> embedded_scm_arg
424 %type <scm> embedded_scm_arg_closed
425 %type <scm> embedded_scm_bare
426 %type <scm> embedded_scm_bare_arg
427 %type <scm> embedded_scm_closed
428 %type <scm> embedded_scm_chord_body
429 %type <scm> embedded_scm_event
430 %type <scm> event_function_event
431 %type <scm> figure_list
432 %type <scm> figure_spec
434 %type <scm> full_markup
435 %type <scm> full_markup_list
436 %type <scm> function_arglist
437 %type <scm> function_arglist_optional
438 %type <scm> function_arglist_keep
439 %type <scm> function_arglist_bare
440 %type <scm> function_arglist_closed
441 %type <scm> function_arglist_closed_optional
442 %type <scm> function_arglist_closed_keep
443 %type <scm> identifier_init
445 %type <scm> lilypond_header
446 %type <scm> lilypond_header_body
447 %type <scm> lyric_element
448 %type <scm> lyric_markup
450 %type <scm> markup_braced_list
451 %type <scm> markup_braced_list_body
452 %type <scm> markup_composed_list
453 %type <scm> markup_command_list
454 %type <scm> markup_command_list_arguments
455 %type <scm> markup_command_basic_arguments
456 %type <scm> markup_head_1_item
457 %type <scm> markup_head_1_list
458 %type <scm> markup_list
459 %type <scm> markup_top
460 %type <scm> mode_changing_head
461 %type <scm> mode_changing_head_with_context
462 %type <scm> multiplied_duration
463 %type <scm> music_function_event
464 %type <scm> music_function_event_arglist
465 %type <scm> music_function_chord_body
466 %type <scm> music_function_chord_body_arglist
467 %type <scm> new_chord
468 %type <scm> new_lyrics
469 %type <scm> number_expression
470 %type <scm> number_factor
471 %type <scm> number_term
472 %type <scm> octave_check
473 %type <scm> optional_context_mod
474 %type <scm> optional_id
475 %type <scm> optional_notemode_duration
477 %type <scm> pitch_also_in_chords
478 %type <scm> post_events
479 %type <scm> property_operation
480 %type <scm> property_path property_path_revved
482 %type <scm> scalar_bare
483 %type <scm> scalar_closed
484 %type <scm> scm_function_call
485 %type <scm> scm_function_call_closed
486 %type <scm> script_abbreviation
487 %type <scm> simple_chord_elements
488 %type <scm> simple_markup
489 %type <scm> simple_string
490 %type <scm> steno_duration
491 %type <scm> steno_pitch
492 %type <scm> steno_tonic_pitch
493 %type <scm> step_number
494 %type <scm> step_numbers
496 %type <scm> tempo_range
498 %type <score> score_block
499 %type <score> score_body
504 /* We don't assign precedence to / and *, because we might need varied
505 prec levels in different prods */
514 SCM nn = PARSER->lexer_->lookup_identifier ("pitchnames");
515 PARSER->lexer_->push_note_state (alist_to_hashq (nn));
516 } embedded_lilypond {
517 PARSER->lexer_->pop_state ();
518 PARSER->lexer_->set_identifier (ly_symbol2scm ("parseStringResult"), $3);
522 lilypond: /* empty */ { }
523 | lilypond toplevel_expression {
525 | lilypond assignment {
528 PARSER->error_level_ = 1;
531 PARSER->error_level_ = 1;
538 PARSER->lexer_->set_identifier (ly_symbol2scm ("$defaultheader"), $1);
542 SCM proc = PARSER->lexer_->lookup_identifier ("toplevel-book-handler");
543 scm_call_2 (proc, PARSER->self_scm (), book->self_scm ());
548 SCM proc = PARSER->lexer_->lookup_identifier ("toplevel-bookpart-handler");
549 scm_call_2 (proc, PARSER->self_scm (), bookpart->self_scm ());
550 bookpart->unprotect ();
555 SCM proc = PARSER->lexer_->lookup_identifier ("toplevel-score-handler");
556 scm_call_2 (proc, PARSER->self_scm (), score->self_scm ());
560 Music *music = unsmob_music ($1);
561 SCM proc = PARSER->lexer_->lookup_identifier ("toplevel-music-handler");
562 scm_call_2 (proc, PARSER->self_scm (), music->self_scm ());
565 SCM proc = PARSER->lexer_->lookup_identifier ("toplevel-text-handler");
566 scm_call_2 (proc, PARSER->self_scm (), scm_list_1 ($1));
569 SCM proc = PARSER->lexer_->lookup_identifier ("toplevel-text-handler");
570 scm_call_2 (proc, PARSER->self_scm (), $1);
574 Output_def * od = $1;
576 if ($1->c_variable ("is-paper") == SCM_BOOL_T)
577 id = ly_symbol2scm ("$defaultpaper");
578 else if ($1->c_variable ("is-midi") == SCM_BOOL_T)
579 id = ly_symbol2scm ("$defaultmidi");
580 else if ($1->c_variable ("is-layout") == SCM_BOOL_T)
581 id = ly_symbol2scm ("$defaultlayout");
583 PARSER->lexer_->set_identifier (id, od->self_scm ());
593 embedded_scm_bare_arg:
598 | context_modification
601 $$ = $1->self_scm ();
604 | context_def_spec_block
607 $$ = $1->self_scm ();
612 $$ = $1->self_scm ();
617 $$ = $1->self_scm ();
622 /* The generic version may end in music, or not */
630 embedded_scm_bare_arg
635 SCM_FUNCTION function_arglist {
636 $$ = MAKE_SYNTAX ("music-function", @$,
644 $$ = MAKE_SYNTAX ("void-music", @$);
647 | music music music_list {
648 $$ = MAKE_SYNTAX ("sequential-music", @$,
649 scm_cons2 ($1, $2, scm_reverse_x ($3, SCM_EOL)));
652 PARSER->error_level_ = 1;
654 | INVALID embedded_lilypond {
655 PARSER->error_level_ = 1;
660 lilypond_header_body:
662 $$ = get_header (PARSER);
663 PARSER->lexer_->add_scope ($$);
665 | lilypond_header_body assignment {
671 HEADER '{' lilypond_header_body '}' {
672 $$ = PARSER->lexer_->remove_scope ();
681 | LYRICS_STRING { $$ = $1; }
685 assignment_id '=' identifier_init {
686 PARSER->lexer_->set_identifier ($1, $3);
688 | assignment_id property_path '=' identifier_init {
689 SCM path = scm_cons (scm_string_to_symbol ($1), $2);
690 PARSER->lexer_->set_identifier (path, $4);
693 TODO: devise standard for protection in parser.
695 The parser stack lives on the C-stack, which means that
696 all objects can be unprotected as soon as they're here.
706 $$ = $1->self_scm ();
710 $$ = $1->self_scm ();
714 $$ = $1->self_scm ();
718 $$ = $1->self_scm ();
721 | context_def_spec_block {
725 /* Hack: Create event-chord around standalone events.
726 Prevents the identifier from being interpreted as a post-event. */
727 Music *mus = unsmob_music ($1);
728 bool is_event = mus &&
729 (scm_memq (ly_symbol2scm ("event"), mus->get_property ("types"))
734 $$ = MAKE_SYNTAX ("event-chord", @$, scm_list_1 ($1));
736 | post_event_nofinger {
739 | number_expression {
754 | context_modification {
759 context_def_spec_block:
760 CONTEXT '{' context_def_spec_body '}'
766 context_def_spec_body:
768 $$ = Context_def::make_scm ();
769 unsmob_context_def ($$)->origin ()->set_spot (@$);
771 | CONTEXT_DEF_IDENTIFIER {
773 unsmob_context_def ($$)->origin ()->set_spot (@$);
775 | context_def_spec_body GROBDESCRIPTIONS embedded_scm {
776 Context_def*td = unsmob_context_def ($$);
778 for (SCM p = $3; scm_is_pair (p); p = scm_cdr (p)) {
779 SCM tag = scm_caar (p);
781 /* TODO: should make new tag "grob-definition" ? */
782 td->add_context_mod (scm_list_3 (ly_symbol2scm ("assign"),
783 tag, scm_cons (scm_cdar (p), SCM_EOL)));
786 | context_def_spec_body context_mod {
787 unsmob_context_def ($$)->add_context_mod ($2);
789 | context_def_spec_body context_modification {
790 Context_def *td = unsmob_context_def ($$);
791 SCM new_mods = unsmob_context_mod ($2)->get_mods ();
792 for (SCM m = new_mods; scm_is_pair (m); m = scm_cdr (m)) {
793 td->add_context_mod (scm_car (m));
801 BOOK '{' book_body '}' {
804 PARSER->lexer_->set_identifier (ly_symbol2scm ("$current-book"), SCM_BOOL_F);
809 * Use 'handlers' like for toplevel-* stuff?
810 * grok \layout and \midi? */
814 init_papers (PARSER);
815 $$->origin ()->set_spot (@$);
816 $$->paper_ = dynamic_cast<Output_def*> (unsmob_output_def (PARSER->lexer_->lookup_identifier ("$defaultpaper"))->clone ());
817 $$->paper_->unprotect ();
818 push_paper (PARSER, $$->paper_);
819 $$->header_ = PARSER->lexer_->lookup_identifier ("$defaultheader");
820 PARSER->lexer_->set_identifier (ly_symbol2scm ("$current-book"), $$->self_scm ());
821 PARSER->lexer_->set_identifier (ly_symbol2scm ("book-output-suffix"), SCM_BOOL_F);
822 PARSER->lexer_->set_identifier (ly_symbol2scm ("book-filename"), SCM_BOOL_F);
825 $$ = unsmob_book ($1);
827 $$->origin ()->set_spot (@$);
828 PARSER->lexer_->set_identifier (ly_symbol2scm ("$current-book"), $1);
830 | book_body paper_block {
833 set_paper (PARSER, $2);
835 | book_body bookpart_block {
837 SCM proc = PARSER->lexer_->lookup_identifier ("book-bookpart-handler");
838 scm_call_2 (proc, $$->self_scm (), bookpart->self_scm ());
839 bookpart->unprotect ();
841 | book_body score_block {
843 SCM proc = PARSER->lexer_->lookup_identifier ("book-score-handler");
844 scm_call_2 (proc, $$->self_scm (), score->self_scm ());
847 | book_body composite_music {
848 Music *music = unsmob_music ($2);
849 SCM proc = PARSER->lexer_->lookup_identifier ("book-music-handler");
850 scm_call_3 (proc, PARSER->self_scm (), $$->self_scm (), music->self_scm ());
852 | book_body full_markup {
853 SCM proc = PARSER->lexer_->lookup_identifier ("book-text-handler");
854 scm_call_2 (proc, $$->self_scm (), scm_list_1 ($2));
856 | book_body full_markup_list {
857 SCM proc = PARSER->lexer_->lookup_identifier ("book-text-handler");
858 scm_call_2 (proc, $$->self_scm (), $2);
860 | book_body lilypond_header {
863 | book_body embedded_scm { }
866 $$->scores_ = SCM_EOL;
867 $$->bookparts_ = SCM_EOL;
872 BOOKPART '{' bookpart_body '}' {
874 PARSER->lexer_->set_identifier (ly_symbol2scm ("$current-bookpart"), SCM_BOOL_F);
881 $$->origin ()->set_spot (@$);
882 PARSER->lexer_->set_identifier (ly_symbol2scm ("$current-bookpart"), $$->self_scm ());
885 $$ = unsmob_book ($1);
887 $$->origin ()->set_spot (@$);
888 PARSER->lexer_->set_identifier (ly_symbol2scm ("$current-bookpart"), $1);
890 | bookpart_body paper_block {
894 | bookpart_body score_block {
896 SCM proc = PARSER->lexer_->lookup_identifier ("bookpart-score-handler");
897 scm_call_2 (proc, $$->self_scm (), score->self_scm ());
900 | bookpart_body composite_music {
901 Music *music = unsmob_music ($2);
902 SCM proc = PARSER->lexer_->lookup_identifier ("bookpart-music-handler");
903 scm_call_3 (proc, PARSER->self_scm (), $$->self_scm (), music->self_scm ());
905 | bookpart_body full_markup {
906 SCM proc = PARSER->lexer_->lookup_identifier ("bookpart-text-handler");
907 scm_call_2 (proc, $$->self_scm (), scm_list_1 ($2));
909 | bookpart_body full_markup_list {
910 SCM proc = PARSER->lexer_->lookup_identifier ("bookpart-text-handler");
911 scm_call_2 (proc, $$->self_scm (), $2);
913 | bookpart_body lilypond_header {
916 | bookpart_body embedded_scm { }
917 | bookpart_body error {
919 $$->scores_ = SCM_EOL;
924 SCORE '{' score_body '}' {
932 SCM scorify = ly_lily_module_constant ("scorify-music");
933 SCM score = scm_call_2 (scorify, m, PARSER->self_scm ());
935 // pass ownernship to C++ again.
936 $$ = unsmob_score (score);
938 $$->origin ()->set_spot (@$);
941 $$ = unsmob_score ($1);
943 $$->origin ()->set_spot (@$);
945 | score_body lilypond_header {
948 | score_body output_def {
949 if ($2->lookup_variable (ly_symbol2scm ("is-paper")) == SCM_BOOL_T)
951 PARSER->parser_error (@2, _("\\paper cannot be used in \\score, use \\layout instead"));
956 $$->add_output_def ($2);
961 $$->error_found_ = true;
973 if ($$->lookup_variable (ly_symbol2scm ("is-paper")) != SCM_BOOL_T)
975 PARSER->parser_error (@1, _ ("need \\paper for paper block"));
977 $$ = get_paper (PARSER);
984 output_def_body '}' {
987 PARSER->lexer_->remove_scope ();
988 PARSER->lexer_->pop_state ();
994 $$ = get_paper (PARSER);
995 $$->input_origin_ = @$;
996 PARSER->lexer_->add_scope ($$->scope_);
999 Output_def *p = get_midi (PARSER);
1001 PARSER->lexer_->add_scope (p->scope_);
1004 Output_def *p = get_layout (PARSER);
1006 PARSER->lexer_->add_scope (p->scope_);
1011 output_def_head_with_mode_switch:
1013 PARSER->lexer_->push_initial_state ();
1019 output_def_head_with_mode_switch '{' {
1021 $$->input_origin_.set_spot (@$);
1023 | output_def_head_with_mode_switch '{' OUTPUT_DEF_IDENTIFIER {
1026 Output_def *o = unsmob_output_def ($3);
1027 o->input_origin_.set_spot (@$);
1030 PARSER->lexer_->remove_scope ();
1031 PARSER->lexer_->add_scope (o->scope_);
1033 | output_def_body assignment {
1036 | output_def_body context_def_spec_block {
1037 assign_context_def ($$, $2);
1039 | output_def_body error {
1045 TEMPO steno_duration '=' tempo_range {
1046 $$ = MAKE_SYNTAX ("tempo", @$, SCM_EOL, $2, $4);
1048 | TEMPO scalar_closed steno_duration '=' tempo_range {
1049 $$ = MAKE_SYNTAX ("tempo", @$, $2, $3, $5);
1052 $$ = MAKE_SYNTAX ("tempo", @$, $2);
1057 The representation of a list is reversed to have efficient append. */
1063 | music_list music {
1064 $$ = scm_cons ($2, $1);
1066 | music_list embedded_scm {
1069 | music_list error {
1070 Music *m = MY_MAKE_MUSIC("Music", @$);
1072 m->set_property ("error-found", SCM_BOOL_T);
1073 $$ = scm_cons (m->self_scm (), $1);
1074 m->unprotect (); /* UGH */
1081 $$ = scm_reverse_x ($2, SCM_EOL);
1087 | composite_music %prec FUNCTION_ARGUMENTS
1092 REPEAT simple_string unsigned_number music
1094 $$ = MAKE_SYNTAX ("repeat", @$, $2, $3, $4, SCM_EOL);
1096 | REPEAT simple_string unsigned_number music ALTERNATIVE braced_music_list
1098 $$ = MAKE_SYNTAX ("repeat", @$, $2, $3, $4, $6);
1103 SEQUENTIAL braced_music_list {
1104 $$ = MAKE_SYNTAX ("sequential-music", @$, $2);
1106 | braced_music_list {
1107 $$ = MAKE_SYNTAX ("sequential-music", @$, $1);
1112 SIMULTANEOUS braced_music_list {
1113 $$ = MAKE_SYNTAX ("simultaneous-music", @$, $2);
1115 | DOUBLE_ANGLE_OPEN music_list DOUBLE_ANGLE_CLOSE {
1116 $$ = MAKE_SYNTAX ("simultaneous-music", @$, scm_reverse_x ($2, SCM_EOL));
1122 | music_property_def
1126 context_modification:
1127 WITH { PARSER->lexer_->push_initial_state (); } '{' context_mod_list '}'
1129 PARSER->lexer_->pop_state ();
1132 | WITH CONTEXT_MOD_IDENTIFIER
1136 | CONTEXT_MOD_IDENTIFIER
1142 optional_context_mod:
1146 | context_modification
1154 $$ = Context_mod ().smobbed_copy ();
1156 | context_mod_list context_mod {
1157 unsmob_context_mod ($1)->add_context_mod ($2);
1159 | context_mod_list CONTEXT_MOD_IDENTIFIER {
1160 Context_mod *md = unsmob_context_mod ($2);
1162 unsmob_context_mod ($1)->add_context_mods (md->get_mods ());
1171 /* Music that can be parsed without lookahead */
1174 | complex_music_prefix closed_music
1176 $$ = FINISH_MAKE_SYNTAX ($1, @$, $2);
1183 | grouped_music_list
1187 simultaneous_music { $$ = $1; }
1188 | sequential_music { $$ = $1; }
1191 /* An argument list. If a function \foo expects scm scm music, then the lexer expands \foo into the token sequence:
1192 MUSIC_FUNCTION EXPECT_MUSIC EXPECT_SCM EXPECT_SCM EXPECT_NO_MORE_ARGS
1193 and this rule returns the reversed list of arguments. */
1197 function_arglist_bare
1198 | EXPECT_MUSIC function_arglist_optional music
1200 $$ = scm_cons ($3, $2);
1202 | EXPECT_SCM function_arglist_optional embedded_scm_arg
1204 $$ = check_scheme_arg (PARSER, @3, SCM_UNDEFINED, $3, $2, $1);
1208 function_arglist_optional:
1209 function_arglist_keep %prec FUNCTION_ARGUMENTS
1210 | EXPECT_OPTIONAL EXPECT_MUSIC function_arglist_optional
1212 $$ = scm_cons (loc_on_music (@3, $1), $3);
1214 | EXPECT_OPTIONAL EXPECT_PITCH function_arglist_optional
1216 $$ = scm_cons ($1, $3);
1218 | EXPECT_OPTIONAL EXPECT_DURATION function_arglist_optional
1220 $$ = scm_cons ($1, $3);
1222 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_optional
1224 $$ = scm_cons (loc_on_music (@3, $1), $3);
1228 function_arglist_keep:
1229 EXPECT_OPTIONAL EXPECT_PITCH function_arglist_keep pitch_also_in_chords {
1230 $$ = scm_cons ($4, $3);
1232 | EXPECT_OPTIONAL EXPECT_DURATION function_arglist_closed_keep duration_length {
1233 $$ = scm_cons ($4, $3);
1235 | EXPECT_OPTIONAL EXPECT_MUSIC function_arglist_keep closed_music
1237 $$ = scm_cons ($4, $3);
1240 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_keep embedded_scm_arg_closed
1242 if (scm_is_true (scm_call_1 ($2, $4)))
1244 $$ = scm_cons ($4, $3);
1246 $$ = scm_cons (loc_on_music (@3, $1), $3);
1247 MYBACKUP (SKIPPED_SCM, $4, @4);
1253 function_arglist_closed:
1254 function_arglist_bare
1255 | EXPECT_MUSIC function_arglist_optional closed_music
1257 $$ = scm_cons ($3, $2);
1259 | EXPECT_SCM function_arglist_optional embedded_scm_arg_closed
1261 $$ = check_scheme_arg (PARSER, @3, SCM_UNDEFINED, $3, $2, $1);
1265 function_arglist_closed_optional:
1266 function_arglist_closed_keep %prec FUNCTION_ARGUMENTS
1267 | EXPECT_OPTIONAL EXPECT_MUSIC function_arglist_closed_optional
1269 $$ = scm_cons (loc_on_music (@3, $1), $3);
1271 | EXPECT_OPTIONAL EXPECT_PITCH function_arglist_closed_optional
1273 $$ = scm_cons ($1, $3);
1275 | EXPECT_OPTIONAL EXPECT_DURATION function_arglist_closed_optional
1277 $$ = scm_cons ($1, $3);
1279 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_closed_optional
1281 $$ = scm_cons (loc_on_music (@3, $1), $3);
1285 function_arglist_closed_keep:
1286 EXPECT_OPTIONAL EXPECT_PITCH function_arglist_keep pitch_also_in_chords {
1287 $$ = scm_cons ($4, $3);
1289 | EXPECT_OPTIONAL EXPECT_DURATION function_arglist_closed_keep duration_length {
1290 $$ = scm_cons ($4, $3);
1292 | EXPECT_OPTIONAL EXPECT_MUSIC function_arglist_keep closed_music
1294 $$ = scm_cons ($4, $3);
1296 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_keep embedded_scm_arg_closed
1298 if (scm_is_true (scm_call_1 ($2, $4)))
1300 $$ = scm_cons ($4, $3);
1302 $$ = scm_cons (loc_on_music (@3, $1), $3);
1303 MYBACKUP (SKIPPED_SCM, $4, @4);
1306 | function_arglist_closed
1309 embedded_scm_closed:
1311 | scm_function_call_closed
1314 embedded_scm_arg_closed:
1315 embedded_scm_bare_arg
1316 | scm_function_call_closed
1319 scm_function_call_closed:
1320 SCM_FUNCTION function_arglist_closed {
1321 $$ = MAKE_SYNTAX ("music-function", @$,
1326 function_arglist_bare:
1327 EXPECT_NO_MORE_ARGS {
1330 | EXPECT_PITCH function_arglist_optional pitch_also_in_chords {
1331 $$ = scm_cons ($3, $2);
1333 | EXPECT_DURATION function_arglist_closed_optional duration_length {
1334 $$ = scm_cons ($3, $2);
1336 | EXPECT_SCM function_arglist_optional SKIPPED_SCM
1338 $$ = check_scheme_arg (PARSER, @3, SCM_UNDEFINED, $3, $2, $1);
1342 music_function_call:
1343 MUSIC_FUNCTION function_arglist {
1344 $$ = MAKE_SYNTAX ("music-function", @$,
1351 /**/ { $$ = SCM_EOL; }
1352 | '=' simple_string {
1359 | repeated_music { $$ = $1; }
1360 | re_rhythmed_music { $$ = $1; }
1361 | complex_music_prefix music
1363 $$ = FINISH_MAKE_SYNTAX ($1, @$, $2);
1367 complex_music_prefix:
1368 CONTEXT simple_string optional_id optional_context_mod {
1369 Context_mod *ctxmod = unsmob_context_mod ($4);
1372 mods = ctxmod->get_mods ();
1373 $$ = START_MAKE_SYNTAX ("context-specification", $2, $3, mods, SCM_BOOL_F);
1375 | NEWCONTEXT simple_string optional_id optional_context_mod {
1376 Context_mod *ctxmod = unsmob_context_mod ($4);
1379 mods = ctxmod->get_mods ();
1380 $$ = START_MAKE_SYNTAX ("context-specification", $2, $3, mods, SCM_BOOL_T);
1383 $$ = START_MAKE_SYNTAX ("time-scaled-music", $2);
1388 mode_changing_head grouped_music_list {
1389 if ($1 == ly_symbol2scm ("chords"))
1391 $$ = MAKE_SYNTAX ("unrelativable-music", @$, $2);
1397 PARSER->lexer_->pop_state ();
1399 | mode_changing_head_with_context optional_context_mod grouped_music_list {
1400 Context_mod *ctxmod = unsmob_context_mod ($2);
1403 mods = ctxmod->get_mods ();
1404 $$ = MAKE_SYNTAX ("context-specification", @$, $1, SCM_EOL, mods, SCM_BOOL_T, $3);
1405 if ($1 == ly_symbol2scm ("ChordNames"))
1407 $$ = MAKE_SYNTAX ("unrelativable-music", @$, $$);
1409 PARSER->lexer_->pop_state ();
1415 SCM nn = PARSER->lexer_->lookup_identifier ("pitchnames");
1416 PARSER->lexer_->push_note_state (alist_to_hashq (nn));
1418 $$ = ly_symbol2scm ("notes");
1422 SCM nn = PARSER->lexer_->lookup_identifier ("drumPitchNames");
1423 PARSER->lexer_->push_note_state (alist_to_hashq (nn));
1425 $$ = ly_symbol2scm ("drums");
1428 PARSER->lexer_->push_figuredbass_state ();
1430 $$ = ly_symbol2scm ("figures");
1433 SCM nn = PARSER->lexer_->lookup_identifier ("chordmodifiers");
1434 PARSER->lexer_->chordmodifier_tab_ = alist_to_hashq (nn);
1435 nn = PARSER->lexer_->lookup_identifier ("pitchnames");
1436 PARSER->lexer_->push_chord_state (alist_to_hashq (nn));
1437 $$ = ly_symbol2scm ("chords");
1441 { PARSER->lexer_->push_lyric_state ();
1442 $$ = ly_symbol2scm ("lyrics");
1446 mode_changing_head_with_context:
1448 SCM nn = PARSER->lexer_->lookup_identifier ("drumPitchNames");
1449 PARSER->lexer_->push_note_state (alist_to_hashq (nn));
1451 $$ = ly_symbol2scm ("DrumStaff");
1454 PARSER->lexer_->push_figuredbass_state ();
1456 $$ = ly_symbol2scm ("FiguredBass");
1459 SCM nn = PARSER->lexer_->lookup_identifier ("chordmodifiers");
1460 PARSER->lexer_->chordmodifier_tab_ = alist_to_hashq (nn);
1461 nn = PARSER->lexer_->lookup_identifier ("pitchnames");
1462 PARSER->lexer_->push_chord_state (alist_to_hashq (nn));
1463 $$ = ly_symbol2scm ("ChordNames");
1466 { PARSER->lexer_->push_lyric_state ();
1467 $$ = ly_symbol2scm ("Lyrics");
1472 ADDLYRICS { PARSER->lexer_->push_lyric_state (); }
1475 /* Can also use music at the expensive of two S/Rs similar to
1476 \repeat \alternative */
1477 PARSER->lexer_->pop_state ();
1479 $$ = scm_cons ($3, SCM_EOL);
1481 | new_lyrics ADDLYRICS {
1482 PARSER->lexer_->push_lyric_state ();
1484 PARSER->lexer_->pop_state ();
1485 $$ = scm_cons ($4, $1);
1490 composite_music new_lyrics {
1491 $$ = MAKE_SYNTAX ("add-lyrics", @$, $1, scm_reverse_x ($2, SCM_EOL));
1492 } %prec FUNCTION_ARGUMENTS
1493 | LYRICSTO simple_string {
1494 PARSER->lexer_->push_lyric_state ();
1496 PARSER->lexer_->pop_state ();
1497 $$ = MAKE_SYNTAX ("lyric-combine", @$, $2, $4);
1502 CHANGE STRING '=' STRING {
1503 $$ = MAKE_SYNTAX ("context-change", @$, scm_string_to_symbol ($2), $4);
1508 property_path_revved:
1509 embedded_scm_closed {
1510 $$ = scm_cons ($1, SCM_EOL);
1512 | property_path_revved embedded_scm_closed {
1513 $$ = scm_cons ($2, $1);
1518 property_path_revved {
1519 $$ = scm_reverse_x ($1, SCM_EOL);
1525 $$ = scm_list_3 (ly_symbol2scm ("assign"),
1526 scm_string_to_symbol ($1), $3);
1528 | UNSET simple_string {
1529 $$ = scm_list_2 (ly_symbol2scm ("unset"),
1530 scm_string_to_symbol ($2));
1532 | OVERRIDE simple_string property_path '=' scalar {
1533 $$ = scm_append (scm_list_2 (scm_list_3 (ly_symbol2scm ("push"),
1534 scm_string_to_symbol ($2), $5),
1537 | REVERT simple_string embedded_scm {
1538 $$ = scm_list_3 (ly_symbol2scm ("pop"),
1539 scm_string_to_symbol ($2), $3);
1544 CONSISTS { $$ = ly_symbol2scm ("consists"); }
1545 | REMOVE { $$ = ly_symbol2scm ("remove"); }
1547 | ACCEPTS { $$ = ly_symbol2scm ("accepts"); }
1548 | DEFAULTCHILD { $$ = ly_symbol2scm ("default-child"); }
1549 | DENIES { $$ = ly_symbol2scm ("denies"); }
1551 | ALIAS { $$ = ly_symbol2scm ("alias"); }
1552 | TYPE { $$ = ly_symbol2scm ("translator-type"); }
1553 | DESCRIPTION { $$ = ly_symbol2scm ("description"); }
1554 | NAME { $$ = ly_symbol2scm ("context-name"); }
1558 property_operation { $$ = $1; }
1559 | context_def_mod STRING {
1560 $$ = scm_list_2 ($1, $2);
1562 | context_def_mod embedded_scm {
1563 if (ly_symbol2scm ("consists") != $1)
1566 PARSER->parser_error (@1, _ ("only \\consists takes non-string argument."));
1570 $$ = scm_list_2 ($1, $2);
1577 if (!is_regular_identifier ($1))
1579 @$.error (_("Grob name should be alphanumeric"));
1582 $$ = scm_list_2 (ly_symbol2scm ("Bottom"),
1583 scm_string_to_symbol ($1));
1585 | simple_string '.' simple_string {
1586 $$ = scm_list_2 (scm_string_to_symbol ($1),
1587 scm_string_to_symbol ($3));
1591 simple_music_property_def:
1592 OVERRIDE context_prop_spec property_path '=' scalar {
1593 $$ = scm_append (scm_list_2 (scm_list_n (scm_car ($2),
1594 ly_symbol2scm ("OverrideProperty"),
1599 | REVERT context_prop_spec embedded_scm {
1600 $$ = scm_list_4 (scm_car ($2),
1601 ly_symbol2scm ("RevertProperty"),
1605 | SET context_prop_spec '=' scalar {
1606 $$ = scm_list_4 (scm_car ($2),
1607 ly_symbol2scm ("PropertySet"),
1611 | UNSET context_prop_spec {
1612 $$ = scm_list_3 (scm_car ($2),
1613 ly_symbol2scm ("PropertyUnset"),
1619 simple_music_property_def {
1620 $$ = LOWLEVEL_MAKE_SYNTAX (ly_lily_module_constant ("property-operation"), scm_cons (PARSER->self_scm (), scm_cons2 (make_input (@$), SCM_BOOL_F, $1)));
1622 | ONCE simple_music_property_def {
1623 $$ = LOWLEVEL_MAKE_SYNTAX (ly_lily_module_constant ("property-operation"), scm_cons (PARSER->self_scm (), scm_cons2 (make_input (@$), SCM_BOOL_T, $2)));
1631 | STRING_IDENTIFIER {
1634 | string '+' string {
1635 $$ = scm_string_append (scm_list_2 ($1, $3));
1639 simple_string: STRING {
1645 | STRING_IDENTIFIER {
1660 | embedded_scm_bare {
1675 scm_function_call_closed
1680 /* TODO: Create a special case that avoids the creation of
1681 EventChords around simple_elements that have no post_events?
1683 simple_chord_elements post_events {
1684 SCM elts = ly_append2 ($1, scm_reverse_x ($2, SCM_EOL));
1687 /* why is this giving wrong start location? -ns
1689 i.set_location (@1, @2);
1690 $$ = MAKE_SYNTAX ("event-chord", i, elts);
1692 | CHORD_REPETITION optional_notemode_duration post_events {
1694 i.set_location (@1, @3);
1695 $$ = MAKE_SYNTAX ("repetition-chord", i,
1696 PARSER->lexer_->chord_repetition_.last_chord_,
1697 PARSER->lexer_->chord_repetition_.repetition_function_,
1698 $2, scm_reverse_x ($3, SCM_EOL));
1700 | MULTI_MEASURE_REST optional_notemode_duration post_events {
1702 i.set_location (@1, @3);
1703 $$ = MAKE_SYNTAX ("multi-measure-rest", i, $2,
1704 scm_reverse_x ($3, SCM_EOL));
1707 /* note chord elements are memorized into
1708 PARSER->lexer_->chord_repetition_ so that the chord repetition
1709 mechanism copy them when a chord repetition symbol is found
1711 | note_chord_element {
1712 PARSER->lexer_->chord_repetition_.last_chord_ = $$;
1718 chord_body optional_notemode_duration post_events
1720 Music *m = unsmob_music ($1);
1721 SCM dur = unsmob_duration ($2)->smobbed_copy ();
1722 SCM es = m->get_property ("elements");
1723 SCM postevs = scm_reverse_x ($3, SCM_EOL);
1725 for (SCM s = es; scm_is_pair (s); s = scm_cdr (s))
1726 unsmob_music (scm_car (s))->set_property ("duration", dur);
1727 es = ly_append2 (es, postevs);
1729 m-> set_property ("elements", es);
1731 $$ = m->self_scm ();
1736 ANGLE_OPEN chord_body_elements ANGLE_CLOSE
1738 $$ = MAKE_SYNTAX ("event-chord", @$, scm_reverse_x ($2, SCM_EOL));
1742 chord_body_elements:
1743 /* empty */ { $$ = SCM_EOL; }
1744 | chord_body_elements chord_body_element {
1745 $$ = scm_cons ($2, $1);
1750 pitch exclamations questions octave_check post_events
1757 Music *n = MY_MAKE_MUSIC ("NoteEvent", @$);
1758 n->set_property ("pitch", $1);
1760 n->set_property ("cautionary", SCM_BOOL_T);
1761 if (ex % 2 || q % 2)
1762 n->set_property ("force-accidental", SCM_BOOL_T);
1764 if (scm_is_pair (post)) {
1765 SCM arts = scm_reverse_x (post, SCM_EOL);
1766 n->set_property ("articulations", arts);
1768 if (scm_is_number (check))
1770 int q = scm_to_int (check);
1771 n->set_property ("absolute-octave", scm_from_int (q-1));
1774 $$ = n->unprotect ();
1776 | DRUM_PITCH post_events {
1777 Music *n = MY_MAKE_MUSIC ("NoteEvent", @$);
1778 n->set_property ("drum-type", $1);
1780 if (scm_is_pair ($2)) {
1781 SCM arts = scm_reverse_x ($2, SCM_EOL);
1782 n->set_property ("articulations", arts);
1784 $$ = n->unprotect ();
1786 | music_function_chord_body
1789 /* We can't accept a music argument, not even a closed one,
1790 * immediately before chord_body_elements, otherwise a function \fun
1791 * with a signature of two music arguments can't be sorted out
1792 * properly in a construct like
1793 * <\fun { c } \fun { c } c>
1794 * The second call could be interpreted either as a chord constituent
1795 * or a music expression.
1798 music_function_chord_body_arglist:
1799 function_arglist_bare
1800 | EXPECT_MUSIC music_function_chord_body_arglist chord_body_element {
1801 $$ = scm_cons ($3, $2);
1803 | EXPECT_SCM function_arglist_optional embedded_scm_chord_body {
1804 $$ = check_scheme_arg (PARSER, @3, SCM_UNDEFINED, $3, $2, $1);
1808 embedded_scm_chord_body:
1809 embedded_scm_bare_arg
1810 | SCM_FUNCTION music_function_chord_body_arglist {
1811 $$ = MAKE_SYNTAX ("music-function", @$,
1816 music_function_chord_body:
1817 MUSIC_FUNCTION music_function_chord_body_arglist {
1818 $$ = MAKE_SYNTAX ("music-function", @$,
1823 /* We could accept a closed music argument before the post events
1824 * indicated by a trailing argument list. For symmetry with chord
1825 * bodies and in order to avoid too tricky and complex behavior, we
1826 * refrain from doing so.
1828 music_function_event_arglist:
1829 function_arglist_bare
1830 | EXPECT_MUSIC music_function_event_arglist post_event {
1831 $$ = scm_cons ($3, $2);
1833 | EXPECT_SCM function_arglist_optional embedded_scm_event {
1834 $$ = check_scheme_arg (PARSER, @3, SCM_UNDEFINED, $3, $2, $1);
1839 embedded_scm_bare_arg
1840 | SCM_FUNCTION music_function_event_arglist {
1841 $$ = MAKE_SYNTAX ("music-function", @$,
1846 music_function_event:
1847 MUSIC_FUNCTION music_function_event_arglist {
1848 $$ = MAKE_SYNTAX ("music-function", @$,
1853 event_function_event:
1854 EVENT_FUNCTION music_function_event_arglist {
1855 $$ = MAKE_SYNTAX ("music-function", @$,
1865 Music *m = MY_MAKE_MUSIC ("LigatureEvent", @$);
1866 m->set_property ("span-direction", scm_from_int (START));
1867 $$ = m->unprotect();
1870 Music *m = MY_MAKE_MUSIC ("LigatureEvent", @$);
1871 m->set_property ("span-direction", scm_from_int (STOP));
1872 $$ = m->unprotect ();
1875 $$ = MAKE_SYNTAX ("voice-separator", @$);
1878 SCM pipe = PARSER->lexer_->lookup_identifier ("pipeSymbol");
1880 Music *m = unsmob_music (pipe);
1885 $$ = m->unprotect ();
1888 $$ = MAKE_SYNTAX ("bar-check", @$);
1892 SCM proc = ly_lily_module_constant ("make-time-signature-set");
1894 $$ = scm_apply_2 (proc, scm_car ($2), scm_cdr ($2), SCM_EOL);
1897 $$ = MAKE_SYNTAX ("make-mark-set", @$, $2);
1903 $$ = MY_MAKE_MUSIC ("PesOrFlexaEvent", @$)->unprotect ();
1906 Music *m = MY_MAKE_MUSIC ("MarkEvent", @$);
1907 $$ = m->unprotect ();
1913 Music *key = MY_MAKE_MUSIC ("KeyChangeEvent", @$);
1914 $$ = key->unprotect ();
1916 | KEY NOTENAME_PITCH SCM_IDENTIFIER {
1918 Music *key = MY_MAKE_MUSIC ("KeyChangeEvent", @$);
1919 if (scm_ilength ($3) > 0)
1921 key->set_property ("pitch-alist", $3);
1922 key->set_property ("tonic", Pitch (0, 0, 0).smobbed_copy ());
1923 key->transpose (* unsmob_pitch ($2));
1925 PARSER->parser_error (@3, _ ("second argument must be pitch list"));
1928 $$ = key->unprotect ();
1937 | post_events post_event {
1938 unsmob_music ($2)->set_spot (@2);
1939 $$ = scm_cons ($2, $$);
1943 post_event_nofinger:
1944 direction_less_event {
1947 | script_dir music_function_event {
1951 unsmob_music ($$)->set_property ("direction", scm_from_int ($1));
1955 if (!PARSER->lexer_->is_lyric_state ())
1956 PARSER->parser_error (@1, _ ("have to be in Lyric mode for lyrics"));
1957 $$ = MY_MAKE_MUSIC ("HyphenEvent", @$)->unprotect ();
1960 if (!PARSER->lexer_->is_lyric_state ())
1961 PARSER->parser_error (@1, _ ("have to be in Lyric mode for lyrics"));
1962 $$ = MY_MAKE_MUSIC ("ExtenderEvent", @$)->unprotect ();
1964 | script_dir direction_reqd_event {
1967 Music *m = unsmob_music ($2);
1968 m->set_property ("direction", scm_from_int ($1));
1972 | script_dir direction_less_event {
1975 Music *m = unsmob_music ($2);
1976 m->set_property ("direction", scm_from_int ($1));
1980 | string_number_event
1985 | script_dir fingering {
1988 Music *m = unsmob_music ($2);
1989 m->set_property ("direction", scm_from_int ($1));
1995 string_number_event:
1997 Music *s = MY_MAKE_MUSIC ("StringNumberEvent", @$);
1998 s->set_property ("string-number", scm_from_int ($1));
1999 $$ = s->unprotect ();
2003 direction_less_char:
2005 $$ = ly_symbol2scm ("bracketOpenSymbol");
2008 $$ = ly_symbol2scm ("bracketCloseSymbol");
2011 $$ = ly_symbol2scm ("tildeSymbol");
2014 $$ = ly_symbol2scm ("parenthesisOpenSymbol");
2017 $$ = ly_symbol2scm ("parenthesisCloseSymbol");
2020 $$ = ly_symbol2scm ("escapedExclamationSymbol");
2023 $$ = ly_symbol2scm ("escapedParenthesisOpenSymbol");
2026 $$ = ly_symbol2scm ("escapedParenthesisCloseSymbol");
2029 $$ = ly_symbol2scm ("escapedBiggerSymbol");
2032 $$ = ly_symbol2scm ("escapedSmallerSymbol");
2036 direction_less_event:
2037 direction_less_char {
2038 SCM predefd = PARSER->lexer_->lookup_identifier_symbol ($1);
2040 if (unsmob_music (predefd))
2042 m = unsmob_music (predefd)->clone ();
2047 m = MY_MAKE_MUSIC ("Music", @$);
2049 $$ = m->unprotect ();
2051 | EVENT_IDENTIFIER {
2055 Music *a = MY_MAKE_MUSIC ("TremoloEvent", @$);
2056 a->set_property ("tremolo-type", scm_from_int ($1));
2057 $$ = a->unprotect ();
2059 | event_function_event
2062 direction_reqd_event:
2066 | script_abbreviation {
2067 SCM s = PARSER->lexer_->lookup_identifier ("dash" + ly_scm2string ($1));
2068 Music *a = MY_MAKE_MUSIC ("ArticulationEvent", @$);
2069 if (scm_is_string (s))
2070 a->set_property ("articulation-type", s);
2071 else PARSER->parser_error (@1, _ ("expecting string as script definition"));
2072 $$ = a->unprotect ();
2077 /**/ { $$ = SCM_EOL; }
2078 | '=' { $$ = scm_from_int (0); }
2079 | '=' sub_quotes { $$ = scm_from_int (-$2); }
2080 | '=' sup_quotes { $$ = scm_from_int ($2); }
2105 | NOTENAME_PITCH sup_quotes {
2106 Pitch p = *unsmob_pitch ($1);
2107 p = p.transposed (Pitch ($2,0,0));
2108 $$ = p.smobbed_copy ();
2110 | NOTENAME_PITCH sub_quotes {
2111 Pitch p =* unsmob_pitch ($1);
2112 p = p.transposed (Pitch (-$2,0,0));
2113 $$ = p.smobbed_copy ();
2125 | TONICNAME_PITCH sup_quotes {
2126 Pitch p = *unsmob_pitch ($1);
2127 p = p.transposed (Pitch ($2,0,0));
2128 $$ = p.smobbed_copy ();
2130 | TONICNAME_PITCH sub_quotes {
2131 Pitch p = *unsmob_pitch ($1);
2133 p = p.transposed (Pitch (-$2,0,0));
2134 $$ = p.smobbed_copy ();
2145 pitch_also_in_chords:
2152 Music *t = MY_MAKE_MUSIC ("TextScriptEvent", @$);
2153 t->set_property ("text", $1);
2154 $$ = t->unprotect ();
2157 Music *t = MY_MAKE_MUSIC ("TextScriptEvent", @$);
2158 t->set_property ("text",
2159 make_simple_markup ($1));
2160 $$ = t->unprotect ();
2166 Music *t = MY_MAKE_MUSIC ("FingeringEvent", @$);
2167 t->set_property ("digit", scm_from_int ($1));
2168 $$ = t->unprotect ();
2172 script_abbreviation:
2174 $$ = scm_from_locale_string ("Hat");
2177 $$ = scm_from_locale_string ("Plus");
2180 $$ = scm_from_locale_string ("Dash");
2183 $$ = scm_from_locale_string ("Bar");
2186 $$ = scm_from_locale_string ("Larger");
2189 $$ = scm_from_locale_string ("Dot");
2192 $$ = scm_from_locale_string ("Underscore");
2199 | '-' { $$ = CENTER; }
2203 multiplied_duration {
2208 optional_notemode_duration:
2210 Duration dd = PARSER->default_duration_;
2211 $$ = dd.smobbed_copy ();
2213 | multiplied_duration {
2215 PARSER->default_duration_ = *unsmob_duration ($$);
2220 bare_unsigned dots {
2222 if (!is_duration ($1))
2223 PARSER->parser_error (@1, _f ("not a duration: %d", $1));
2227 $$ = Duration (len, $2).smobbed_copy ();
2229 | DURATION_IDENTIFIER dots {
2230 Duration *d = unsmob_duration ($1);
2231 Duration k (d->duration_log (), d->dot_count () + $2);
2232 k = k.compressed (d->factor ());
2238 multiplied_duration:
2242 | multiplied_duration '*' bare_unsigned {
2243 $$ = unsmob_duration ($$)->compressed ( $3) .smobbed_copy ();
2245 | multiplied_duration '*' FRACTION {
2246 Rational m (scm_to_int (scm_car ($3)), scm_to_int (scm_cdr ($3)));
2248 $$ = unsmob_duration ($$)->compressed (m).smobbed_copy ();
2253 FRACTION { $$ = $1; }
2254 | UNSIGNED '/' UNSIGNED {
2255 $$ = scm_cons (scm_from_int ($1), scm_from_int ($3));
2272 | ':' bare_unsigned {
2273 if (!is_duration ($2))
2274 PARSER->parser_error (@2, _f ("not a duration: %d", $2));
2281 $$ = scm_from_int ($1);
2283 | STRING { $$ = $1; }
2284 | full_markup { $$ = $1; }
2287 figured_bass_alteration:
2288 '-' { $$ = ly_rational2scm (FLAT_ALTERATION); }
2289 | '+' { $$ = ly_rational2scm (SHARP_ALTERATION); }
2290 | '!' { $$ = scm_from_int (0); }
2295 Music *bfr = MY_MAKE_MUSIC ("BassFigureEvent", @$);
2296 $$ = bfr->unprotect ();
2299 Music *bfr = MY_MAKE_MUSIC ("BassFigureEvent", @$);
2300 $$ = bfr->self_scm ();
2302 if (scm_is_number ($1))
2303 bfr->set_property ("figure", $1);
2304 else if (Text_interface::is_markup ($1))
2305 bfr->set_property ("text", $1);
2311 unsmob_music ($1)->set_property ("bracket-stop", SCM_BOOL_T);
2313 | bass_figure figured_bass_alteration {
2314 Music *m = unsmob_music ($1);
2315 if (scm_to_double ($2)) {
2316 SCM salter = m->get_property ("alteration");
2317 SCM alter = scm_is_number (salter) ? salter : scm_from_int (0);
2318 m->set_property ("alteration",
2319 scm_sum (alter, $2));
2321 m->set_property ("alteration", scm_from_int (0));
2324 | bass_figure figured_bass_modification {
2325 Music *m = unsmob_music ($1);
2326 if ($2 == ly_symbol2scm ("plus"))
2328 m->set_property ("augmented", SCM_BOOL_T);
2330 else if ($2 == ly_symbol2scm ("slash"))
2332 m->set_property ("diminished", SCM_BOOL_T);
2334 else if ($2 == ly_symbol2scm ("exclamation"))
2336 m->set_property ("no-continuation", SCM_BOOL_T);
2338 else if ($2 == ly_symbol2scm ("backslash"))
2340 m->set_property ("augmented-slash", SCM_BOOL_T);
2346 figured_bass_modification:
2348 $$ = ly_symbol2scm ("plus");
2351 $$ = ly_symbol2scm ("exclamation");
2354 $$ = ly_symbol2scm ("slash");
2357 $$ = ly_symbol2scm ("backslash");
2367 unsmob_music ($$)->set_property ("bracket-start", SCM_BOOL_T);
2375 | figure_list br_bass_figure {
2376 $$ = scm_cons ($2, $1);
2381 FIGURE_OPEN figure_list FIGURE_CLOSE {
2382 $$ = scm_reverse_x ($2, SCM_EOL);
2393 pitch exclamations questions octave_check optional_notemode_duration optional_rest {
2394 if (!PARSER->lexer_->is_note_state ())
2395 PARSER->parser_error (@1, _ ("have to be in Note mode for notes"));
2399 n = MY_MAKE_MUSIC ("RestEvent", @$);
2401 n = MY_MAKE_MUSIC ("NoteEvent", @$);
2403 n->set_property ("pitch", $1);
2404 n->set_property ("duration", $5);
2406 if (scm_is_number ($4))
2408 int q = scm_to_int ($4);
2409 n->set_property ("absolute-octave", scm_from_int (q-1));
2413 n->set_property ("cautionary", SCM_BOOL_T);
2414 if ($2 % 2 || $3 % 2)
2415 n->set_property ("force-accidental", SCM_BOOL_T);
2417 $$ = n->unprotect ();
2419 | DRUM_PITCH optional_notemode_duration {
2420 Music *n = MY_MAKE_MUSIC ("NoteEvent", @$);
2421 n->set_property ("duration", $2);
2422 n->set_property ("drum-type", $1);
2424 $$ = n->unprotect ();
2426 | RESTNAME optional_notemode_duration {
2428 if (ly_scm2string ($1) == "s") {
2430 ev = MY_MAKE_MUSIC ("SkipEvent", @$);
2433 ev = MY_MAKE_MUSIC ("RestEvent", @$);
2436 ev->set_property ("duration", $2);
2437 $$ = ev->unprotect ();
2439 | lyric_element optional_notemode_duration {
2440 if (!PARSER->lexer_->is_lyric_state ())
2441 PARSER->parser_error (@1, _ ("have to be in Lyric mode for lyrics"));
2443 Music *levent = MY_MAKE_MUSIC ("LyricEvent", @$);
2444 levent->set_property ("text", $1);
2445 levent->set_property ("duration",$2);
2446 $$= levent->unprotect ();
2450 simple_chord_elements:
2452 $$ = scm_list_1 ($1);
2455 if (!PARSER->lexer_->is_chord_state ())
2456 PARSER->parser_error (@1, _ ("have to be in Chord mode for chords"));
2459 | figure_spec optional_notemode_duration {
2460 for (SCM s = $1; scm_is_pair (s); s = scm_cdr (s))
2462 unsmob_music (scm_car (s))->set_property ("duration", $2);
2478 steno_tonic_pitch optional_notemode_duration {
2479 $$ = make_chord_elements ($1, $2, SCM_EOL);
2481 | steno_tonic_pitch optional_notemode_duration chord_separator chord_items {
2482 SCM its = scm_reverse_x ($4, SCM_EOL);
2483 $$ = make_chord_elements ($1, $2, scm_cons ($3, its));
2491 | chord_items chord_item {
2492 $$ = scm_cons ($2, $$);
2498 $$ = ly_symbol2scm ("chord-colon");
2501 $$ = ly_symbol2scm ("chord-caret");
2503 | CHORD_SLASH steno_tonic_pitch {
2504 $$ = scm_list_2 (ly_symbol2scm ("chord-slash"), $2);
2506 | CHORD_BASS steno_tonic_pitch {
2507 $$ = scm_list_2 (ly_symbol2scm ("chord-bass"), $2);
2516 $$ = scm_reverse_x ($1, SCM_EOL);
2524 step_number { $$ = scm_cons ($1, SCM_EOL); }
2525 | step_numbers '.' step_number {
2526 $$ = scm_cons ($3, $$);
2532 $$ = make_chord_step ($1, 0);
2534 | bare_unsigned '+' {
2535 $$ = make_chord_step ($1, SHARP_ALTERATION);
2537 | bare_unsigned CHORD_MINUS {
2538 $$ = make_chord_step ($1, FLAT_ALTERATION);
2544 $$ = scm_from_int ($1);
2546 | bare_unsigned '~' bare_unsigned {
2547 $$ = scm_cons (scm_from_int ($1), scm_from_int ($3));
2554 TODO: should deprecate in favor of Scheme?
2558 number_expression '+' number_term {
2559 $$ = scm_sum ($1, $3);
2561 | number_expression '-' number_term {
2562 $$ = scm_difference ($1, $3);
2571 | number_factor '*' number_factor {
2572 $$ = scm_product ($1, $3);
2574 | number_factor '/' number_factor {
2575 $$ = scm_divide ($1, $3);
2580 '-' number_factor { /* %prec UNARY_MINUS */
2581 $$ = scm_difference ($2, SCM_UNDEFINED);
2589 $$ = scm_from_int ($1);
2594 | NUMBER_IDENTIFIER {
2597 | REAL NUMBER_IDENTIFIER {
2598 $$ = scm_from_double (scm_to_double ($1) *scm_to_double ($2));
2600 | UNSIGNED NUMBER_IDENTIFIER {
2601 $$ = scm_from_double ($1 *scm_to_double ($2));
2613 bare_unsigned { $$ = scm_from_int ($1); }
2614 | NUMBER_IDENTIFIER {
2621 | exclamations '!' { $$ ++; }
2626 | questions '?' { $$ ++; }
2630 This should be done more dynamically if possible.
2634 LYRIC_MARKUP_IDENTIFIER {
2638 { PARSER->lexer_->push_markup_state (); }
2641 PARSER->lexer_->pop_state ();
2646 MARKUPLINES_IDENTIFIER {
2650 { PARSER->lexer_->push_markup_state (); }
2653 PARSER->lexer_->pop_state ();
2662 { PARSER->lexer_->push_markup_state (); }
2665 PARSER->lexer_->pop_state ();
2671 $$ = scm_list_2 (ly_lily_module_constant ("line-markup"), $1);
2673 | markup_head_1_list simple_markup {
2674 $$ = scm_car (scm_call_2 (ly_lily_module_constant ("map-markup-command-list"), $1, scm_list_1 ($2)));
2682 MARKUPLINES_IDENTIFIER {
2685 | markup_composed_list {
2688 | markup_braced_list {
2691 | markup_command_list {
2692 $$ = scm_list_1 ($1);
2696 markup_composed_list:
2697 markup_head_1_list markup_braced_list {
2698 $$ = scm_call_2 (ly_lily_module_constant ("map-markup-command-list"), $1, $2);
2704 '{' markup_braced_list_body '}' {
2705 $$ = scm_reverse_x ($2, SCM_EOL);
2709 markup_braced_list_body:
2710 /* empty */ { $$ = SCM_EOL; }
2711 | markup_braced_list_body markup {
2712 $$ = scm_cons ($2, $1);
2714 | markup_braced_list_body markup_list {
2715 $$ = scm_reverse_x ($2, $1);
2719 markup_command_list:
2720 MARKUP_LIST_FUNCTION markup_command_list_arguments {
2721 $$ = scm_cons ($1, scm_reverse_x($2, SCM_EOL));
2725 markup_command_basic_arguments:
2726 EXPECT_MARKUP_LIST markup_command_list_arguments markup_list {
2727 $$ = scm_cons ($3, $2);
2729 | EXPECT_SCM markup_command_list_arguments embedded_scm_closed {
2730 $$ = check_scheme_arg (PARSER, @3, SCM_UNDEFINED, $3, $2, $1);
2732 | EXPECT_NO_MORE_ARGS {
2737 markup_command_list_arguments:
2738 markup_command_basic_arguments { $$ = $1; }
2739 | EXPECT_MARKUP markup_command_list_arguments markup {
2740 $$ = scm_cons ($3, $2);
2745 MARKUP_FUNCTION EXPECT_MARKUP markup_command_list_arguments {
2746 $$ = scm_cons ($1, scm_reverse_x ($3, SCM_EOL));
2751 markup_head_1_item {
2752 $$ = scm_list_1 ($1);
2754 | markup_head_1_list markup_head_1_item {
2755 $$ = scm_cons ($2, $1);
2761 $$ = make_simple_markup ($1);
2763 | MARKUP_IDENTIFIER {
2766 | LYRIC_MARKUP_IDENTIFIER {
2769 | STRING_IDENTIFIER {
2773 SCM nn = PARSER->lexer_->lookup_identifier ("pitchnames");
2774 PARSER->lexer_->push_note_state (alist_to_hashq (nn));
2775 } '{' score_body '}' {
2777 $$ = scm_list_2 (ly_lily_module_constant ("score-markup"), sc->self_scm ());
2779 PARSER->lexer_->pop_state ();
2781 | MARKUP_FUNCTION markup_command_basic_arguments {
2782 $$ = scm_cons ($1, scm_reverse_x ($2, SCM_EOL));
2787 markup_head_1_list simple_markup {
2788 SCM mapper = ly_lily_module_constant ("map-markup-command-list");
2789 $$ = scm_car (scm_call_2 (mapper, $1, scm_list_1 ($2)));
2799 Lily_parser::set_yydebug (bool x)
2805 Lily_parser::do_yyparse ()
2807 yyparse ((void*)this);
2816 It is a little strange to have this function in this file, but
2817 otherwise, we have to import music classes into the lexer.
2821 Lily_lexer::try_special_identifiers (SCM *destination, SCM sid)
2823 if (scm_is_string (sid)) {
2825 return STRING_IDENTIFIER;
2826 } else if (unsmob_book (sid)) {
2827 Book *book = unsmob_book (sid)->clone ();
2828 *destination = book->self_scm ();
2831 return BOOK_IDENTIFIER;
2832 } else if (scm_is_number (sid)) {
2834 return NUMBER_IDENTIFIER;
2835 } else if (unsmob_context_def (sid)) {
2836 Context_def *def= unsmob_context_def (sid)->clone ();
2838 *destination = def->self_scm ();
2841 return CONTEXT_DEF_IDENTIFIER;
2842 } else if (unsmob_context_mod (sid)) {
2843 *destination = unsmob_context_mod (sid)->smobbed_copy ();
2845 return CONTEXT_MOD_IDENTIFIER;
2846 } else if (unsmob_score (sid)) {
2847 Score *score = new Score (*unsmob_score (sid));
2848 *destination = score->self_scm ();
2850 score->unprotect ();
2851 return SCORE_IDENTIFIER;
2852 } else if (Music *mus = unsmob_music (sid)) {
2853 mus = mus->clone ();
2854 *destination = mus->self_scm ();
2855 unsmob_music (*destination)->
2856 set_property ("origin", make_input (last_input_));
2858 bool is_event = scm_memq (ly_symbol2scm ("event"), mus->get_property ("types"))
2862 return is_event ? EVENT_IDENTIFIER : MUSIC_IDENTIFIER;
2863 } else if (unsmob_pitch (sid)) {
2864 *destination = unsmob_pitch (sid)->smobbed_copy ();
2865 return PITCH_IDENTIFIER;
2866 } else if (unsmob_duration (sid)) {
2867 *destination = unsmob_duration (sid)->smobbed_copy ();
2868 return DURATION_IDENTIFIER;
2869 } else if (unsmob_output_def (sid)) {
2870 Output_def *p = unsmob_output_def (sid);
2873 *destination = p->self_scm ();
2875 return OUTPUT_DEF_IDENTIFIER;
2876 } else if (Text_interface::is_markup (sid)) {
2878 if (is_lyric_state ())
2879 return LYRIC_MARKUP_IDENTIFIER;
2880 return MARKUP_IDENTIFIER;
2881 } else if (Text_interface::is_markup_list (sid)) {
2883 return MARKUPLINES_IDENTIFIER;
2890 get_next_unique_context_id ()
2892 return scm_from_locale_string ("$uniqueContextId");
2897 get_next_unique_lyrics_context_id ()
2899 static int new_context_count;
2901 snprintf (s, sizeof (s)-1, "uniqueContext%d", new_context_count++);
2902 return scm_from_locale_string (s);
2906 SCM check_scheme_arg (Lily_parser *parser, Input loc, SCM fallback,
2907 SCM arg, SCM args, SCM pred)
2909 SCM type_check_arg = ly_lily_module_constant ("type-check-arg");
2910 if (scm_is_false (scm_call_4 (type_check_arg, make_input (loc),
2913 if (SCM_UNBNDP (fallback))
2914 fallback = SCM_BOOL_F;
2916 fallback = loc_on_music (loc, fallback);
2918 parser->error_level_ = 1;
2920 return scm_cons (fallback, args);
2922 return scm_cons (arg, args);
2925 SCM loc_on_music (Input loc, SCM arg)
2927 if (Music *m = unsmob_music (arg))
2931 return m->unprotect ();
2937 is_regular_identifier (SCM id)
2939 string str = ly_scm2string (id);
2940 char const *s = str.c_str ();
2949 v = v && isalnum (*s);
2956 make_music_with_input (SCM name, Input where)
2958 Music *m = make_music_by_name (name);
2959 m->set_spot (where);
2964 get_first_context_id (SCM type, Music *m)
2966 SCM id = m->get_property ("context-id");
2967 if (SCM_BOOL_T == scm_equal_p (m->get_property ("context-type"), type)
2968 && scm_is_string (m->get_property ("context-id"))
2969 && scm_c_string_length (id) > 0)
2977 make_simple_markup (SCM a)
2985 return t && t == 1 << intlog2 (t);
2989 set_music_properties (Music *p, SCM a)
2991 for (SCM k = a; scm_is_pair (k); k = scm_cdr (k))
2992 p->set_property (scm_caar (k), scm_cdar (k));
2997 make_chord_step (int step, Rational alter)
3000 alter += FLAT_ALTERATION;
3004 Pitch m ((step -1) / 7, (step - 1) % 7, alter);
3005 return m.smobbed_copy ();
3010 make_chord_elements (SCM pitch, SCM dur, SCM modification_list)
3012 SCM chord_ctor = ly_lily_module_constant ("construct-chord-elements");
3013 return scm_call_3 (chord_ctor, pitch, dur, modification_list);
3017 /* Todo: actually also use apply iso. call too ... */
3019 ly_input_procedure_p (SCM x)
3021 return ly_is_procedure (x)
3022 || (scm_is_pair (x) && ly_is_procedure (scm_car (x)));
3026 yylex (YYSTYPE *s, YYLTYPE *loc, void *v)
3028 Lily_parser *pars = (Lily_parser*) v;
3029 Lily_lexer *lex = pars->lexer_;
3031 lex->lexval_ = (void*) s;
3033 lex->prepare_for_next_token ();
3034 return lex->yylex ();