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
62 /* ADDLYRICS needs to have lower precedence than FUNCTION_ARGUMENTS,
63 * or we won't be able to tell music apart from closed_music without
64 * lookahead in the context of function calls.
67 %right FUNCTION_ARGUMENTS
68 MARKUP LYRICS_STRING MARKUP_IDENTIFIER STRING STRING_IDENTIFIER
69 MARKUPLIST WITH CONTEXT_MOD_IDENTIFIER MARKUPLIST_IDENTIFIER
70 SCORE BOOK BOOKPART PAPER LAYOUT MIDI
71 SEQUENTIAL SIMULTANEOUS DOUBLE_ANGLE_OPEN MUSIC_IDENTIFIER '{'
72 PITCH_IDENTIFIER NOTENAME_PITCH TONICNAME_PITCH
73 SCM_FUNCTION SCM_IDENTIFIER SCM_TOKEN
74 UNSIGNED DURATION_IDENTIFIER
75 CHORDMODE CHORDS DRUMMODE DRUMS FIGUREMODE FIGURES LYRICMODE LYRICS
77 CONTEXT TIMES NEWCONTEXT
79 /* The above are the symbols that can start function arguments */
91 %{ // -*-Fundamental-*-
96 * The rules for who is protecting what are very shady. Uniformise
99 * There are too many lexical modes?
110 #include "context-def.hh"
111 #include "context-mod.hh"
112 #include "dimensions.hh"
113 #include "file-path.hh"
115 #include "international.hh"
116 #include "lily-guile.hh"
117 #include "lily-lexer.hh"
118 #include "lily-parser.hh"
122 #include "output-def.hh"
123 #include "paper-book.hh"
124 #include "scm-hash.hh"
126 #include "text-interface.hh"
129 #define MYBACKUP(Token, Value, Location) \
131 if (yychar == YYEMPTY) \
132 PARSER->lexer_->push_extra_token (Token, Value); \
134 PARSER->parser_error \
135 (Location, _("cannot backup token")); \
143 Output_def *outputdef;
153 #define MY_MAKE_MUSIC(x, spot) make_music_with_input (ly_symbol2scm (x), spot)
156 - Don't use lily module, create a new module instead.
157 - delay application of the function
159 #define LOWLEVEL_MAKE_SYNTAX(proc, args) \
160 scm_apply_0 (proc, args)
161 /* Syntactic Sugar. */
162 #define MAKE_SYNTAX(name, location, ...) \
163 LOWLEVEL_MAKE_SYNTAX (ly_lily_module_constant (name), scm_list_n (PARSER->self_scm (), make_input (location), ##__VA_ARGS__, SCM_UNDEFINED));
164 #define START_MAKE_SYNTAX(name, ...) \
165 scm_list_n (ly_lily_module_constant (name), ##__VA_ARGS__, SCM_UNDEFINED)
166 #define FINISH_MAKE_SYNTAX(start, location, ...) \
167 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)))))
169 SCM get_next_unique_context_id ();
170 SCM get_next_unique_lyrics_context_id ();
177 #define _(x) gettext (x)
181 static Music *make_music_with_input (SCM name, Input where);
182 SCM check_scheme_arg (Lily_parser *parser, Input loc, SCM fallback,
183 SCM arg, SCM args, SCM pred);
184 SCM loc_on_music (Input loc, SCM arg);
185 SCM get_first_context_id (SCM type, Music *m);
186 SCM make_chord_elements (SCM pitch, SCM dur, SCM modification_list);
187 SCM make_chord_step (int step, Rational alter);
188 SCM make_simple_markup (SCM a);
189 SCM try_unpack_lyrics (SCM pred, SCM arg);
190 bool is_duration (int t);
191 bool is_regular_identifier (SCM id);
192 bool ly_input_procedure_p (SCM x);
193 int yylex (YYSTYPE *s, YYLTYPE *loc, void *v);
194 void set_music_properties (Music *p, SCM a);
198 /* The third option is an alias that will be used to display the
199 syntax error. Bison CVS now correctly handles backslash escapes.
201 FIXME: Bison needs to translate some of these, eg, STRING.
205 /* Keyword tokens with plain escaped name. */
206 %token ACCEPTS "\\accepts"
207 %token ADDLYRICS "\\addlyrics"
208 %token ALIAS "\\alias"
209 %token ALTERNATIVE "\\alternative"
211 %token BOOKPART "\\bookpart"
212 %token CHANGE "\\change"
213 %token CHORDMODE "\\chordmode"
214 %token CHORDS "\\chords"
215 %token CONSISTS "\\consists"
216 %token CONTEXT "\\context"
217 %token DEFAULT "\\default"
218 %token DEFAULTCHILD "\\defaultchild"
219 %token DENIES "\\denies"
220 %token DESCRIPTION "\\description"
221 %token DRUMMODE "\\drummode"
222 %token DRUMS "\\drums"
223 %token FIGUREMODE "\\figuremode"
224 %token FIGURES "\\figures"
225 %token GROBDESCRIPTIONS "\\grobdescriptions"
226 %token HEADER "\\header"
227 %token INVALID "\\version-error"
229 %token LAYOUT "\\layout"
230 %token LYRICMODE "\\lyricmode"
231 %token LYRICS "\\lyrics"
232 %token LYRICSTO "\\lyricsto"
234 %token MARKUP "\\markup"
235 %token MARKUPLIST "\\markuplist"
238 %token NOTEMODE "\\notemode"
239 %token OVERRIDE "\\override"
240 %token PAPER "\\paper"
241 %token REMOVE "\\remove"
242 %token REPEAT "\\repeat"
244 %token REVERT "\\revert"
245 %token SCORE "\\score"
246 %token SEQUENTIAL "\\sequential"
248 %token SIMULTANEOUS "\\simultaneous"
249 %token TEMPO "\\tempo"
250 %token TIMES "\\times"
252 %token UNSET "\\unset"
255 /* Keyword token exceptions. */
256 %token TIME_T "\\time"
257 %token NEWCONTEXT "\\new"
260 /* Other string tokens. */
262 %token CHORD_BASS "/+"
263 %token CHORD_CARET "^"
264 %token CHORD_COLON ":"
265 %token CHORD_MINUS "-"
266 %token CHORD_SLASH "/"
267 %token ANGLE_OPEN "<"
268 %token ANGLE_CLOSE ">"
269 %token DOUBLE_ANGLE_OPEN "<<"
270 %token DOUBLE_ANGLE_CLOSE ">>"
271 %token E_BACKSLASH "\\"
272 %token E_ANGLE_CLOSE "\\>"
273 %token E_CHAR "\\C[haracter]"
275 %token E_EXCLAMATION "\\!"
276 %token E_BRACKET_OPEN "\\["
278 %token E_BRACKET_CLOSE "\\]"
279 %token E_ANGLE_OPEN "\\<"
285 If we give names, Bison complains.
287 %token FIGURE_CLOSE /* "\\>" */
288 %token FIGURE_OPEN /* "\\<" */
289 %token FIGURE_SPACE "_"
292 %token CHORDMODIFIERS
294 %token MULTI_MEASURE_REST
297 %token <i> E_UNSIGNED
298 %token <scm> UNSIGNED
300 /* Artificial tokens, for more generic function syntax */
301 %token <i> EXPECT_MARKUP "markup?"
302 %token <i> EXPECT_PITCH "ly:pitch?"
303 %token <i> EXPECT_DURATION "ly:duration?"
304 %token <scm> EXPECT_SCM "scheme?"
305 %token <scm> SKIPPED_SCM "(scheme?)"
306 %token <i> EXPECT_MARKUP_LIST "markup-list?"
307 %token <scm> EXPECT_OPTIONAL "optional?"
308 /* After the last argument. */
309 %token <i> EXPECT_NO_MORE_ARGS;
311 /* An artificial token for parsing embedded Lilypond */
312 %token <i> EMBEDDED_LILY "#{"
314 %token <scm> BOOK_IDENTIFIER
315 %token <scm> CHORDMODIFIER_PITCH
316 %token <scm> CHORD_MODIFIER
317 %token <scm> CHORD_REPETITION
318 %token <scm> CONTEXT_DEF_IDENTIFIER
319 %token <scm> CONTEXT_MOD_IDENTIFIER
320 %token <scm> DRUM_PITCH
321 %token <scm> PITCH_IDENTIFIER
322 %token <scm> DURATION_IDENTIFIER
323 %token <scm> EVENT_IDENTIFIER
324 %token <scm> EVENT_FUNCTION
325 %token <scm> FRACTION
326 %token <scm> LYRICS_STRING
327 %token <scm> LYRIC_MARKUP_IDENTIFIER
328 %token <scm> MARKUP_FUNCTION
329 %token <scm> MARKUP_LIST_FUNCTION
330 %token <scm> MARKUP_IDENTIFIER
331 %token <scm> MARKUPLIST_IDENTIFIER
332 %token <scm> MUSIC_FUNCTION
333 %token <scm> MUSIC_IDENTIFIER
334 %token <scm> NOTENAME_PITCH
335 %token <scm> NUMBER_IDENTIFIER
336 %token <scm> OUTPUT_DEF_IDENTIFIER
338 %token <scm> RESTNAME
339 %token <scm> SCM_FUNCTION
340 %token <scm> SCM_IDENTIFIER
341 %token <scm> SCM_TOKEN
342 %token <scm> SCORE_IDENTIFIER
344 %token <scm> STRING_IDENTIFIER
345 %token <scm> TONICNAME_PITCH
348 %type <book> book_block
349 %type <book> book_body
350 %type <book> bookpart_block
351 %type <book> bookpart_body
353 %type <i> bare_unsigned
354 %type <scm> figured_bass_alteration
356 %type <i> exclamations
357 %type <i> optional_rest
362 %type <i> tremolo_type
365 %type <scm> composite_music
366 %type <scm> grouped_music_list
367 %type <scm> braced_music_list
368 %type <scm> closed_music
370 %type <scm> music_bare
371 %type <scm> complex_music
372 %type <scm> complex_music_prefix
373 %type <scm> mode_changed_music
374 %type <scm> repeated_music
375 %type <scm> sequential_music
376 %type <scm> simple_music
377 %type <scm> simultaneous_music
378 %type <scm> chord_body
379 %type <scm> chord_body_element
380 %type <scm> command_element
381 %type <scm> command_event
382 %type <scm> context_modification
383 %type <scm> context_change
384 %type <scm> direction_less_event
385 %type <scm> direction_reqd_event
386 %type <scm> embedded_lilypond
387 %type <scm> event_chord
388 %type <scm> fingering
389 %type <scm> gen_text_def
390 %type <scm> music_property_def
391 %type <scm> note_chord_element
392 %type <scm> post_event
393 %type <scm> post_event_nofinger
394 %type <scm> re_rhythmed_music
395 %type <scm> simple_element
396 %type <scm> simple_music_property_def
397 %type <scm> start_symbol
398 %type <scm> string_number_event
399 %type <scm> tempo_event
401 %type <outputdef> output_def_body
402 %type <outputdef> output_def_head
403 %type <outputdef> output_def_head_with_mode_switch
404 %type <outputdef> output_def
405 %type <outputdef> paper_block
407 %type <scm> music_function_call
408 %type <scm> music_list
409 %type <scm> assignment_id
410 %type <scm> bare_number
411 %type <scm> unsigned_number
412 %type <scm> bass_figure
413 %type <scm> figured_bass_modification
414 %type <scm> br_bass_figure
415 %type <scm> bass_number
416 %type <scm> chord_body_elements
417 %type <scm> chord_item
418 %type <scm> chord_items
419 %type <scm> chord_separator
420 %type <scm> context_def_mod
421 %type <scm> context_def_spec_block
422 %type <scm> context_def_spec_body
423 %type <scm> context_mod
424 %type <scm> context_mod_list
425 %type <scm> context_prop_spec
426 %type <scm> direction_less_char
427 %type <scm> duration_length
428 %type <scm> embedded_scm
429 %type <scm> embedded_scm_arg
430 %type <scm> embedded_scm_arg_closed
431 %type <scm> embedded_scm_bare
432 %type <scm> embedded_scm_bare_arg
433 %type <scm> embedded_scm_closed
434 %type <scm> embedded_scm_chord_body
435 %type <scm> embedded_scm_event
436 %type <scm> event_function_event
437 %type <scm> figure_list
438 %type <scm> figure_spec
440 %type <scm> full_markup
441 %type <scm> full_markup_list
442 %type <scm> function_arglist
443 %type <scm> function_arglist_optional
444 %type <scm> function_arglist_keep
445 %type <scm> function_arglist_bare
446 %type <scm> function_arglist_closed
447 %type <scm> function_arglist_closed_optional
448 %type <scm> function_arglist_closed_keep
449 %type <scm> identifier_init
451 %type <scm> lilypond_header
452 %type <scm> lilypond_header_body
453 %type <scm> lyric_element
454 %type <scm> lyric_markup
456 %type <scm> markup_braced_list
457 %type <scm> markup_braced_list_body
458 %type <scm> markup_composed_list
459 %type <scm> markup_command_list
460 %type <scm> markup_command_list_arguments
461 %type <scm> markup_command_basic_arguments
462 %type <scm> markup_head_1_item
463 %type <scm> markup_head_1_list
464 %type <scm> markup_list
465 %type <scm> markup_top
466 %type <scm> mode_changing_head
467 %type <scm> mode_changing_head_with_context
468 %type <scm> multiplied_duration
469 %type <scm> music_function_event
470 %type <scm> music_function_event_arglist
471 %type <scm> music_function_chord_body
472 %type <scm> music_function_chord_body_arglist
473 %type <scm> new_chord
474 %type <scm> new_lyrics
475 %type <scm> number_expression
476 %type <scm> number_factor
477 %type <scm> number_term
478 %type <scm> octave_check
479 %type <scm> optional_context_mod
480 %type <scm> optional_id
481 %type <scm> optional_notemode_duration
483 %type <scm> pitch_also_in_chords
484 %type <scm> post_events
485 %type <scm> property_operation
486 %type <scm> property_path property_path_revved
488 %type <scm> scalar_bare
489 %type <scm> scalar_closed
490 %type <scm> scm_function_call
491 %type <scm> scm_function_call_closed
492 %type <scm> script_abbreviation
493 %type <scm> simple_chord_elements
494 %type <scm> simple_markup
495 %type <scm> simple_string
496 %type <scm> steno_duration
497 %type <scm> steno_pitch
498 %type <scm> steno_tonic_pitch
499 %type <scm> step_number
500 %type <scm> step_numbers
502 %type <scm> tempo_range
504 %type <score> score_block
505 %type <score> score_body
510 /* We don't assign precedence to / and *, because we might need varied
511 prec levels in different prods */
520 SCM nn = PARSER->lexer_->lookup_identifier ("pitchnames");
521 PARSER->lexer_->push_note_state (alist_to_hashq (nn));
522 } embedded_lilypond {
523 PARSER->lexer_->pop_state ();
524 PARSER->lexer_->set_identifier (ly_symbol2scm ("parseStringResult"), $3);
528 lilypond: /* empty */ { }
529 | lilypond toplevel_expression {
531 | lilypond assignment {
534 PARSER->error_level_ = 1;
537 PARSER->error_level_ = 1;
544 PARSER->lexer_->set_identifier (ly_symbol2scm ("$defaultheader"), $1);
548 SCM proc = PARSER->lexer_->lookup_identifier ("toplevel-book-handler");
549 scm_call_2 (proc, PARSER->self_scm (), book->self_scm ());
554 SCM proc = PARSER->lexer_->lookup_identifier ("toplevel-bookpart-handler");
555 scm_call_2 (proc, PARSER->self_scm (), bookpart->self_scm ());
556 bookpart->unprotect ();
561 SCM proc = PARSER->lexer_->lookup_identifier ("toplevel-score-handler");
562 scm_call_2 (proc, PARSER->self_scm (), score->self_scm ());
566 Music *music = unsmob_music ($1);
567 SCM proc = PARSER->lexer_->lookup_identifier ("toplevel-music-handler");
568 scm_call_2 (proc, PARSER->self_scm (), music->self_scm ());
571 SCM proc = PARSER->lexer_->lookup_identifier ("toplevel-text-handler");
572 scm_call_2 (proc, PARSER->self_scm (), scm_list_1 ($1));
575 SCM proc = PARSER->lexer_->lookup_identifier ("toplevel-text-handler");
576 scm_call_2 (proc, PARSER->self_scm (), $1);
580 Output_def * od = $1;
582 if ($1->c_variable ("is-paper") == SCM_BOOL_T)
583 id = ly_symbol2scm ("$defaultpaper");
584 else if ($1->c_variable ("is-midi") == SCM_BOOL_T)
585 id = ly_symbol2scm ("$defaultmidi");
586 else if ($1->c_variable ("is-layout") == SCM_BOOL_T)
587 id = ly_symbol2scm ("$defaultlayout");
589 PARSER->lexer_->set_identifier (id, od->self_scm ());
599 embedded_scm_bare_arg:
605 | context_modification
608 $$ = $1->self_scm ();
611 | context_def_spec_block
614 $$ = $1->self_scm ();
619 $$ = $1->self_scm ();
624 $$ = $1->self_scm ();
629 /* The generic version may end in music, or not */
637 embedded_scm_bare_arg
643 SCM_FUNCTION function_arglist {
644 $$ = MAKE_SYNTAX ("music-function", @$,
652 $$ = MAKE_SYNTAX ("void-music", @$);
655 | music music music_list {
656 $$ = MAKE_SYNTAX ("sequential-music", @$,
657 scm_cons2 ($1, $2, scm_reverse_x ($3, SCM_EOL)));
660 PARSER->error_level_ = 1;
662 | INVALID embedded_lilypond {
663 PARSER->error_level_ = 1;
668 lilypond_header_body:
670 $$ = get_header (PARSER);
671 PARSER->lexer_->add_scope ($$);
673 | lilypond_header_body assignment {
679 HEADER '{' lilypond_header_body '}' {
680 $$ = PARSER->lexer_->remove_scope ();
689 | LYRICS_STRING { $$ = $1; }
693 assignment_id '=' identifier_init {
694 PARSER->lexer_->set_identifier ($1, $3);
696 | assignment_id property_path '=' identifier_init {
697 SCM path = scm_cons (scm_string_to_symbol ($1), $2);
698 PARSER->lexer_->set_identifier (path, $4);
701 TODO: devise standard for protection in parser.
703 The parser stack lives on the C-stack, which means that
704 all objects can be unprotected as soon as they're here.
714 $$ = $1->self_scm ();
718 $$ = $1->self_scm ();
722 $$ = $1->self_scm ();
726 $$ = $1->self_scm ();
729 | context_def_spec_block {
733 /* Hack: Create event-chord around standalone events.
734 Prevents the identifier from being interpreted as a post-event. */
735 Music *mus = unsmob_music ($1);
736 bool is_event = mus &&
737 (scm_memq (ly_symbol2scm ("event"), mus->get_property ("types"))
742 $$ = MAKE_SYNTAX ("event-chord", @$, scm_list_1 ($1));
744 | post_event_nofinger {
747 | number_expression {
762 | context_modification {
767 context_def_spec_block:
768 CONTEXT '{' context_def_spec_body '}'
774 context_def_spec_body:
776 $$ = Context_def::make_scm ();
777 unsmob_context_def ($$)->origin ()->set_spot (@$);
779 | CONTEXT_DEF_IDENTIFIER {
781 unsmob_context_def ($$)->origin ()->set_spot (@$);
783 | context_def_spec_body GROBDESCRIPTIONS embedded_scm {
784 Context_def*td = unsmob_context_def ($$);
786 for (SCM p = $3; scm_is_pair (p); p = scm_cdr (p)) {
787 SCM tag = scm_caar (p);
789 /* TODO: should make new tag "grob-definition" ? */
790 td->add_context_mod (scm_list_3 (ly_symbol2scm ("assign"),
791 tag, scm_cons (scm_cdar (p), SCM_EOL)));
794 | context_def_spec_body context_mod {
795 unsmob_context_def ($$)->add_context_mod ($2);
797 | context_def_spec_body context_modification {
798 Context_def *td = unsmob_context_def ($$);
799 SCM new_mods = unsmob_context_mod ($2)->get_mods ();
800 for (SCM m = new_mods; scm_is_pair (m); m = scm_cdr (m)) {
801 td->add_context_mod (scm_car (m));
809 BOOK '{' book_body '}' {
812 PARSER->lexer_->set_identifier (ly_symbol2scm ("$current-book"), SCM_BOOL_F);
817 * Use 'handlers' like for toplevel-* stuff?
818 * grok \layout and \midi? */
822 init_papers (PARSER);
823 $$->origin ()->set_spot (@$);
824 $$->paper_ = dynamic_cast<Output_def*> (unsmob_output_def (PARSER->lexer_->lookup_identifier ("$defaultpaper"))->clone ());
825 $$->paper_->unprotect ();
826 push_paper (PARSER, $$->paper_);
827 $$->header_ = PARSER->lexer_->lookup_identifier ("$defaultheader");
828 PARSER->lexer_->set_identifier (ly_symbol2scm ("$current-book"), $$->self_scm ());
829 PARSER->lexer_->set_identifier (ly_symbol2scm ("book-output-suffix"), SCM_BOOL_F);
830 PARSER->lexer_->set_identifier (ly_symbol2scm ("book-filename"), SCM_BOOL_F);
833 $$ = unsmob_book ($1);
835 $$->origin ()->set_spot (@$);
836 PARSER->lexer_->set_identifier (ly_symbol2scm ("$current-book"), $1);
838 | book_body paper_block {
841 set_paper (PARSER, $2);
843 | book_body bookpart_block {
845 SCM proc = PARSER->lexer_->lookup_identifier ("book-bookpart-handler");
846 scm_call_2 (proc, $$->self_scm (), bookpart->self_scm ());
847 bookpart->unprotect ();
849 | book_body score_block {
851 SCM proc = PARSER->lexer_->lookup_identifier ("book-score-handler");
852 scm_call_2 (proc, $$->self_scm (), score->self_scm ());
855 | book_body composite_music {
856 Music *music = unsmob_music ($2);
857 SCM proc = PARSER->lexer_->lookup_identifier ("book-music-handler");
858 scm_call_3 (proc, PARSER->self_scm (), $$->self_scm (), music->self_scm ());
860 | book_body full_markup {
861 SCM proc = PARSER->lexer_->lookup_identifier ("book-text-handler");
862 scm_call_2 (proc, $$->self_scm (), scm_list_1 ($2));
864 | book_body full_markup_list {
865 SCM proc = PARSER->lexer_->lookup_identifier ("book-text-handler");
866 scm_call_2 (proc, $$->self_scm (), $2);
868 | book_body lilypond_header {
871 | book_body embedded_scm { }
874 $$->scores_ = SCM_EOL;
875 $$->bookparts_ = SCM_EOL;
880 BOOKPART '{' bookpart_body '}' {
882 PARSER->lexer_->set_identifier (ly_symbol2scm ("$current-bookpart"), SCM_BOOL_F);
889 $$->origin ()->set_spot (@$);
890 PARSER->lexer_->set_identifier (ly_symbol2scm ("$current-bookpart"), $$->self_scm ());
893 $$ = unsmob_book ($1);
895 $$->origin ()->set_spot (@$);
896 PARSER->lexer_->set_identifier (ly_symbol2scm ("$current-bookpart"), $1);
898 | bookpart_body paper_block {
902 | bookpart_body score_block {
904 SCM proc = PARSER->lexer_->lookup_identifier ("bookpart-score-handler");
905 scm_call_2 (proc, $$->self_scm (), score->self_scm ());
908 | bookpart_body composite_music {
909 Music *music = unsmob_music ($2);
910 SCM proc = PARSER->lexer_->lookup_identifier ("bookpart-music-handler");
911 scm_call_3 (proc, PARSER->self_scm (), $$->self_scm (), music->self_scm ());
913 | bookpart_body full_markup {
914 SCM proc = PARSER->lexer_->lookup_identifier ("bookpart-text-handler");
915 scm_call_2 (proc, $$->self_scm (), scm_list_1 ($2));
917 | bookpart_body full_markup_list {
918 SCM proc = PARSER->lexer_->lookup_identifier ("bookpart-text-handler");
919 scm_call_2 (proc, $$->self_scm (), $2);
921 | bookpart_body lilypond_header {
924 | bookpart_body embedded_scm { }
925 | bookpart_body error {
927 $$->scores_ = SCM_EOL;
932 SCORE '{' score_body '}' {
940 SCM scorify = ly_lily_module_constant ("scorify-music");
941 SCM score = scm_call_2 (scorify, m, PARSER->self_scm ());
943 // pass ownernship to C++ again.
944 $$ = unsmob_score (score);
946 $$->origin ()->set_spot (@$);
949 $$ = unsmob_score ($1);
951 $$->origin ()->set_spot (@$);
953 | score_body lilypond_header {
956 | score_body output_def {
957 if ($2->lookup_variable (ly_symbol2scm ("is-paper")) == SCM_BOOL_T)
959 PARSER->parser_error (@2, _("\\paper cannot be used in \\score, use \\layout instead"));
964 $$->add_output_def ($2);
969 $$->error_found_ = true;
981 if ($$->lookup_variable (ly_symbol2scm ("is-paper")) != SCM_BOOL_T)
983 PARSER->parser_error (@1, _ ("need \\paper for paper block"));
985 $$ = get_paper (PARSER);
992 output_def_body '}' {
995 PARSER->lexer_->remove_scope ();
996 PARSER->lexer_->pop_state ();
1002 $$ = get_paper (PARSER);
1003 $$->input_origin_ = @$;
1004 PARSER->lexer_->add_scope ($$->scope_);
1007 Output_def *p = get_midi (PARSER);
1009 PARSER->lexer_->add_scope (p->scope_);
1012 Output_def *p = get_layout (PARSER);
1014 PARSER->lexer_->add_scope (p->scope_);
1019 output_def_head_with_mode_switch:
1021 PARSER->lexer_->push_initial_state ();
1027 output_def_head_with_mode_switch '{' {
1029 $$->input_origin_.set_spot (@$);
1031 | output_def_head_with_mode_switch '{' OUTPUT_DEF_IDENTIFIER {
1034 Output_def *o = unsmob_output_def ($3);
1035 o->input_origin_.set_spot (@$);
1038 PARSER->lexer_->remove_scope ();
1039 PARSER->lexer_->add_scope (o->scope_);
1041 | output_def_body assignment {
1044 | output_def_body context_def_spec_block {
1045 assign_context_def ($$, $2);
1047 | output_def_body error {
1053 TEMPO steno_duration '=' tempo_range {
1054 $$ = MAKE_SYNTAX ("tempo", @$, SCM_EOL, $2, $4);
1056 | TEMPO scalar_closed steno_duration '=' tempo_range {
1057 $$ = MAKE_SYNTAX ("tempo", @$, $2, $3, $5);
1060 $$ = MAKE_SYNTAX ("tempo", @$, $2);
1065 The representation of a list is reversed to have efficient append. */
1071 | music_list music {
1072 $$ = scm_cons ($2, $1);
1074 | music_list embedded_scm {
1077 | music_list error {
1078 Music *m = MY_MAKE_MUSIC("Music", @$);
1080 m->set_property ("error-found", SCM_BOOL_T);
1081 $$ = scm_cons (m->self_scm (), $1);
1082 m->unprotect (); /* UGH */
1089 $$ = scm_reverse_x ($2, SCM_EOL);
1095 | composite_music %prec COMPOSITE
1100 REPEAT simple_string unsigned_number music
1102 $$ = MAKE_SYNTAX ("repeat", @$, $2, $3, $4, SCM_EOL);
1104 | REPEAT simple_string unsigned_number music ALTERNATIVE braced_music_list
1106 $$ = MAKE_SYNTAX ("repeat", @$, $2, $3, $4, $6);
1111 SEQUENTIAL braced_music_list {
1112 $$ = MAKE_SYNTAX ("sequential-music", @$, $2);
1114 | braced_music_list {
1115 $$ = MAKE_SYNTAX ("sequential-music", @$, $1);
1120 SIMULTANEOUS braced_music_list {
1121 $$ = MAKE_SYNTAX ("simultaneous-music", @$, $2);
1123 | DOUBLE_ANGLE_OPEN music_list DOUBLE_ANGLE_CLOSE {
1124 $$ = MAKE_SYNTAX ("simultaneous-music", @$, scm_reverse_x ($2, SCM_EOL));
1130 | music_property_def
1134 context_modification:
1135 WITH { PARSER->lexer_->push_initial_state (); } '{' context_mod_list '}'
1137 PARSER->lexer_->pop_state ();
1140 | WITH CONTEXT_MOD_IDENTIFIER
1144 | CONTEXT_MOD_IDENTIFIER
1150 optional_context_mod:
1154 | context_modification
1162 $$ = Context_mod ().smobbed_copy ();
1164 | context_mod_list context_mod {
1165 unsmob_context_mod ($1)->add_context_mod ($2);
1167 | context_mod_list CONTEXT_MOD_IDENTIFIER {
1168 Context_mod *md = unsmob_context_mod ($2);
1170 unsmob_context_mod ($1)->add_context_mods (md->get_mods ());
1179 /* Music that can be parsed without lookahead */
1182 | complex_music_prefix closed_music
1184 $$ = FINISH_MAKE_SYNTAX ($1, @$, $2);
1191 | grouped_music_list
1195 simultaneous_music { $$ = $1; }
1196 | sequential_music { $$ = $1; }
1199 /* An argument list. If a function \foo expects scm scm pitch, then the lexer expands \foo into the token sequence:
1200 MUSIC_FUNCTION EXPECT_PITCH EXPECT_SCM EXPECT_SCM EXPECT_NO_MORE_ARGS
1201 and this rule returns the reversed list of arguments. */
1205 function_arglist_bare
1206 | EXPECT_SCM function_arglist_optional embedded_scm_arg
1208 $$ = check_scheme_arg (PARSER, @3, SCM_UNDEFINED,
1211 | EXPECT_SCM function_arglist_optional SKIPPED_SCM
1213 $$ = check_scheme_arg (PARSER, @3, SCM_UNDEFINED,
1218 function_arglist_optional:
1219 function_arglist_keep %prec FUNCTION_ARGUMENTS
1220 | EXPECT_OPTIONAL EXPECT_PITCH function_arglist_optional
1222 $$ = scm_cons ($1, $3);
1224 | EXPECT_OPTIONAL EXPECT_DURATION function_arglist_optional
1226 $$ = scm_cons ($1, $3);
1228 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_optional
1230 $$ = scm_cons (loc_on_music (@3, $1), $3);
1234 function_arglist_keep:
1235 EXPECT_OPTIONAL EXPECT_PITCH function_arglist_keep pitch_also_in_chords {
1236 $$ = scm_cons ($4, $3);
1238 | EXPECT_OPTIONAL EXPECT_DURATION function_arglist_closed_keep duration_length {
1239 $$ = scm_cons ($4, $3);
1241 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_keep embedded_scm_arg_closed
1243 if (scm_is_true (scm_call_1 ($2, $4)))
1245 $$ = scm_cons ($4, $3);
1247 $$ = try_unpack_lyrics ($2, $4);
1248 if (!SCM_UNBNDP ($$))
1249 $$ = scm_cons ($$, $3);
1251 $$ = scm_cons (loc_on_music (@3, $1), $3);
1252 MYBACKUP (SKIPPED_SCM, $4, @4);
1260 function_arglist_closed:
1261 function_arglist_bare
1262 | EXPECT_SCM function_arglist_optional embedded_scm_arg_closed
1264 $$ = check_scheme_arg (PARSER, @3, SCM_UNDEFINED,
1267 | EXPECT_SCM function_arglist_optional SKIPPED_SCM
1269 $$ = check_scheme_arg (PARSER, @3, SCM_UNDEFINED,
1274 function_arglist_closed_optional:
1275 function_arglist_closed_keep %prec FUNCTION_ARGUMENTS
1276 | EXPECT_OPTIONAL EXPECT_PITCH function_arglist_closed_optional
1278 $$ = scm_cons ($1, $3);
1280 | EXPECT_OPTIONAL EXPECT_DURATION function_arglist_closed_optional
1282 $$ = scm_cons ($1, $3);
1284 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_closed_optional
1286 $$ = scm_cons (loc_on_music (@3, $1), $3);
1290 function_arglist_closed_keep:
1291 EXPECT_OPTIONAL EXPECT_PITCH function_arglist_keep pitch_also_in_chords {
1292 $$ = scm_cons ($4, $3);
1294 | EXPECT_OPTIONAL EXPECT_DURATION function_arglist_closed_keep duration_length {
1295 $$ = scm_cons ($4, $3);
1297 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_keep embedded_scm_arg_closed
1299 if (scm_is_true (scm_call_1 ($2, $4)))
1301 $$ = scm_cons ($4, $3);
1303 $$ = try_unpack_lyrics ($2, $4);
1304 if (!SCM_UNBNDP ($$))
1305 $$ = scm_cons ($$, $3);
1307 $$ = scm_cons (loc_on_music (@3, $1), $3);
1308 MYBACKUP (SKIPPED_SCM, $4, @4);
1312 | function_arglist_closed
1315 embedded_scm_closed:
1317 | scm_function_call_closed
1320 embedded_scm_arg_closed:
1321 embedded_scm_bare_arg
1322 | scm_function_call_closed
1326 scm_function_call_closed:
1327 SCM_FUNCTION function_arglist_closed {
1328 $$ = MAKE_SYNTAX ("music-function", @$,
1333 function_arglist_bare:
1334 EXPECT_NO_MORE_ARGS {
1337 | EXPECT_PITCH function_arglist_optional pitch_also_in_chords {
1338 $$ = scm_cons ($3, $2);
1340 | EXPECT_DURATION function_arglist_closed_optional duration_length {
1341 $$ = scm_cons ($3, $2);
1345 music_function_call:
1346 MUSIC_FUNCTION function_arglist {
1347 $$ = MAKE_SYNTAX ("music-function", @$,
1354 /**/ { $$ = SCM_EOL; }
1355 | '=' simple_string {
1362 | repeated_music { $$ = $1; }
1363 | re_rhythmed_music { $$ = $1; }
1364 | complex_music_prefix music
1366 $$ = FINISH_MAKE_SYNTAX ($1, @$, $2);
1370 complex_music_prefix:
1371 CONTEXT simple_string optional_id optional_context_mod {
1372 Context_mod *ctxmod = unsmob_context_mod ($4);
1375 mods = ctxmod->get_mods ();
1376 $$ = START_MAKE_SYNTAX ("context-specification", $2, $3, mods, SCM_BOOL_F);
1378 | NEWCONTEXT simple_string optional_id optional_context_mod {
1379 Context_mod *ctxmod = unsmob_context_mod ($4);
1382 mods = ctxmod->get_mods ();
1383 $$ = START_MAKE_SYNTAX ("context-specification", $2, $3, mods, SCM_BOOL_T);
1386 $$ = START_MAKE_SYNTAX ("time-scaled-music", $2);
1391 mode_changing_head grouped_music_list {
1392 if ($1 == ly_symbol2scm ("chords"))
1394 $$ = MAKE_SYNTAX ("unrelativable-music", @$, $2);
1400 PARSER->lexer_->pop_state ();
1402 | mode_changing_head_with_context optional_context_mod grouped_music_list {
1403 Context_mod *ctxmod = unsmob_context_mod ($2);
1406 mods = ctxmod->get_mods ();
1407 $$ = MAKE_SYNTAX ("context-specification", @$, $1, SCM_EOL, mods, SCM_BOOL_T, $3);
1408 if ($1 == ly_symbol2scm ("ChordNames"))
1410 $$ = MAKE_SYNTAX ("unrelativable-music", @$, $$);
1412 PARSER->lexer_->pop_state ();
1418 SCM nn = PARSER->lexer_->lookup_identifier ("pitchnames");
1419 PARSER->lexer_->push_note_state (alist_to_hashq (nn));
1421 $$ = ly_symbol2scm ("notes");
1425 SCM nn = PARSER->lexer_->lookup_identifier ("drumPitchNames");
1426 PARSER->lexer_->push_note_state (alist_to_hashq (nn));
1428 $$ = ly_symbol2scm ("drums");
1431 PARSER->lexer_->push_figuredbass_state ();
1433 $$ = ly_symbol2scm ("figures");
1436 SCM nn = PARSER->lexer_->lookup_identifier ("chordmodifiers");
1437 PARSER->lexer_->chordmodifier_tab_ = alist_to_hashq (nn);
1438 nn = PARSER->lexer_->lookup_identifier ("pitchnames");
1439 PARSER->lexer_->push_chord_state (alist_to_hashq (nn));
1440 $$ = ly_symbol2scm ("chords");
1444 { PARSER->lexer_->push_lyric_state ();
1445 $$ = ly_symbol2scm ("lyrics");
1449 mode_changing_head_with_context:
1451 SCM nn = PARSER->lexer_->lookup_identifier ("drumPitchNames");
1452 PARSER->lexer_->push_note_state (alist_to_hashq (nn));
1454 $$ = ly_symbol2scm ("DrumStaff");
1457 PARSER->lexer_->push_figuredbass_state ();
1459 $$ = ly_symbol2scm ("FiguredBass");
1462 SCM nn = PARSER->lexer_->lookup_identifier ("chordmodifiers");
1463 PARSER->lexer_->chordmodifier_tab_ = alist_to_hashq (nn);
1464 nn = PARSER->lexer_->lookup_identifier ("pitchnames");
1465 PARSER->lexer_->push_chord_state (alist_to_hashq (nn));
1466 $$ = ly_symbol2scm ("ChordNames");
1469 { PARSER->lexer_->push_lyric_state ();
1470 $$ = ly_symbol2scm ("Lyrics");
1475 ADDLYRICS { PARSER->lexer_->push_lyric_state (); }
1478 /* Can also use music at the expensive of two S/Rs similar to
1479 \repeat \alternative */
1480 PARSER->lexer_->pop_state ();
1482 $$ = scm_cons ($3, SCM_EOL);
1484 | new_lyrics ADDLYRICS {
1485 PARSER->lexer_->push_lyric_state ();
1487 PARSER->lexer_->pop_state ();
1488 $$ = scm_cons ($4, $1);
1493 composite_music new_lyrics {
1494 $$ = MAKE_SYNTAX ("add-lyrics", @$, $1, scm_reverse_x ($2, SCM_EOL));
1496 | LYRICSTO simple_string {
1497 PARSER->lexer_->push_lyric_state ();
1499 PARSER->lexer_->pop_state ();
1500 $$ = MAKE_SYNTAX ("lyric-combine", @$, $2, $4);
1505 CHANGE STRING '=' STRING {
1506 $$ = MAKE_SYNTAX ("context-change", @$, scm_string_to_symbol ($2), $4);
1511 property_path_revved:
1512 embedded_scm_closed {
1513 $$ = scm_cons ($1, SCM_EOL);
1515 | property_path_revved embedded_scm_closed {
1516 $$ = scm_cons ($2, $1);
1521 property_path_revved {
1522 $$ = scm_reverse_x ($1, SCM_EOL);
1528 $$ = scm_list_3 (ly_symbol2scm ("assign"),
1529 scm_string_to_symbol ($1), $3);
1531 | UNSET simple_string {
1532 $$ = scm_list_2 (ly_symbol2scm ("unset"),
1533 scm_string_to_symbol ($2));
1535 | OVERRIDE simple_string property_path '=' scalar {
1536 $$ = scm_append (scm_list_2 (scm_list_3 (ly_symbol2scm ("push"),
1537 scm_string_to_symbol ($2), $5),
1540 | REVERT simple_string embedded_scm {
1541 $$ = scm_list_3 (ly_symbol2scm ("pop"),
1542 scm_string_to_symbol ($2), $3);
1547 CONSISTS { $$ = ly_symbol2scm ("consists"); }
1548 | REMOVE { $$ = ly_symbol2scm ("remove"); }
1550 | ACCEPTS { $$ = ly_symbol2scm ("accepts"); }
1551 | DEFAULTCHILD { $$ = ly_symbol2scm ("default-child"); }
1552 | DENIES { $$ = ly_symbol2scm ("denies"); }
1554 | ALIAS { $$ = ly_symbol2scm ("alias"); }
1555 | TYPE { $$ = ly_symbol2scm ("translator-type"); }
1556 | DESCRIPTION { $$ = ly_symbol2scm ("description"); }
1557 | NAME { $$ = ly_symbol2scm ("context-name"); }
1561 property_operation { $$ = $1; }
1562 | context_def_mod STRING {
1563 $$ = scm_list_2 ($1, $2);
1565 | context_def_mod embedded_scm {
1566 if (ly_symbol2scm ("consists") != $1)
1569 PARSER->parser_error (@1, _ ("only \\consists takes non-string argument."));
1573 $$ = scm_list_2 ($1, $2);
1580 if (!is_regular_identifier ($1))
1582 @$.error (_("Grob name should be alphanumeric"));
1585 $$ = scm_list_2 (ly_symbol2scm ("Bottom"),
1586 scm_string_to_symbol ($1));
1588 | simple_string '.' simple_string {
1589 $$ = scm_list_2 (scm_string_to_symbol ($1),
1590 scm_string_to_symbol ($3));
1594 simple_music_property_def:
1595 OVERRIDE context_prop_spec property_path '=' scalar {
1596 $$ = scm_append (scm_list_2 (scm_list_n (scm_car ($2),
1597 ly_symbol2scm ("OverrideProperty"),
1602 | REVERT context_prop_spec embedded_scm {
1603 $$ = scm_list_4 (scm_car ($2),
1604 ly_symbol2scm ("RevertProperty"),
1608 | SET context_prop_spec '=' scalar {
1609 $$ = scm_list_4 (scm_car ($2),
1610 ly_symbol2scm ("PropertySet"),
1614 | UNSET context_prop_spec {
1615 $$ = scm_list_3 (scm_car ($2),
1616 ly_symbol2scm ("PropertyUnset"),
1622 simple_music_property_def {
1623 $$ = LOWLEVEL_MAKE_SYNTAX (ly_lily_module_constant ("property-operation"), scm_cons2 (PARSER->self_scm (), make_input (@$), $1));
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 {
1679 scm_function_call_closed
1684 /* TODO: Create a special case that avoids the creation of
1685 EventChords around simple_elements that have no post_events?
1687 simple_chord_elements post_events {
1688 SCM elts = ly_append2 ($1, scm_reverse_x ($2, SCM_EOL));
1691 /* why is this giving wrong start location? -ns
1693 i.set_location (@1, @2);
1694 $$ = MAKE_SYNTAX ("event-chord", i, elts);
1696 | CHORD_REPETITION optional_notemode_duration post_events {
1698 i.set_location (@1, @3);
1699 $$ = MAKE_SYNTAX ("repetition-chord", i,
1700 PARSER->lexer_->chord_repetition_.last_chord_,
1701 PARSER->lexer_->chord_repetition_.repetition_function_,
1702 $2, scm_reverse_x ($3, SCM_EOL));
1704 | MULTI_MEASURE_REST optional_notemode_duration post_events {
1706 i.set_location (@1, @3);
1707 $$ = MAKE_SYNTAX ("multi-measure-rest", i, $2,
1708 scm_reverse_x ($3, SCM_EOL));
1711 /* note chord elements are memorized into
1712 PARSER->lexer_->chord_repetition_ so that the chord repetition
1713 mechanism copy them when a chord repetition symbol is found
1715 | note_chord_element {
1716 PARSER->lexer_->chord_repetition_.last_chord_ = $$;
1722 chord_body optional_notemode_duration post_events
1724 Music *m = unsmob_music ($1);
1725 SCM dur = unsmob_duration ($2)->smobbed_copy ();
1726 SCM es = m->get_property ("elements");
1727 SCM postevs = scm_reverse_x ($3, SCM_EOL);
1729 for (SCM s = es; scm_is_pair (s); s = scm_cdr (s))
1730 unsmob_music (scm_car (s))->set_property ("duration", dur);
1731 es = ly_append2 (es, postevs);
1733 m-> set_property ("elements", es);
1735 $$ = m->self_scm ();
1740 ANGLE_OPEN chord_body_elements ANGLE_CLOSE
1742 $$ = MAKE_SYNTAX ("event-chord", @$, scm_reverse_x ($2, SCM_EOL));
1746 chord_body_elements:
1747 /* empty */ { $$ = SCM_EOL; }
1748 | chord_body_elements chord_body_element {
1749 $$ = scm_cons ($2, $1);
1754 pitch exclamations questions octave_check post_events
1761 Music *n = MY_MAKE_MUSIC ("NoteEvent", @$);
1762 n->set_property ("pitch", $1);
1764 n->set_property ("cautionary", SCM_BOOL_T);
1765 if (ex % 2 || q % 2)
1766 n->set_property ("force-accidental", SCM_BOOL_T);
1768 if (scm_is_pair (post)) {
1769 SCM arts = scm_reverse_x (post, SCM_EOL);
1770 n->set_property ("articulations", arts);
1772 if (scm_is_number (check))
1774 int q = scm_to_int (check);
1775 n->set_property ("absolute-octave", scm_from_int (q-1));
1778 $$ = n->unprotect ();
1780 | DRUM_PITCH post_events {
1781 Music *n = MY_MAKE_MUSIC ("NoteEvent", @$);
1782 n->set_property ("drum-type", $1);
1784 if (scm_is_pair ($2)) {
1785 SCM arts = scm_reverse_x ($2, SCM_EOL);
1786 n->set_property ("articulations", arts);
1788 $$ = n->unprotect ();
1790 | music_function_chord_body
1793 /* We can't accept a music argument, not even a closed one,
1794 * immediately before chord_body_elements, otherwise a function \fun
1795 * with a signature of two music arguments can't be sorted out
1796 * properly in a construct like
1797 * <\fun { c } \fun { c } c>
1798 * The second call could be interpreted either as a chord constituent
1799 * or a music expression.
1802 music_function_chord_body_arglist:
1803 function_arglist_bare
1804 | EXPECT_SCM music_function_chord_body_arglist embedded_scm_chord_body
1806 $$ = check_scheme_arg (PARSER, @3, SCM_UNDEFINED,
1811 embedded_scm_chord_body:
1812 embedded_scm_bare_arg
1813 | SCM_FUNCTION music_function_chord_body_arglist {
1814 $$ = MAKE_SYNTAX ("music-function", @$,
1817 | chord_body_element
1821 music_function_chord_body:
1822 MUSIC_FUNCTION music_function_chord_body_arglist {
1823 $$ = MAKE_SYNTAX ("music-function", @$,
1828 /* We could accept a closed music argument before the post events
1829 * indicated by a trailing argument list. For symmetry with chord
1830 * bodies and in order to avoid too tricky and complex behavior, we
1831 * refrain from doing so.
1833 music_function_event_arglist:
1834 function_arglist_bare
1835 | EXPECT_SCM music_function_event_arglist embedded_scm_event
1837 $$ = check_scheme_arg (PARSER, @3, SCM_UNDEFINED,
1843 embedded_scm_bare_arg
1844 | SCM_FUNCTION music_function_event_arglist {
1845 $$ = MAKE_SYNTAX ("music-function", @$,
1852 music_function_event:
1853 MUSIC_FUNCTION music_function_event_arglist {
1854 $$ = MAKE_SYNTAX ("music-function", @$,
1859 event_function_event:
1860 EVENT_FUNCTION music_function_event_arglist {
1861 $$ = MAKE_SYNTAX ("music-function", @$,
1871 Music *m = MY_MAKE_MUSIC ("LigatureEvent", @$);
1872 m->set_property ("span-direction", scm_from_int (START));
1873 $$ = m->unprotect();
1876 Music *m = MY_MAKE_MUSIC ("LigatureEvent", @$);
1877 m->set_property ("span-direction", scm_from_int (STOP));
1878 $$ = m->unprotect ();
1881 $$ = MAKE_SYNTAX ("voice-separator", @$);
1884 SCM pipe = PARSER->lexer_->lookup_identifier ("pipeSymbol");
1886 Music *m = unsmob_music (pipe);
1891 $$ = m->unprotect ();
1894 $$ = MAKE_SYNTAX ("bar-check", @$);
1898 SCM proc = ly_lily_module_constant ("make-time-signature-set");
1900 $$ = scm_apply_2 (proc, scm_car ($2), scm_cdr ($2), SCM_EOL);
1903 $$ = MAKE_SYNTAX ("make-mark-set", @$, $2);
1909 $$ = MY_MAKE_MUSIC ("PesOrFlexaEvent", @$)->unprotect ();
1912 Music *m = MY_MAKE_MUSIC ("MarkEvent", @$);
1913 $$ = m->unprotect ();
1919 Music *key = MY_MAKE_MUSIC ("KeyChangeEvent", @$);
1920 $$ = key->unprotect ();
1922 | KEY NOTENAME_PITCH SCM_IDENTIFIER {
1924 Music *key = MY_MAKE_MUSIC ("KeyChangeEvent", @$);
1925 if (scm_ilength ($3) > 0)
1927 key->set_property ("pitch-alist", $3);
1928 key->set_property ("tonic", Pitch (0, 0, 0).smobbed_copy ());
1929 key->transpose (* unsmob_pitch ($2));
1931 PARSER->parser_error (@3, _ ("second argument must be pitch list"));
1934 $$ = key->unprotect ();
1943 | post_events post_event {
1944 unsmob_music ($2)->set_spot (@2);
1945 $$ = scm_cons ($2, $$);
1949 post_event_nofinger:
1950 direction_less_event {
1953 | script_dir music_function_event {
1957 unsmob_music ($$)->set_property ("direction", scm_from_int ($1));
1961 if (!PARSER->lexer_->is_lyric_state ())
1962 PARSER->parser_error (@1, _ ("have to be in Lyric mode for lyrics"));
1963 $$ = MY_MAKE_MUSIC ("HyphenEvent", @$)->unprotect ();
1966 if (!PARSER->lexer_->is_lyric_state ())
1967 PARSER->parser_error (@1, _ ("have to be in Lyric mode for lyrics"));
1968 $$ = MY_MAKE_MUSIC ("ExtenderEvent", @$)->unprotect ();
1970 | script_dir direction_reqd_event {
1973 Music *m = unsmob_music ($2);
1974 m->set_property ("direction", scm_from_int ($1));
1978 | script_dir direction_less_event {
1981 Music *m = unsmob_music ($2);
1982 m->set_property ("direction", scm_from_int ($1));
1986 | string_number_event
1991 | script_dir fingering {
1994 Music *m = unsmob_music ($2);
1995 m->set_property ("direction", scm_from_int ($1));
2001 string_number_event:
2003 Music *s = MY_MAKE_MUSIC ("StringNumberEvent", @$);
2004 s->set_property ("string-number", scm_from_int ($1));
2005 $$ = s->unprotect ();
2009 direction_less_char:
2011 $$ = ly_symbol2scm ("bracketOpenSymbol");
2014 $$ = ly_symbol2scm ("bracketCloseSymbol");
2017 $$ = ly_symbol2scm ("tildeSymbol");
2020 $$ = ly_symbol2scm ("parenthesisOpenSymbol");
2023 $$ = ly_symbol2scm ("parenthesisCloseSymbol");
2026 $$ = ly_symbol2scm ("escapedExclamationSymbol");
2029 $$ = ly_symbol2scm ("escapedParenthesisOpenSymbol");
2032 $$ = ly_symbol2scm ("escapedParenthesisCloseSymbol");
2035 $$ = ly_symbol2scm ("escapedBiggerSymbol");
2038 $$ = ly_symbol2scm ("escapedSmallerSymbol");
2042 direction_less_event:
2043 direction_less_char {
2044 SCM predefd = PARSER->lexer_->lookup_identifier_symbol ($1);
2046 if (unsmob_music (predefd))
2048 m = unsmob_music (predefd)->clone ();
2053 m = MY_MAKE_MUSIC ("Music", @$);
2055 $$ = m->unprotect ();
2057 | EVENT_IDENTIFIER {
2061 Music *a = MY_MAKE_MUSIC ("TremoloEvent", @$);
2062 a->set_property ("tremolo-type", scm_from_int ($1));
2063 $$ = a->unprotect ();
2065 | event_function_event
2068 direction_reqd_event:
2072 | script_abbreviation {
2073 SCM s = PARSER->lexer_->lookup_identifier ("dash" + ly_scm2string ($1));
2074 Music *a = MY_MAKE_MUSIC ("ArticulationEvent", @$);
2075 if (scm_is_string (s))
2076 a->set_property ("articulation-type", s);
2077 else PARSER->parser_error (@1, _ ("expecting string as script definition"));
2078 $$ = a->unprotect ();
2083 /**/ { $$ = SCM_EOL; }
2084 | '=' { $$ = scm_from_int (0); }
2085 | '=' sub_quotes { $$ = scm_from_int (-$2); }
2086 | '=' sup_quotes { $$ = scm_from_int ($2); }
2111 | NOTENAME_PITCH sup_quotes {
2112 Pitch p = *unsmob_pitch ($1);
2113 p = p.transposed (Pitch ($2,0,0));
2114 $$ = p.smobbed_copy ();
2116 | NOTENAME_PITCH sub_quotes {
2117 Pitch p =* unsmob_pitch ($1);
2118 p = p.transposed (Pitch (-$2,0,0));
2119 $$ = p.smobbed_copy ();
2131 | TONICNAME_PITCH sup_quotes {
2132 Pitch p = *unsmob_pitch ($1);
2133 p = p.transposed (Pitch ($2,0,0));
2134 $$ = p.smobbed_copy ();
2136 | TONICNAME_PITCH sub_quotes {
2137 Pitch p = *unsmob_pitch ($1);
2139 p = p.transposed (Pitch (-$2,0,0));
2140 $$ = p.smobbed_copy ();
2151 pitch_also_in_chords:
2158 Music *t = MY_MAKE_MUSIC ("TextScriptEvent", @$);
2159 t->set_property ("text", $1);
2160 $$ = t->unprotect ();
2163 Music *t = MY_MAKE_MUSIC ("TextScriptEvent", @$);
2164 t->set_property ("text",
2165 make_simple_markup ($1));
2166 $$ = t->unprotect ();
2172 Music *t = MY_MAKE_MUSIC ("FingeringEvent", @$);
2173 t->set_property ("digit", $1);
2174 $$ = t->unprotect ();
2178 script_abbreviation:
2180 $$ = scm_from_locale_string ("Hat");
2183 $$ = scm_from_locale_string ("Plus");
2186 $$ = scm_from_locale_string ("Dash");
2189 $$ = scm_from_locale_string ("Bar");
2192 $$ = scm_from_locale_string ("Larger");
2195 $$ = scm_from_locale_string ("Dot");
2198 $$ = scm_from_locale_string ("Underscore");
2205 | '-' { $$ = CENTER; }
2209 multiplied_duration {
2214 optional_notemode_duration:
2216 Duration dd = PARSER->default_duration_;
2217 $$ = dd.smobbed_copy ();
2219 | multiplied_duration {
2221 PARSER->default_duration_ = *unsmob_duration ($$);
2226 bare_unsigned dots {
2228 if (!is_duration ($1))
2229 PARSER->parser_error (@1, _f ("not a duration: %d", $1));
2233 $$ = Duration (len, $2).smobbed_copy ();
2235 | DURATION_IDENTIFIER dots {
2236 Duration *d = unsmob_duration ($1);
2237 Duration k (d->duration_log (), d->dot_count () + $2);
2238 k = k.compressed (d->factor ());
2244 multiplied_duration:
2248 | multiplied_duration '*' bare_unsigned {
2249 $$ = unsmob_duration ($$)->compressed ( $3) .smobbed_copy ();
2251 | multiplied_duration '*' FRACTION {
2252 Rational m (scm_to_int (scm_car ($3)), scm_to_int (scm_cdr ($3)));
2254 $$ = unsmob_duration ($$)->compressed (m).smobbed_copy ();
2259 FRACTION { $$ = $1; }
2260 | UNSIGNED '/' UNSIGNED {
2261 $$ = scm_cons ($1, $3);
2278 | ':' bare_unsigned {
2279 if (!is_duration ($2))
2280 PARSER->parser_error (@2, _f ("not a duration: %d", $2));
2286 UNSIGNED { $$ = $1; }
2287 | STRING { $$ = $1; }
2288 | full_markup { $$ = $1; }
2291 figured_bass_alteration:
2292 '-' { $$ = ly_rational2scm (FLAT_ALTERATION); }
2293 | '+' { $$ = ly_rational2scm (SHARP_ALTERATION); }
2294 | '!' { $$ = scm_from_int (0); }
2299 Music *bfr = MY_MAKE_MUSIC ("BassFigureEvent", @$);
2300 $$ = bfr->unprotect ();
2303 Music *bfr = MY_MAKE_MUSIC ("BassFigureEvent", @$);
2304 $$ = bfr->self_scm ();
2306 if (scm_is_number ($1))
2307 bfr->set_property ("figure", $1);
2308 else if (Text_interface::is_markup ($1))
2309 bfr->set_property ("text", $1);
2315 unsmob_music ($1)->set_property ("bracket-stop", SCM_BOOL_T);
2317 | bass_figure figured_bass_alteration {
2318 Music *m = unsmob_music ($1);
2319 if (scm_to_double ($2)) {
2320 SCM salter = m->get_property ("alteration");
2321 SCM alter = scm_is_number (salter) ? salter : scm_from_int (0);
2322 m->set_property ("alteration",
2323 scm_sum (alter, $2));
2325 m->set_property ("alteration", scm_from_int (0));
2328 | bass_figure figured_bass_modification {
2329 Music *m = unsmob_music ($1);
2330 if ($2 == ly_symbol2scm ("plus"))
2332 m->set_property ("augmented", SCM_BOOL_T);
2334 else if ($2 == ly_symbol2scm ("slash"))
2336 m->set_property ("diminished", SCM_BOOL_T);
2338 else if ($2 == ly_symbol2scm ("exclamation"))
2340 m->set_property ("no-continuation", SCM_BOOL_T);
2342 else if ($2 == ly_symbol2scm ("backslash"))
2344 m->set_property ("augmented-slash", SCM_BOOL_T);
2350 figured_bass_modification:
2352 $$ = ly_symbol2scm ("plus");
2355 $$ = ly_symbol2scm ("exclamation");
2358 $$ = ly_symbol2scm ("slash");
2361 $$ = ly_symbol2scm ("backslash");
2371 unsmob_music ($$)->set_property ("bracket-start", SCM_BOOL_T);
2379 | figure_list br_bass_figure {
2380 $$ = scm_cons ($2, $1);
2385 FIGURE_OPEN figure_list FIGURE_CLOSE {
2386 $$ = scm_reverse_x ($2, SCM_EOL);
2397 pitch exclamations questions octave_check optional_notemode_duration optional_rest {
2398 if (!PARSER->lexer_->is_note_state ())
2399 PARSER->parser_error (@1, _ ("have to be in Note mode for notes"));
2403 n = MY_MAKE_MUSIC ("RestEvent", @$);
2405 n = MY_MAKE_MUSIC ("NoteEvent", @$);
2407 n->set_property ("pitch", $1);
2408 n->set_property ("duration", $5);
2410 if (scm_is_number ($4))
2412 int q = scm_to_int ($4);
2413 n->set_property ("absolute-octave", scm_from_int (q-1));
2417 n->set_property ("cautionary", SCM_BOOL_T);
2418 if ($2 % 2 || $3 % 2)
2419 n->set_property ("force-accidental", SCM_BOOL_T);
2421 $$ = n->unprotect ();
2423 | DRUM_PITCH optional_notemode_duration {
2424 Music *n = MY_MAKE_MUSIC ("NoteEvent", @$);
2425 n->set_property ("duration", $2);
2426 n->set_property ("drum-type", $1);
2428 $$ = n->unprotect ();
2430 | RESTNAME optional_notemode_duration {
2432 if (ly_scm2string ($1) == "s") {
2434 ev = MY_MAKE_MUSIC ("SkipEvent", @$);
2437 ev = MY_MAKE_MUSIC ("RestEvent", @$);
2440 ev->set_property ("duration", $2);
2441 $$ = ev->unprotect ();
2443 | lyric_element optional_notemode_duration {
2444 if (!PARSER->lexer_->is_lyric_state ())
2445 PARSER->parser_error (@1, _ ("have to be in Lyric mode for lyrics"));
2447 Music *levent = MY_MAKE_MUSIC ("LyricEvent", @$);
2448 levent->set_property ("text", $1);
2449 levent->set_property ("duration",$2);
2450 $$= levent->unprotect ();
2454 simple_chord_elements:
2456 $$ = scm_list_1 ($1);
2459 if (!PARSER->lexer_->is_chord_state ())
2460 PARSER->parser_error (@1, _ ("have to be in Chord mode for chords"));
2463 | figure_spec optional_notemode_duration {
2464 for (SCM s = $1; scm_is_pair (s); s = scm_cdr (s))
2466 unsmob_music (scm_car (s))->set_property ("duration", $2);
2482 steno_tonic_pitch optional_notemode_duration {
2483 $$ = make_chord_elements ($1, $2, SCM_EOL);
2485 | steno_tonic_pitch optional_notemode_duration chord_separator chord_items {
2486 SCM its = scm_reverse_x ($4, SCM_EOL);
2487 $$ = make_chord_elements ($1, $2, scm_cons ($3, its));
2495 | chord_items chord_item {
2496 $$ = scm_cons ($2, $$);
2502 $$ = ly_symbol2scm ("chord-colon");
2505 $$ = ly_symbol2scm ("chord-caret");
2507 | CHORD_SLASH steno_tonic_pitch {
2508 $$ = scm_list_2 (ly_symbol2scm ("chord-slash"), $2);
2510 | CHORD_BASS steno_tonic_pitch {
2511 $$ = scm_list_2 (ly_symbol2scm ("chord-bass"), $2);
2520 $$ = scm_reverse_x ($1, SCM_EOL);
2528 step_number { $$ = scm_cons ($1, SCM_EOL); }
2529 | step_numbers '.' step_number {
2530 $$ = scm_cons ($3, $$);
2536 $$ = make_chord_step ($1, 0);
2538 | bare_unsigned '+' {
2539 $$ = make_chord_step ($1, SHARP_ALTERATION);
2541 | bare_unsigned CHORD_MINUS {
2542 $$ = make_chord_step ($1, FLAT_ALTERATION);
2548 $$ = scm_from_int ($1);
2550 | bare_unsigned '~' bare_unsigned {
2551 $$ = scm_cons (scm_from_int ($1), scm_from_int ($3));
2558 TODO: should deprecate in favor of Scheme?
2562 number_expression '+' number_term {
2563 $$ = scm_sum ($1, $3);
2565 | number_expression '-' number_term {
2566 $$ = scm_difference ($1, $3);
2575 | number_factor '*' number_factor {
2576 $$ = scm_product ($1, $3);
2578 | number_factor '/' number_factor {
2579 $$ = scm_divide ($1, $3);
2584 '-' number_factor { /* %prec UNARY_MINUS */
2585 $$ = scm_difference ($2, SCM_UNDEFINED);
2598 | NUMBER_IDENTIFIER {
2601 | REAL NUMBER_IDENTIFIER {
2602 $$ = scm_from_double (scm_to_double ($1) *scm_to_double ($2));
2604 | bare_unsigned NUMBER_IDENTIFIER {
2605 $$ = scm_from_double ($1 *scm_to_double ($2));
2612 $$ = scm_to_int ($1);
2623 | exclamations '!' { $$ ++; }
2628 | questions '?' { $$ ++; }
2632 This should be done more dynamically if possible.
2636 LYRIC_MARKUP_IDENTIFIER {
2640 { PARSER->lexer_->push_markup_state (); }
2643 PARSER->lexer_->pop_state ();
2648 MARKUPLIST_IDENTIFIER {
2652 { PARSER->lexer_->push_markup_state (); }
2655 PARSER->lexer_->pop_state ();
2664 { PARSER->lexer_->push_markup_state (); }
2667 PARSER->lexer_->pop_state ();
2673 $$ = scm_list_2 (ly_lily_module_constant ("line-markup"), $1);
2675 | markup_head_1_list simple_markup {
2676 $$ = scm_car (scm_call_2 (ly_lily_module_constant ("map-markup-command-list"), $1, scm_list_1 ($2)));
2684 MARKUPLIST_IDENTIFIER {
2687 | markup_composed_list {
2690 | markup_braced_list {
2693 | markup_command_list {
2694 $$ = scm_list_1 ($1);
2698 markup_composed_list:
2699 markup_head_1_list markup_braced_list {
2700 $$ = scm_call_2 (ly_lily_module_constant ("map-markup-command-list"), $1, $2);
2706 '{' markup_braced_list_body '}' {
2707 $$ = scm_reverse_x ($2, SCM_EOL);
2711 markup_braced_list_body:
2712 /* empty */ { $$ = SCM_EOL; }
2713 | markup_braced_list_body markup {
2714 $$ = scm_cons ($2, $1);
2716 | markup_braced_list_body markup_list {
2717 $$ = scm_reverse_x ($2, $1);
2721 markup_command_list:
2722 MARKUP_LIST_FUNCTION markup_command_list_arguments {
2723 $$ = scm_cons ($1, scm_reverse_x($2, SCM_EOL));
2727 markup_command_basic_arguments:
2728 EXPECT_MARKUP_LIST markup_command_list_arguments markup_list {
2729 $$ = scm_cons ($3, $2);
2731 | EXPECT_SCM markup_command_list_arguments embedded_scm_closed {
2732 $$ = check_scheme_arg (PARSER, @3, SCM_UNDEFINED, $3, $2, $1);
2734 | EXPECT_NO_MORE_ARGS {
2739 markup_command_list_arguments:
2740 markup_command_basic_arguments { $$ = $1; }
2741 | EXPECT_MARKUP markup_command_list_arguments markup {
2742 $$ = scm_cons ($3, $2);
2747 MARKUP_FUNCTION EXPECT_MARKUP markup_command_list_arguments {
2748 $$ = scm_cons ($1, scm_reverse_x ($3, SCM_EOL));
2753 markup_head_1_item {
2754 $$ = scm_list_1 ($1);
2756 | markup_head_1_list markup_head_1_item {
2757 $$ = scm_cons ($2, $1);
2763 $$ = make_simple_markup ($1);
2765 | MARKUP_IDENTIFIER {
2768 | LYRIC_MARKUP_IDENTIFIER {
2771 | STRING_IDENTIFIER {
2775 SCM nn = PARSER->lexer_->lookup_identifier ("pitchnames");
2776 PARSER->lexer_->push_note_state (alist_to_hashq (nn));
2777 } '{' score_body '}' {
2779 $$ = scm_list_2 (ly_lily_module_constant ("score-markup"), sc->self_scm ());
2781 PARSER->lexer_->pop_state ();
2783 | MARKUP_FUNCTION markup_command_basic_arguments {
2784 $$ = scm_cons ($1, scm_reverse_x ($2, SCM_EOL));
2789 markup_head_1_list simple_markup {
2790 SCM mapper = ly_lily_module_constant ("map-markup-command-list");
2791 $$ = scm_car (scm_call_2 (mapper, $1, scm_list_1 ($2)));
2801 Lily_parser::set_yydebug (bool x)
2807 Lily_parser::do_yyparse ()
2809 yyparse ((void*)this);
2818 It is a little strange to have this function in this file, but
2819 otherwise, we have to import music classes into the lexer.
2823 Lily_lexer::try_special_identifiers (SCM *destination, SCM sid)
2825 if (scm_is_string (sid)) {
2827 return STRING_IDENTIFIER;
2828 } else if (unsmob_book (sid)) {
2829 Book *book = unsmob_book (sid)->clone ();
2830 *destination = book->self_scm ();
2833 return BOOK_IDENTIFIER;
2834 } else if (scm_is_number (sid)) {
2836 return NUMBER_IDENTIFIER;
2837 } else if (unsmob_context_def (sid)) {
2838 Context_def *def= unsmob_context_def (sid)->clone ();
2840 *destination = def->self_scm ();
2843 return CONTEXT_DEF_IDENTIFIER;
2844 } else if (unsmob_context_mod (sid)) {
2845 *destination = unsmob_context_mod (sid)->smobbed_copy ();
2847 return CONTEXT_MOD_IDENTIFIER;
2848 } else if (unsmob_score (sid)) {
2849 Score *score = new Score (*unsmob_score (sid));
2850 *destination = score->self_scm ();
2852 score->unprotect ();
2853 return SCORE_IDENTIFIER;
2854 } else if (Music *mus = unsmob_music (sid)) {
2855 mus = mus->clone ();
2856 *destination = mus->self_scm ();
2857 unsmob_music (*destination)->
2858 set_property ("origin", make_input (last_input_));
2860 bool is_event = scm_memq (ly_symbol2scm ("event"), mus->get_property ("types"))
2864 return is_event ? EVENT_IDENTIFIER : MUSIC_IDENTIFIER;
2865 } else if (unsmob_pitch (sid)) {
2866 *destination = unsmob_pitch (sid)->smobbed_copy ();
2867 return PITCH_IDENTIFIER;
2868 } else if (unsmob_duration (sid)) {
2869 *destination = unsmob_duration (sid)->smobbed_copy ();
2870 return DURATION_IDENTIFIER;
2871 } else if (unsmob_output_def (sid)) {
2872 Output_def *p = unsmob_output_def (sid);
2875 *destination = p->self_scm ();
2877 return OUTPUT_DEF_IDENTIFIER;
2878 } else if (Text_interface::is_markup (sid)) {
2880 if (is_lyric_state ())
2881 return LYRIC_MARKUP_IDENTIFIER;
2882 return MARKUP_IDENTIFIER;
2883 } else if (Text_interface::is_markup_list (sid)) {
2885 return MARKUPLIST_IDENTIFIER;
2892 get_next_unique_context_id ()
2894 return scm_from_locale_string ("$uniqueContextId");
2899 get_next_unique_lyrics_context_id ()
2901 static int new_context_count;
2903 snprintf (s, sizeof (s)-1, "uniqueContext%d", new_context_count++);
2904 return scm_from_locale_string (s);
2907 SCM check_scheme_arg (Lily_parser *my_lily_parser, Input loc, SCM fallback,
2908 SCM arg, SCM args, SCM pred)
2910 SCM unwrap = SCM_UNDEFINED;
2911 if (scm_is_true (scm_call_1 (pred, arg)))
2912 return scm_cons (arg, args);
2913 unwrap = try_unpack_lyrics (pred, arg);
2914 if (!SCM_UNBNDP (unwrap))
2915 return scm_cons (unwrap, args);
2916 if (SCM_UNBNDP (fallback)) {
2917 args = scm_cons (SCM_BOOL_F, args);
2918 fallback = SCM_BOOL_F;
2920 args = scm_cons (loc_on_music (loc, fallback), args);
2921 fallback = SCM_CDR (scm_last_pair (args));
2923 scm_set_cdr_x (scm_last_pair (args), SCM_EOL);
2924 MAKE_SYNTAX ("argument-error", loc, scm_length (args), pred, arg);
2925 scm_set_cdr_x (scm_last_pair (args), fallback);
2929 SCM loc_on_music (Input loc, SCM arg)
2931 if (Music *m = unsmob_music (arg))
2935 return m->unprotect ();
2941 is_regular_identifier (SCM id)
2943 string str = ly_scm2string (id);
2944 char const *s = str.c_str ();
2953 v = v && isalnum (*s);
2960 make_music_with_input (SCM name, Input where)
2962 Music *m = make_music_by_name (name);
2963 m->set_spot (where);
2968 get_first_context_id (SCM type, Music *m)
2970 SCM id = m->get_property ("context-id");
2971 if (SCM_BOOL_T == scm_equal_p (m->get_property ("context-type"), type)
2972 && scm_is_string (m->get_property ("context-id"))
2973 && scm_c_string_length (id) > 0)
2981 make_simple_markup (SCM a)
2989 return t && t == 1 << intlog2 (t);
2993 set_music_properties (Music *p, SCM a)
2995 for (SCM k = a; scm_is_pair (k); k = scm_cdr (k))
2996 p->set_property (scm_caar (k), scm_cdar (k));
3001 make_chord_step (int step, Rational alter)
3004 alter += FLAT_ALTERATION;
3008 Pitch m ((step -1) / 7, (step - 1) % 7, alter);
3009 return m.smobbed_copy ();
3014 make_chord_elements (SCM pitch, SCM dur, SCM modification_list)
3016 SCM chord_ctor = ly_lily_module_constant ("construct-chord-elements");
3017 return scm_call_3 (chord_ctor, pitch, dur, modification_list);
3021 try_unpack_lyrics (SCM pred, SCM arg)
3023 if (Music *m = unsmob_music (arg))
3024 if (m->is_mus_type ("lyric-event")) {
3025 SCM text = m->get_property ("text");
3026 if (scm_is_true (scm_call_1 (pred, text)))
3029 return SCM_UNDEFINED;
3032 /* Todo: actually also use apply iso. call too ... */
3034 ly_input_procedure_p (SCM x)
3036 return ly_is_procedure (x)
3037 || (scm_is_pair (x) && ly_is_procedure (scm_car (x)));
3041 yylex (YYSTYPE *s, YYLTYPE *loc, void *v)
3043 Lily_parser *pars = (Lily_parser*) v;
3044 Lily_lexer *lex = pars->lexer_;
3046 lex->lexval_ = (void*) s;
3048 lex->prepare_for_next_token ();
3049 return lex->yylex ();