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 SEQUENTIAL SIMULTANEOUS DOUBLE_ANGLE_OPEN MUSIC_IDENTIFIER '{'
62 PITCH_IDENTIFIER NOTENAME_PITCH TONICNAME_PITCH
63 SCM_FUNCTION SCM_IDENTIFIER SCM_TOKEN
64 UNSIGNED DURATION_IDENTIFIER
65 CHORDMODE CHORDS DRUMMODE DRUMS FIGUREMODE FIGURES LYRICMODE LYRICS
67 CONTEXT TIMES NEWCONTEXT
69 /* The above are the symbols that can start function arguments */
82 %{ // -*-Fundamental-*-
87 * The rules for who is protecting what are very shady. Uniformise
90 * There are too many lexical modes?
101 #include "context-def.hh"
102 #include "context-mod.hh"
103 #include "dimensions.hh"
104 #include "file-path.hh"
106 #include "international.hh"
107 #include "lily-guile.hh"
108 #include "lily-lexer.hh"
109 #include "lily-parser.hh"
113 #include "output-def.hh"
114 #include "paper-book.hh"
115 #include "scm-hash.hh"
117 #include "text-interface.hh"
125 Output_def *outputdef;
135 #define MY_MAKE_MUSIC(x, spot) make_music_with_input (ly_symbol2scm (x), spot)
138 - Don't use lily module, create a new module instead.
139 - delay application of the function
141 #define LOWLEVEL_MAKE_SYNTAX(proc, args) \
142 scm_apply_0 (proc, args)
143 /* Syntactic Sugar. */
144 #define MAKE_SYNTAX(name, location, ...) \
145 LOWLEVEL_MAKE_SYNTAX (ly_lily_module_constant (name), scm_list_n (PARSER->self_scm (), make_input (location), ##__VA_ARGS__, SCM_UNDEFINED));
146 #define START_MAKE_SYNTAX(name, ...) \
147 scm_list_n (ly_lily_module_constant (name), ##__VA_ARGS__, SCM_UNDEFINED)
148 #define FINISH_MAKE_SYNTAX(start, location, ...) \
149 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)))))
151 SCM get_next_unique_context_id ();
152 SCM get_next_unique_lyrics_context_id ();
159 #define _(x) gettext (x)
163 static Music *make_music_with_input (SCM name, Input where);
164 SCM check_scheme_arg (Lily_parser *parser, Input loc, SCM fallback,
165 SCM arg, SCM args, SCM pred);
166 SCM loc_on_music (Input loc, SCM arg);
167 SCM get_first_context_id (SCM type, Music *m);
168 SCM make_chord_elements (SCM pitch, SCM dur, SCM modification_list);
169 SCM make_chord_step (int step, Rational alter);
170 SCM make_simple_markup (SCM a);
171 bool is_duration (int t);
172 bool is_regular_identifier (SCM id);
173 bool ly_input_procedure_p (SCM x);
174 int yylex (YYSTYPE *s, YYLTYPE *loc, void *v);
175 void set_music_properties (Music *p, SCM a);
179 /* The third option is an alias that will be used to display the
180 syntax error. Bison CVS now correctly handles backslash escapes.
182 FIXME: Bison needs to translate some of these, eg, STRING.
186 /* Keyword tokens with plain escaped name. */
187 %token ACCEPTS "\\accepts"
188 %token ADDLYRICS "\\addlyrics"
189 %token ALIAS "\\alias"
190 %token ALTERNATIVE "\\alternative"
192 %token BOOKPART "\\bookpart"
193 %token CHANGE "\\change"
194 %token CHORDMODE "\\chordmode"
195 %token CHORDS "\\chords"
196 %token CONSISTS "\\consists"
197 %token CONTEXT "\\context"
198 %token DEFAULT "\\default"
199 %token DEFAULTCHILD "\\defaultchild"
200 %token DENIES "\\denies"
201 %token DESCRIPTION "\\description"
202 %token DRUMMODE "\\drummode"
203 %token DRUMS "\\drums"
204 %token FIGUREMODE "\\figuremode"
205 %token FIGURES "\\figures"
206 %token GROBDESCRIPTIONS "\\grobdescriptions"
207 %token HEADER "\\header"
208 %token INVALID "\\version-error"
210 %token LAYOUT "\\layout"
211 %token LYRICMODE "\\lyricmode"
212 %token LYRICS "\\lyrics"
213 %token LYRICSTO "\\lyricsto"
215 %token MARKUP "\\markup"
216 %token MARKUPLINES "\\markuplines"
219 %token NOTEMODE "\\notemode"
221 %token OVERRIDE "\\override"
222 %token PAPER "\\paper"
223 %token REMOVE "\\remove"
224 %token REPEAT "\\repeat"
226 %token REVERT "\\revert"
227 %token SCORE "\\score"
228 %token SEQUENTIAL "\\sequential"
230 %token SIMULTANEOUS "\\simultaneous"
231 %token TEMPO "\\tempo"
232 %token TIMES "\\times"
234 %token UNSET "\\unset"
237 /* Keyword token exceptions. */
238 %token TIME_T "\\time"
239 %token NEWCONTEXT "\\new"
242 /* Other string tokens. */
244 %token CHORD_BASS "/+"
245 %token CHORD_CARET "^"
246 %token CHORD_COLON ":"
247 %token CHORD_MINUS "-"
248 %token CHORD_SLASH "/"
249 %token ANGLE_OPEN "<"
250 %token ANGLE_CLOSE ">"
251 %token DOUBLE_ANGLE_OPEN "<<"
252 %token DOUBLE_ANGLE_CLOSE ">>"
253 %token E_BACKSLASH "\\"
254 %token E_ANGLE_CLOSE "\\>"
255 %token E_CHAR "\\C[haracter]"
257 %token E_EXCLAMATION "\\!"
258 %token E_BRACKET_OPEN "\\["
260 %token E_BRACKET_CLOSE "\\]"
261 %token E_ANGLE_OPEN "\\<"
267 If we give names, Bison complains.
269 %token FIGURE_CLOSE /* "\\>" */
270 %token FIGURE_OPEN /* "\\<" */
271 %token FIGURE_SPACE "_"
274 %token CHORDMODIFIERS
276 %token MULTI_MEASURE_REST
279 %token <i> E_UNSIGNED
282 /* Artificial tokens, for more generic function syntax */
283 %token <i> EXPECT_MARKUP "markup?"
284 %token <i> EXPECT_MUSIC "ly:music?"
285 %token <i> EXPECT_PITCH "ly:pitch?"
286 %token <i> EXPECT_DURATION "ly:duration?"
287 %token <scm> EXPECT_SCM "scheme?"
288 %token <i> EXPECT_MARKUP_LIST "markup-list?"
289 %token <scm> EXPECT_OPTIONAL "optional?"
290 /* After the last argument. */
291 %token <i> EXPECT_NO_MORE_ARGS;
293 /* An artificial token for parsing embedded Lilypond */
294 %token <i> EMBEDDED_LILY "#{"
296 %token <scm> BOOK_IDENTIFIER
297 %token <scm> CHORDMODIFIER_PITCH
298 %token <scm> CHORD_MODIFIER
299 %token <scm> CHORD_REPETITION
300 %token <scm> CONTEXT_DEF_IDENTIFIER
301 %token <scm> CONTEXT_MOD_IDENTIFIER
302 %token <scm> DRUM_PITCH
303 %token <scm> PITCH_IDENTIFIER
304 %token <scm> DURATION_IDENTIFIER
305 %token <scm> EVENT_IDENTIFIER
306 %token <scm> EVENT_FUNCTION
307 %token <scm> FRACTION
308 %token <scm> LYRICS_STRING
309 %token <scm> LYRIC_MARKUP_IDENTIFIER
310 %token <scm> MARKUP_FUNCTION
311 %token <scm> MARKUP_LIST_FUNCTION
312 %token <scm> MARKUP_IDENTIFIER
313 %token <scm> MARKUPLINES_IDENTIFIER
314 %token <scm> MUSIC_FUNCTION
315 %token <scm> MUSIC_IDENTIFIER
316 %token <scm> NOTENAME_PITCH
317 %token <scm> NUMBER_IDENTIFIER
318 %token <scm> OUTPUT_DEF_IDENTIFIER
320 %token <scm> RESTNAME
321 %token <scm> SCM_FUNCTION
322 %token <scm> SCM_IDENTIFIER
323 %token <scm> SCM_TOKEN
324 %token <scm> SCORE_IDENTIFIER
326 %token <scm> STRING_IDENTIFIER
327 %token <scm> TONICNAME_PITCH
330 %type <book> book_block
331 %type <book> book_body
332 %type <book> bookpart_block
333 %type <book> bookpart_body
335 %type <i> bare_unsigned
336 %type <scm> figured_bass_alteration
338 %type <i> exclamations
339 %type <i> optional_rest
344 %type <i> tremolo_type
347 %type <scm> composite_music
348 %type <scm> grouped_music_list
349 %type <scm> braced_music_list
350 %type <scm> closed_music
352 %type <scm> music_bare
353 %type <scm> complex_music
354 %type <scm> complex_music_prefix
355 %type <scm> mode_changed_music
356 %type <scm> repeated_music
357 %type <scm> sequential_music
358 %type <scm> simple_music
359 %type <scm> simultaneous_music
360 %type <scm> chord_body
361 %type <scm> chord_body_element
362 %type <scm> command_element
363 %type <scm> command_event
364 %type <scm> context_modification
365 %type <scm> context_change
366 %type <scm> direction_less_event
367 %type <scm> direction_reqd_event
368 %type <scm> embedded_lilypond
369 %type <scm> event_chord
370 %type <scm> fingering
371 %type <scm> gen_text_def
372 %type <scm> music_property_def
373 %type <scm> note_chord_element
374 %type <scm> post_event
375 %type <scm> post_event_nofinger
376 %type <scm> re_rhythmed_music
377 %type <scm> simple_element
378 %type <scm> simple_music_property_def
379 %type <scm> start_symbol
380 %type <scm> string_number_event
381 %type <scm> tempo_event
383 %type <outputdef> output_def_body
384 %type <outputdef> output_def_head
385 %type <outputdef> output_def_head_with_mode_switch
386 %type <outputdef> output_def
387 %type <outputdef> paper_block
389 %type <scm> music_function_call
390 %type <scm> music_list
391 %type <scm> assignment_id
392 %type <scm> bare_number
393 %type <scm> unsigned_number
394 %type <scm> bass_figure
395 %type <scm> figured_bass_modification
396 %type <scm> br_bass_figure
397 %type <scm> bass_number
398 %type <scm> chord_body_elements
399 %type <scm> chord_item
400 %type <scm> chord_items
401 %type <scm> chord_separator
402 %type <scm> context_def_mod
403 %type <scm> context_def_spec_block
404 %type <scm> context_def_spec_body
405 %type <scm> context_mod
406 %type <scm> context_mod_list
407 %type <scm> context_prop_spec
408 %type <scm> direction_less_char
409 %type <scm> duration_length
410 %type <scm> embedded_scm
411 %type <scm> embedded_scm_bare
412 %type <scm> embedded_scm_closed
413 %type <scm> embedded_scm_chord_body
414 %type <scm> embedded_scm_event
415 %type <scm> event_function_event
416 %type <scm> figure_list
417 %type <scm> figure_spec
419 %type <scm> full_markup
420 %type <scm> full_markup_list
421 %type <scm> function_arglist
422 %type <scm> function_arglist_optional
423 %type <scm> function_arglist_keep
424 %type <scm> function_arglist_bare
425 %type <scm> function_arglist_closed
426 %type <scm> function_arglist_closed_optional
427 %type <scm> function_arglist_closed_keep
428 %type <scm> identifier_init
430 %type <scm> lilypond_header
431 %type <scm> lilypond_header_body
432 %type <scm> lyric_element
433 %type <scm> lyric_markup
435 %type <scm> markup_braced_list
436 %type <scm> markup_braced_list_body
437 %type <scm> markup_composed_list
438 %type <scm> markup_command_list
439 %type <scm> markup_command_list_arguments
440 %type <scm> markup_command_basic_arguments
441 %type <scm> markup_head_1_item
442 %type <scm> markup_head_1_list
443 %type <scm> markup_list
444 %type <scm> markup_top
445 %type <scm> mode_changing_head
446 %type <scm> mode_changing_head_with_context
447 %type <scm> multiplied_duration
448 %type <scm> music_function_event
449 %type <scm> music_function_event_arglist
450 %type <scm> music_function_chord_body
451 %type <scm> music_function_chord_body_arglist
452 %type <scm> new_chord
453 %type <scm> new_lyrics
454 %type <scm> number_expression
455 %type <scm> number_factor
456 %type <scm> number_term
457 %type <scm> octave_check
458 %type <scm> optional_context_mod
459 %type <scm> optional_id
460 %type <scm> optional_notemode_duration
462 %type <scm> pitch_also_in_chords
463 %type <scm> post_events
464 %type <scm> property_operation
465 %type <scm> property_path property_path_revved
467 %type <scm> scalar_bare
468 %type <scm> scalar_closed
469 %type <scm> scm_function_call
470 %type <scm> scm_function_call_closed
471 %type <scm> script_abbreviation
472 %type <scm> simple_chord_elements
473 %type <scm> simple_markup
474 %type <scm> simple_string
475 %type <scm> steno_duration
476 %type <scm> steno_pitch
477 %type <scm> steno_tonic_pitch
478 %type <scm> step_number
479 %type <scm> step_numbers
481 %type <scm> tempo_range
483 %type <score> score_block
484 %type <score> score_body
489 /* We don't assign precedence to / and *, because we might need varied
490 prec levels in different prods */
499 SCM nn = PARSER->lexer_->lookup_identifier ("pitchnames");
500 PARSER->lexer_->push_note_state (alist_to_hashq (nn));
501 } embedded_lilypond {
502 PARSER->lexer_->pop_state ();
503 PARSER->lexer_->set_identifier (ly_symbol2scm ("parseStringResult"), $3);
507 lilypond: /* empty */ { }
508 | lilypond toplevel_expression {
510 | lilypond assignment {
513 PARSER->error_level_ = 1;
516 PARSER->error_level_ = 1;
523 PARSER->lexer_->set_identifier (ly_symbol2scm ("$defaultheader"), $1);
527 SCM proc = PARSER->lexer_->lookup_identifier ("toplevel-book-handler");
528 scm_call_2 (proc, PARSER->self_scm (), book->self_scm ());
533 SCM proc = PARSER->lexer_->lookup_identifier ("toplevel-bookpart-handler");
534 scm_call_2 (proc, PARSER->self_scm (), bookpart->self_scm ());
535 bookpart->unprotect ();
540 SCM proc = PARSER->lexer_->lookup_identifier ("toplevel-score-handler");
541 scm_call_2 (proc, PARSER->self_scm (), score->self_scm ());
545 Music *music = unsmob_music ($1);
546 SCM proc = PARSER->lexer_->lookup_identifier ("toplevel-music-handler");
547 scm_call_2 (proc, PARSER->self_scm (), music->self_scm ());
550 SCM proc = PARSER->lexer_->lookup_identifier ("toplevel-text-handler");
551 scm_call_2 (proc, PARSER->self_scm (), scm_list_1 ($1));
554 SCM proc = PARSER->lexer_->lookup_identifier ("toplevel-text-handler");
555 scm_call_2 (proc, PARSER->self_scm (), $1);
559 Output_def * od = $1;
561 if ($1->c_variable ("is-paper") == SCM_BOOL_T)
562 id = ly_symbol2scm ("$defaultpaper");
563 else if ($1->c_variable ("is-midi") == SCM_BOOL_T)
564 id = ly_symbol2scm ("$defaultmidi");
565 else if ($1->c_variable ("is-layout") == SCM_BOOL_T)
566 id = ly_symbol2scm ("$defaultlayout");
568 PARSER->lexer_->set_identifier (id, od->self_scm ());
578 /* The generic version may end in music, or not */
586 SCM_FUNCTION function_arglist {
587 $$ = MAKE_SYNTAX ("music-function", @$,
595 $$ = MAKE_SYNTAX ("void-music", @$);
598 | music music music_list {
599 $$ = MAKE_SYNTAX ("sequential-music", @$,
600 scm_cons2 ($1, $2, scm_reverse_x ($3, SCM_EOL)));
603 PARSER->error_level_ = 1;
605 | INVALID embedded_lilypond {
606 PARSER->error_level_ = 1;
611 lilypond_header_body:
613 $$ = get_header (PARSER);
614 PARSER->lexer_->add_scope ($$);
616 | lilypond_header_body assignment {
622 HEADER '{' lilypond_header_body '}' {
623 $$ = PARSER->lexer_->remove_scope ();
632 | LYRICS_STRING { $$ = $1; }
636 assignment_id '=' identifier_init {
637 PARSER->lexer_->set_identifier ($1, $3);
639 | assignment_id property_path '=' identifier_init {
640 SCM path = scm_cons (scm_string_to_symbol ($1), $2);
641 PARSER->lexer_->set_identifier (path, $4);
644 TODO: devise standard for protection in parser.
646 The parser stack lives on the C-stack, which means that
647 all objects can be unprotected as soon as they're here.
657 $$ = $1->self_scm ();
661 $$ = $1->self_scm ();
665 $$ = $1->self_scm ();
669 $$ = $1->self_scm ();
672 | context_def_spec_block {
676 /* Hack: Create event-chord around standalone events.
677 Prevents the identifier from being interpreted as a post-event. */
678 Music *mus = unsmob_music ($1);
679 bool is_event = mus &&
680 (scm_memq (ly_symbol2scm ("event"), mus->get_property ("types"))
685 $$ = MAKE_SYNTAX ("event-chord", @$, scm_list_1 ($1));
687 | post_event_nofinger {
690 | number_expression {
705 | context_modification {
710 context_def_spec_block:
711 CONTEXT '{' context_def_spec_body '}'
717 context_def_spec_body:
719 $$ = Context_def::make_scm ();
720 unsmob_context_def ($$)->origin ()->set_spot (@$);
722 | CONTEXT_DEF_IDENTIFIER {
724 unsmob_context_def ($$)->origin ()->set_spot (@$);
726 | context_def_spec_body GROBDESCRIPTIONS embedded_scm {
727 Context_def*td = unsmob_context_def ($$);
729 for (SCM p = $3; scm_is_pair (p); p = scm_cdr (p)) {
730 SCM tag = scm_caar (p);
732 /* TODO: should make new tag "grob-definition" ? */
733 td->add_context_mod (scm_list_3 (ly_symbol2scm ("assign"),
734 tag, scm_cons (scm_cdar (p), SCM_EOL)));
737 | context_def_spec_body context_mod {
738 unsmob_context_def ($$)->add_context_mod ($2);
740 | context_def_spec_body context_modification {
741 Context_def *td = unsmob_context_def ($$);
742 SCM new_mods = unsmob_context_mod ($2)->get_mods ();
743 for (SCM m = new_mods; scm_is_pair (m); m = scm_cdr (m)) {
744 td->add_context_mod (scm_car (m));
752 BOOK '{' book_body '}' {
755 PARSER->lexer_->set_identifier (ly_symbol2scm ("$current-book"), SCM_BOOL_F);
760 * Use 'handlers' like for toplevel-* stuff?
761 * grok \layout and \midi? */
765 init_papers (PARSER);
766 $$->origin ()->set_spot (@$);
767 $$->paper_ = dynamic_cast<Output_def*> (unsmob_output_def (PARSER->lexer_->lookup_identifier ("$defaultpaper"))->clone ());
768 $$->paper_->unprotect ();
769 push_paper (PARSER, $$->paper_);
770 $$->header_ = PARSER->lexer_->lookup_identifier ("$defaultheader");
771 PARSER->lexer_->set_identifier (ly_symbol2scm ("$current-book"), $$->self_scm ());
772 PARSER->lexer_->set_identifier (ly_symbol2scm ("book-output-suffix"), SCM_BOOL_F);
773 PARSER->lexer_->set_identifier (ly_symbol2scm ("book-filename"), SCM_BOOL_F);
776 $$ = unsmob_book ($1);
778 $$->origin ()->set_spot (@$);
779 PARSER->lexer_->set_identifier (ly_symbol2scm ("$current-book"), $1);
781 | book_body paper_block {
784 set_paper (PARSER, $2);
786 | book_body bookpart_block {
788 SCM proc = PARSER->lexer_->lookup_identifier ("book-bookpart-handler");
789 scm_call_2 (proc, $$->self_scm (), bookpart->self_scm ());
790 bookpart->unprotect ();
792 | book_body score_block {
794 SCM proc = PARSER->lexer_->lookup_identifier ("book-score-handler");
795 scm_call_2 (proc, $$->self_scm (), score->self_scm ());
798 | book_body composite_music {
799 Music *music = unsmob_music ($2);
800 SCM proc = PARSER->lexer_->lookup_identifier ("book-music-handler");
801 scm_call_3 (proc, PARSER->self_scm (), $$->self_scm (), music->self_scm ());
803 | book_body full_markup {
804 SCM proc = PARSER->lexer_->lookup_identifier ("book-text-handler");
805 scm_call_2 (proc, $$->self_scm (), scm_list_1 ($2));
807 | book_body full_markup_list {
808 SCM proc = PARSER->lexer_->lookup_identifier ("book-text-handler");
809 scm_call_2 (proc, $$->self_scm (), $2);
811 | book_body lilypond_header {
814 | book_body embedded_scm { }
817 $$->scores_ = SCM_EOL;
818 $$->bookparts_ = SCM_EOL;
823 BOOKPART '{' bookpart_body '}' {
825 PARSER->lexer_->set_identifier (ly_symbol2scm ("$current-bookpart"), SCM_BOOL_F);
832 $$->origin ()->set_spot (@$);
833 PARSER->lexer_->set_identifier (ly_symbol2scm ("$current-bookpart"), $$->self_scm ());
836 $$ = unsmob_book ($1);
838 $$->origin ()->set_spot (@$);
839 PARSER->lexer_->set_identifier (ly_symbol2scm ("$current-bookpart"), $1);
841 | bookpart_body paper_block {
845 | bookpart_body score_block {
847 SCM proc = PARSER->lexer_->lookup_identifier ("bookpart-score-handler");
848 scm_call_2 (proc, $$->self_scm (), score->self_scm ());
851 | bookpart_body composite_music {
852 Music *music = unsmob_music ($2);
853 SCM proc = PARSER->lexer_->lookup_identifier ("bookpart-music-handler");
854 scm_call_3 (proc, PARSER->self_scm (), $$->self_scm (), music->self_scm ());
856 | bookpart_body full_markup {
857 SCM proc = PARSER->lexer_->lookup_identifier ("bookpart-text-handler");
858 scm_call_2 (proc, $$->self_scm (), scm_list_1 ($2));
860 | bookpart_body full_markup_list {
861 SCM proc = PARSER->lexer_->lookup_identifier ("bookpart-text-handler");
862 scm_call_2 (proc, $$->self_scm (), $2);
864 | bookpart_body lilypond_header {
867 | bookpart_body embedded_scm { }
868 | bookpart_body error {
870 $$->scores_ = SCM_EOL;
875 SCORE '{' score_body '}' {
883 SCM scorify = ly_lily_module_constant ("scorify-music");
884 SCM score = scm_call_2 (scorify, m, PARSER->self_scm ());
886 // pass ownernship to C++ again.
887 $$ = unsmob_score (score);
889 $$->origin ()->set_spot (@$);
892 $$ = unsmob_score ($1);
894 $$->origin ()->set_spot (@$);
896 | score_body lilypond_header {
899 | score_body output_def {
900 if ($2->lookup_variable (ly_symbol2scm ("is-paper")) == SCM_BOOL_T)
902 PARSER->parser_error (@2, _("\\paper cannot be used in \\score, use \\layout instead"));
907 $$->add_output_def ($2);
912 $$->error_found_ = true;
924 if ($$->lookup_variable (ly_symbol2scm ("is-paper")) != SCM_BOOL_T)
926 PARSER->parser_error (@1, _ ("need \\paper for paper block"));
928 $$ = get_paper (PARSER);
935 output_def_body '}' {
938 PARSER->lexer_->remove_scope ();
939 PARSER->lexer_->pop_state ();
945 $$ = get_paper (PARSER);
946 $$->input_origin_ = @$;
947 PARSER->lexer_->add_scope ($$->scope_);
950 Output_def *p = get_midi (PARSER);
952 PARSER->lexer_->add_scope (p->scope_);
955 Output_def *p = get_layout (PARSER);
957 PARSER->lexer_->add_scope (p->scope_);
962 output_def_head_with_mode_switch:
964 PARSER->lexer_->push_initial_state ();
970 output_def_head_with_mode_switch '{' {
972 $$->input_origin_.set_spot (@$);
974 | output_def_head_with_mode_switch '{' OUTPUT_DEF_IDENTIFIER {
977 Output_def *o = unsmob_output_def ($3);
978 o->input_origin_.set_spot (@$);
981 PARSER->lexer_->remove_scope ();
982 PARSER->lexer_->add_scope (o->scope_);
984 | output_def_body assignment {
987 | output_def_body context_def_spec_block {
988 assign_context_def ($$, $2);
990 | output_def_body error {
996 TEMPO steno_duration '=' tempo_range {
997 $$ = MAKE_SYNTAX ("tempo", @$, SCM_EOL, $2, $4);
999 | TEMPO scalar_closed steno_duration '=' tempo_range {
1000 $$ = MAKE_SYNTAX ("tempo", @$, $2, $3, $5);
1003 $$ = MAKE_SYNTAX ("tempo", @$, $2);
1008 The representation of a list is reversed to have efficient append. */
1014 | music_list music {
1015 $$ = scm_cons ($2, $1);
1017 | music_list embedded_scm {
1020 | music_list error {
1021 Music *m = MY_MAKE_MUSIC("Music", @$);
1023 m->set_property ("error-found", SCM_BOOL_T);
1024 $$ = scm_cons (m->self_scm (), $1);
1025 m->unprotect (); /* UGH */
1032 $$ = scm_reverse_x ($2, SCM_EOL);
1043 REPEAT simple_string unsigned_number music
1045 $$ = MAKE_SYNTAX ("repeat", @$, $2, $3, $4, SCM_EOL);
1047 | REPEAT simple_string unsigned_number music ALTERNATIVE braced_music_list
1049 $$ = MAKE_SYNTAX ("repeat", @$, $2, $3, $4, $6);
1054 SEQUENTIAL braced_music_list {
1055 $$ = MAKE_SYNTAX ("sequential-music", @$, $2);
1057 | braced_music_list {
1058 $$ = MAKE_SYNTAX ("sequential-music", @$, $1);
1063 SIMULTANEOUS braced_music_list {
1064 $$ = MAKE_SYNTAX ("simultaneous-music", @$, $2);
1066 | DOUBLE_ANGLE_OPEN music_list DOUBLE_ANGLE_CLOSE {
1067 $$ = MAKE_SYNTAX ("simultaneous-music", @$, scm_reverse_x ($2, SCM_EOL));
1073 | music_property_def
1077 context_modification:
1078 WITH { PARSER->lexer_->push_initial_state (); } '{' context_mod_list '}'
1080 PARSER->lexer_->pop_state ();
1083 | WITH CONTEXT_MOD_IDENTIFIER
1087 | CONTEXT_MOD_IDENTIFIER
1093 optional_context_mod:
1097 | context_modification
1105 $$ = Context_mod ().smobbed_copy ();
1107 | context_mod_list context_mod {
1108 unsmob_context_mod ($1)->add_context_mod ($2);
1110 | context_mod_list CONTEXT_MOD_IDENTIFIER {
1111 Context_mod *md = unsmob_context_mod ($2);
1113 unsmob_context_mod ($1)->add_context_mods (md->get_mods ());
1122 /* Music that can't be followed by additional events or durations */
1125 | complex_music_prefix closed_music
1127 $$ = FINISH_MAKE_SYNTAX ($1, @$, $2);
1128 } %prec FUNCTION_ARGUMENTS
1129 /* \addlyrics attaches to innermost closed_music */
1135 | grouped_music_list
1139 simultaneous_music { $$ = $1; }
1140 | sequential_music { $$ = $1; }
1143 /* An argument list. If a function \foo expects scm scm music, then the lexer expands \foo into the token sequence:
1144 MUSIC_FUNCTION EXPECT_MUSIC EXPECT_SCM EXPECT_SCM EXPECT_NO_MORE_ARGS
1145 and this rule returns the reversed list of arguments. */
1149 function_arglist_bare
1150 | EXPECT_MUSIC function_arglist_optional music
1152 $$ = scm_cons ($3, $2);
1154 | EXPECT_SCM function_arglist_optional embedded_scm
1156 $$ = check_scheme_arg (PARSER, @3, SCM_UNDEFINED, $3, $2, $1);
1160 function_arglist_optional:
1161 function_arglist_keep %prec FUNCTION_ARGUMENTS
1162 | EXPECT_OPTIONAL EXPECT_MUSIC function_arglist_optional
1164 $$ = scm_cons (loc_on_music (@3, $1), $3);
1166 | EXPECT_OPTIONAL EXPECT_PITCH function_arglist_optional
1168 $$ = scm_cons ($1, $3);
1170 | EXPECT_OPTIONAL EXPECT_DURATION function_arglist_optional
1172 $$ = scm_cons ($1, $3);
1174 | EXPECT_OPTIONAL EXPECT_MARKUP function_arglist_optional
1176 $$ = scm_cons ($1, $3);
1178 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_optional
1180 $$ = scm_cons (loc_on_music (@3, $1), $3);
1184 function_arglist_keep:
1185 EXPECT_OPTIONAL EXPECT_MARKUP function_arglist_keep full_markup {
1186 $$ = scm_cons ($4, $3);
1188 | EXPECT_OPTIONAL EXPECT_MARKUP function_arglist_keep simple_string {
1189 $$ = scm_cons ($4, $3);
1191 | EXPECT_OPTIONAL EXPECT_PITCH function_arglist_keep pitch_also_in_chords {
1192 $$ = scm_cons ($4, $3);
1194 | EXPECT_OPTIONAL EXPECT_DURATION function_arglist_closed_keep duration_length {
1195 $$ = scm_cons ($4, $3);
1197 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_keep simple_string
1199 $$ = check_scheme_arg (PARSER, @4, $1, $4, $3, $2);
1201 | EXPECT_OPTIONAL EXPECT_MUSIC function_arglist_keep closed_music
1203 $$ = scm_cons ($4, $3);
1205 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_keep embedded_scm
1207 $$ = check_scheme_arg (PARSER, @4, $1, $4, $3, $2);
1213 function_arglist_closed:
1214 function_arglist_bare
1215 | EXPECT_MUSIC function_arglist_optional closed_music
1217 $$ = scm_cons ($3, $2);
1219 | EXPECT_SCM function_arglist_optional embedded_scm_closed
1221 $$ = check_scheme_arg (PARSER, @3, SCM_UNDEFINED, $3, $2, $1);
1225 function_arglist_closed_optional:
1226 function_arglist_closed_keep %prec FUNCTION_ARGUMENTS
1227 | EXPECT_OPTIONAL EXPECT_MUSIC function_arglist_closed_optional
1229 $$ = scm_cons (loc_on_music (@3, $1), $3);
1231 | EXPECT_OPTIONAL EXPECT_PITCH function_arglist_closed_optional
1233 $$ = scm_cons ($1, $3);
1235 | EXPECT_OPTIONAL EXPECT_DURATION function_arglist_closed_optional
1237 $$ = scm_cons ($1, $3);
1239 | EXPECT_OPTIONAL EXPECT_MARKUP function_arglist_closed_optional
1241 $$ = scm_cons ($1, $3);
1243 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_closed_optional
1245 $$ = scm_cons (loc_on_music (@3, $1), $3);
1249 function_arglist_closed_keep:
1250 EXPECT_OPTIONAL EXPECT_MARKUP function_arglist_keep full_markup {
1251 $$ = scm_cons ($4, $3);
1253 | EXPECT_OPTIONAL EXPECT_MARKUP function_arglist_keep simple_string {
1254 $$ = scm_cons ($4, $3);
1256 | EXPECT_OPTIONAL EXPECT_PITCH function_arglist_keep pitch_also_in_chords {
1257 $$ = scm_cons ($4, $3);
1259 | EXPECT_OPTIONAL EXPECT_DURATION function_arglist_closed_keep duration_length {
1260 $$ = scm_cons ($4, $3);
1262 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_keep simple_string
1264 $$ = check_scheme_arg (PARSER, @4, $1, $4, $3, $2);
1266 | EXPECT_OPTIONAL EXPECT_MUSIC function_arglist_keep closed_music
1268 $$ = scm_cons ($4, $3);
1270 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_keep embedded_scm_closed
1272 $$ = check_scheme_arg (PARSER, @4, $1, $4, $3, $2);
1274 | function_arglist_closed
1277 embedded_scm_closed:
1279 | scm_function_call_closed
1282 scm_function_call_closed:
1283 SCM_FUNCTION function_arglist_closed {
1284 $$ = MAKE_SYNTAX ("music-function", @$,
1289 function_arglist_bare:
1290 EXPECT_NO_MORE_ARGS {
1293 | EXPECT_MARKUP function_arglist_optional full_markup {
1294 $$ = scm_cons ($3, $2);
1296 | EXPECT_MARKUP function_arglist_optional simple_string {
1297 $$ = scm_cons ($3, $2);
1299 | EXPECT_PITCH function_arglist_optional pitch_also_in_chords {
1300 $$ = scm_cons ($3, $2);
1302 | EXPECT_DURATION function_arglist_closed_optional duration_length {
1303 $$ = scm_cons ($3, $2);
1305 | EXPECT_SCM function_arglist_optional simple_string {
1306 $$ = check_scheme_arg (PARSER, @3, SCM_UNDEFINED, $3, $2, $1);
1310 music_function_call:
1311 MUSIC_FUNCTION function_arglist {
1312 $$ = MAKE_SYNTAX ("music-function", @$,
1319 /**/ { $$ = SCM_EOL; }
1320 | '=' simple_string {
1327 | repeated_music { $$ = $1; }
1328 | re_rhythmed_music { $$ = $1; }
1329 | complex_music_prefix music
1331 $$ = FINISH_MAKE_SYNTAX ($1, @$, $2);
1335 complex_music_prefix:
1336 CONTEXT simple_string optional_id optional_context_mod {
1337 Context_mod *ctxmod = unsmob_context_mod ($4);
1340 mods = ctxmod->get_mods ();
1341 $$ = START_MAKE_SYNTAX ("context-specification", $2, $3, mods, SCM_BOOL_F);
1343 | NEWCONTEXT simple_string optional_id optional_context_mod {
1344 Context_mod *ctxmod = unsmob_context_mod ($4);
1347 mods = ctxmod->get_mods ();
1348 $$ = START_MAKE_SYNTAX ("context-specification", $2, $3, mods, SCM_BOOL_T);
1351 $$ = START_MAKE_SYNTAX ("time-scaled-music", $2);
1356 mode_changing_head grouped_music_list {
1357 if ($1 == ly_symbol2scm ("chords"))
1359 $$ = MAKE_SYNTAX ("unrelativable-music", @$, $2);
1365 PARSER->lexer_->pop_state ();
1367 | mode_changing_head_with_context optional_context_mod grouped_music_list {
1368 Context_mod *ctxmod = unsmob_context_mod ($2);
1371 mods = ctxmod->get_mods ();
1372 $$ = MAKE_SYNTAX ("context-specification", @$, $1, SCM_EOL, mods, SCM_BOOL_T, $3);
1373 if ($1 == ly_symbol2scm ("ChordNames"))
1375 $$ = MAKE_SYNTAX ("unrelativable-music", @$, $$);
1377 PARSER->lexer_->pop_state ();
1383 SCM nn = PARSER->lexer_->lookup_identifier ("pitchnames");
1384 PARSER->lexer_->push_note_state (alist_to_hashq (nn));
1386 $$ = ly_symbol2scm ("notes");
1390 SCM nn = PARSER->lexer_->lookup_identifier ("drumPitchNames");
1391 PARSER->lexer_->push_note_state (alist_to_hashq (nn));
1393 $$ = ly_symbol2scm ("drums");
1396 PARSER->lexer_->push_figuredbass_state ();
1398 $$ = ly_symbol2scm ("figures");
1401 SCM nn = PARSER->lexer_->lookup_identifier ("chordmodifiers");
1402 PARSER->lexer_->chordmodifier_tab_ = alist_to_hashq (nn);
1403 nn = PARSER->lexer_->lookup_identifier ("pitchnames");
1404 PARSER->lexer_->push_chord_state (alist_to_hashq (nn));
1405 $$ = ly_symbol2scm ("chords");
1409 { PARSER->lexer_->push_lyric_state ();
1410 $$ = ly_symbol2scm ("lyrics");
1414 mode_changing_head_with_context:
1416 SCM nn = PARSER->lexer_->lookup_identifier ("drumPitchNames");
1417 PARSER->lexer_->push_note_state (alist_to_hashq (nn));
1419 $$ = ly_symbol2scm ("DrumStaff");
1422 PARSER->lexer_->push_figuredbass_state ();
1424 $$ = ly_symbol2scm ("FiguredBass");
1427 SCM nn = PARSER->lexer_->lookup_identifier ("chordmodifiers");
1428 PARSER->lexer_->chordmodifier_tab_ = alist_to_hashq (nn);
1429 nn = PARSER->lexer_->lookup_identifier ("pitchnames");
1430 PARSER->lexer_->push_chord_state (alist_to_hashq (nn));
1431 $$ = ly_symbol2scm ("ChordNames");
1434 { PARSER->lexer_->push_lyric_state ();
1435 $$ = ly_symbol2scm ("Lyrics");
1440 ADDLYRICS { PARSER->lexer_->push_lyric_state (); }
1443 /* Can also use music at the expensive of two S/Rs similar to
1444 \repeat \alternative */
1445 PARSER->lexer_->pop_state ();
1447 $$ = scm_cons ($3, SCM_EOL);
1449 | new_lyrics ADDLYRICS {
1450 PARSER->lexer_->push_lyric_state ();
1452 PARSER->lexer_->pop_state ();
1453 $$ = scm_cons ($4, $1);
1458 closed_music new_lyrics {
1459 $$ = MAKE_SYNTAX ("add-lyrics", @$, $1, scm_reverse_x ($2, SCM_EOL));
1461 | LYRICSTO simple_string {
1462 PARSER->lexer_->push_lyric_state ();
1464 PARSER->lexer_->pop_state ();
1465 $$ = MAKE_SYNTAX ("lyric-combine", @$, $2, $4);
1470 CHANGE STRING '=' STRING {
1471 $$ = MAKE_SYNTAX ("context-change", @$, scm_string_to_symbol ($2), $4);
1476 property_path_revved:
1477 embedded_scm_closed {
1478 $$ = scm_cons ($1, SCM_EOL);
1480 | property_path_revved embedded_scm_closed {
1481 $$ = scm_cons ($2, $1);
1486 property_path_revved {
1487 $$ = scm_reverse_x ($1, SCM_EOL);
1493 $$ = scm_list_3 (ly_symbol2scm ("assign"),
1494 scm_string_to_symbol ($1), $3);
1496 | UNSET simple_string {
1497 $$ = scm_list_2 (ly_symbol2scm ("unset"),
1498 scm_string_to_symbol ($2));
1500 | OVERRIDE simple_string property_path '=' scalar {
1501 $$ = scm_append (scm_list_2 (scm_list_3 (ly_symbol2scm ("push"),
1502 scm_string_to_symbol ($2), $5),
1505 | REVERT simple_string embedded_scm {
1506 $$ = scm_list_3 (ly_symbol2scm ("pop"),
1507 scm_string_to_symbol ($2), $3);
1512 CONSISTS { $$ = ly_symbol2scm ("consists"); }
1513 | REMOVE { $$ = ly_symbol2scm ("remove"); }
1515 | ACCEPTS { $$ = ly_symbol2scm ("accepts"); }
1516 | DEFAULTCHILD { $$ = ly_symbol2scm ("default-child"); }
1517 | DENIES { $$ = ly_symbol2scm ("denies"); }
1519 | ALIAS { $$ = ly_symbol2scm ("alias"); }
1520 | TYPE { $$ = ly_symbol2scm ("translator-type"); }
1521 | DESCRIPTION { $$ = ly_symbol2scm ("description"); }
1522 | NAME { $$ = ly_symbol2scm ("context-name"); }
1526 property_operation { $$ = $1; }
1527 | context_def_mod STRING {
1528 $$ = scm_list_2 ($1, $2);
1530 | context_def_mod embedded_scm {
1531 if (ly_symbol2scm ("consists") != $1)
1534 PARSER->parser_error (@1, _ ("only \\consists takes non-string argument."));
1538 $$ = scm_list_2 ($1, $2);
1545 if (!is_regular_identifier ($1))
1547 @$.error (_("Grob name should be alphanumeric"));
1550 $$ = scm_list_2 (ly_symbol2scm ("Bottom"),
1551 scm_string_to_symbol ($1));
1553 | simple_string '.' simple_string {
1554 $$ = scm_list_2 (scm_string_to_symbol ($1),
1555 scm_string_to_symbol ($3));
1559 simple_music_property_def:
1560 OVERRIDE context_prop_spec property_path '=' scalar {
1561 $$ = scm_append (scm_list_2 (scm_list_n (scm_car ($2),
1562 ly_symbol2scm ("OverrideProperty"),
1567 | REVERT context_prop_spec embedded_scm {
1568 $$ = scm_list_4 (scm_car ($2),
1569 ly_symbol2scm ("RevertProperty"),
1573 | SET context_prop_spec '=' scalar {
1574 $$ = scm_list_4 (scm_car ($2),
1575 ly_symbol2scm ("PropertySet"),
1579 | UNSET context_prop_spec {
1580 $$ = scm_list_3 (scm_car ($2),
1581 ly_symbol2scm ("PropertyUnset"),
1587 simple_music_property_def {
1588 $$ = LOWLEVEL_MAKE_SYNTAX (ly_lily_module_constant ("property-operation"), scm_cons (PARSER->self_scm (), scm_cons2 (make_input (@$), SCM_BOOL_F, $1)));
1590 | ONCE simple_music_property_def {
1591 $$ = LOWLEVEL_MAKE_SYNTAX (ly_lily_module_constant ("property-operation"), scm_cons (PARSER->self_scm (), scm_cons2 (make_input (@$), SCM_BOOL_T, $2)));
1599 | STRING_IDENTIFIER {
1602 | string '+' string {
1603 $$ = scm_string_append (scm_list_2 ($1, $3));
1607 simple_string: STRING {
1613 | STRING_IDENTIFIER {
1628 | embedded_scm_bare {
1643 scm_function_call_closed
1648 /* TODO: Create a special case that avoids the creation of
1649 EventChords around simple_elements that have no post_events?
1651 simple_chord_elements post_events {
1652 SCM elts = ly_append2 ($1, scm_reverse_x ($2, SCM_EOL));
1655 /* why is this giving wrong start location? -ns
1657 i.set_location (@1, @2);
1658 $$ = MAKE_SYNTAX ("event-chord", i, elts);
1660 | CHORD_REPETITION optional_notemode_duration post_events {
1662 i.set_location (@1, @3);
1663 $$ = MAKE_SYNTAX ("repetition-chord", i,
1664 PARSER->lexer_->chord_repetition_.last_chord_,
1665 PARSER->lexer_->chord_repetition_.repetition_function_,
1666 $2, scm_reverse_x ($3, SCM_EOL));
1668 | MULTI_MEASURE_REST optional_notemode_duration post_events {
1670 i.set_location (@1, @3);
1671 $$ = MAKE_SYNTAX ("multi-measure-rest", i, $2,
1672 scm_reverse_x ($3, SCM_EOL));
1675 /* note chord elements are memorized into
1676 PARSER->lexer_->chord_repetition_ so that the chord repetition
1677 mechanism copy them when a chord repetition symbol is found
1679 | note_chord_element {
1680 PARSER->lexer_->chord_repetition_.last_chord_ = $$;
1686 chord_body optional_notemode_duration post_events
1688 Music *m = unsmob_music ($1);
1689 SCM dur = unsmob_duration ($2)->smobbed_copy ();
1690 SCM es = m->get_property ("elements");
1691 SCM postevs = scm_reverse_x ($3, SCM_EOL);
1693 for (SCM s = es; scm_is_pair (s); s = scm_cdr (s))
1694 unsmob_music (scm_car (s))->set_property ("duration", dur);
1695 es = ly_append2 (es, postevs);
1697 m-> set_property ("elements", es);
1699 $$ = m->self_scm ();
1704 ANGLE_OPEN chord_body_elements ANGLE_CLOSE
1706 $$ = MAKE_SYNTAX ("event-chord", @$, scm_reverse_x ($2, SCM_EOL));
1710 chord_body_elements:
1711 /* empty */ { $$ = SCM_EOL; }
1712 | chord_body_elements chord_body_element {
1713 $$ = scm_cons ($2, $1);
1718 pitch exclamations questions octave_check post_events
1725 Music *n = MY_MAKE_MUSIC ("NoteEvent", @$);
1726 n->set_property ("pitch", $1);
1728 n->set_property ("cautionary", SCM_BOOL_T);
1729 if (ex % 2 || q % 2)
1730 n->set_property ("force-accidental", SCM_BOOL_T);
1732 if (scm_is_pair (post)) {
1733 SCM arts = scm_reverse_x (post, SCM_EOL);
1734 n->set_property ("articulations", arts);
1736 if (scm_is_number (check))
1738 int q = scm_to_int (check);
1739 n->set_property ("absolute-octave", scm_from_int (q-1));
1742 $$ = n->unprotect ();
1744 | DRUM_PITCH post_events {
1745 Music *n = MY_MAKE_MUSIC ("NoteEvent", @$);
1746 n->set_property ("drum-type", $1);
1748 if (scm_is_pair ($2)) {
1749 SCM arts = scm_reverse_x ($2, SCM_EOL);
1750 n->set_property ("articulations", arts);
1752 $$ = n->unprotect ();
1754 | music_function_chord_body
1757 /* We can't accept a music argument, not even a closed one,
1758 * immediately before chord_body_elements, otherwise a function \fun
1759 * with a signature of two music arguments can't be sorted out
1760 * properly in a construct like
1761 * <\fun { c } \fun { c } c>
1762 * The second call could be interpreted either as a chord constituent
1763 * or a music expression.
1766 music_function_chord_body_arglist:
1767 function_arglist_bare
1768 | EXPECT_MUSIC music_function_chord_body_arglist chord_body_element {
1769 $$ = scm_cons ($3, $2);
1771 | EXPECT_SCM function_arglist_optional embedded_scm_chord_body {
1772 $$ = check_scheme_arg (PARSER, @3, SCM_UNDEFINED, $3, $2, $1);
1776 embedded_scm_chord_body:
1778 | SCM_FUNCTION music_function_chord_body_arglist {
1779 $$ = MAKE_SYNTAX ("music-function", @$,
1784 music_function_chord_body:
1785 MUSIC_FUNCTION music_function_chord_body_arglist {
1786 $$ = MAKE_SYNTAX ("music-function", @$,
1791 /* We could accept a closed music argument before the post events
1792 * indicated by a trailing argument list. For symmetry with chord
1793 * bodies and in order to avoid too tricky and complex behavior, we
1794 * refrain from doing so.
1796 music_function_event_arglist:
1797 function_arglist_bare
1798 | EXPECT_MUSIC music_function_event_arglist post_event {
1799 $$ = scm_cons ($3, $2);
1801 | EXPECT_SCM function_arglist_optional embedded_scm_event {
1802 $$ = check_scheme_arg (PARSER, @3, SCM_UNDEFINED, $3, $2, $1);
1808 | SCM_FUNCTION music_function_event_arglist {
1809 $$ = MAKE_SYNTAX ("music-function", @$,
1814 music_function_event:
1815 MUSIC_FUNCTION music_function_event_arglist {
1816 $$ = MAKE_SYNTAX ("music-function", @$,
1821 event_function_event:
1822 EVENT_FUNCTION music_function_event_arglist {
1823 $$ = MAKE_SYNTAX ("music-function", @$,
1833 Music *m = MY_MAKE_MUSIC ("LigatureEvent", @$);
1834 m->set_property ("span-direction", scm_from_int (START));
1835 $$ = m->unprotect();
1838 Music *m = MY_MAKE_MUSIC ("LigatureEvent", @$);
1839 m->set_property ("span-direction", scm_from_int (STOP));
1840 $$ = m->unprotect ();
1843 $$ = MAKE_SYNTAX ("voice-separator", @$);
1846 SCM pipe = PARSER->lexer_->lookup_identifier ("pipeSymbol");
1848 Music *m = unsmob_music (pipe);
1853 $$ = m->unprotect ();
1856 $$ = MAKE_SYNTAX ("bar-check", @$);
1860 SCM proc = ly_lily_module_constant ("make-time-signature-set");
1862 $$ = scm_apply_2 (proc, scm_car ($2), scm_cdr ($2), SCM_EOL);
1865 $$ = MAKE_SYNTAX ("make-mark-set", @$, $2);
1871 $$ = MY_MAKE_MUSIC ("PesOrFlexaEvent", @$)->unprotect ();
1874 Music *m = MY_MAKE_MUSIC ("MarkEvent", @$);
1875 $$ = m->unprotect ();
1881 Music *key = MY_MAKE_MUSIC ("KeyChangeEvent", @$);
1882 $$ = key->unprotect ();
1884 | KEY NOTENAME_PITCH SCM_IDENTIFIER {
1886 Music *key = MY_MAKE_MUSIC ("KeyChangeEvent", @$);
1887 if (scm_ilength ($3) > 0)
1889 key->set_property ("pitch-alist", $3);
1890 key->set_property ("tonic", Pitch (0, 0, 0).smobbed_copy ());
1891 key->transpose (* unsmob_pitch ($2));
1893 PARSER->parser_error (@3, _ ("second argument must be pitch list"));
1896 $$ = key->unprotect ();
1905 | post_events post_event {
1906 unsmob_music ($2)->set_spot (@2);
1907 $$ = scm_cons ($2, $$);
1911 post_event_nofinger:
1912 direction_less_event {
1915 | script_dir music_function_event {
1919 unsmob_music ($$)->set_property ("direction", scm_from_int ($1));
1923 if (!PARSER->lexer_->is_lyric_state ())
1924 PARSER->parser_error (@1, _ ("have to be in Lyric mode for lyrics"));
1925 $$ = MY_MAKE_MUSIC ("HyphenEvent", @$)->unprotect ();
1928 if (!PARSER->lexer_->is_lyric_state ())
1929 PARSER->parser_error (@1, _ ("have to be in Lyric mode for lyrics"));
1930 $$ = MY_MAKE_MUSIC ("ExtenderEvent", @$)->unprotect ();
1932 | script_dir direction_reqd_event {
1935 Music *m = unsmob_music ($2);
1936 m->set_property ("direction", scm_from_int ($1));
1940 | script_dir direction_less_event {
1943 Music *m = unsmob_music ($2);
1944 m->set_property ("direction", scm_from_int ($1));
1948 | string_number_event
1953 | script_dir fingering {
1956 Music *m = unsmob_music ($2);
1957 m->set_property ("direction", scm_from_int ($1));
1963 string_number_event:
1965 Music *s = MY_MAKE_MUSIC ("StringNumberEvent", @$);
1966 s->set_property ("string-number", scm_from_int ($1));
1967 $$ = s->unprotect ();
1971 direction_less_char:
1973 $$ = ly_symbol2scm ("bracketOpenSymbol");
1976 $$ = ly_symbol2scm ("bracketCloseSymbol");
1979 $$ = ly_symbol2scm ("tildeSymbol");
1982 $$ = ly_symbol2scm ("parenthesisOpenSymbol");
1985 $$ = ly_symbol2scm ("parenthesisCloseSymbol");
1988 $$ = ly_symbol2scm ("escapedExclamationSymbol");
1991 $$ = ly_symbol2scm ("escapedParenthesisOpenSymbol");
1994 $$ = ly_symbol2scm ("escapedParenthesisCloseSymbol");
1997 $$ = ly_symbol2scm ("escapedBiggerSymbol");
2000 $$ = ly_symbol2scm ("escapedSmallerSymbol");
2004 direction_less_event:
2005 direction_less_char {
2006 SCM predefd = PARSER->lexer_->lookup_identifier_symbol ($1);
2008 if (unsmob_music (predefd))
2010 m = unsmob_music (predefd)->clone ();
2015 m = MY_MAKE_MUSIC ("Music", @$);
2017 $$ = m->unprotect ();
2019 | EVENT_IDENTIFIER {
2023 Music *a = MY_MAKE_MUSIC ("TremoloEvent", @$);
2024 a->set_property ("tremolo-type", scm_from_int ($1));
2025 $$ = a->unprotect ();
2027 | event_function_event
2030 direction_reqd_event:
2034 | script_abbreviation {
2035 SCM s = PARSER->lexer_->lookup_identifier ("dash" + ly_scm2string ($1));
2036 Music *a = MY_MAKE_MUSIC ("ArticulationEvent", @$);
2037 if (scm_is_string (s))
2038 a->set_property ("articulation-type", s);
2039 else PARSER->parser_error (@1, _ ("expecting string as script definition"));
2040 $$ = a->unprotect ();
2045 /**/ { $$ = SCM_EOL; }
2046 | '=' { $$ = scm_from_int (0); }
2047 | '=' sub_quotes { $$ = scm_from_int (-$2); }
2048 | '=' sup_quotes { $$ = scm_from_int ($2); }
2073 | NOTENAME_PITCH sup_quotes {
2074 Pitch p = *unsmob_pitch ($1);
2075 p = p.transposed (Pitch ($2,0,0));
2076 $$ = p.smobbed_copy ();
2078 | NOTENAME_PITCH sub_quotes {
2079 Pitch p =* unsmob_pitch ($1);
2080 p = p.transposed (Pitch (-$2,0,0));
2081 $$ = p.smobbed_copy ();
2093 | TONICNAME_PITCH sup_quotes {
2094 Pitch p = *unsmob_pitch ($1);
2095 p = p.transposed (Pitch ($2,0,0));
2096 $$ = p.smobbed_copy ();
2098 | TONICNAME_PITCH sub_quotes {
2099 Pitch p = *unsmob_pitch ($1);
2101 p = p.transposed (Pitch (-$2,0,0));
2102 $$ = p.smobbed_copy ();
2113 pitch_also_in_chords:
2120 Music *t = MY_MAKE_MUSIC ("TextScriptEvent", @$);
2121 t->set_property ("text", $1);
2122 $$ = t->unprotect ();
2125 Music *t = MY_MAKE_MUSIC ("TextScriptEvent", @$);
2126 t->set_property ("text",
2127 make_simple_markup ($1));
2128 $$ = t->unprotect ();
2134 Music *t = MY_MAKE_MUSIC ("FingeringEvent", @$);
2135 t->set_property ("digit", scm_from_int ($1));
2136 $$ = t->unprotect ();
2140 script_abbreviation:
2142 $$ = scm_from_locale_string ("Hat");
2145 $$ = scm_from_locale_string ("Plus");
2148 $$ = scm_from_locale_string ("Dash");
2151 $$ = scm_from_locale_string ("Bar");
2154 $$ = scm_from_locale_string ("Larger");
2157 $$ = scm_from_locale_string ("Dot");
2160 $$ = scm_from_locale_string ("Underscore");
2167 | '-' { $$ = CENTER; }
2171 multiplied_duration {
2176 optional_notemode_duration:
2178 Duration dd = PARSER->default_duration_;
2179 $$ = dd.smobbed_copy ();
2181 | multiplied_duration {
2183 PARSER->default_duration_ = *unsmob_duration ($$);
2188 bare_unsigned dots {
2190 if (!is_duration ($1))
2191 PARSER->parser_error (@1, _f ("not a duration: %d", $1));
2195 $$ = Duration (len, $2).smobbed_copy ();
2197 | DURATION_IDENTIFIER dots {
2198 Duration *d = unsmob_duration ($1);
2199 Duration k (d->duration_log (), d->dot_count () + $2);
2200 k = k.compressed (d->factor ());
2206 multiplied_duration:
2210 | multiplied_duration '*' bare_unsigned {
2211 $$ = unsmob_duration ($$)->compressed ( $3) .smobbed_copy ();
2213 | multiplied_duration '*' FRACTION {
2214 Rational m (scm_to_int (scm_car ($3)), scm_to_int (scm_cdr ($3)));
2216 $$ = unsmob_duration ($$)->compressed (m).smobbed_copy ();
2221 FRACTION { $$ = $1; }
2222 | UNSIGNED '/' UNSIGNED {
2223 $$ = scm_cons (scm_from_int ($1), scm_from_int ($3));
2240 | ':' bare_unsigned {
2241 if (!is_duration ($2))
2242 PARSER->parser_error (@2, _f ("not a duration: %d", $2));
2249 $$ = scm_from_int ($1);
2251 | STRING { $$ = $1; }
2252 | full_markup { $$ = $1; }
2255 figured_bass_alteration:
2256 '-' { $$ = ly_rational2scm (FLAT_ALTERATION); }
2257 | '+' { $$ = ly_rational2scm (SHARP_ALTERATION); }
2258 | '!' { $$ = scm_from_int (0); }
2263 Music *bfr = MY_MAKE_MUSIC ("BassFigureEvent", @$);
2264 $$ = bfr->unprotect ();
2267 Music *bfr = MY_MAKE_MUSIC ("BassFigureEvent", @$);
2268 $$ = bfr->self_scm ();
2270 if (scm_is_number ($1))
2271 bfr->set_property ("figure", $1);
2272 else if (Text_interface::is_markup ($1))
2273 bfr->set_property ("text", $1);
2279 unsmob_music ($1)->set_property ("bracket-stop", SCM_BOOL_T);
2281 | bass_figure figured_bass_alteration {
2282 Music *m = unsmob_music ($1);
2283 if (scm_to_double ($2)) {
2284 SCM salter = m->get_property ("alteration");
2285 SCM alter = scm_is_number (salter) ? salter : scm_from_int (0);
2286 m->set_property ("alteration",
2287 scm_sum (alter, $2));
2289 m->set_property ("alteration", scm_from_int (0));
2292 | bass_figure figured_bass_modification {
2293 Music *m = unsmob_music ($1);
2294 if ($2 == ly_symbol2scm ("plus"))
2296 m->set_property ("augmented", SCM_BOOL_T);
2298 else if ($2 == ly_symbol2scm ("slash"))
2300 m->set_property ("diminished", SCM_BOOL_T);
2302 else if ($2 == ly_symbol2scm ("exclamation"))
2304 m->set_property ("no-continuation", SCM_BOOL_T);
2306 else if ($2 == ly_symbol2scm ("backslash"))
2308 m->set_property ("augmented-slash", SCM_BOOL_T);
2314 figured_bass_modification:
2316 $$ = ly_symbol2scm ("plus");
2319 $$ = ly_symbol2scm ("exclamation");
2322 $$ = ly_symbol2scm ("slash");
2325 $$ = ly_symbol2scm ("backslash");
2335 unsmob_music ($$)->set_property ("bracket-start", SCM_BOOL_T);
2343 | figure_list br_bass_figure {
2344 $$ = scm_cons ($2, $1);
2349 FIGURE_OPEN figure_list FIGURE_CLOSE {
2350 $$ = scm_reverse_x ($2, SCM_EOL);
2361 pitch exclamations questions octave_check optional_notemode_duration optional_rest {
2362 if (!PARSER->lexer_->is_note_state ())
2363 PARSER->parser_error (@1, _ ("have to be in Note mode for notes"));
2367 n = MY_MAKE_MUSIC ("RestEvent", @$);
2369 n = MY_MAKE_MUSIC ("NoteEvent", @$);
2371 n->set_property ("pitch", $1);
2372 n->set_property ("duration", $5);
2374 if (scm_is_number ($4))
2376 int q = scm_to_int ($4);
2377 n->set_property ("absolute-octave", scm_from_int (q-1));
2381 n->set_property ("cautionary", SCM_BOOL_T);
2382 if ($2 % 2 || $3 % 2)
2383 n->set_property ("force-accidental", SCM_BOOL_T);
2385 $$ = n->unprotect ();
2387 | DRUM_PITCH optional_notemode_duration {
2388 Music *n = MY_MAKE_MUSIC ("NoteEvent", @$);
2389 n->set_property ("duration", $2);
2390 n->set_property ("drum-type", $1);
2392 $$ = n->unprotect ();
2394 | RESTNAME optional_notemode_duration {
2396 if (ly_scm2string ($1) == "s") {
2398 ev = MY_MAKE_MUSIC ("SkipEvent", @$);
2401 ev = MY_MAKE_MUSIC ("RestEvent", @$);
2404 ev->set_property ("duration", $2);
2405 $$ = ev->unprotect ();
2407 | lyric_element optional_notemode_duration {
2408 if (!PARSER->lexer_->is_lyric_state ())
2409 PARSER->parser_error (@1, _ ("have to be in Lyric mode for lyrics"));
2411 Music *levent = MY_MAKE_MUSIC ("LyricEvent", @$);
2412 levent->set_property ("text", $1);
2413 levent->set_property ("duration",$2);
2414 $$= levent->unprotect ();
2418 simple_chord_elements:
2420 $$ = scm_list_1 ($1);
2423 if (!PARSER->lexer_->is_chord_state ())
2424 PARSER->parser_error (@1, _ ("have to be in Chord mode for chords"));
2427 | figure_spec optional_notemode_duration {
2428 for (SCM s = $1; scm_is_pair (s); s = scm_cdr (s))
2430 unsmob_music (scm_car (s))->set_property ("duration", $2);
2446 steno_tonic_pitch optional_notemode_duration {
2447 $$ = make_chord_elements ($1, $2, SCM_EOL);
2449 | steno_tonic_pitch optional_notemode_duration chord_separator chord_items {
2450 SCM its = scm_reverse_x ($4, SCM_EOL);
2451 $$ = make_chord_elements ($1, $2, scm_cons ($3, its));
2459 | chord_items chord_item {
2460 $$ = scm_cons ($2, $$);
2466 $$ = ly_symbol2scm ("chord-colon");
2469 $$ = ly_symbol2scm ("chord-caret");
2471 | CHORD_SLASH steno_tonic_pitch {
2472 $$ = scm_list_2 (ly_symbol2scm ("chord-slash"), $2);
2474 | CHORD_BASS steno_tonic_pitch {
2475 $$ = scm_list_2 (ly_symbol2scm ("chord-bass"), $2);
2484 $$ = scm_reverse_x ($1, SCM_EOL);
2492 step_number { $$ = scm_cons ($1, SCM_EOL); }
2493 | step_numbers '.' step_number {
2494 $$ = scm_cons ($3, $$);
2500 $$ = make_chord_step ($1, 0);
2502 | bare_unsigned '+' {
2503 $$ = make_chord_step ($1, SHARP_ALTERATION);
2505 | bare_unsigned CHORD_MINUS {
2506 $$ = make_chord_step ($1, FLAT_ALTERATION);
2512 $$ = scm_from_int ($1);
2514 | bare_unsigned '~' bare_unsigned {
2515 $$ = scm_cons (scm_from_int ($1), scm_from_int ($3));
2522 TODO: should deprecate in favor of Scheme?
2526 number_expression '+' number_term {
2527 $$ = scm_sum ($1, $3);
2529 | number_expression '-' number_term {
2530 $$ = scm_difference ($1, $3);
2539 | number_factor '*' number_factor {
2540 $$ = scm_product ($1, $3);
2542 | number_factor '/' number_factor {
2543 $$ = scm_divide ($1, $3);
2548 '-' number_factor { /* %prec UNARY_MINUS */
2549 $$ = scm_difference ($2, SCM_UNDEFINED);
2557 $$ = scm_from_int ($1);
2562 | NUMBER_IDENTIFIER {
2565 | REAL NUMBER_IDENTIFIER {
2566 $$ = scm_from_double (scm_to_double ($1) *scm_to_double ($2));
2568 | UNSIGNED NUMBER_IDENTIFIER {
2569 $$ = scm_from_double ($1 *scm_to_double ($2));
2581 bare_unsigned { $$ = scm_from_int ($1); }
2582 | NUMBER_IDENTIFIER {
2589 | exclamations '!' { $$ ++; }
2594 | questions '?' { $$ ++; }
2598 This should be done more dynamically if possible.
2602 LYRIC_MARKUP_IDENTIFIER {
2606 { PARSER->lexer_->push_markup_state (); }
2609 PARSER->lexer_->pop_state ();
2614 MARKUPLINES_IDENTIFIER {
2618 { PARSER->lexer_->push_markup_state (); }
2621 PARSER->lexer_->pop_state ();
2630 { PARSER->lexer_->push_markup_state (); }
2633 PARSER->lexer_->pop_state ();
2639 $$ = scm_list_2 (ly_lily_module_constant ("line-markup"), $1);
2641 | markup_head_1_list simple_markup {
2642 $$ = scm_car (scm_call_2 (ly_lily_module_constant ("map-markup-command-list"), $1, scm_list_1 ($2)));
2650 MARKUPLINES_IDENTIFIER {
2653 | markup_composed_list {
2656 | markup_braced_list {
2659 | markup_command_list {
2660 $$ = scm_list_1 ($1);
2664 markup_composed_list:
2665 markup_head_1_list markup_braced_list {
2666 $$ = scm_call_2 (ly_lily_module_constant ("map-markup-command-list"), $1, $2);
2672 '{' markup_braced_list_body '}' {
2673 $$ = scm_reverse_x ($2, SCM_EOL);
2677 markup_braced_list_body:
2678 /* empty */ { $$ = SCM_EOL; }
2679 | markup_braced_list_body markup {
2680 $$ = scm_cons ($2, $1);
2682 | markup_braced_list_body markup_list {
2683 $$ = scm_reverse_x ($2, $1);
2687 markup_command_list:
2688 MARKUP_LIST_FUNCTION markup_command_list_arguments {
2689 $$ = scm_cons ($1, scm_reverse_x($2, SCM_EOL));
2693 markup_command_basic_arguments:
2694 EXPECT_MARKUP_LIST markup_command_list_arguments markup_list {
2695 $$ = scm_cons ($3, $2);
2697 | EXPECT_SCM markup_command_list_arguments embedded_scm_closed {
2698 $$ = check_scheme_arg (PARSER, @3, SCM_UNDEFINED, $3, $2, $1);
2700 | EXPECT_NO_MORE_ARGS {
2705 markup_command_list_arguments:
2706 markup_command_basic_arguments { $$ = $1; }
2707 | EXPECT_MARKUP markup_command_list_arguments markup {
2708 $$ = scm_cons ($3, $2);
2713 MARKUP_FUNCTION EXPECT_MARKUP markup_command_list_arguments {
2714 $$ = scm_cons ($1, scm_reverse_x ($3, SCM_EOL));
2719 markup_head_1_item {
2720 $$ = scm_list_1 ($1);
2722 | markup_head_1_list markup_head_1_item {
2723 $$ = scm_cons ($2, $1);
2729 $$ = make_simple_markup ($1);
2731 | MARKUP_IDENTIFIER {
2734 | LYRIC_MARKUP_IDENTIFIER {
2737 | STRING_IDENTIFIER {
2741 SCM nn = PARSER->lexer_->lookup_identifier ("pitchnames");
2742 PARSER->lexer_->push_note_state (alist_to_hashq (nn));
2743 } '{' score_body '}' {
2745 $$ = scm_list_2 (ly_lily_module_constant ("score-markup"), sc->self_scm ());
2747 PARSER->lexer_->pop_state ();
2749 | MARKUP_FUNCTION markup_command_basic_arguments {
2750 $$ = scm_cons ($1, scm_reverse_x ($2, SCM_EOL));
2755 markup_head_1_list simple_markup {
2756 SCM mapper = ly_lily_module_constant ("map-markup-command-list");
2757 $$ = scm_car (scm_call_2 (mapper, $1, scm_list_1 ($2)));
2767 Lily_parser::set_yydebug (bool x)
2773 Lily_parser::do_yyparse ()
2775 yyparse ((void*)this);
2784 It is a little strange to have this function in this file, but
2785 otherwise, we have to import music classes into the lexer.
2789 Lily_lexer::try_special_identifiers (SCM *destination, SCM sid)
2791 if (scm_is_string (sid)) {
2793 return STRING_IDENTIFIER;
2794 } else if (unsmob_book (sid)) {
2795 Book *book = unsmob_book (sid)->clone ();
2796 *destination = book->self_scm ();
2799 return BOOK_IDENTIFIER;
2800 } else if (scm_is_number (sid)) {
2802 return NUMBER_IDENTIFIER;
2803 } else if (unsmob_context_def (sid)) {
2804 Context_def *def= unsmob_context_def (sid)->clone ();
2806 *destination = def->self_scm ();
2809 return CONTEXT_DEF_IDENTIFIER;
2810 } else if (unsmob_context_mod (sid)) {
2811 *destination = unsmob_context_mod (sid)->smobbed_copy ();
2813 return CONTEXT_MOD_IDENTIFIER;
2814 } else if (unsmob_score (sid)) {
2815 Score *score = new Score (*unsmob_score (sid));
2816 *destination = score->self_scm ();
2818 score->unprotect ();
2819 return SCORE_IDENTIFIER;
2820 } else if (Music *mus = unsmob_music (sid)) {
2821 mus = mus->clone ();
2822 *destination = mus->self_scm ();
2823 unsmob_music (*destination)->
2824 set_property ("origin", make_input (last_input_));
2826 bool is_event = scm_memq (ly_symbol2scm ("event"), mus->get_property ("types"))
2830 return is_event ? EVENT_IDENTIFIER : MUSIC_IDENTIFIER;
2831 } else if (unsmob_pitch (sid)) {
2832 *destination = unsmob_pitch (sid)->smobbed_copy ();
2833 return PITCH_IDENTIFIER;
2834 } else if (unsmob_duration (sid)) {
2835 *destination = unsmob_duration (sid)->smobbed_copy ();
2836 return DURATION_IDENTIFIER;
2837 } else if (unsmob_output_def (sid)) {
2838 Output_def *p = unsmob_output_def (sid);
2841 *destination = p->self_scm ();
2843 return OUTPUT_DEF_IDENTIFIER;
2844 } else if (Text_interface::is_markup (sid)) {
2846 if (is_lyric_state ())
2847 return LYRIC_MARKUP_IDENTIFIER;
2848 return MARKUP_IDENTIFIER;
2849 } else if (Text_interface::is_markup_list (sid)) {
2851 return MARKUPLINES_IDENTIFIER;
2858 get_next_unique_context_id ()
2860 return scm_from_locale_string ("$uniqueContextId");
2865 get_next_unique_lyrics_context_id ()
2867 static int new_context_count;
2869 snprintf (s, sizeof (s)-1, "uniqueContext%d", new_context_count++);
2870 return scm_from_locale_string (s);
2874 SCM check_scheme_arg (Lily_parser *parser, Input loc, SCM fallback,
2875 SCM arg, SCM args, SCM pred)
2877 SCM type_check_arg = ly_lily_module_constant ("type-check-arg");
2878 if (scm_is_false (scm_call_4 (type_check_arg, make_input (loc),
2881 if (SCM_UNBNDP (fallback))
2882 fallback = SCM_BOOL_F;
2884 fallback = loc_on_music (loc, fallback);
2886 parser->error_level_ = 1;
2888 return scm_cons (fallback, args);
2890 return scm_cons (arg, args);
2893 SCM loc_on_music (Input loc, SCM arg)
2895 if (Music *m = unsmob_music (arg))
2899 return m->unprotect ();
2905 is_regular_identifier (SCM id)
2907 string str = ly_scm2string (id);
2908 char const *s = str.c_str ();
2917 v = v && isalnum (*s);
2924 make_music_with_input (SCM name, Input where)
2926 Music *m = make_music_by_name (name);
2927 m->set_spot (where);
2932 get_first_context_id (SCM type, Music *m)
2934 SCM id = m->get_property ("context-id");
2935 if (SCM_BOOL_T == scm_equal_p (m->get_property ("context-type"), type)
2936 && scm_is_string (m->get_property ("context-id"))
2937 && scm_c_string_length (id) > 0)
2945 make_simple_markup (SCM a)
2953 return t && t == 1 << intlog2 (t);
2957 set_music_properties (Music *p, SCM a)
2959 for (SCM k = a; scm_is_pair (k); k = scm_cdr (k))
2960 p->set_property (scm_caar (k), scm_cdar (k));
2965 make_chord_step (int step, Rational alter)
2968 alter += FLAT_ALTERATION;
2972 Pitch m ((step -1) / 7, (step - 1) % 7, alter);
2973 return m.smobbed_copy ();
2978 make_chord_elements (SCM pitch, SCM dur, SCM modification_list)
2980 SCM chord_ctor = ly_lily_module_constant ("construct-chord-elements");
2981 return scm_call_3 (chord_ctor, pitch, dur, modification_list);
2985 /* Todo: actually also use apply iso. call too ... */
2987 ly_input_procedure_p (SCM x)
2989 return ly_is_procedure (x)
2990 || (scm_is_pair (x) && ly_is_procedure (scm_car (x)));
2994 yylex (YYSTYPE *s, YYLTYPE *loc, void *v)
2996 Lily_parser *pars = (Lily_parser*) v;
2997 Lily_lexer *lex = pars->lexer_;
2999 lex->lexval_ = (void*) s;
3001 lex->prepare_for_next_token ();
3002 return lex->yylex ();