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
68 /* The above are the symbols that can start function arguments */
81 %{ // -*-Fundamental-*-
86 * The rules for who is protecting what are very shady. Uniformise
89 * There are too many lexical modes?
100 #include "context-def.hh"
101 #include "context-mod.hh"
102 #include "dimensions.hh"
103 #include "file-path.hh"
105 #include "international.hh"
106 #include "lily-guile.hh"
107 #include "lily-lexer.hh"
108 #include "lily-parser.hh"
112 #include "output-def.hh"
113 #include "paper-book.hh"
114 #include "scm-hash.hh"
116 #include "text-interface.hh"
124 Output_def *outputdef;
134 #define MY_MAKE_MUSIC(x, spot) make_music_with_input (ly_symbol2scm (x), spot)
137 - Don't use lily module, create a new module instead.
138 - delay application of the function
140 #define LOWLEVEL_MAKE_SYNTAX(proc, args) \
141 scm_apply_0 (proc, args)
142 /* Syntactic Sugar. */
143 #define MAKE_SYNTAX(name, location, ...) \
144 LOWLEVEL_MAKE_SYNTAX (ly_lily_module_constant (name), scm_list_n (PARSER->self_scm (), make_input (location), __VA_ARGS__, SCM_UNDEFINED));
146 SCM get_next_unique_context_id ();
147 SCM get_next_unique_lyrics_context_id ();
154 #define _(x) gettext (x)
158 static Music *make_music_with_input (SCM name, Input where);
159 SCM run_music_function (Lily_parser *parser, Input loc, SCM func, SCM args);
160 SCM check_scheme_arg (Lily_parser *parser, Input loc, SCM fallback,
161 SCM arg, SCM args, SCM pred);
162 SCM loc_on_music (Input loc, SCM arg);
163 SCM get_first_context_id (SCM type, Music *m);
164 SCM make_chord_elements (SCM pitch, SCM dur, SCM modification_list);
165 SCM make_chord_step (int step, Rational alter);
166 SCM make_simple_markup (SCM a);
167 bool is_duration (int t);
168 bool is_regular_identifier (SCM id);
169 bool ly_input_procedure_p (SCM x);
170 int yylex (YYSTYPE *s, YYLTYPE *loc, void *v);
171 void set_music_properties (Music *p, SCM a);
175 /* The third option is an alias that will be used to display the
176 syntax error. Bison CVS now correctly handles backslash escapes.
178 FIXME: Bison needs to translate some of these, eg, STRING.
182 /* Keyword tokens with plain escaped name. */
183 %token ACCEPTS "\\accepts"
184 %token ADDLYRICS "\\addlyrics"
185 %token ALIAS "\\alias"
186 %token ALTERNATIVE "\\alternative"
188 %token BOOKPART "\\bookpart"
189 %token CHANGE "\\change"
190 %token CHORDMODE "\\chordmode"
191 %token CHORDS "\\chords"
192 %token CONSISTS "\\consists"
193 %token CONTEXT "\\context"
194 %token DEFAULT "\\default"
195 %token DEFAULTCHILD "\\defaultchild"
196 %token DENIES "\\denies"
197 %token DESCRIPTION "\\description"
198 %token DRUMMODE "\\drummode"
199 %token DRUMS "\\drums"
200 %token FIGUREMODE "\\figuremode"
201 %token FIGURES "\\figures"
202 %token GROBDESCRIPTIONS "\\grobdescriptions"
203 %token HEADER "\\header"
204 %token INVALID "\\version-error"
206 %token LAYOUT "\\layout"
207 %token LYRICMODE "\\lyricmode"
208 %token LYRICS "\\lyrics"
209 %token LYRICSTO "\\lyricsto"
211 %token MARKUP "\\markup"
212 %token MARKUPLINES "\\markuplines"
215 %token NOTEMODE "\\notemode"
217 %token OVERRIDE "\\override"
218 %token PAPER "\\paper"
219 %token REMOVE "\\remove"
220 %token REPEAT "\\repeat"
222 %token REVERT "\\revert"
223 %token SCORE "\\score"
224 %token SEQUENTIAL "\\sequential"
226 %token SIMULTANEOUS "\\simultaneous"
227 %token TEMPO "\\tempo"
228 %token TIMES "\\times"
230 %token UNSET "\\unset"
233 /* Keyword token exceptions. */
234 %token TIME_T "\\time"
235 %token NEWCONTEXT "\\new"
238 /* Other string tokens. */
240 %token CHORD_BASS "/+"
241 %token CHORD_CARET "^"
242 %token CHORD_COLON ":"
243 %token CHORD_MINUS "-"
244 %token CHORD_SLASH "/"
245 %token ANGLE_OPEN "<"
246 %token ANGLE_CLOSE ">"
247 %token DOUBLE_ANGLE_OPEN "<<"
248 %token DOUBLE_ANGLE_CLOSE ">>"
249 %token E_BACKSLASH "\\"
250 %token E_ANGLE_CLOSE "\\>"
251 %token E_CHAR "\\C[haracter]"
253 %token E_EXCLAMATION "\\!"
254 %token E_BRACKET_OPEN "\\["
256 %token E_BRACKET_CLOSE "\\]"
257 %token E_ANGLE_OPEN "\\<"
263 If we give names, Bison complains.
265 %token FIGURE_CLOSE /* "\\>" */
266 %token FIGURE_OPEN /* "\\<" */
267 %token FIGURE_SPACE "_"
270 %token CHORDMODIFIERS
272 %token MULTI_MEASURE_REST
275 %token <i> E_UNSIGNED
278 /* Artificial tokens, for more generic function syntax */
279 %token <i> EXPECT_MARKUP "markup?"
280 %token <i> EXPECT_MUSIC "ly:music?"
281 %token <i> EXPECT_PITCH "ly:pitch?"
282 %token <i> EXPECT_DURATION "ly:duration?"
283 %token <scm> EXPECT_SCM "scheme?"
284 %token <i> EXPECT_MARKUP_LIST "markup-list?"
285 %token <scm> EXPECT_OPTIONAL "optional?"
286 /* After the last argument. */
287 %token <i> EXPECT_NO_MORE_ARGS;
289 /* An artificial token for parsing embedded Lilypond */
290 %token <i> EMBEDDED_LILY "#{"
292 %token <scm> BOOK_IDENTIFIER
293 %token <scm> CHORDMODIFIER_PITCH
294 %token <scm> CHORD_MODIFIER
295 %token <scm> CHORD_REPETITION
296 %token <scm> CONTEXT_DEF_IDENTIFIER
297 %token <scm> CONTEXT_MOD_IDENTIFIER
298 %token <scm> DRUM_PITCH
299 %token <scm> PITCH_IDENTIFIER
300 %token <scm> DURATION_IDENTIFIER
301 %token <scm> EVENT_IDENTIFIER
302 %token <scm> EVENT_FUNCTION
303 %token <scm> FRACTION
304 %token <scm> LYRICS_STRING
305 %token <scm> LYRIC_MARKUP_IDENTIFIER
306 %token <scm> MARKUP_FUNCTION
307 %token <scm> MARKUP_LIST_FUNCTION
308 %token <scm> MARKUP_IDENTIFIER
309 %token <scm> MARKUPLINES_IDENTIFIER
310 %token <scm> MUSIC_FUNCTION
311 %token <scm> MUSIC_IDENTIFIER
312 %token <scm> NOTENAME_PITCH
313 %token <scm> NUMBER_IDENTIFIER
314 %token <scm> OUTPUT_DEF_IDENTIFIER
316 %token <scm> RESTNAME
317 %token <scm> SCM_FUNCTION
318 %token <scm> SCM_IDENTIFIER
319 %token <scm> SCM_TOKEN
320 %token <scm> SCORE_IDENTIFIER
322 %token <scm> STRING_IDENTIFIER
323 %token <scm> TONICNAME_PITCH
326 %type <book> book_block
327 %type <book> book_body
328 %type <book> bookpart_block
329 %type <book> bookpart_body
331 %type <i> bare_unsigned
332 %type <scm> figured_bass_alteration
334 %type <i> exclamations
335 %type <i> optional_rest
340 %type <i> tremolo_type
343 %type <scm> composite_music
344 %type <scm> grouped_music_list
345 %type <scm> braced_music_list
346 %type <scm> closed_music
348 %type <scm> complex_music
349 %type <scm> mode_changed_music
350 %type <scm> repeated_music
351 %type <scm> sequential_music
352 %type <scm> simple_music
353 %type <scm> simultaneous_music
354 %type <scm> chord_body
355 %type <scm> chord_body_element
356 %type <scm> command_element
357 %type <scm> command_event
358 %type <scm> context_modification
359 %type <scm> context_change
360 %type <scm> direction_less_event
361 %type <scm> direction_reqd_event
362 %type <scm> embedded_lilypond
363 %type <scm> event_chord
364 %type <scm> fingering
365 %type <scm> gen_text_def
366 %type <scm> music_property_def
367 %type <scm> note_chord_element
368 %type <scm> post_event
369 %type <scm> post_event_nofinger
370 %type <scm> re_rhythmed_music
371 %type <scm> simple_element
372 %type <scm> simple_music_property_def
373 %type <scm> start_symbol
374 %type <scm> string_number_event
375 %type <scm> tempo_event
377 %type <outputdef> output_def_body
378 %type <outputdef> output_def_head
379 %type <outputdef> output_def_head_with_mode_switch
380 %type <outputdef> output_def
381 %type <outputdef> paper_block
383 %type <scm> music_function_call
384 %type <scm> music_list
385 %type <scm> assignment_id
386 %type <scm> bare_number
387 %type <scm> unsigned_number
388 %type <scm> bass_figure
389 %type <scm> figured_bass_modification
390 %type <scm> br_bass_figure
391 %type <scm> bass_number
392 %type <scm> chord_body_elements
393 %type <scm> chord_item
394 %type <scm> chord_items
395 %type <scm> chord_separator
396 %type <scm> context_def_mod
397 %type <scm> context_def_spec_block
398 %type <scm> context_def_spec_body
399 %type <scm> context_mod
400 %type <scm> context_mod_list
401 %type <scm> context_prop_spec
402 %type <scm> direction_less_char
403 %type <scm> duration_length
404 %type <scm> embedded_scm
405 %type <scm> embedded_scm_bare
406 %type <scm> embedded_scm_closed
407 %type <scm> embedded_scm_chord_body
408 %type <scm> embedded_scm_event
409 %type <scm> event_function_event
410 %type <scm> figure_list
411 %type <scm> figure_spec
413 %type <scm> full_markup
414 %type <scm> full_markup_list
415 %type <scm> function_arglist
416 %type <scm> function_arglist_optional
417 %type <scm> function_arglist_keep
418 %type <scm> function_arglist_bare
419 %type <scm> function_arglist_closed
420 %type <scm> function_arglist_closed_optional
421 %type <scm> function_arglist_closed_keep
422 %type <scm> identifier_init
424 %type <scm> lilypond_header
425 %type <scm> lilypond_header_body
426 %type <scm> lyric_element
427 %type <scm> lyric_markup
429 %type <scm> markup_braced_list
430 %type <scm> markup_braced_list_body
431 %type <scm> markup_composed_list
432 %type <scm> markup_command_list
433 %type <scm> markup_command_list_arguments
434 %type <scm> markup_command_basic_arguments
435 %type <scm> markup_head_1_item
436 %type <scm> markup_head_1_list
437 %type <scm> markup_list
438 %type <scm> markup_top
439 %type <scm> mode_changing_head
440 %type <scm> mode_changing_head_with_context
441 %type <scm> multiplied_duration
442 %type <scm> music_function_event
443 %type <scm> music_function_event_arglist
444 %type <scm> music_function_chord_body
445 %type <scm> music_function_chord_body_arglist
446 %type <scm> new_chord
447 %type <scm> new_lyrics
448 %type <scm> number_expression
449 %type <scm> number_factor
450 %type <scm> number_term
451 %type <scm> octave_check
452 %type <scm> optional_context_mod
453 %type <scm> optional_id
454 %type <scm> optional_notemode_duration
456 %type <scm> pitch_also_in_chords
457 %type <scm> post_events
458 %type <scm> property_operation
459 %type <scm> property_path property_path_revved
461 %type <scm> scalar_bare
462 %type <scm> scalar_closed
463 %type <scm> scm_function_call
464 %type <scm> scm_function_call_closed
465 %type <scm> script_abbreviation
466 %type <scm> simple_chord_elements
467 %type <scm> simple_markup
468 %type <scm> simple_string
469 %type <scm> steno_duration
470 %type <scm> steno_pitch
471 %type <scm> steno_tonic_pitch
472 %type <scm> step_number
473 %type <scm> step_numbers
475 %type <scm> tempo_range
477 %type <score> score_block
478 %type <score> score_body
483 /* We don't assign precedence to / and *, because we might need varied
484 prec levels in different prods */
493 SCM nn = PARSER->lexer_->lookup_identifier ("pitchnames");
494 PARSER->lexer_->push_note_state (alist_to_hashq (nn));
495 } embedded_lilypond {
496 PARSER->lexer_->pop_state ();
497 PARSER->lexer_->set_identifier (ly_symbol2scm ("parseStringResult"), $3);
501 lilypond: /* empty */ { }
502 | lilypond toplevel_expression {
504 | lilypond assignment {
507 PARSER->error_level_ = 1;
510 PARSER->error_level_ = 1;
517 PARSER->lexer_->set_identifier (ly_symbol2scm ("$defaultheader"), $1);
521 SCM proc = PARSER->lexer_->lookup_identifier ("toplevel-book-handler");
522 scm_call_2 (proc, PARSER->self_scm (), book->self_scm ());
527 SCM proc = PARSER->lexer_->lookup_identifier ("toplevel-bookpart-handler");
528 scm_call_2 (proc, PARSER->self_scm (), bookpart->self_scm ());
529 bookpart->unprotect ();
534 SCM proc = PARSER->lexer_->lookup_identifier ("toplevel-score-handler");
535 scm_call_2 (proc, PARSER->self_scm (), score->self_scm ());
539 Music *music = unsmob_music ($1);
540 SCM proc = PARSER->lexer_->lookup_identifier ("toplevel-music-handler");
541 scm_call_2 (proc, PARSER->self_scm (), music->self_scm ());
544 SCM proc = PARSER->lexer_->lookup_identifier ("toplevel-text-handler");
545 scm_call_2 (proc, PARSER->self_scm (), scm_list_1 ($1));
548 SCM proc = PARSER->lexer_->lookup_identifier ("toplevel-text-handler");
549 scm_call_2 (proc, PARSER->self_scm (), $1);
553 Output_def * od = $1;
555 if ($1->c_variable ("is-paper") == SCM_BOOL_T)
556 id = ly_symbol2scm ("$defaultpaper");
557 else if ($1->c_variable ("is-midi") == SCM_BOOL_T)
558 id = ly_symbol2scm ("$defaultmidi");
559 else if ($1->c_variable ("is-layout") == SCM_BOOL_T)
560 id = ly_symbol2scm ("$defaultlayout");
562 PARSER->lexer_->set_identifier (id, od->self_scm ());
572 /* The generic version may end in music, or not */
580 SCM_FUNCTION function_arglist {
581 $$ = run_music_function (PARSER, @$,
587 { $$ = MAKE_SYNTAX ("void-music", @$, SCM_UNDEFINED); }
589 | music music music_list {
590 $$ = MAKE_SYNTAX ("sequential-music", @$,
591 scm_cons2 ($1, $2, scm_reverse_x ($3, SCM_EOL)));
594 PARSER->error_level_ = 1;
596 | INVALID embedded_lilypond {
597 PARSER->error_level_ = 1;
602 lilypond_header_body:
604 $$ = get_header (PARSER);
605 PARSER->lexer_->add_scope ($$);
607 | lilypond_header_body assignment {
613 HEADER '{' lilypond_header_body '}' {
614 $$ = PARSER->lexer_->remove_scope ();
623 | LYRICS_STRING { $$ = $1; }
627 assignment_id '=' identifier_init {
628 PARSER->lexer_->set_identifier ($1, $3);
630 | assignment_id property_path '=' identifier_init {
631 SCM path = scm_cons (scm_string_to_symbol ($1), $2);
632 PARSER->lexer_->set_identifier (path, $4);
635 TODO: devise standard for protection in parser.
637 The parser stack lives on the C-stack, which means that
638 all objects can be unprotected as soon as they're here.
648 $$ = $1->self_scm ();
652 $$ = $1->self_scm ();
656 $$ = $1->self_scm ();
660 $$ = $1->self_scm ();
663 | context_def_spec_block {
667 /* Hack: Create event-chord around standalone events.
668 Prevents the identifier from being interpreted as a post-event. */
669 Music *mus = unsmob_music ($1);
670 bool is_event = mus &&
671 (scm_memq (ly_symbol2scm ("event"), mus->get_property ("types"))
676 $$ = MAKE_SYNTAX ("event-chord", @$, scm_list_1 ($1));
678 | post_event_nofinger {
681 | number_expression {
696 | context_modification {
701 context_def_spec_block:
702 CONTEXT '{' context_def_spec_body '}'
708 context_def_spec_body:
710 $$ = Context_def::make_scm ();
711 unsmob_context_def ($$)->origin ()->set_spot (@$);
713 | CONTEXT_DEF_IDENTIFIER {
715 unsmob_context_def ($$)->origin ()->set_spot (@$);
717 | context_def_spec_body GROBDESCRIPTIONS embedded_scm {
718 Context_def*td = unsmob_context_def ($$);
720 for (SCM p = $3; scm_is_pair (p); p = scm_cdr (p)) {
721 SCM tag = scm_caar (p);
723 /* TODO: should make new tag "grob-definition" ? */
724 td->add_context_mod (scm_list_3 (ly_symbol2scm ("assign"),
725 tag, scm_cons (scm_cdar (p), SCM_EOL)));
728 | context_def_spec_body context_mod {
729 unsmob_context_def ($$)->add_context_mod ($2);
731 | context_def_spec_body context_modification {
732 Context_def *td = unsmob_context_def ($$);
733 SCM new_mods = unsmob_context_mod ($2)->get_mods ();
734 for (SCM m = new_mods; scm_is_pair (m); m = scm_cdr (m)) {
735 td->add_context_mod (scm_car (m));
743 BOOK '{' book_body '}' {
746 PARSER->lexer_->set_identifier (ly_symbol2scm ("$current-book"), SCM_BOOL_F);
751 * Use 'handlers' like for toplevel-* stuff?
752 * grok \layout and \midi? */
756 init_papers (PARSER);
757 $$->origin ()->set_spot (@$);
758 $$->paper_ = dynamic_cast<Output_def*> (unsmob_output_def (PARSER->lexer_->lookup_identifier ("$defaultpaper"))->clone ());
759 $$->paper_->unprotect ();
760 push_paper (PARSER, $$->paper_);
761 $$->header_ = PARSER->lexer_->lookup_identifier ("$defaultheader");
762 PARSER->lexer_->set_identifier (ly_symbol2scm ("$current-book"), $$->self_scm ());
763 PARSER->lexer_->set_identifier (ly_symbol2scm ("book-output-suffix"), SCM_BOOL_F);
764 PARSER->lexer_->set_identifier (ly_symbol2scm ("book-filename"), SCM_BOOL_F);
767 $$ = unsmob_book ($1);
769 $$->origin ()->set_spot (@$);
770 PARSER->lexer_->set_identifier (ly_symbol2scm ("$current-book"), $1);
772 | book_body paper_block {
775 set_paper (PARSER, $2);
777 | book_body bookpart_block {
779 SCM proc = PARSER->lexer_->lookup_identifier ("book-bookpart-handler");
780 scm_call_2 (proc, $$->self_scm (), bookpart->self_scm ());
781 bookpart->unprotect ();
783 | book_body score_block {
785 SCM proc = PARSER->lexer_->lookup_identifier ("book-score-handler");
786 scm_call_2 (proc, $$->self_scm (), score->self_scm ());
789 | book_body composite_music {
790 Music *music = unsmob_music ($2);
791 SCM proc = PARSER->lexer_->lookup_identifier ("book-music-handler");
792 scm_call_3 (proc, PARSER->self_scm (), $$->self_scm (), music->self_scm ());
794 | book_body full_markup {
795 SCM proc = PARSER->lexer_->lookup_identifier ("book-text-handler");
796 scm_call_2 (proc, $$->self_scm (), scm_list_1 ($2));
798 | book_body full_markup_list {
799 SCM proc = PARSER->lexer_->lookup_identifier ("book-text-handler");
800 scm_call_2 (proc, $$->self_scm (), $2);
802 | book_body lilypond_header {
805 | book_body embedded_scm { }
808 $$->scores_ = SCM_EOL;
809 $$->bookparts_ = SCM_EOL;
814 BOOKPART '{' bookpart_body '}' {
816 PARSER->lexer_->set_identifier (ly_symbol2scm ("$current-bookpart"), SCM_BOOL_F);
823 $$->origin ()->set_spot (@$);
824 PARSER->lexer_->set_identifier (ly_symbol2scm ("$current-bookpart"), $$->self_scm ());
827 $$ = unsmob_book ($1);
829 $$->origin ()->set_spot (@$);
830 PARSER->lexer_->set_identifier (ly_symbol2scm ("$current-bookpart"), $1);
832 | bookpart_body paper_block {
836 | bookpart_body score_block {
838 SCM proc = PARSER->lexer_->lookup_identifier ("bookpart-score-handler");
839 scm_call_2 (proc, $$->self_scm (), score->self_scm ());
842 | bookpart_body composite_music {
843 Music *music = unsmob_music ($2);
844 SCM proc = PARSER->lexer_->lookup_identifier ("bookpart-music-handler");
845 scm_call_3 (proc, PARSER->self_scm (), $$->self_scm (), music->self_scm ());
847 | bookpart_body full_markup {
848 SCM proc = PARSER->lexer_->lookup_identifier ("bookpart-text-handler");
849 scm_call_2 (proc, $$->self_scm (), scm_list_1 ($2));
851 | bookpart_body full_markup_list {
852 SCM proc = PARSER->lexer_->lookup_identifier ("bookpart-text-handler");
853 scm_call_2 (proc, $$->self_scm (), $2);
855 | bookpart_body lilypond_header {
858 | bookpart_body embedded_scm { }
859 | bookpart_body error {
861 $$->scores_ = SCM_EOL;
866 SCORE '{' score_body '}' {
874 SCM scorify = ly_lily_module_constant ("scorify-music");
875 SCM score = scm_call_2 (scorify, m, PARSER->self_scm ());
877 // pass ownernship to C++ again.
878 $$ = unsmob_score (score);
880 $$->origin ()->set_spot (@$);
883 $$ = unsmob_score ($1);
885 $$->origin ()->set_spot (@$);
887 | score_body lilypond_header {
890 | score_body output_def {
891 if ($2->lookup_variable (ly_symbol2scm ("is-paper")) == SCM_BOOL_T)
893 PARSER->parser_error (@2, _("\\paper cannot be used in \\score, use \\layout instead"));
898 $$->add_output_def ($2);
903 $$->error_found_ = true;
915 if ($$->lookup_variable (ly_symbol2scm ("is-paper")) != SCM_BOOL_T)
917 PARSER->parser_error (@1, _ ("need \\paper for paper block"));
919 $$ = get_paper (PARSER);
926 output_def_body '}' {
929 PARSER->lexer_->remove_scope ();
930 PARSER->lexer_->pop_state ();
936 $$ = get_paper (PARSER);
937 $$->input_origin_ = @$;
938 PARSER->lexer_->add_scope ($$->scope_);
941 Output_def *p = get_midi (PARSER);
943 PARSER->lexer_->add_scope (p->scope_);
946 Output_def *p = get_layout (PARSER);
948 PARSER->lexer_->add_scope (p->scope_);
953 output_def_head_with_mode_switch:
955 PARSER->lexer_->push_initial_state ();
961 output_def_head_with_mode_switch '{' {
963 $$->input_origin_.set_spot (@$);
965 | output_def_head_with_mode_switch '{' OUTPUT_DEF_IDENTIFIER {
968 Output_def *o = unsmob_output_def ($3);
969 o->input_origin_.set_spot (@$);
972 PARSER->lexer_->remove_scope ();
973 PARSER->lexer_->add_scope (o->scope_);
975 | output_def_body assignment {
978 | output_def_body context_def_spec_block {
979 assign_context_def ($$, $2);
981 | output_def_body error {
987 TEMPO steno_duration '=' tempo_range {
988 $$ = MAKE_SYNTAX ("tempo", @$, SCM_EOL, $2, $4);
990 | TEMPO scalar_closed steno_duration '=' tempo_range {
991 $$ = MAKE_SYNTAX ("tempo", @$, $2, $3, $5);
994 $$ = MAKE_SYNTAX ("tempo", @$, $2);
999 The representation of a list is reversed to have efficient append. */
1005 | music_list music {
1006 $$ = scm_cons ($2, $1);
1008 | music_list embedded_scm {
1011 | music_list error {
1012 Music *m = MY_MAKE_MUSIC("Music", @$);
1014 m->set_property ("error-found", SCM_BOOL_T);
1015 $$ = scm_cons (m->self_scm (), $1);
1016 m->unprotect (); /* UGH */
1023 $$ = scm_reverse_x ($2, SCM_EOL);
1034 REPEAT simple_string unsigned_number music
1036 $$ = MAKE_SYNTAX ("repeat", @$, $2, $3, $4, SCM_EOL);
1038 | REPEAT simple_string unsigned_number music ALTERNATIVE braced_music_list
1040 $$ = MAKE_SYNTAX ("repeat", @$, $2, $3, $4, $6);
1045 SEQUENTIAL braced_music_list {
1046 $$ = MAKE_SYNTAX ("sequential-music", @$, $2);
1048 | braced_music_list {
1049 $$ = MAKE_SYNTAX ("sequential-music", @$, $1);
1054 SIMULTANEOUS braced_music_list {
1055 $$ = MAKE_SYNTAX ("simultaneous-music", @$, $2);
1057 | DOUBLE_ANGLE_OPEN music_list DOUBLE_ANGLE_CLOSE {
1058 $$ = MAKE_SYNTAX ("simultaneous-music", @$, scm_reverse_x ($2, SCM_EOL));
1064 | music_property_def
1068 context_modification:
1069 WITH { PARSER->lexer_->push_initial_state (); } '{' context_mod_list '}'
1071 PARSER->lexer_->pop_state ();
1074 | WITH CONTEXT_MOD_IDENTIFIER
1078 | CONTEXT_MOD_IDENTIFIER
1084 optional_context_mod:
1088 | context_modification
1096 $$ = Context_mod ().smobbed_copy ();
1098 | context_mod_list context_mod {
1099 unsmob_context_mod ($1)->add_context_mod ($2);
1101 | context_mod_list CONTEXT_MOD_IDENTIFIER {
1102 Context_mod *md = unsmob_context_mod ($2);
1104 unsmob_context_mod ($1)->add_context_mods (md->get_mods ());
1113 /* Music that can't be followed by additional events or durations */
1117 | grouped_music_list
1121 simultaneous_music { $$ = $1; }
1122 | sequential_music { $$ = $1; }
1125 /* An argument list. If a function \foo expects scm scm music, then the lexer expands \foo into the token sequence:
1126 MUSIC_FUNCTION EXPECT_MUSIC EXPECT_SCM EXPECT_SCM EXPECT_NO_MORE_ARGS
1127 and this rule returns the reversed list of arguments. */
1131 function_arglist_bare
1132 | EXPECT_MUSIC function_arglist_optional music
1134 $$ = scm_cons ($3, $2);
1136 | EXPECT_SCM function_arglist_optional embedded_scm
1138 $$ = check_scheme_arg (PARSER, @3, SCM_UNDEFINED, $3, $2, $1);
1142 function_arglist_optional:
1143 function_arglist_keep %prec FUNCTION_ARGUMENTS
1144 | EXPECT_OPTIONAL EXPECT_MUSIC function_arglist_optional
1146 $$ = scm_cons (loc_on_music (@3, $1), $3);
1148 | EXPECT_OPTIONAL EXPECT_PITCH function_arglist_optional
1150 $$ = scm_cons ($1, $3);
1152 | EXPECT_OPTIONAL EXPECT_DURATION function_arglist_optional
1154 $$ = scm_cons ($1, $3);
1156 | EXPECT_OPTIONAL EXPECT_MARKUP function_arglist_optional
1158 $$ = scm_cons ($1, $3);
1160 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_optional
1162 $$ = scm_cons (loc_on_music (@3, $1), $3);
1166 function_arglist_keep:
1167 EXPECT_OPTIONAL EXPECT_MARKUP function_arglist_keep full_markup {
1168 $$ = scm_cons ($4, $3);
1170 | EXPECT_OPTIONAL EXPECT_MARKUP function_arglist_keep simple_string {
1171 $$ = scm_cons ($4, $3);
1173 | EXPECT_OPTIONAL EXPECT_PITCH function_arglist_keep pitch_also_in_chords {
1174 $$ = scm_cons ($4, $3);
1176 | EXPECT_OPTIONAL EXPECT_DURATION function_arglist_closed_keep duration_length {
1177 $$ = scm_cons ($4, $3);
1179 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_keep simple_string
1181 $$ = check_scheme_arg (PARSER, @4, $1, $4, $3, $2);
1183 | EXPECT_OPTIONAL EXPECT_MUSIC function_arglist_keep closed_music
1185 $$ = scm_cons ($4, $3);
1187 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_keep embedded_scm
1189 $$ = check_scheme_arg (PARSER, @4, $1, $4, $3, $2);
1195 function_arglist_closed:
1196 function_arglist_bare
1197 | EXPECT_MUSIC function_arglist_optional closed_music
1199 $$ = scm_cons ($3, $2);
1201 | EXPECT_SCM function_arglist_optional embedded_scm_closed
1203 $$ = check_scheme_arg (PARSER, @3, SCM_UNDEFINED, $3, $2, $1);
1207 function_arglist_closed_optional:
1208 function_arglist_closed_keep %prec FUNCTION_ARGUMENTS
1209 | EXPECT_OPTIONAL EXPECT_MUSIC function_arglist_closed_optional
1211 $$ = scm_cons (loc_on_music (@3, $1), $3);
1213 | EXPECT_OPTIONAL EXPECT_PITCH function_arglist_closed_optional
1215 $$ = scm_cons ($1, $3);
1217 | EXPECT_OPTIONAL EXPECT_DURATION function_arglist_closed_optional
1219 $$ = scm_cons ($1, $3);
1221 | EXPECT_OPTIONAL EXPECT_MARKUP function_arglist_closed_optional
1223 $$ = scm_cons ($1, $3);
1225 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_closed_optional
1227 $$ = scm_cons (loc_on_music (@3, $1), $3);
1231 function_arglist_closed_keep:
1232 EXPECT_OPTIONAL EXPECT_MARKUP function_arglist_keep full_markup {
1233 $$ = scm_cons ($4, $3);
1235 | EXPECT_OPTIONAL EXPECT_MARKUP function_arglist_keep simple_string {
1236 $$ = scm_cons ($4, $3);
1238 | EXPECT_OPTIONAL EXPECT_PITCH function_arglist_keep pitch_also_in_chords {
1239 $$ = scm_cons ($4, $3);
1241 | EXPECT_OPTIONAL EXPECT_DURATION function_arglist_closed_keep duration_length {
1242 $$ = scm_cons ($4, $3);
1244 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_keep simple_string
1246 $$ = check_scheme_arg (PARSER, @4, $1, $4, $3, $2);
1248 | EXPECT_OPTIONAL EXPECT_MUSIC function_arglist_keep closed_music
1250 $$ = scm_cons ($4, $3);
1252 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_keep embedded_scm_closed
1254 $$ = check_scheme_arg (PARSER, @4, $1, $4, $3, $2);
1256 | function_arglist_closed
1259 embedded_scm_closed:
1261 | scm_function_call_closed
1264 scm_function_call_closed:
1265 SCM_FUNCTION function_arglist_closed {
1266 $$ = run_music_function (PARSER, @$,
1271 function_arglist_bare:
1272 EXPECT_NO_MORE_ARGS {
1275 | EXPECT_MARKUP function_arglist_optional full_markup {
1276 $$ = scm_cons ($3, $2);
1278 | EXPECT_MARKUP function_arglist_optional simple_string {
1279 $$ = scm_cons ($3, $2);
1281 | EXPECT_PITCH function_arglist_optional pitch_also_in_chords {
1282 $$ = scm_cons ($3, $2);
1284 | EXPECT_DURATION function_arglist_closed_optional duration_length {
1285 $$ = scm_cons ($3, $2);
1287 | EXPECT_SCM function_arglist_optional simple_string {
1288 $$ = check_scheme_arg (PARSER, @3, SCM_UNDEFINED, $3, $2, $1);
1292 music_function_call:
1293 MUSIC_FUNCTION function_arglist {
1294 $$ = run_music_function (PARSER, @$,
1301 /**/ { $$ = SCM_EOL; }
1302 | '=' simple_string {
1309 | CONTEXT simple_string optional_id optional_context_mod music {
1310 Context_mod *ctxmod = unsmob_context_mod ($4);
1313 mods = ctxmod->get_mods ();
1314 $$ = MAKE_SYNTAX ("context-specification", @$, $2, $3, $5, mods, SCM_BOOL_F);
1316 | NEWCONTEXT simple_string optional_id optional_context_mod music {
1317 Context_mod *ctxmod = unsmob_context_mod ($4);
1320 mods = ctxmod->get_mods ();
1321 $$ = MAKE_SYNTAX ("context-specification", @$, $2, $3, $5, mods, SCM_BOOL_T);
1324 | TIMES fraction music {
1325 $$ = MAKE_SYNTAX ("time-scaled-music", @$, $2, $3);
1327 | repeated_music { $$ = $1; }
1328 | re_rhythmed_music { $$ = $1; }
1332 mode_changing_head grouped_music_list {
1333 if ($1 == ly_symbol2scm ("chords"))
1335 $$ = MAKE_SYNTAX ("unrelativable-music", @$, $2);
1341 PARSER->lexer_->pop_state ();
1343 | mode_changing_head_with_context optional_context_mod grouped_music_list {
1344 Context_mod *ctxmod = unsmob_context_mod ($2);
1347 mods = ctxmod->get_mods ();
1348 $$ = MAKE_SYNTAX ("context-specification", @$, $1, SCM_EOL, $3, mods, SCM_BOOL_T);
1349 if ($1 == ly_symbol2scm ("ChordNames"))
1351 $$ = MAKE_SYNTAX ("unrelativable-music", @$, $$);
1353 PARSER->lexer_->pop_state ();
1359 SCM nn = PARSER->lexer_->lookup_identifier ("pitchnames");
1360 PARSER->lexer_->push_note_state (alist_to_hashq (nn));
1362 $$ = ly_symbol2scm ("notes");
1366 SCM nn = PARSER->lexer_->lookup_identifier ("drumPitchNames");
1367 PARSER->lexer_->push_note_state (alist_to_hashq (nn));
1369 $$ = ly_symbol2scm ("drums");
1372 PARSER->lexer_->push_figuredbass_state ();
1374 $$ = ly_symbol2scm ("figures");
1377 SCM nn = PARSER->lexer_->lookup_identifier ("chordmodifiers");
1378 PARSER->lexer_->chordmodifier_tab_ = alist_to_hashq (nn);
1379 nn = PARSER->lexer_->lookup_identifier ("pitchnames");
1380 PARSER->lexer_->push_chord_state (alist_to_hashq (nn));
1381 $$ = ly_symbol2scm ("chords");
1385 { PARSER->lexer_->push_lyric_state ();
1386 $$ = ly_symbol2scm ("lyrics");
1390 mode_changing_head_with_context:
1392 SCM nn = PARSER->lexer_->lookup_identifier ("drumPitchNames");
1393 PARSER->lexer_->push_note_state (alist_to_hashq (nn));
1395 $$ = ly_symbol2scm ("DrumStaff");
1398 PARSER->lexer_->push_figuredbass_state ();
1400 $$ = ly_symbol2scm ("FiguredBass");
1403 SCM nn = PARSER->lexer_->lookup_identifier ("chordmodifiers");
1404 PARSER->lexer_->chordmodifier_tab_ = alist_to_hashq (nn);
1405 nn = PARSER->lexer_->lookup_identifier ("pitchnames");
1406 PARSER->lexer_->push_chord_state (alist_to_hashq (nn));
1407 $$ = ly_symbol2scm ("ChordNames");
1410 { PARSER->lexer_->push_lyric_state ();
1411 $$ = ly_symbol2scm ("Lyrics");
1416 ADDLYRICS { PARSER->lexer_->push_lyric_state (); }
1419 /* Can also use music at the expensive of two S/Rs similar to
1420 \repeat \alternative */
1421 PARSER->lexer_->pop_state ();
1423 $$ = scm_cons ($3, SCM_EOL);
1425 | new_lyrics ADDLYRICS {
1426 PARSER->lexer_->push_lyric_state ();
1428 PARSER->lexer_->pop_state ();
1429 $$ = scm_cons ($4, $1);
1434 closed_music new_lyrics {
1435 $$ = MAKE_SYNTAX ("add-lyrics", @$, $1, scm_reverse_x ($2, SCM_EOL));
1437 | LYRICSTO simple_string {
1438 PARSER->lexer_->push_lyric_state ();
1440 PARSER->lexer_->pop_state ();
1441 $$ = MAKE_SYNTAX ("lyric-combine", @$, $2, $4);
1446 CHANGE STRING '=' STRING {
1447 $$ = MAKE_SYNTAX ("context-change", @$, scm_string_to_symbol ($2), $4);
1452 property_path_revved:
1453 embedded_scm_closed {
1454 $$ = scm_cons ($1, SCM_EOL);
1456 | property_path_revved embedded_scm_closed {
1457 $$ = scm_cons ($2, $1);
1462 property_path_revved {
1463 $$ = scm_reverse_x ($1, SCM_EOL);
1469 $$ = scm_list_3 (ly_symbol2scm ("assign"),
1470 scm_string_to_symbol ($1), $3);
1472 | UNSET simple_string {
1473 $$ = scm_list_2 (ly_symbol2scm ("unset"),
1474 scm_string_to_symbol ($2));
1476 | OVERRIDE simple_string property_path '=' scalar {
1477 $$ = scm_append (scm_list_2 (scm_list_3 (ly_symbol2scm ("push"),
1478 scm_string_to_symbol ($2), $5),
1481 | REVERT simple_string embedded_scm {
1482 $$ = scm_list_3 (ly_symbol2scm ("pop"),
1483 scm_string_to_symbol ($2), $3);
1488 CONSISTS { $$ = ly_symbol2scm ("consists"); }
1489 | REMOVE { $$ = ly_symbol2scm ("remove"); }
1491 | ACCEPTS { $$ = ly_symbol2scm ("accepts"); }
1492 | DEFAULTCHILD { $$ = ly_symbol2scm ("default-child"); }
1493 | DENIES { $$ = ly_symbol2scm ("denies"); }
1495 | ALIAS { $$ = ly_symbol2scm ("alias"); }
1496 | TYPE { $$ = ly_symbol2scm ("translator-type"); }
1497 | DESCRIPTION { $$ = ly_symbol2scm ("description"); }
1498 | NAME { $$ = ly_symbol2scm ("context-name"); }
1502 property_operation { $$ = $1; }
1503 | context_def_mod STRING {
1504 $$ = scm_list_2 ($1, $2);
1506 | context_def_mod embedded_scm {
1507 if (ly_symbol2scm ("consists") != $1)
1510 PARSER->parser_error (@1, _ ("only \\consists takes non-string argument."));
1514 $$ = scm_list_2 ($1, $2);
1521 if (!is_regular_identifier ($1))
1523 @$.error (_("Grob name should be alphanumeric"));
1526 $$ = scm_list_2 (ly_symbol2scm ("Bottom"),
1527 scm_string_to_symbol ($1));
1529 | simple_string '.' simple_string {
1530 $$ = scm_list_2 (scm_string_to_symbol ($1),
1531 scm_string_to_symbol ($3));
1535 simple_music_property_def:
1536 OVERRIDE context_prop_spec property_path '=' scalar {
1537 $$ = scm_append (scm_list_2 (scm_list_n (scm_car ($2),
1538 ly_symbol2scm ("OverrideProperty"),
1543 | REVERT context_prop_spec embedded_scm {
1544 $$ = scm_list_4 (scm_car ($2),
1545 ly_symbol2scm ("RevertProperty"),
1549 | SET context_prop_spec '=' scalar {
1550 $$ = scm_list_4 (scm_car ($2),
1551 ly_symbol2scm ("PropertySet"),
1555 | UNSET context_prop_spec {
1556 $$ = scm_list_3 (scm_car ($2),
1557 ly_symbol2scm ("PropertyUnset"),
1563 simple_music_property_def {
1564 $$ = LOWLEVEL_MAKE_SYNTAX (ly_lily_module_constant ("property-operation"), scm_cons (PARSER->self_scm (), scm_cons2 (make_input (@$), SCM_BOOL_F, $1)));
1566 | ONCE simple_music_property_def {
1567 $$ = LOWLEVEL_MAKE_SYNTAX (ly_lily_module_constant ("property-operation"), scm_cons (PARSER->self_scm (), scm_cons2 (make_input (@$), SCM_BOOL_T, $2)));
1575 | STRING_IDENTIFIER {
1578 | string '+' string {
1579 $$ = scm_string_append (scm_list_2 ($1, $3));
1583 simple_string: STRING {
1589 | STRING_IDENTIFIER {
1604 | embedded_scm_bare {
1619 scm_function_call_closed
1624 /* TODO: Create a special case that avoids the creation of
1625 EventChords around simple_elements that have no post_events?
1627 simple_chord_elements post_events {
1628 SCM elts = ly_append2 ($1, scm_reverse_x ($2, SCM_EOL));
1631 /* why is this giving wrong start location? -ns
1633 i.set_location (@1, @2);
1634 $$ = MAKE_SYNTAX ("event-chord", i, elts);
1636 | CHORD_REPETITION optional_notemode_duration post_events {
1638 i.set_location (@1, @3);
1639 $$ = MAKE_SYNTAX ("repetition-chord", i,
1640 PARSER->lexer_->chord_repetition_.last_chord_,
1641 PARSER->lexer_->chord_repetition_.repetition_function_,
1642 $2, scm_reverse_x ($3, SCM_EOL));
1644 | MULTI_MEASURE_REST optional_notemode_duration post_events {
1646 i.set_location (@1, @3);
1647 $$ = MAKE_SYNTAX ("multi-measure-rest", i, $2,
1648 scm_reverse_x ($3, SCM_EOL));
1651 /* note chord elements are memorized into
1652 PARSER->lexer_->chord_repetition_ so that the chord repetition
1653 mechanism copy them when a chord repetition symbol is found
1655 | note_chord_element {
1656 PARSER->lexer_->chord_repetition_.last_chord_ = $$;
1662 chord_body optional_notemode_duration post_events
1664 Music *m = unsmob_music ($1);
1665 SCM dur = unsmob_duration ($2)->smobbed_copy ();
1666 SCM es = m->get_property ("elements");
1667 SCM postevs = scm_reverse_x ($3, SCM_EOL);
1669 for (SCM s = es; scm_is_pair (s); s = scm_cdr (s))
1670 unsmob_music (scm_car (s))->set_property ("duration", dur);
1671 es = ly_append2 (es, postevs);
1673 m-> set_property ("elements", es);
1675 $$ = m->self_scm ();
1680 ANGLE_OPEN chord_body_elements ANGLE_CLOSE
1682 $$ = MAKE_SYNTAX ("event-chord", @$, scm_reverse_x ($2, SCM_EOL));
1686 chord_body_elements:
1687 /* empty */ { $$ = SCM_EOL; }
1688 | chord_body_elements chord_body_element {
1689 $$ = scm_cons ($2, $1);
1694 pitch exclamations questions octave_check post_events
1701 Music *n = MY_MAKE_MUSIC ("NoteEvent", @$);
1702 n->set_property ("pitch", $1);
1704 n->set_property ("cautionary", SCM_BOOL_T);
1705 if (ex % 2 || q % 2)
1706 n->set_property ("force-accidental", SCM_BOOL_T);
1708 if (scm_is_pair (post)) {
1709 SCM arts = scm_reverse_x (post, SCM_EOL);
1710 n->set_property ("articulations", arts);
1712 if (scm_is_number (check))
1714 int q = scm_to_int (check);
1715 n->set_property ("absolute-octave", scm_from_int (q-1));
1718 $$ = n->unprotect ();
1720 | DRUM_PITCH post_events {
1721 Music *n = MY_MAKE_MUSIC ("NoteEvent", @$);
1722 n->set_property ("drum-type", $1);
1724 if (scm_is_pair ($2)) {
1725 SCM arts = scm_reverse_x ($2, SCM_EOL);
1726 n->set_property ("articulations", arts);
1728 $$ = n->unprotect ();
1730 | music_function_chord_body
1733 /* We can't accept a music argument, not even a closed one,
1734 * immediately before chord_body_elements, otherwise a function \fun
1735 * with a signature of two music arguments can't be sorted out
1736 * properly in a construct like
1737 * <\fun { c } \fun { c } c>
1738 * The second call could be interpreted either as a chord constituent
1739 * or a music expression.
1742 music_function_chord_body_arglist:
1743 function_arglist_bare
1744 | EXPECT_MUSIC music_function_chord_body_arglist chord_body_element {
1745 $$ = scm_cons ($3, $2);
1747 | EXPECT_SCM function_arglist_optional embedded_scm_chord_body {
1748 $$ = check_scheme_arg (PARSER, @3, SCM_UNDEFINED, $3, $2, $1);
1752 embedded_scm_chord_body:
1754 | SCM_FUNCTION music_function_chord_body_arglist {
1755 $$ = run_music_function (PARSER, @$,
1760 music_function_chord_body:
1761 MUSIC_FUNCTION music_function_chord_body_arglist {
1762 $$ = run_music_function (PARSER, @$,
1767 /* We could accept a closed music argument before the post events
1768 * indicated by a trailing argument list. For symmetry with chord
1769 * bodies and in order to avoid too tricky and complex behavior, we
1770 * refrain from doing so.
1772 music_function_event_arglist:
1773 function_arglist_bare
1774 | EXPECT_MUSIC music_function_event_arglist post_event {
1775 $$ = scm_cons ($3, $2);
1777 | EXPECT_SCM function_arglist_optional embedded_scm_event {
1778 $$ = check_scheme_arg (PARSER, @3, SCM_UNDEFINED, $3, $2, $1);
1784 | SCM_FUNCTION music_function_event_arglist {
1785 $$ = run_music_function (PARSER, @$,
1790 music_function_event:
1791 MUSIC_FUNCTION music_function_event_arglist {
1792 $$ = run_music_function (PARSER, @$,
1797 event_function_event:
1798 EVENT_FUNCTION music_function_event_arglist {
1799 $$ = run_music_function (PARSER, @$,
1809 Music *m = MY_MAKE_MUSIC ("LigatureEvent", @$);
1810 m->set_property ("span-direction", scm_from_int (START));
1811 $$ = m->unprotect();
1814 Music *m = MY_MAKE_MUSIC ("LigatureEvent", @$);
1815 m->set_property ("span-direction", scm_from_int (STOP));
1816 $$ = m->unprotect ();
1819 $$ = MAKE_SYNTAX ("voice-separator", @$, SCM_UNDEFINED);
1822 SCM pipe = PARSER->lexer_->lookup_identifier ("pipeSymbol");
1824 Music *m = unsmob_music (pipe);
1829 $$ = m->unprotect ();
1832 $$ = MAKE_SYNTAX ("bar-check", @$, SCM_UNDEFINED);
1836 SCM proc = ly_lily_module_constant ("make-time-signature-set");
1838 $$ = scm_apply_2 (proc, scm_car ($2), scm_cdr ($2), SCM_EOL);
1841 $$ = MAKE_SYNTAX ("make-mark-set", @$, $2);
1847 $$ = MY_MAKE_MUSIC ("PesOrFlexaEvent", @$)->unprotect ();
1850 Music *m = MY_MAKE_MUSIC ("MarkEvent", @$);
1851 $$ = m->unprotect ();
1857 Music *key = MY_MAKE_MUSIC ("KeyChangeEvent", @$);
1858 $$ = key->unprotect ();
1860 | KEY NOTENAME_PITCH SCM_IDENTIFIER {
1862 Music *key = MY_MAKE_MUSIC ("KeyChangeEvent", @$);
1863 if (scm_ilength ($3) > 0)
1865 key->set_property ("pitch-alist", $3);
1866 key->set_property ("tonic", Pitch (0, 0, 0).smobbed_copy ());
1867 key->transpose (* unsmob_pitch ($2));
1869 PARSER->parser_error (@3, _ ("second argument must be pitch list"));
1872 $$ = key->unprotect ();
1881 | post_events post_event {
1882 unsmob_music ($2)->set_spot (@2);
1883 $$ = scm_cons ($2, $$);
1887 post_event_nofinger:
1888 direction_less_event {
1891 | script_dir music_function_event {
1895 unsmob_music ($$)->set_property ("direction", scm_from_int ($1));
1899 if (!PARSER->lexer_->is_lyric_state ())
1900 PARSER->parser_error (@1, _ ("have to be in Lyric mode for lyrics"));
1901 $$ = MY_MAKE_MUSIC ("HyphenEvent", @$)->unprotect ();
1904 if (!PARSER->lexer_->is_lyric_state ())
1905 PARSER->parser_error (@1, _ ("have to be in Lyric mode for lyrics"));
1906 $$ = MY_MAKE_MUSIC ("ExtenderEvent", @$)->unprotect ();
1908 | script_dir direction_reqd_event {
1911 Music *m = unsmob_music ($2);
1912 m->set_property ("direction", scm_from_int ($1));
1916 | script_dir direction_less_event {
1919 Music *m = unsmob_music ($2);
1920 m->set_property ("direction", scm_from_int ($1));
1924 | string_number_event
1929 | script_dir fingering {
1932 Music *m = unsmob_music ($2);
1933 m->set_property ("direction", scm_from_int ($1));
1939 string_number_event:
1941 Music *s = MY_MAKE_MUSIC ("StringNumberEvent", @$);
1942 s->set_property ("string-number", scm_from_int ($1));
1943 $$ = s->unprotect ();
1947 direction_less_char:
1949 $$ = ly_symbol2scm ("bracketOpenSymbol");
1952 $$ = ly_symbol2scm ("bracketCloseSymbol");
1955 $$ = ly_symbol2scm ("tildeSymbol");
1958 $$ = ly_symbol2scm ("parenthesisOpenSymbol");
1961 $$ = ly_symbol2scm ("parenthesisCloseSymbol");
1964 $$ = ly_symbol2scm ("escapedExclamationSymbol");
1967 $$ = ly_symbol2scm ("escapedParenthesisOpenSymbol");
1970 $$ = ly_symbol2scm ("escapedParenthesisCloseSymbol");
1973 $$ = ly_symbol2scm ("escapedBiggerSymbol");
1976 $$ = ly_symbol2scm ("escapedSmallerSymbol");
1980 direction_less_event:
1981 direction_less_char {
1982 SCM predefd = PARSER->lexer_->lookup_identifier_symbol ($1);
1984 if (unsmob_music (predefd))
1986 m = unsmob_music (predefd)->clone ();
1991 m = MY_MAKE_MUSIC ("Music", @$);
1993 $$ = m->unprotect ();
1995 | EVENT_IDENTIFIER {
1999 Music *a = MY_MAKE_MUSIC ("TremoloEvent", @$);
2000 a->set_property ("tremolo-type", scm_from_int ($1));
2001 $$ = a->unprotect ();
2003 | event_function_event
2006 direction_reqd_event:
2010 | script_abbreviation {
2011 SCM s = PARSER->lexer_->lookup_identifier ("dash" + ly_scm2string ($1));
2012 Music *a = MY_MAKE_MUSIC ("ArticulationEvent", @$);
2013 if (scm_is_string (s))
2014 a->set_property ("articulation-type", s);
2015 else PARSER->parser_error (@1, _ ("expecting string as script definition"));
2016 $$ = a->unprotect ();
2021 /**/ { $$ = SCM_EOL; }
2022 | '=' { $$ = scm_from_int (0); }
2023 | '=' sub_quotes { $$ = scm_from_int (-$2); }
2024 | '=' sup_quotes { $$ = scm_from_int ($2); }
2049 | NOTENAME_PITCH sup_quotes {
2050 Pitch p = *unsmob_pitch ($1);
2051 p = p.transposed (Pitch ($2,0,0));
2052 $$ = p.smobbed_copy ();
2054 | NOTENAME_PITCH sub_quotes {
2055 Pitch p =* unsmob_pitch ($1);
2056 p = p.transposed (Pitch (-$2,0,0));
2057 $$ = p.smobbed_copy ();
2069 | TONICNAME_PITCH sup_quotes {
2070 Pitch p = *unsmob_pitch ($1);
2071 p = p.transposed (Pitch ($2,0,0));
2072 $$ = p.smobbed_copy ();
2074 | TONICNAME_PITCH sub_quotes {
2075 Pitch p = *unsmob_pitch ($1);
2077 p = p.transposed (Pitch (-$2,0,0));
2078 $$ = p.smobbed_copy ();
2089 pitch_also_in_chords:
2096 Music *t = MY_MAKE_MUSIC ("TextScriptEvent", @$);
2097 t->set_property ("text", $1);
2098 $$ = t->unprotect ();
2101 Music *t = MY_MAKE_MUSIC ("TextScriptEvent", @$);
2102 t->set_property ("text",
2103 make_simple_markup ($1));
2104 $$ = t->unprotect ();
2110 Music *t = MY_MAKE_MUSIC ("FingeringEvent", @$);
2111 t->set_property ("digit", scm_from_int ($1));
2112 $$ = t->unprotect ();
2116 script_abbreviation:
2118 $$ = scm_from_locale_string ("Hat");
2121 $$ = scm_from_locale_string ("Plus");
2124 $$ = scm_from_locale_string ("Dash");
2127 $$ = scm_from_locale_string ("Bar");
2130 $$ = scm_from_locale_string ("Larger");
2133 $$ = scm_from_locale_string ("Dot");
2136 $$ = scm_from_locale_string ("Underscore");
2143 | '-' { $$ = CENTER; }
2147 multiplied_duration {
2152 optional_notemode_duration:
2154 Duration dd = PARSER->default_duration_;
2155 $$ = dd.smobbed_copy ();
2157 | multiplied_duration {
2159 PARSER->default_duration_ = *unsmob_duration ($$);
2164 bare_unsigned dots {
2166 if (!is_duration ($1))
2167 PARSER->parser_error (@1, _f ("not a duration: %d", $1));
2171 $$ = Duration (len, $2).smobbed_copy ();
2173 | DURATION_IDENTIFIER dots {
2174 Duration *d = unsmob_duration ($1);
2175 Duration k (d->duration_log (), d->dot_count () + $2);
2176 k = k.compressed (d->factor ());
2182 multiplied_duration:
2186 | multiplied_duration '*' bare_unsigned {
2187 $$ = unsmob_duration ($$)->compressed ( $3) .smobbed_copy ();
2189 | multiplied_duration '*' FRACTION {
2190 Rational m (scm_to_int (scm_car ($3)), scm_to_int (scm_cdr ($3)));
2192 $$ = unsmob_duration ($$)->compressed (m).smobbed_copy ();
2197 FRACTION { $$ = $1; }
2198 | UNSIGNED '/' UNSIGNED {
2199 $$ = scm_cons (scm_from_int ($1), scm_from_int ($3));
2216 | ':' bare_unsigned {
2217 if (!is_duration ($2))
2218 PARSER->parser_error (@2, _f ("not a duration: %d", $2));
2225 $$ = scm_from_int ($1);
2227 | STRING { $$ = $1; }
2228 | full_markup { $$ = $1; }
2231 figured_bass_alteration:
2232 '-' { $$ = ly_rational2scm (FLAT_ALTERATION); }
2233 | '+' { $$ = ly_rational2scm (SHARP_ALTERATION); }
2234 | '!' { $$ = scm_from_int (0); }
2239 Music *bfr = MY_MAKE_MUSIC ("BassFigureEvent", @$);
2240 $$ = bfr->unprotect ();
2243 Music *bfr = MY_MAKE_MUSIC ("BassFigureEvent", @$);
2244 $$ = bfr->self_scm ();
2246 if (scm_is_number ($1))
2247 bfr->set_property ("figure", $1);
2248 else if (Text_interface::is_markup ($1))
2249 bfr->set_property ("text", $1);
2255 unsmob_music ($1)->set_property ("bracket-stop", SCM_BOOL_T);
2257 | bass_figure figured_bass_alteration {
2258 Music *m = unsmob_music ($1);
2259 if (scm_to_double ($2)) {
2260 SCM salter = m->get_property ("alteration");
2261 SCM alter = scm_is_number (salter) ? salter : scm_from_int (0);
2262 m->set_property ("alteration",
2263 scm_sum (alter, $2));
2265 m->set_property ("alteration", scm_from_int (0));
2268 | bass_figure figured_bass_modification {
2269 Music *m = unsmob_music ($1);
2270 if ($2 == ly_symbol2scm ("plus"))
2272 m->set_property ("augmented", SCM_BOOL_T);
2274 else if ($2 == ly_symbol2scm ("slash"))
2276 m->set_property ("diminished", SCM_BOOL_T);
2278 else if ($2 == ly_symbol2scm ("exclamation"))
2280 m->set_property ("no-continuation", SCM_BOOL_T);
2282 else if ($2 == ly_symbol2scm ("backslash"))
2284 m->set_property ("augmented-slash", SCM_BOOL_T);
2290 figured_bass_modification:
2292 $$ = ly_symbol2scm ("plus");
2295 $$ = ly_symbol2scm ("exclamation");
2298 $$ = ly_symbol2scm ("slash");
2301 $$ = ly_symbol2scm ("backslash");
2311 unsmob_music ($$)->set_property ("bracket-start", SCM_BOOL_T);
2319 | figure_list br_bass_figure {
2320 $$ = scm_cons ($2, $1);
2325 FIGURE_OPEN figure_list FIGURE_CLOSE {
2326 $$ = scm_reverse_x ($2, SCM_EOL);
2337 pitch exclamations questions octave_check optional_notemode_duration optional_rest {
2338 if (!PARSER->lexer_->is_note_state ())
2339 PARSER->parser_error (@1, _ ("have to be in Note mode for notes"));
2343 n = MY_MAKE_MUSIC ("RestEvent", @$);
2345 n = MY_MAKE_MUSIC ("NoteEvent", @$);
2347 n->set_property ("pitch", $1);
2348 n->set_property ("duration", $5);
2350 if (scm_is_number ($4))
2352 int q = scm_to_int ($4);
2353 n->set_property ("absolute-octave", scm_from_int (q-1));
2357 n->set_property ("cautionary", SCM_BOOL_T);
2358 if ($2 % 2 || $3 % 2)
2359 n->set_property ("force-accidental", SCM_BOOL_T);
2361 $$ = n->unprotect ();
2363 | DRUM_PITCH optional_notemode_duration {
2364 Music *n = MY_MAKE_MUSIC ("NoteEvent", @$);
2365 n->set_property ("duration", $2);
2366 n->set_property ("drum-type", $1);
2368 $$ = n->unprotect ();
2370 | RESTNAME optional_notemode_duration {
2372 if (ly_scm2string ($1) == "s") {
2374 ev = MY_MAKE_MUSIC ("SkipEvent", @$);
2377 ev = MY_MAKE_MUSIC ("RestEvent", @$);
2380 ev->set_property ("duration", $2);
2381 $$ = ev->unprotect ();
2383 | lyric_element optional_notemode_duration {
2384 if (!PARSER->lexer_->is_lyric_state ())
2385 PARSER->parser_error (@1, _ ("have to be in Lyric mode for lyrics"));
2387 Music *levent = MY_MAKE_MUSIC ("LyricEvent", @$);
2388 levent->set_property ("text", $1);
2389 levent->set_property ("duration",$2);
2390 $$= levent->unprotect ();
2394 simple_chord_elements:
2396 $$ = scm_list_1 ($1);
2399 if (!PARSER->lexer_->is_chord_state ())
2400 PARSER->parser_error (@1, _ ("have to be in Chord mode for chords"));
2403 | figure_spec optional_notemode_duration {
2404 for (SCM s = $1; scm_is_pair (s); s = scm_cdr (s))
2406 unsmob_music (scm_car (s))->set_property ("duration", $2);
2422 steno_tonic_pitch optional_notemode_duration {
2423 $$ = make_chord_elements ($1, $2, SCM_EOL);
2425 | steno_tonic_pitch optional_notemode_duration chord_separator chord_items {
2426 SCM its = scm_reverse_x ($4, SCM_EOL);
2427 $$ = make_chord_elements ($1, $2, scm_cons ($3, its));
2435 | chord_items chord_item {
2436 $$ = scm_cons ($2, $$);
2442 $$ = ly_symbol2scm ("chord-colon");
2445 $$ = ly_symbol2scm ("chord-caret");
2447 | CHORD_SLASH steno_tonic_pitch {
2448 $$ = scm_list_2 (ly_symbol2scm ("chord-slash"), $2);
2450 | CHORD_BASS steno_tonic_pitch {
2451 $$ = scm_list_2 (ly_symbol2scm ("chord-bass"), $2);
2460 $$ = scm_reverse_x ($1, SCM_EOL);
2468 step_number { $$ = scm_cons ($1, SCM_EOL); }
2469 | step_numbers '.' step_number {
2470 $$ = scm_cons ($3, $$);
2476 $$ = make_chord_step ($1, 0);
2478 | bare_unsigned '+' {
2479 $$ = make_chord_step ($1, SHARP_ALTERATION);
2481 | bare_unsigned CHORD_MINUS {
2482 $$ = make_chord_step ($1, FLAT_ALTERATION);
2488 $$ = scm_from_int ($1);
2490 | bare_unsigned '~' bare_unsigned {
2491 $$ = scm_cons (scm_from_int ($1), scm_from_int ($3));
2498 TODO: should deprecate in favor of Scheme?
2502 number_expression '+' number_term {
2503 $$ = scm_sum ($1, $3);
2505 | number_expression '-' number_term {
2506 $$ = scm_difference ($1, $3);
2515 | number_factor '*' number_factor {
2516 $$ = scm_product ($1, $3);
2518 | number_factor '/' number_factor {
2519 $$ = scm_divide ($1, $3);
2524 '-' number_factor { /* %prec UNARY_MINUS */
2525 $$ = scm_difference ($2, SCM_UNDEFINED);
2533 $$ = scm_from_int ($1);
2538 | NUMBER_IDENTIFIER {
2541 | REAL NUMBER_IDENTIFIER {
2542 $$ = scm_from_double (scm_to_double ($1) *scm_to_double ($2));
2544 | UNSIGNED NUMBER_IDENTIFIER {
2545 $$ = scm_from_double ($1 *scm_to_double ($2));
2557 bare_unsigned { $$ = scm_from_int ($1); }
2558 | NUMBER_IDENTIFIER {
2565 | exclamations '!' { $$ ++; }
2570 | questions '?' { $$ ++; }
2574 This should be done more dynamically if possible.
2578 LYRIC_MARKUP_IDENTIFIER {
2582 { PARSER->lexer_->push_markup_state (); }
2585 PARSER->lexer_->pop_state ();
2590 MARKUPLINES_IDENTIFIER {
2594 { PARSER->lexer_->push_markup_state (); }
2597 PARSER->lexer_->pop_state ();
2606 { PARSER->lexer_->push_markup_state (); }
2609 PARSER->lexer_->pop_state ();
2615 $$ = scm_list_2 (ly_lily_module_constant ("line-markup"), $1);
2617 | markup_head_1_list simple_markup {
2618 $$ = scm_car (scm_call_2 (ly_lily_module_constant ("map-markup-command-list"), $1, scm_list_1 ($2)));
2626 MARKUPLINES_IDENTIFIER {
2629 | markup_composed_list {
2632 | markup_braced_list {
2635 | markup_command_list {
2636 $$ = scm_list_1 ($1);
2640 markup_composed_list:
2641 markup_head_1_list markup_braced_list {
2642 $$ = scm_call_2 (ly_lily_module_constant ("map-markup-command-list"), $1, $2);
2648 '{' markup_braced_list_body '}' {
2649 $$ = scm_reverse_x ($2, SCM_EOL);
2653 markup_braced_list_body:
2654 /* empty */ { $$ = SCM_EOL; }
2655 | markup_braced_list_body markup {
2656 $$ = scm_cons ($2, $1);
2658 | markup_braced_list_body markup_list {
2659 $$ = scm_reverse_x ($2, $1);
2663 markup_command_list:
2664 MARKUP_LIST_FUNCTION markup_command_list_arguments {
2665 $$ = scm_cons ($1, scm_reverse_x($2, SCM_EOL));
2669 markup_command_basic_arguments:
2670 EXPECT_MARKUP_LIST markup_command_list_arguments markup_list {
2671 $$ = scm_cons ($3, $2);
2673 | EXPECT_SCM markup_command_list_arguments embedded_scm_closed {
2674 $$ = check_scheme_arg (PARSER, @3, SCM_UNDEFINED, $3, $2, $1);
2676 | EXPECT_NO_MORE_ARGS {
2681 markup_command_list_arguments:
2682 markup_command_basic_arguments { $$ = $1; }
2683 | EXPECT_MARKUP markup_command_list_arguments markup {
2684 $$ = scm_cons ($3, $2);
2689 MARKUP_FUNCTION EXPECT_MARKUP markup_command_list_arguments {
2690 $$ = scm_cons ($1, scm_reverse_x ($3, SCM_EOL));
2695 markup_head_1_item {
2696 $$ = scm_list_1 ($1);
2698 | markup_head_1_list markup_head_1_item {
2699 $$ = scm_cons ($2, $1);
2705 $$ = make_simple_markup ($1);
2707 | MARKUP_IDENTIFIER {
2710 | LYRIC_MARKUP_IDENTIFIER {
2713 | STRING_IDENTIFIER {
2717 SCM nn = PARSER->lexer_->lookup_identifier ("pitchnames");
2718 PARSER->lexer_->push_note_state (alist_to_hashq (nn));
2719 } '{' score_body '}' {
2721 $$ = scm_list_2 (ly_lily_module_constant ("score-markup"), sc->self_scm ());
2723 PARSER->lexer_->pop_state ();
2725 | MARKUP_FUNCTION markup_command_basic_arguments {
2726 $$ = scm_cons ($1, scm_reverse_x ($2, SCM_EOL));
2731 markup_head_1_list simple_markup {
2732 SCM mapper = ly_lily_module_constant ("map-markup-command-list");
2733 $$ = scm_car (scm_call_2 (mapper, $1, scm_list_1 ($2)));
2743 Lily_parser::set_yydebug (bool x)
2749 Lily_parser::do_yyparse ()
2751 yyparse ((void*)this);
2760 It is a little strange to have this function in this file, but
2761 otherwise, we have to import music classes into the lexer.
2765 Lily_lexer::try_special_identifiers (SCM *destination, SCM sid)
2767 if (scm_is_string (sid)) {
2769 return STRING_IDENTIFIER;
2770 } else if (unsmob_book (sid)) {
2771 Book *book = unsmob_book (sid)->clone ();
2772 *destination = book->self_scm ();
2775 return BOOK_IDENTIFIER;
2776 } else if (scm_is_number (sid)) {
2778 return NUMBER_IDENTIFIER;
2779 } else if (unsmob_context_def (sid)) {
2780 Context_def *def= unsmob_context_def (sid)->clone ();
2782 *destination = def->self_scm ();
2785 return CONTEXT_DEF_IDENTIFIER;
2786 } else if (unsmob_context_mod (sid)) {
2787 *destination = unsmob_context_mod (sid)->smobbed_copy ();
2789 return CONTEXT_MOD_IDENTIFIER;
2790 } else if (unsmob_score (sid)) {
2791 Score *score = new Score (*unsmob_score (sid));
2792 *destination = score->self_scm ();
2794 score->unprotect ();
2795 return SCORE_IDENTIFIER;
2796 } else if (Music *mus = unsmob_music (sid)) {
2797 mus = mus->clone ();
2798 *destination = mus->self_scm ();
2799 unsmob_music (*destination)->
2800 set_property ("origin", make_input (last_input_));
2802 bool is_event = scm_memq (ly_symbol2scm ("event"), mus->get_property ("types"))
2806 return is_event ? EVENT_IDENTIFIER : MUSIC_IDENTIFIER;
2807 } else if (unsmob_pitch (sid)) {
2808 *destination = unsmob_pitch (sid)->smobbed_copy ();
2809 return PITCH_IDENTIFIER;
2810 } else if (unsmob_duration (sid)) {
2811 *destination = unsmob_duration (sid)->smobbed_copy ();
2812 return DURATION_IDENTIFIER;
2813 } else if (unsmob_output_def (sid)) {
2814 Output_def *p = unsmob_output_def (sid);
2817 *destination = p->self_scm ();
2819 return OUTPUT_DEF_IDENTIFIER;
2820 } else if (Text_interface::is_markup (sid)) {
2822 if (is_lyric_state ())
2823 return LYRIC_MARKUP_IDENTIFIER;
2824 return MARKUP_IDENTIFIER;
2825 } else if (Text_interface::is_markup_list (sid)) {
2827 return MARKUPLINES_IDENTIFIER;
2834 get_next_unique_context_id ()
2836 return scm_from_locale_string ("$uniqueContextId");
2841 get_next_unique_lyrics_context_id ()
2843 static int new_context_count;
2845 snprintf (s, sizeof (s)-1, "uniqueContext%d", new_context_count++);
2846 return scm_from_locale_string (s);
2851 run_music_function (Lily_parser *parser, Input loc, SCM func, SCM args)
2853 SCM sig = scm_object_property (func, ly_symbol2scm ("music-function-signature"));
2855 args = scm_reverse_x (args, SCM_EOL);
2857 SCM fallback = SCM_BOOL_F;
2858 SCM pred = scm_car (sig);
2860 if (scm_is_pair (pred))
2862 fallback = loc_on_music (loc, scm_cdr (pred));
2863 pred = scm_car (pred);
2866 SCM syntax_args = scm_list_n (parser->self_scm (), make_input (loc), pred, fallback, func, args, SCM_UNDEFINED);
2867 return LOWLEVEL_MAKE_SYNTAX (ly_lily_module_constant ("music-function"), syntax_args);
2870 SCM check_scheme_arg (Lily_parser *parser, Input loc, SCM fallback,
2871 SCM arg, SCM args, SCM pred)
2873 SCM type_check_arg = ly_lily_module_constant ("type-check-arg");
2874 if (scm_is_false (scm_call_4 (type_check_arg, make_input (loc),
2877 if (SCM_UNBNDP (fallback))
2878 fallback = SCM_BOOL_F;
2880 fallback = loc_on_music (loc, fallback);
2882 parser->error_level_ = 1;
2884 return scm_cons (fallback, args);
2886 return scm_cons (arg, args);
2889 SCM loc_on_music (Input loc, SCM arg)
2891 if (Music *m = unsmob_music (arg))
2895 return m->unprotect ();
2901 is_regular_identifier (SCM id)
2903 string str = ly_scm2string (id);
2904 char const *s = str.c_str ();
2913 v = v && isalnum (*s);
2920 make_music_with_input (SCM name, Input where)
2922 Music *m = make_music_by_name (name);
2923 m->set_spot (where);
2928 get_first_context_id (SCM type, Music *m)
2930 SCM id = m->get_property ("context-id");
2931 if (SCM_BOOL_T == scm_equal_p (m->get_property ("context-type"), type)
2932 && scm_is_string (m->get_property ("context-id"))
2933 && scm_c_string_length (id) > 0)
2941 make_simple_markup (SCM a)
2949 return t && t == 1 << intlog2 (t);
2953 set_music_properties (Music *p, SCM a)
2955 for (SCM k = a; scm_is_pair (k); k = scm_cdr (k))
2956 p->set_property (scm_caar (k), scm_cdar (k));
2961 make_chord_step (int step, Rational alter)
2964 alter += FLAT_ALTERATION;
2968 Pitch m ((step -1) / 7, (step - 1) % 7, alter);
2969 return m.smobbed_copy ();
2974 make_chord_elements (SCM pitch, SCM dur, SCM modification_list)
2976 SCM chord_ctor = ly_lily_module_constant ("construct-chord-elements");
2977 return scm_call_3 (chord_ctor, pitch, dur, modification_list);
2981 /* Todo: actually also use apply iso. call too ... */
2983 ly_input_procedure_p (SCM x)
2985 return ly_is_procedure (x)
2986 || (scm_is_pair (x) && ly_is_procedure (scm_car (x)));
2990 yylex (YYSTYPE *s, YYLTYPE *loc, void *v)
2992 Lily_parser *pars = (Lily_parser*) v;
2993 Lily_lexer *lex = pars->lexer_;
2995 lex->lexval_ = (void*) s;
2997 lex->prepare_for_next_token ();
2998 return lex->yylex ();