1 /* -*- mode: c++; c-file-style: "linux"; indent-tabs-mode: t -*- */
3 This file is part of LilyPond, the GNU music typesetter.
5 Copyright (C) 1997--2012 Han-Wen Nienhuys <hanwen@xs4all.nl>
6 Jan Nieuwenhuizen <janneke@gnu.org>
8 LilyPond is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
13 LilyPond is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
22 /* Mode and indentation are at best a rough approximation based on TAB
23 * formatting (reasonable for compatibility with unspecific editor
24 * modes as Bison modes are hard to find) and need manual correction
25 * frequently. Without a reasonably dependable way of formatting a
26 * Bison file sensibly, there is little point in trying to fix the
27 * inconsistent state of indentation.
32 #define yyerror Lily_parser::parser_error
34 /* We use custom location type: Input objects */
37 #define YYLLOC_DEFAULT(Current,Rhs,N) \
38 ((Current).set_location ((Rhs)[1], (Rhs)[N]))
40 #define YYPRINT(file, type, value) \
42 if (scm_is_eq (value, SCM_UNSPECIFIED)) \
44 char *p = scm_to_locale_string \
45 (scm_simple_format (SCM_BOOL_F, \
46 scm_from_locale_string ("~S"), \
47 scm_list_1 (value))); \
54 %parse-param {Lily_parser *parser}
55 %parse-param {SCM *retval}
56 %lex-param {Lily_parser *parser}
60 /* We use SCMs to do strings, because it saves us the trouble of
61 deleting them. Let's hope that a stack overflow doesn't trigger a move
62 of the parse stack onto the heap. */
68 /* The above precedences tackle the shift/reduce problem
71 \repeat .. \alternative
73 \repeat { \repeat .. \alternative }
77 \repeat { \repeat } \alternative
83 /* ADDLYRICS needs to have lower precedence than argument scanning,
84 * or we won't be able to tell music apart from closed_music without
85 * lookahead in the context of function calls.
90 /* \default is only applied after exhausting function arguments */
92 %nonassoc FUNCTION_ARGLIST
94 /* expressions with units are permitted into argument lists */
96 %right PITCH_IDENTIFIER NOTENAME_PITCH TONICNAME_PITCH
97 UNSIGNED REAL DURATION_IDENTIFIER ':'
99 /* The above are the symbols that can start optional function arguments
100 that are recognized in the grammar rather than by predicate
103 %nonassoc NUMBER_IDENTIFIER '/'
105 /* Number-unit expressions, where permitted, are concatenated into
106 * function arguments, just like fractions and tremoli. Tremoli must
107 * not have higher precedence than UNSIGNED, or Lilypond will not
108 * join ':' with a following optional number.
121 %{ // -*-Fundamental-*-
126 * The rules for who is protecting what are very shady. Uniformise
129 * There are too many lexical modes?
140 #include "context-def.hh"
141 #include "context-mod.hh"
142 #include "dimensions.hh"
143 #include "file-path.hh"
145 #include "international.hh"
146 #include "lily-guile.hh"
147 #include "lily-lexer.hh"
148 #include "lily-parser.hh"
152 #include "output-def.hh"
153 #include "paper-book.hh"
154 #include "scm-hash.hh"
156 #include "text-interface.hh"
160 Lily_parser::parser_error (Input const *i, Lily_parser *parser, SCM *, const string &s)
162 parser->parser_error (*i, s);
165 #define MYBACKUP(Token, Value, Location) \
167 if (yychar == YYEMPTY) \
170 parser->lexer_->push_extra_token (Token, Value); \
171 parser->lexer_->push_extra_token (BACKUP); \
173 parser->parser_error \
174 (Location, _("Too much lookahead")); \
179 #define MYREPARSE(Location, Pred, Token, Value) \
181 if (yychar == YYEMPTY) \
183 parser->lexer_->push_extra_token (Token, Value); \
184 parser->lexer_->push_extra_token (REPARSE, \
187 parser->parser_error \
188 (Location, _("Too much lookahead")); \
197 #define MY_MAKE_MUSIC(x, spot) \
198 make_music_with_input (ly_symbol2scm (x), \
199 parser->lexer_->override_input (spot))
202 - Don't use lily module, create a new module instead.
203 - delay application of the function
205 #define LOWLEVEL_MAKE_SYNTAX(proc, args) \
206 scm_apply_0 (proc, args)
207 /* Syntactic Sugar. */
208 #define MAKE_SYNTAX(name, location, ...) \
209 LOWLEVEL_MAKE_SYNTAX (ly_lily_module_constant (name), scm_list_n (parser->self_scm (), make_input (parser->lexer_->override_input (location)), ##__VA_ARGS__, SCM_UNDEFINED))
210 #define START_MAKE_SYNTAX(name, ...) \
211 scm_list_n (ly_lily_module_constant (name) , ##__VA_ARGS__, SCM_UNDEFINED)
212 #define FINISH_MAKE_SYNTAX(start, location, ...) \
213 LOWLEVEL_MAKE_SYNTAX (scm_car (start), scm_cons2 (parser->self_scm (), make_input (parser->lexer_->override_input (location)), scm_append_x (scm_list_2 (scm_cdr (start), scm_list_n (__VA_ARGS__, SCM_UNDEFINED)))))
215 SCM get_next_unique_context_id ();
216 SCM get_next_unique_lyrics_context_id ();
223 #define _(x) gettext (x)
227 static Music *make_music_with_input (SCM name, Input where);
228 SCM check_scheme_arg (Lily_parser *parser, Input loc,
229 SCM arg, SCM args, SCM pred, SCM disp = SCM_UNDEFINED);
230 SCM make_music_from_simple (Lily_parser *parser, Input loc, SCM pitch);
231 SCM loc_on_music (Input loc, SCM arg);
232 SCM make_chord_elements (Input loc, SCM pitch, SCM dur, SCM modification_list);
233 SCM make_chord_step (SCM step, Rational alter);
234 SCM make_simple_markup (SCM a);
235 SCM make_duration (SCM t, int dots = 0);
236 bool is_regular_identifier (SCM id, bool multiple=false);
237 SCM try_string_variants (SCM pred, SCM str);
238 int yylex (YYSTYPE *s, YYLTYPE *loc, Lily_parser *parser);
242 /* The third option is an alias that will be used to display the
243 syntax error. Bison CVS now correctly handles backslash escapes.
245 FIXME: Bison needs to translate some of these, eg, STRING.
249 /* Keyword tokens with plain escaped name. */
250 %token END_OF_FILE 0 "end of input"
251 %token ACCEPTS "\\accepts"
252 %token ADDLYRICS "\\addlyrics"
253 %token ALIAS "\\alias"
254 %token ALTERNATIVE "\\alternative"
256 %token BOOKPART "\\bookpart"
257 %token CHANGE "\\change"
258 %token CHORDMODE "\\chordmode"
259 %token CHORDS "\\chords"
260 %token CONSISTS "\\consists"
261 %token CONTEXT "\\context"
262 %token DEFAULT "\\default"
263 %token DEFAULTCHILD "\\defaultchild"
264 %token DENIES "\\denies"
265 %token DESCRIPTION "\\description"
266 %token DRUMMODE "\\drummode"
267 %token DRUMS "\\drums"
268 %token FIGUREMODE "\\figuremode"
269 %token FIGURES "\\figures"
270 %token HEADER "\\header"
271 %token INVALID "\\version-error"
272 %token LAYOUT "\\layout"
273 %token LYRICMODE "\\lyricmode"
274 %token LYRICS "\\lyrics"
275 %token LYRICSTO "\\lyricsto"
276 %token MARKUP "\\markup"
277 %token MARKUPLIST "\\markuplist"
280 %token NOTEMODE "\\notemode"
281 %token OVERRIDE "\\override"
282 %token PAPER "\\paper"
283 %token REMOVE "\\remove"
284 %token REPEAT "\\repeat"
286 %token REVERT "\\revert"
287 %token SCORE "\\score"
288 %token SEQUENTIAL "\\sequential"
290 %token SIMULTANEOUS "\\simultaneous"
291 %token TEMPO "\\tempo"
293 %token UNSET "\\unset"
296 /* Keyword token exceptions. */
297 %token NEWCONTEXT "\\new"
300 /* Other string tokens. */
302 %token CHORD_BASS "/+"
303 %token CHORD_CARET "^"
304 %token CHORD_COLON ":"
305 %token CHORD_MINUS "-"
306 %token CHORD_SLASH "/"
307 %token ANGLE_OPEN "<"
308 %token ANGLE_CLOSE ">"
309 %token DOUBLE_ANGLE_OPEN "<<"
310 %token DOUBLE_ANGLE_CLOSE ">>"
311 %token E_BACKSLASH "\\"
312 %token E_EXCLAMATION "\\!"
317 If we give names, Bison complains.
319 %token FIGURE_CLOSE /* "\\>" */
320 %token FIGURE_OPEN /* "\\<" */
321 %token FIGURE_SPACE "_"
324 %token MULTI_MEASURE_REST
330 /* Artificial tokens, for more generic function syntax */
331 %token EXPECT_MARKUP "markup?"
332 %token EXPECT_SCM "scheme?"
333 %token BACKUP "(backed-up?)"
334 %token REPARSE "(reparsed?)"
335 %token EXPECT_MARKUP_LIST "markup-list?"
336 %token EXPECT_OPTIONAL "optional?"
337 /* After the last argument. */
338 %token EXPECT_NO_MORE_ARGS;
340 /* An artificial token for parsing embedded Lilypond */
341 %token EMBEDDED_LILY "#{"
343 %token BOOK_IDENTIFIER
344 %token CHORD_MODIFIER
345 %token CHORD_REPETITION
346 %token CONTEXT_DEF_IDENTIFIER
347 %token CONTEXT_MOD_IDENTIFIER
349 %token PITCH_IDENTIFIER
350 %token DURATION_IDENTIFIER
351 %token EVENT_IDENTIFIER
352 %token EVENT_FUNCTION
355 %token MARKUP_FUNCTION
356 %token MARKUP_LIST_FUNCTION
357 %token MARKUP_IDENTIFIER
358 %token MARKUPLIST_IDENTIFIER
359 %token MUSIC_FUNCTION
360 %token MUSIC_IDENTIFIER
361 %token NOTENAME_PITCH
362 %token NUMBER_IDENTIFIER
363 %token OUTPUT_DEF_IDENTIFIER
368 %token SCM_IDENTIFIER
372 %token TONICNAME_PITCH
376 /* We don't assign precedence to / and *, because we might need varied
377 prec levels in different prods */
386 SCM nn = parser->lexer_->lookup_identifier ("pitchnames");
387 parser->lexer_->push_note_state (nn);
388 } embedded_lilypond {
389 parser->lexer_->pop_state ();
394 lilypond: /* empty */ { $$ = SCM_UNSPECIFIED; }
395 | lilypond toplevel_expression {
397 | lilypond assignment {
400 parser->error_level_ = 1;
403 parser->error_level_ = 1;
410 parser->lexer_->add_scope (get_header (parser));
412 parser->lexer_->set_identifier (ly_symbol2scm ("$defaultheader"), $2);
415 SCM proc = parser->lexer_->lookup_identifier ("toplevel-book-handler");
416 scm_call_2 (proc, parser->self_scm (), $1);
419 SCM proc = parser->lexer_->lookup_identifier ("toplevel-bookpart-handler");
420 scm_call_2 (proc, parser->self_scm (), $1);
423 SCM proc = parser->lexer_->lookup_identifier ("toplevel-score-handler");
424 scm_call_2 (proc, parser->self_scm (), $1);
427 SCM proc = parser->lexer_->lookup_identifier ("toplevel-music-handler");
428 scm_call_2 (proc, parser->self_scm (), $1);
431 SCM proc = parser->lexer_->lookup_identifier ("toplevel-text-handler");
432 scm_call_2 (proc, parser->self_scm (), scm_list_1 ($1));
435 SCM proc = parser->lexer_->lookup_identifier ("toplevel-text-handler");
436 scm_call_2 (proc, parser->self_scm (), $1);
439 // Evaluate and ignore #xxx, as opposed to \xxx
440 parser->lexer_->eval_scm_token ($1);
442 | embedded_scm_active
444 SCM out = SCM_UNDEFINED;
445 if (Text_interface::is_markup ($1))
446 out = scm_list_1 ($1);
447 else if (Text_interface::is_markup_list ($1))
449 if (scm_is_pair (out))
451 SCM proc = parser->lexer_->lookup_identifier ("toplevel-text-handler");
452 scm_call_2 (proc, parser->self_scm (), out);
453 } else if (!scm_is_eq ($1, SCM_UNSPECIFIED))
454 parser->parser_error (@1, _("bad expression type"));
458 Output_def * od = unsmob_output_def ($1);
460 if (od->c_variable ("is-paper") == SCM_BOOL_T)
461 id = ly_symbol2scm ("$defaultpaper");
462 else if (od->c_variable ("is-midi") == SCM_BOOL_T)
463 id = ly_symbol2scm ("$defaultmidi");
464 else if (od->c_variable ("is-layout") == SCM_BOOL_T)
465 id = ly_symbol2scm ("$defaultlayout");
467 parser->lexer_->set_identifier (id, $1);
474 $$ = parser->lexer_->eval_scm_token ($1);
484 embedded_scm_bare_arg:
488 $$ = parser->lexer_->eval_scm_token ($1);
491 | context_modification
493 | context_def_spec_block
499 /* The generic version may end in music, or not */
506 /* embedded_scm_arg is _not_ casting pitches to music by default, this
507 * has to be done by the function itself. Note that this may cause
508 * the results of scm_function_call or embedded_scm_bare_arg to be
509 * turned into music from pitches as well. Note that this creates a
510 * distinctly awkward situation for calculated drum pitches. Those
511 * are at the current point of time rejected as music constituents as
512 * they can't be distinguished from "proper" symbols.
516 embedded_scm_bare_arg
522 SCM_FUNCTION function_arglist {
523 $$ = MAKE_SYNTAX ("music-function", @$,
531 // FIXME: @$ does not contain a useful source location
532 // for empty rules, and the only token in the whole
533 // production, EMBEDDED_LILY, is synthetic and also
534 // contains no source location.
535 $$ = MAKE_SYNTAX ("void-music", @$);
538 | music_embedded music_embedded music_list {
539 $3 = scm_reverse_x ($3, SCM_EOL);
540 if (unsmob_music ($2))
541 $3 = scm_cons ($2, $3);
542 if (unsmob_music ($1))
543 $3 = scm_cons ($1, $3);
544 $$ = MAKE_SYNTAX ("sequential-music", @$, $3);
547 parser->error_level_ = 1;
548 $$ = SCM_UNSPECIFIED;
550 | INVALID embedded_lilypond {
551 parser->error_level_ = 1;
557 lilypond_header_body:
558 /* empty */ { $$ = SCM_UNSPECIFIED; }
559 | lilypond_header_body assignment {
562 | lilypond_header_body embedded_scm {
568 HEADER '{' lilypond_header_body '}' {
569 $$ = parser->lexer_->remove_scope ();
581 assignment_id '=' identifier_init {
582 parser->lexer_->set_identifier ($1, $3);
583 $$ = SCM_UNSPECIFIED;
585 | assignment_id property_path '=' identifier_init {
586 SCM path = scm_cons (scm_string_to_symbol ($1), $2);
587 parser->lexer_->set_identifier (path, $4);
588 $$ = SCM_UNSPECIFIED;
598 | context_def_spec_block
600 | post_event_nofinger post_events
602 $$ = scm_reverse_x ($2, SCM_EOL);
603 if (Music *m = unsmob_music ($1))
605 if (m->is_mus_type ("post-event-wrapper"))
607 (scm_list_2 (m->get_property ("elements"),
610 $$ = scm_cons ($1, $$);
613 && scm_is_null (scm_cdr ($$)))
617 Music * m = MY_MAKE_MUSIC ("PostEvents", @$);
618 m->set_property ("elements", $$);
619 $$ = m->unprotect ();
627 | context_modification
630 context_def_spec_block:
631 CONTEXT '{' context_def_spec_body '}'
634 unsmob_context_def ($$)->origin ()->set_spot (@$);
642 SCM nn = parser->lexer_->lookup_identifier ("pitchnames");
643 parser->lexer_->push_note_state (nn);
647 parser->lexer_->pop_state ();
652 context_mod_embedded:
655 if (unsmob_music ($1)) {
656 SCM proc = parser->lexer_->lookup_identifier ("context-mod-music-handler");
657 $1 = scm_call_2 (proc, parser->self_scm (), $1);
659 if (unsmob_context_mod ($1))
662 parser->parser_error (@1, _ ("not a context mod"));
663 $$ = Context_mod ().smobbed_copy ();
669 context_def_spec_body:
671 $$ = Context_def::make_scm ();
673 | CONTEXT_DEF_IDENTIFIER {
676 | context_def_spec_body context_mod {
677 if (!SCM_UNBNDP ($2))
678 unsmob_context_def ($$)->add_context_mod ($2);
680 | context_def_spec_body context_modification {
681 Context_def *td = unsmob_context_def ($$);
682 SCM new_mods = unsmob_context_mod ($2)->get_mods ();
683 for (SCM m = new_mods; scm_is_pair (m); m = scm_cdr (m)) {
684 td->add_context_mod (scm_car (m));
687 | context_def_spec_body context_mod_embedded {
688 Context_def *td = unsmob_context_def ($$);
689 SCM new_mods = unsmob_context_mod ($2)->get_mods ();
690 for (SCM m = new_mods; scm_is_pair (m); m = scm_cdr (m)) {
691 td->add_context_mod (scm_car (m));
699 BOOK '{' book_body '}' {
701 unsmob_book ($$)->origin ()->set_spot (@$);
703 parser->lexer_->set_identifier (ly_symbol2scm ("$current-book"), SCM_BOOL_F);
708 * Use 'handlers' like for toplevel-* stuff?
709 * grok \layout and \midi? */
712 Book *book = new Book;
713 init_papers (parser);
714 book->paper_ = dynamic_cast<Output_def*> (unsmob_output_def (parser->lexer_->lookup_identifier ("$defaultpaper"))->clone ());
715 book->paper_->unprotect ();
716 push_paper (parser, book->paper_);
717 book->header_ = get_header (parser);
718 $$ = book->unprotect ();
719 parser->lexer_->set_identifier (ly_symbol2scm ("$current-book"), $$);
722 parser->lexer_->set_identifier (ly_symbol2scm ("$current-book"), $1);
724 | book_body paper_block {
725 unsmob_book ($1)->paper_ = unsmob_output_def ($2);
726 set_paper (parser, unsmob_output_def ($2));
728 | book_body bookpart_block {
729 SCM proc = parser->lexer_->lookup_identifier ("book-bookpart-handler");
730 scm_call_2 (proc, $1, $2);
732 | book_body score_block {
733 SCM proc = parser->lexer_->lookup_identifier ("book-score-handler");
734 scm_call_2 (proc, $1, $2);
736 | book_body composite_music {
737 SCM proc = parser->lexer_->lookup_identifier ("book-music-handler");
738 scm_call_3 (proc, parser->self_scm (), $1, $2);
740 | book_body full_markup {
741 SCM proc = parser->lexer_->lookup_identifier ("book-text-handler");
742 scm_call_2 (proc, $1, scm_list_1 ($2));
744 | book_body full_markup_list {
745 SCM proc = parser->lexer_->lookup_identifier ("book-text-handler");
746 scm_call_2 (proc, $1, $2);
748 | book_body SCM_TOKEN {
749 // Evaluate and ignore #xxx, as opposed to \xxx
750 parser->lexer_->eval_scm_token ($2);
752 | book_body embedded_scm_active
754 SCM out = SCM_UNDEFINED;
755 if (Text_interface::is_markup ($2))
756 out = scm_list_1 ($2);
757 else if (Text_interface::is_markup_list ($2))
759 if (scm_is_pair (out))
761 SCM proc = parser->lexer_->lookup_identifier ("book-text-handler");
762 scm_call_2 (proc, $1, out);
763 } else if (!scm_is_eq ($2, SCM_UNSPECIFIED))
764 parser->parser_error (@2, _("bad expression type"));
768 parser->lexer_->add_scope (unsmob_book ($1)->header_);
771 Book *book = unsmob_book ($1);
773 book->scores_ = SCM_EOL;
774 book->bookparts_ = SCM_EOL;
779 BOOKPART '{' bookpart_body '}' {
781 unsmob_book ($$)->origin ()->set_spot (@$);
782 parser->lexer_->set_identifier (ly_symbol2scm ("$current-bookpart"), SCM_BOOL_F);
788 Book *book = new Book;
789 $$ = book->unprotect ();
790 parser->lexer_->set_identifier (ly_symbol2scm ("$current-bookpart"), $$);
793 parser->lexer_->set_identifier (ly_symbol2scm ("$current-bookpart"), $1);
795 | bookpart_body paper_block {
796 unsmob_book ($$)->paper_ = unsmob_output_def ($2);
798 | bookpart_body score_block {
799 SCM proc = parser->lexer_->lookup_identifier ("bookpart-score-handler");
800 scm_call_2 (proc, $1, $2);
802 | bookpart_body composite_music {
803 SCM proc = parser->lexer_->lookup_identifier ("bookpart-music-handler");
804 scm_call_3 (proc, parser->self_scm (), $1, $2);
806 | bookpart_body full_markup {
807 SCM proc = parser->lexer_->lookup_identifier ("bookpart-text-handler");
808 scm_call_2 (proc, $1, scm_list_1 ($2));
810 | bookpart_body full_markup_list {
811 SCM proc = parser->lexer_->lookup_identifier ("bookpart-text-handler");
812 scm_call_2 (proc, $1, $2);
814 | bookpart_body SCM_TOKEN {
815 // Evaluate and ignore #xxx, as opposed to \xxx
816 parser->lexer_->eval_scm_token ($2);
818 | bookpart_body embedded_scm_active
820 SCM out = SCM_UNDEFINED;
821 if (Text_interface::is_markup ($2))
822 out = scm_list_1 ($2);
823 else if (Text_interface::is_markup_list ($2))
825 if (scm_is_pair (out))
827 SCM proc = parser->lexer_->lookup_identifier ("bookpart-text-handler");
828 scm_call_2 (proc, $1, out);
829 } else if (!scm_is_eq ($2, SCM_UNSPECIFIED))
830 parser->parser_error (@2, _("bad expression type"));
834 Book *book = unsmob_book ($1);
835 if (!ly_is_module (book->header_))
836 book->header_ = ly_make_module (false);
837 parser->lexer_->add_scope (book->header_);
839 | bookpart_body error {
840 Book *book = unsmob_book ($1);
842 book->scores_ = SCM_EOL;
847 SCORE '{' score_body '}' {
854 SCM scorify = ly_lily_module_constant ("scorify-music");
855 $$ = scm_call_2 (scorify, $1, parser->self_scm ());
857 unsmob_score ($$)->origin ()->set_spot (@$);
859 | embedded_scm_active {
861 if (unsmob_score ($1))
862 score = new Score (*unsmob_score ($1));
865 parser->parser_error (@1, _("score expected"));
867 unsmob_score ($$)->origin ()->set_spot (@$);
868 $$ = score->unprotect ();
872 Score *score = unsmob_score ($1);
873 if (!ly_is_module (score->get_header ()))
874 score->set_header (ly_make_module (false));
875 parser->lexer_->add_scope (score->get_header ());
877 | score_body output_def {
878 Output_def *od = unsmob_output_def ($2);
879 if (od->lookup_variable (ly_symbol2scm ("is-paper")) == SCM_BOOL_T)
881 parser->parser_error (@2, _("\\paper cannot be used in \\score, use \\layout instead"));
886 unsmob_score ($1)->add_output_def (od);
890 unsmob_score ($$)->error_found_ = true;
901 Output_def *od = unsmob_output_def ($1);
903 if (od->lookup_variable (ly_symbol2scm ("is-paper")) != SCM_BOOL_T)
905 parser->parser_error (@1, _ ("need \\paper for paper block"));
906 $$ = get_paper (parser)->unprotect ();
913 output_def_body '}' {
916 parser->lexer_->remove_scope ();
917 parser->lexer_->pop_state ();
923 Output_def *p = get_paper (parser);
924 p->input_origin_ = @$;
925 parser->lexer_->add_scope (p->scope_);
926 $$ = p->unprotect ();
929 Output_def *p = get_midi (parser);
930 $$ = p->unprotect ();
931 parser->lexer_->add_scope (p->scope_);
934 Output_def *p = get_layout (parser);
936 parser->lexer_->add_scope (p->scope_);
937 $$ = p->unprotect ();
941 output_def_head_with_mode_switch:
943 parser->lexer_->push_initial_state ();
948 // We need this weird nonterminal because both music as well as a
949 // context definition can start with \context and the difference is
950 // only apparent after looking at the next token. If it is '{', there
951 // is still time to escape from notes mode.
953 music_or_context_def:
955 | context_def_spec_block
959 output_def_head_with_mode_switch '{' {
961 unsmob_output_def ($$)->input_origin_.set_spot (@$);
963 | output_def_head_with_mode_switch '{' OUTPUT_DEF_IDENTIFIER {
964 Output_def *o = unsmob_output_def ($3);
965 o->input_origin_.set_spot (@$);
967 parser->lexer_->remove_scope ();
968 parser->lexer_->add_scope (o->scope_);
970 | output_def_body assignment {
973 | output_def_body embedded_scm {
978 SCM nn = parser->lexer_->lookup_identifier ("pitchnames");
979 parser->lexer_->push_note_state (nn);
980 } music_or_context_def
982 parser->lexer_->pop_state ();
983 if (unsmob_context_def ($3))
984 assign_context_def (unsmob_output_def ($1), $3);
987 SCM proc = parser->lexer_->lookup_identifier
988 ("output-def-music-handler");
989 scm_call_3 (proc, parser->self_scm (),
993 | output_def_body error {
999 TEMPO steno_duration '=' tempo_range {
1000 $$ = MAKE_SYNTAX ("tempo", @$, SCM_EOL, $2, $4);
1002 | TEMPO scalar_closed steno_duration '=' tempo_range {
1003 $$ = MAKE_SYNTAX ("tempo", @$, $2, $3, $5);
1006 $$ = MAKE_SYNTAX ("tempo", @$, $2);
1011 The representation of a list is reversed to have efficient append. */
1017 | music_list music_embedded {
1018 if (unsmob_music ($2))
1019 $$ = scm_cons ($2, $1);
1021 | music_list error {
1022 Music *m = MY_MAKE_MUSIC("Music", @$);
1024 m->set_property ("error-found", SCM_BOOL_T);
1025 $$ = scm_cons (m->self_scm (), $1);
1026 m->unprotect (); /* UGH */
1033 $$ = scm_reverse_x ($2, SCM_EOL);
1038 | lyric_element_music
1044 if (unsmob_music ($1)->is_mus_type ("post-event")) {
1045 parser->parser_error (@1, _ ("unexpected post-event"));
1046 $$ = SCM_UNSPECIFIED;
1049 | music_embedded_backup
1053 | music_embedded_backup BACKUP lyric_element_music
1059 music_embedded_backup:
1062 if (scm_is_eq ($1, SCM_UNSPECIFIED))
1064 else if (Music *m = unsmob_music ($1)) {
1065 if (m->is_mus_type ("post-event")) {
1066 parser->parser_error
1067 (@1, _ ("unexpected post-event"));
1068 $$ = SCM_UNSPECIFIED;
1071 } else if (parser->lexer_->is_lyric_state ()
1072 && Text_interface::is_markup ($1))
1073 MYBACKUP (LYRIC_ELEMENT, $1, @1);
1075 @$.warning (_ ("Ignoring non-music expression"));
1084 $$ = make_music_from_simple (parser, @1, $1);
1085 if (!unsmob_music ($$))
1086 parser->parser_error (@1, _ ("music expected"));
1088 | composite_music %prec COMPOSITE
1093 | composite_music %prec COMPOSITE
1097 REPEAT simple_string unsigned_number music
1099 $$ = MAKE_SYNTAX ("repeat", @$, $2, $3, $4, SCM_EOL);
1101 | REPEAT simple_string unsigned_number music ALTERNATIVE braced_music_list
1103 $$ = MAKE_SYNTAX ("repeat", @$, $2, $3, $4, $6);
1108 SEQUENTIAL braced_music_list {
1109 $$ = MAKE_SYNTAX ("sequential-music", @$, $2);
1111 | braced_music_list {
1112 $$ = MAKE_SYNTAX ("sequential-music", @$, $1);
1117 SIMULTANEOUS braced_music_list {
1118 $$ = MAKE_SYNTAX ("simultaneous-music", @$, $2);
1120 | DOUBLE_ANGLE_OPEN music_list DOUBLE_ANGLE_CLOSE {
1121 $$ = MAKE_SYNTAX ("simultaneous-music", @$, scm_reverse_x ($2, SCM_EOL));
1127 | music_property_def
1131 context_modification:
1134 SCM nn = parser->lexer_->lookup_identifier ("pitchnames");
1135 parser->lexer_->push_note_state (nn);
1136 } '{' context_mod_list '}'
1138 parser->lexer_->pop_state ();
1141 | WITH CONTEXT_MOD_IDENTIFIER
1145 | CONTEXT_MOD_IDENTIFIER
1149 | WITH context_modification_arg
1151 if (unsmob_music ($2)) {
1152 SCM proc = parser->lexer_->lookup_identifier ("context-mod-music-handler");
1153 $2 = scm_call_2 (proc, parser->self_scm (), $2);
1155 if (unsmob_context_mod ($2))
1158 parser->parser_error (@2, _ ("not a context mod"));
1159 $$ = Context_mod ().smobbed_copy ();
1164 context_modification_arg:
1169 optional_context_mod:
1173 | context_modification
1181 $$ = Context_mod ().smobbed_copy ();
1183 | context_mod_list context_mod {
1184 if (!SCM_UNBNDP ($2))
1185 unsmob_context_mod ($1)->add_context_mod ($2);
1187 | context_mod_list CONTEXT_MOD_IDENTIFIER {
1188 Context_mod *md = unsmob_context_mod ($2);
1190 unsmob_context_mod ($1)->add_context_mods (md->get_mods ());
1192 | context_mod_list context_mod_embedded {
1193 unsmob_context_mod ($1)->add_context_mods
1194 (unsmob_context_mod ($2)->get_mods ());
1203 /* Music that can be parsed without lookahead */
1206 | complex_music_prefix closed_music
1208 $$ = FINISH_MAKE_SYNTAX ($1, @$, $2);
1210 | music_function_call_closed
1216 | grouped_music_list
1220 simultaneous_music { $$ = $1; }
1221 | sequential_music { $$ = $1; }
1224 /* Function argument lists are arguably the most complex part in the
1225 * parser. They are pretty tricky to understand because of the way
1226 * they are processed, and because of optional arguments that can be
1227 * omitted. When there are several optional arguments in a row,
1228 * omitting one automatically omits all following arguments. Optional
1229 * arguments can only be omitted when either
1231 * a) the omission is explicitly started with \default
1232 * b) the omission is implicitly started by an argument not matching
1233 * its predicate, and there is a mandatory argument later that can
1234 * "catch" the argument that does not fit.
1236 * When argument parsing starts, the lexer pushes EXPECT_SCM tokens
1237 * (corresponding to mandatory arguments and having a predicate
1238 * function as semantic value) or EXPECT_OPTIONAL EXPECT_SCM (where
1239 * the semantic value of the EXPECT_OPTIONAL token is the default to
1240 * use when the optional argument is omitted, and EXPECT_SCM again has
1241 * the argument predicate as semantic value) in reverse order to the
1242 * parser, followed by EXPECT_NO_MORE_ARGS. The argument list is then
1243 * processed inside-out while actual tokens are consumed.
1245 * This means that the argument list tokens determine the actions
1246 * taken as they arrive. The structure of the argument list is known
1247 * to the parser and stored in its parse stack when the first argument
1248 * is being parsed. What the parser does not know is which predicates
1249 * will match and whether or not \default will be appearing in the
1250 * argument list, and where.
1252 * Many of the basic nonterminals used for argument list scanning come
1253 * in a "normal" and a "closed" flavor. A closed expression is one
1254 * that can be parsed without a lookahead token. That makes it
1255 * feasible for an optional argument that may need to be skipped:
1256 * skipping can only be accomplished by pushing back the token into
1257 * the lexer, and that only works when there is no lookahead token.
1259 * Sequences of 0 or more optional arguments are scanned using either
1260 * function_arglist_backup or function_arglist_nonbackup. The first
1261 * is used when optional arguments are followed by at least one
1262 * mandatory argument: in that case optional arguments may be skipped
1263 * by either a false predicate (in which case the expression will be
1264 * pushed back as one or more tokens, preceded by a BACKUP token) or
1265 * by using \default.
1267 * If optional arguments are at the end of the argument list, they are
1268 * instead scanned using function_arglist_nonbackup: here the only
1269 * manner to enter into skipping of optional arguments is the use of
1272 * The argument list of a normal function call is parsed using
1273 * function_arglist. The part of an argument list before a mandatory
1274 * argument is parsed using function_arglist_optional.
1276 * The difference is that leading optional arguments are scanned using
1277 * function_arglist_nonbackup and function_arglist_backup,
1280 * Most other details are obvious in the rules themselves.
1284 function_arglist_nonbackup_common:
1285 EXPECT_OPTIONAL EXPECT_SCM function_arglist_nonbackup FRACTION
1287 $$ = check_scheme_arg (parser, @4, $4, $3, $2);
1289 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_closed_nonbackup post_event_nofinger
1291 $$ = check_scheme_arg (parser, @4, $4, $3, $2);
1293 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_closed_nonbackup '-' UNSIGNED
1295 SCM n = scm_difference ($5, SCM_UNDEFINED);
1296 if (scm_is_true (scm_call_1 ($2, n)))
1297 $$ = scm_cons (n, $3);
1299 Music *t = MY_MAKE_MUSIC ("FingeringEvent", @5);
1300 t->set_property ("digit", $5);
1301 $$ = check_scheme_arg (parser, @4, t->unprotect (),
1306 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_closed_nonbackup '-' REAL
1308 $$ = check_scheme_arg (parser, @4,
1309 scm_difference ($5, SCM_UNDEFINED),
1312 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_closed_nonbackup '-' NUMBER_IDENTIFIER
1314 $$ = check_scheme_arg (parser, @4,
1315 scm_difference ($5, SCM_UNDEFINED),
1320 function_arglist_closed_nonbackup:
1321 function_arglist_nonbackup_common
1322 | function_arglist_closed_common
1323 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_nonbackup embedded_scm_arg_closed
1325 $$ = check_scheme_arg (parser, @4, $4, $3, $2);
1327 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_closed_nonbackup bare_number_closed
1329 $$ = check_scheme_arg (parser, @4, $4, $3, $2);
1331 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_nonbackup SCM_IDENTIFIER
1333 $$ = check_scheme_arg (parser, @4,
1334 try_string_variants ($2, $4),
1337 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_nonbackup STRING
1339 $$ = check_scheme_arg (parser, @4,
1340 try_string_variants ($2, $4),
1343 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_nonbackup full_markup
1345 $$ = check_scheme_arg (parser, @4, $4, $3, $2);
1351 | SYMBOL_LIST '.' symbol_list_rev
1353 $$ = scm_append (scm_list_2 ($1, scm_reverse_x ($3, SCM_EOL)));
1359 | symbol_list_rev '.' symbol_list_part
1361 $$ = scm_append_x (scm_list_2 ($3, $1));
1365 // symbol_list_part delivers elements in reverse copy.
1370 SCM sym_l_p = ly_lily_module_constant ("symbol-list?");
1371 $$ = try_string_variants (sym_l_p, $1);
1372 if (SCM_UNBNDP ($$)) {
1373 parser->parser_error (@1, _("not a symbol"));
1376 $$ = scm_reverse ($$);
1381 symbol_list_element:
1387 function_arglist_nonbackup:
1388 function_arglist_nonbackup_common
1389 | function_arglist_common
1390 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_nonbackup embedded_scm_arg
1392 if (scm_is_true (scm_call_1 ($2, $4)))
1393 $$ = scm_cons ($4, $3);
1395 $$ = check_scheme_arg (parser, @4,
1396 make_music_from_simple
1400 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_closed_nonbackup bare_number_common
1402 $$ = check_scheme_arg (parser, @4, $4, $3, $2);
1404 | function_arglist_nonbackup_reparse REPARSE duration_length
1406 $$ = check_scheme_arg (parser, @3, $3, $1, $2);
1408 | function_arglist_nonbackup_reparse REPARSE bare_number_common
1410 $$ = check_scheme_arg (parser, @3, $3, $1, $2);
1412 | function_arglist_nonbackup_reparse REPARSE SCM_ARG
1414 $$ = check_scheme_arg (parser, @3, $3, $1, $2);
1416 | function_arglist_nonbackup_reparse REPARSE lyric_element_music
1418 $$ = check_scheme_arg (parser, @3, $3, $1, $2);
1420 | function_arglist_nonbackup_reparse REPARSE symbol_list_arg
1422 $$ = check_scheme_arg (parser, @3, $3, $1, $2);
1426 function_arglist_nonbackup_reparse:
1427 EXPECT_OPTIONAL EXPECT_SCM function_arglist_nonbackup SCM_IDENTIFIER
1430 SCM res = try_string_variants ($2, $4);
1431 if (!SCM_UNBNDP (res))
1432 if (scm_is_pair (res))
1433 MYREPARSE (@4, $2, SYMBOL_LIST, res);
1435 MYREPARSE (@4, $2, SCM_ARG, res);
1436 else if (scm_is_true
1438 ($2, make_music_from_simple
1440 MYREPARSE (@4, $2, STRING, $4);
1442 MYREPARSE (@4, $2, SCM_ARG, $4);
1444 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_nonbackup STRING
1447 SCM res = try_string_variants ($2, $4);
1448 if (!SCM_UNBNDP (res))
1449 if (scm_is_pair (res))
1450 MYREPARSE (@4, $2, SYMBOL_LIST, res);
1452 MYREPARSE (@4, $2, SCM_ARG, res);
1453 else if (scm_is_true
1455 ($2, make_music_from_simple
1457 MYREPARSE (@4, $2, STRING, $4);
1459 MYREPARSE (@4, $2, SCM_ARG, $4);
1461 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_nonbackup full_markup
1464 if (scm_is_true (scm_call_1 ($2, $4)))
1465 MYREPARSE (@4, $2, SCM_ARG, $4);
1466 else if (scm_is_true
1468 ($2, make_music_from_simple
1470 MYREPARSE (@4, $2, STRING, $4);
1472 MYREPARSE (@4, $2, SCM_ARG, $4);
1474 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_closed_nonbackup UNSIGNED
1477 if (scm_is_true (scm_call_1 ($2, $4)))
1478 MYREPARSE (@4, $2, REAL, $4);
1480 SCM d = make_duration ($4);
1481 if (SCM_UNBNDP (d) || scm_is_false (scm_call_1 ($2, d)))
1482 MYREPARSE (@4, $2, REAL, $4); // trigger error
1484 MYREPARSE (@4, $2, DURATION_IDENTIFIER, d);
1487 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_closed_nonbackup DURATION_IDENTIFIER {
1489 MYREPARSE (@4, $2, DURATION_IDENTIFIER, $4);
1494 function_arglist_backup:
1495 function_arglist_backup_common
1496 | function_arglist_common
1499 function_arglist_closed_backup:
1500 function_arglist_backup_common
1501 | function_arglist_closed_common
1504 function_arglist_backup_common:
1505 EXPECT_OPTIONAL EXPECT_SCM function_arglist_backup embedded_scm_arg_closed
1507 if (scm_is_true (scm_call_1 ($2, $4)))
1509 $$ = scm_cons ($4, $3);
1511 $$ = scm_cons (loc_on_music (@3, $1), $3);
1512 MYBACKUP (SCM_ARG, $4, @4);
1515 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_closed_backup post_event_nofinger
1517 if (scm_is_true (scm_call_1 ($2, $4)))
1519 $$ = scm_cons ($4, $3);
1521 $$ = scm_cons (loc_on_music (@3, $1), $3);
1522 MYBACKUP (EVENT_IDENTIFIER, $4, @4);
1525 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_backup full_markup
1527 if (scm_is_true (scm_call_1 ($2, $4)))
1528 $$ = scm_cons ($4, $3);
1530 $$ = scm_cons (loc_on_music (@3, $1), $3);
1531 MYBACKUP (LYRIC_ELEMENT, $4, @4);
1534 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_closed_backup UNSIGNED
1536 if (scm_is_true (scm_call_1 ($2, $4)))
1538 MYREPARSE (@4, $2, REAL, $4);
1541 SCM d = make_duration ($4);
1542 if (SCM_UNBNDP (d) || scm_is_false (scm_call_1 ($2, d)))
1544 $$ = scm_cons (loc_on_music (@3, $1), $3);
1545 MYBACKUP (UNSIGNED, $4, @4);
1547 MYREPARSE (@4, $2, DURATION_IDENTIFIER, d);
1552 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_closed_backup REAL
1554 if (scm_is_true (scm_call_1 ($2, $4)))
1557 MYREPARSE (@4, $2, REAL, $4);
1559 $$ = scm_cons (loc_on_music (@3, $1), $3);
1560 MYBACKUP (REAL, $4, @4);
1563 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_closed_backup NUMBER_IDENTIFIER
1565 if (scm_is_true (scm_call_1 ($2, $4)))
1567 $$ = scm_cons ($4, $3);
1569 $$ = scm_cons (loc_on_music (@3, $1), $3);
1570 MYBACKUP (NUMBER_IDENTIFIER, $4, @4);
1573 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_backup FRACTION
1575 if (scm_is_true (scm_call_1 ($2, $4)))
1577 $$ = scm_cons ($4, $3);
1579 $$ = scm_cons (loc_on_music (@3, $1), $3);
1580 MYBACKUP (FRACTION, $4, @4);
1583 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_closed_backup '-' UNSIGNED
1585 SCM n = scm_difference ($5, SCM_UNDEFINED);
1586 if (scm_is_true (scm_call_1 ($2, n))) {
1588 MYREPARSE (@5, $2, REAL, n);
1590 Music *t = MY_MAKE_MUSIC ("FingeringEvent", @5);
1591 t->set_property ("digit", $5);
1592 $$ = t->unprotect ();
1593 if (scm_is_true (scm_call_1 ($2, $$)))
1594 $$ = scm_cons ($$, $3);
1596 $$ = scm_cons (loc_on_music (@3, $1), $3);
1597 MYBACKUP (UNSIGNED, $5, @5);
1598 parser->lexer_->push_extra_token ('-');
1603 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_closed_backup '-' REAL
1605 SCM n = scm_difference ($5, SCM_UNDEFINED);
1606 if (scm_is_true (scm_call_1 ($2, n))) {
1607 MYREPARSE (@5, $2, REAL, n);
1610 $$ = scm_cons (loc_on_music (@3, $1), $3);
1611 MYBACKUP (REAL, n, @5);
1614 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_closed_backup '-' NUMBER_IDENTIFIER
1616 SCM n = scm_difference ($5, SCM_UNDEFINED);
1617 if (scm_is_true (scm_call_1 ($2, n))) {
1618 $$ = scm_cons (n, $3);
1620 $$ = scm_cons (loc_on_music (@3, $1), $3);
1621 MYBACKUP (NUMBER_IDENTIFIER, n, @5);
1624 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_backup PITCH_IDENTIFIER
1626 if (scm_is_true (scm_call_1 ($2, $4)))
1628 $$ = scm_cons ($4, $3);
1630 $$ = scm_cons (loc_on_music (@3, $1), $3);
1631 MYBACKUP (PITCH_IDENTIFIER, $4, @4);
1634 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_backup NOTENAME_PITCH
1636 if (scm_is_true (scm_call_1 ($2, $4)))
1638 MYREPARSE (@4, $2, NOTENAME_PITCH, $4);
1641 $$ = scm_cons (loc_on_music (@3, $1), $3);
1642 MYBACKUP (NOTENAME_PITCH, $4, @4);
1645 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_backup TONICNAME_PITCH
1647 if (scm_is_true (scm_call_1 ($2, $4)))
1649 MYREPARSE (@4, $2, TONICNAME_PITCH, $4);
1652 $$ = scm_cons (loc_on_music (@3, $1), $3);
1653 MYBACKUP (TONICNAME_PITCH, $4, @4);
1656 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_closed_backup DURATION_IDENTIFIER
1658 if (scm_is_true (scm_call_1 ($2, $4)))
1660 MYREPARSE (@4, $2, DURATION_IDENTIFIER, $4);
1663 $$ = scm_cons (loc_on_music (@3, $1), $3);
1664 MYBACKUP (DURATION_IDENTIFIER, $4, @4);
1667 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_backup SCM_IDENTIFIER
1669 SCM res = try_string_variants ($2, $4);
1670 if (!SCM_UNBNDP (res))
1671 if (scm_is_pair (res)) {
1673 MYREPARSE (@4, $2, SYMBOL_LIST, res);
1676 $$ = scm_cons (res, $3);
1678 $$ = scm_cons (loc_on_music (@3, $1), $3);
1679 MYBACKUP (SCM_IDENTIFIER, $4, @4);
1682 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_backup STRING
1684 SCM res = try_string_variants ($2, $4);
1685 if (!SCM_UNBNDP (res))
1686 if (scm_is_pair (res)) {
1688 MYREPARSE (@4, $2, SYMBOL_LIST, res);
1691 $$ = scm_cons (res, $3);
1693 $$ = scm_cons (loc_on_music (@3, $1), $3);
1694 MYBACKUP (STRING, $4, @4);
1697 | function_arglist_backup REPARSE bare_number_common
1699 $$ = check_scheme_arg (parser, @3,
1702 | function_arglist_backup REPARSE duration_length
1704 $$ = check_scheme_arg (parser, @3,
1707 | function_arglist_backup REPARSE symbol_list_arg
1709 $$ = check_scheme_arg (parser, @3, $3, $1, $2);
1711 | function_arglist_backup REPARSE pitch_also_in_chords
1713 $$ = check_scheme_arg (parser, @3, $3, $1, $2);
1718 function_arglist_nonbackup
1719 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_skip_nonbackup DEFAULT
1721 $$ = scm_cons (loc_on_music (@4, $1), $3);
1725 function_arglist_skip_nonbackup:
1726 function_arglist_nonbackup
1727 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_skip_nonbackup
1729 $$ = scm_cons (loc_on_music (@3, $1), $3);
1733 function_arglist_common:
1734 EXPECT_NO_MORE_ARGS {
1737 | EXPECT_SCM function_arglist_optional embedded_scm_arg
1739 if (scm_is_true (scm_call_1 ($1, $3)))
1740 $$ = scm_cons ($3, $2);
1742 $$ = check_scheme_arg (parser, @3,
1743 make_music_from_simple
1747 | EXPECT_SCM function_arglist_closed_optional bare_number_common
1749 $$ = check_scheme_arg (parser, @3,
1752 | EXPECT_SCM function_arglist_optional FRACTION
1754 $$ = check_scheme_arg (parser, @3,
1757 | EXPECT_SCM function_arglist_closed_optional post_event_nofinger
1759 $$ = check_scheme_arg (parser, @3,
1762 | EXPECT_SCM function_arglist_closed_optional '-' NUMBER_IDENTIFIER
1764 SCM n = scm_difference ($4, SCM_UNDEFINED);
1765 $$ = check_scheme_arg (parser, @4, n, $2, $1);
1767 | function_arglist_common_reparse REPARSE SCM_ARG
1769 $$ = check_scheme_arg (parser, @3,
1772 | function_arglist_common_reparse REPARSE lyric_element_music
1774 $$ = check_scheme_arg (parser, @3,
1777 | function_arglist_common_reparse REPARSE bare_number_common
1779 $$ = check_scheme_arg (parser, @3,
1782 | function_arglist_common_reparse REPARSE duration_length
1784 $$ = check_scheme_arg (parser, @3,
1787 | function_arglist_common_reparse REPARSE symbol_list_arg
1789 $$ = check_scheme_arg (parser, @3, $3, $1, $2);
1793 function_arglist_common_reparse:
1794 EXPECT_SCM function_arglist_optional SCM_IDENTIFIER
1797 SCM res = try_string_variants ($1, $3);
1798 if (!SCM_UNBNDP (res))
1799 if (scm_is_pair (res))
1800 MYREPARSE (@3, $1, SYMBOL_LIST, res);
1802 MYREPARSE (@3, $1, SCM_ARG, res);
1803 else if (scm_is_true
1805 ($1, make_music_from_simple (parser, @3, $3))))
1806 MYREPARSE (@3, $1, LYRIC_ELEMENT, $3);
1808 // This is going to flag a syntax error, we
1809 // know the predicate to be false.
1810 MYREPARSE (@3, $1, SCM_ARG, $3);
1812 | EXPECT_SCM function_arglist_optional STRING
1815 SCM res = try_string_variants ($1, $3);
1816 if (!SCM_UNBNDP (res))
1817 if (scm_is_pair (res))
1818 MYREPARSE (@3, $1, SYMBOL_LIST, res);
1820 MYREPARSE (@3, $1, SCM_ARG, res);
1821 else if (scm_is_true
1823 ($1, make_music_from_simple (parser, @3, $3))))
1824 MYREPARSE (@3, $1, LYRIC_ELEMENT, $3);
1826 // This is going to flag a syntax error, we
1827 // know the predicate to be false.
1828 MYREPARSE (@3, $1, SCM_ARG, $3);
1830 | EXPECT_SCM function_arglist_optional full_markup
1833 if (scm_is_true (scm_call_1 ($1, $3)))
1834 MYREPARSE (@3, $1, SCM_ARG, $3);
1835 else if (scm_is_true
1837 ($1, make_music_from_simple (parser, @3, $3))))
1838 MYREPARSE (@3, $1, LYRIC_ELEMENT, $3);
1840 // This is going to flag a syntax error, we
1841 // know the predicate to be false.
1842 MYREPARSE (@3, $1, SCM_ARG, $3);
1844 | EXPECT_SCM function_arglist_closed_optional UNSIGNED
1847 if (scm_is_true (scm_call_1 ($1, $3)))
1848 MYREPARSE (@3, $1, REAL, $3);
1850 SCM d = make_duration ($3);
1851 if (SCM_UNBNDP (d) || scm_is_false (scm_call_1 ($1, d)))
1852 MYREPARSE (@3, $1, REAL, $3);
1854 MYREPARSE (@3, $1, DURATION_IDENTIFIER, d);
1857 | EXPECT_SCM function_arglist_closed_optional DURATION_IDENTIFIER
1860 MYREPARSE (@3, $1, DURATION_IDENTIFIER, $3);
1862 | EXPECT_SCM function_arglist_closed_optional '-' UNSIGNED
1865 SCM n = scm_difference ($4, SCM_UNDEFINED);
1866 if (scm_is_true (scm_call_1 ($1, n)))
1867 MYREPARSE (@4, $1, REAL, n);
1869 Music *t = MY_MAKE_MUSIC ("FingeringEvent", @4);
1870 t->set_property ("digit", $4);
1871 SCM m = t->unprotect ();
1872 if (scm_is_true (scm_call_1 ($1, m)))
1873 MYREPARSE (@4, $1, SCM_ARG, m);
1875 MYREPARSE (@4, $1, SCM_ARG, $4);
1879 | EXPECT_SCM function_arglist_closed_optional '-' REAL
1882 SCM n = scm_difference ($4, SCM_UNDEFINED);
1883 MYREPARSE (@4, $1, REAL, n);
1887 function_arglist_closed:
1888 function_arglist_closed_nonbackup
1889 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_skip_nonbackup DEFAULT
1891 $$ = scm_cons (loc_on_music (@4, $1), $3);
1895 function_arglist_closed_common:
1896 EXPECT_NO_MORE_ARGS {
1899 | EXPECT_SCM function_arglist_optional embedded_scm_arg_closed
1901 $$ = check_scheme_arg (parser, @3,
1904 | EXPECT_SCM function_arglist_closed_optional bare_number_common_closed
1906 $$ = check_scheme_arg (parser, @3,
1909 | EXPECT_SCM function_arglist_closed_optional '-' NUMBER_IDENTIFIER
1911 $$ = check_scheme_arg (parser, @3,
1912 scm_difference ($4, SCM_UNDEFINED),
1915 | EXPECT_SCM function_arglist_closed_optional post_event_nofinger
1917 $$ = check_scheme_arg (parser, @3,
1920 | EXPECT_SCM function_arglist_optional FRACTION
1922 $$ = check_scheme_arg (parser, @3,
1925 | function_arglist_common_reparse REPARSE SCM_ARG
1927 $$ = check_scheme_arg (parser, @3,
1930 | function_arglist_common_reparse REPARSE bare_number_common_closed
1932 $$ = check_scheme_arg (parser, @3,
1935 | function_arglist_common_reparse REPARSE symbol_list_arg
1937 $$ = check_scheme_arg (parser, @3, $3, $1, $2);
1941 function_arglist_optional:
1942 function_arglist_backup
1943 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_skip_backup DEFAULT
1945 $$ = scm_cons (loc_on_music (@4, $1), $3);
1947 | function_arglist_skip_backup BACKUP
1950 function_arglist_skip_backup:
1951 function_arglist_backup
1952 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_skip_backup
1954 $$ = scm_cons (loc_on_music (@3, $1), $3);
1958 function_arglist_closed_optional:
1959 function_arglist_closed_backup
1960 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_skip_backup DEFAULT
1962 $$ = scm_cons (loc_on_music (@4, $1), $3);
1964 | function_arglist_skip_backup BACKUP
1967 embedded_scm_closed:
1969 | scm_function_call_closed
1972 embedded_scm_arg_closed:
1973 embedded_scm_bare_arg
1974 | scm_function_call_closed
1978 scm_function_call_closed:
1979 SCM_FUNCTION function_arglist_closed {
1980 $$ = MAKE_SYNTAX ("music-function", @$,
1985 music_function_call:
1986 MUSIC_FUNCTION function_arglist {
1987 $$ = MAKE_SYNTAX ("music-function", @$,
1994 /**/ { $$ = SCM_EOL; }
1995 | '=' simple_string {
2002 | repeated_music { $$ = $1; }
2003 | re_rhythmed_music { $$ = $1; }
2004 | complex_music_prefix music
2006 $$ = FINISH_MAKE_SYNTAX ($1, @$, $2);
2010 complex_music_prefix:
2011 CONTEXT symbol optional_id optional_context_mod {
2012 Context_mod *ctxmod = unsmob_context_mod ($4);
2015 mods = ctxmod->get_mods ();
2016 $$ = START_MAKE_SYNTAX ("context-specification", $2, $3, mods, SCM_BOOL_F);
2018 | NEWCONTEXT symbol optional_id optional_context_mod {
2019 Context_mod *ctxmod = unsmob_context_mod ($4);
2022 mods = ctxmod->get_mods ();
2023 $$ = START_MAKE_SYNTAX ("context-specification", $2, $3, mods, SCM_BOOL_T);
2028 mode_changing_head grouped_music_list {
2029 if ($1 == ly_symbol2scm ("chords"))
2031 $$ = MAKE_SYNTAX ("unrelativable-music", @$, $2);
2037 parser->lexer_->pop_state ();
2039 | mode_changing_head_with_context optional_context_mod grouped_music_list {
2040 Context_mod *ctxmod = unsmob_context_mod ($2);
2043 mods = ctxmod->get_mods ();
2044 $$ = MAKE_SYNTAX ("context-specification", @$, $1, SCM_EOL, mods, SCM_BOOL_T, $3);
2045 if ($1 == ly_symbol2scm ("ChordNames"))
2047 $$ = MAKE_SYNTAX ("unrelativable-music", @$, $$);
2049 parser->lexer_->pop_state ();
2055 SCM nn = parser->lexer_->lookup_identifier ("pitchnames");
2056 parser->lexer_->push_note_state (nn);
2058 $$ = ly_symbol2scm ("notes");
2062 SCM nn = parser->lexer_->lookup_identifier ("drumPitchNames");
2063 parser->lexer_->push_note_state (nn);
2065 $$ = ly_symbol2scm ("drums");
2068 parser->lexer_->push_figuredbass_state ();
2070 $$ = ly_symbol2scm ("figures");
2073 SCM nn = parser->lexer_->lookup_identifier ("chordmodifiers");
2074 parser->lexer_->chordmodifier_tab_ = alist_to_hashq (nn);
2075 nn = parser->lexer_->lookup_identifier ("pitchnames");
2076 parser->lexer_->push_chord_state (nn);
2077 $$ = ly_symbol2scm ("chords");
2081 { parser->lexer_->push_lyric_state ();
2082 $$ = ly_symbol2scm ("lyrics");
2086 mode_changing_head_with_context:
2088 SCM nn = parser->lexer_->lookup_identifier ("drumPitchNames");
2089 parser->lexer_->push_note_state (nn);
2091 $$ = ly_symbol2scm ("DrumStaff");
2094 parser->lexer_->push_figuredbass_state ();
2096 $$ = ly_symbol2scm ("FiguredBass");
2099 SCM nn = parser->lexer_->lookup_identifier ("chordmodifiers");
2100 parser->lexer_->chordmodifier_tab_ = alist_to_hashq (nn);
2101 nn = parser->lexer_->lookup_identifier ("pitchnames");
2102 parser->lexer_->push_chord_state (nn);
2103 $$ = ly_symbol2scm ("ChordNames");
2106 { parser->lexer_->push_lyric_state ();
2107 $$ = ly_symbol2scm ("Lyrics");
2112 ADDLYRICS { parser->lexer_->push_lyric_state (); }
2115 /* Can also use music at the expensive of two S/Rs similar to
2116 \repeat \alternative */
2117 parser->lexer_->pop_state ();
2119 $$ = scm_cons ($3, SCM_EOL);
2121 | new_lyrics ADDLYRICS {
2122 parser->lexer_->push_lyric_state ();
2124 parser->lexer_->pop_state ();
2125 $$ = scm_cons ($4, $1);
2130 composite_music new_lyrics {
2131 $$ = MAKE_SYNTAX ("add-lyrics", @$, $1, scm_reverse_x ($2, SCM_EOL));
2133 | LYRICSTO simple_string {
2134 parser->lexer_->push_lyric_state ();
2136 parser->lexer_->pop_state ();
2137 $$ = MAKE_SYNTAX ("lyric-combine", @$, $2, $4);
2142 CHANGE STRING '=' STRING {
2143 $$ = MAKE_SYNTAX ("context-change", @$, scm_string_to_symbol ($2), $4);
2150 $$ = scm_reverse_x ($1, SCM_EOL);
2152 | symbol_list_rev property_path {
2153 $$ = scm_reverse_x ($1, $2);
2159 $$ = scm_list_3 (ly_symbol2scm ("assign"), $1, $3);
2162 $$ = scm_list_2 (ly_symbol2scm ("unset"), $2);
2164 | OVERRIDE property_path '=' scalar {
2165 if (scm_ilength ($2) < 2) {
2166 parser->parser_error (@2, _("bad grob property path"));
2169 $$ = scm_cons (ly_symbol2scm ("push"),
2170 scm_cons2 (scm_car ($2),
2175 | REVERT revert_arg {
2176 $$ = scm_cons (ly_symbol2scm ("pop"), $2);
2180 // This is all quite awkward for the sake of substantial backward
2181 // compatibility while at the same time allowing a more "natural" form
2182 // of specification not separating grob specification from grob
2183 // property path. The purpose of this definition of revert_arg is to
2184 // allow the symbol list which specifies grob and property to revert
2185 // to be optionally be split into two parts after the grob (which in
2186 // this case is just the first element of the list). symbol_list_part
2187 // is only one path component, but it can be parsed without lookahead,
2188 // so we can follow it with a synthetic BACKUP token when needed. If
2189 // the first symbol_list_part already contains multiple elements (only
2190 // possible if a Scheme expression provides them), we just parse for
2191 // additional elements introduced by '.', which is what the
2192 // SYMBOL_LIST backup in connection with the immediately following
2193 // rule using symbol_list_arg does.
2195 // As long as we don't have our coffers filled with both grob and at
2196 // least one grob property specification, the rest of the required
2197 // symbol list chain may be provided either with or without a leading
2198 // dot. This is for both allowing the traditional
2199 // \revert Accidental #'color
2200 // as well as well as the "naive" form
2201 // \revert Accidental.color
2204 revert_arg_backup BACKUP symbol_list_arg
2213 if (scm_is_null ($1)
2214 || scm_is_null (scm_cdr ($1)))
2215 MYBACKUP (SCM_ARG, $1, @1);
2217 MYBACKUP (SYMBOL_LIST, scm_reverse_x ($1, SCM_EOL), @1);
2221 // revert_arg_part delivers results in reverse
2224 | revert_arg_backup BACKUP SCM_ARG '.' symbol_list_part
2226 $$ = scm_append_x (scm_list_2 ($5, $3));
2228 | revert_arg_backup BACKUP SCM_ARG symbol_list_part
2230 $$ = scm_append_x (scm_list_2 ($4, $3));
2235 CONSISTS { $$ = ly_symbol2scm ("consists"); }
2236 | REMOVE { $$ = ly_symbol2scm ("remove"); }
2238 | ACCEPTS { $$ = ly_symbol2scm ("accepts"); }
2239 | DEFAULTCHILD { $$ = ly_symbol2scm ("default-child"); }
2240 | DENIES { $$ = ly_symbol2scm ("denies"); }
2242 | ALIAS { $$ = ly_symbol2scm ("alias"); }
2243 | TYPE { $$ = ly_symbol2scm ("translator-type"); }
2244 | DESCRIPTION { $$ = ly_symbol2scm ("description"); }
2245 | NAME { $$ = ly_symbol2scm ("context-name"); }
2249 property_operation { $$ = $1; }
2250 | context_def_mod STRING {
2251 $$ = scm_list_2 ($1, $2);
2253 | context_def_mod embedded_scm
2255 if (!scm_is_string ($2)
2256 && ly_symbol2scm ("consists") != $1
2257 && ly_symbol2scm ("remove") != $1)
2260 parser->parser_error (@1, _ ("only \\consists and \\remove take non-string argument."));
2264 $$ = scm_list_2 ($1, $2);
2269 // If defined, at least two members.
2273 SCM l = scm_reverse_x ($1, SCM_EOL);
2276 (scm_object_property (scm_car (l),
2277 ly_symbol2scm ("is-grob?"))))
2278 l = scm_cons (ly_symbol2scm ("Bottom"), l);
2279 if (scm_is_null (l) || scm_is_null (scm_cdr (l))) {
2280 parser->parser_error (@1, _ ("bad grob property path"));
2287 // If defined, at least three members
2291 if (!SCM_UNBNDP ($1) && scm_is_null (scm_cddr ($1)))
2293 parser->parser_error (@1, _ ("bad grob property path"));
2297 | grob_prop_spec property_path
2299 if (!SCM_UNBNDP ($1)) {
2300 $$ = scm_append_x (scm_list_2 ($1, $2));
2301 if (scm_is_null (scm_cddr ($$))) {
2302 parser->parser_error (@$, _ ("bad grob property path"));
2310 // Exactly two elements or undefined
2314 SCM l = scm_reverse_x ($1, SCM_EOL);
2315 switch (scm_ilength (l)) {
2317 l = scm_cons (ly_symbol2scm ("Bottom"), l);
2321 parser->parser_error (@1, _ ("bad context property path"));
2328 simple_music_property_def:
2329 OVERRIDE grob_prop_path '=' scalar {
2330 if (SCM_UNBNDP ($2))
2333 $$ = scm_list_5 (scm_car ($2),
2334 ly_symbol2scm ("OverrideProperty"),
2340 | REVERT simple_revert_context revert_arg {
2341 $$ = scm_list_4 ($2,
2342 ly_symbol2scm ("RevertProperty"),
2346 | SET context_prop_spec '=' scalar {
2347 if (SCM_UNBNDP ($2))
2350 $$ = scm_list_4 (scm_car ($2),
2351 ly_symbol2scm ("PropertySet"),
2355 | UNSET context_prop_spec {
2356 if (SCM_UNBNDP ($2))
2359 $$ = scm_list_3 (scm_car ($2),
2360 ly_symbol2scm ("PropertyUnset"),
2366 // This is all quite awkward for the sake of substantial backward
2367 // compatibility while at the same time allowing a more "natural" form
2368 // of specification not separating grob specification from grob
2369 // property path. The purpose of this definition of
2370 // simple_revert_context is to allow the symbol list which specifies
2371 // grob and property to revert to be optionally be split into two
2372 // parts after the grob (which may be preceded by a context
2373 // specification, a case which we distinguish by checking whether the
2374 // first symbol is a valid grob symbol instead).
2376 // See revert_arg above for the main work horse of this arrangement.
2377 // simple_revert_context just caters for the context and delegates the
2378 // rest of the job to revert_arg.
2380 simple_revert_context:
2383 $1 = scm_reverse_x ($1, SCM_EOL);
2384 if (scm_is_null ($1)
2386 (scm_object_property (scm_car ($1),
2387 ly_symbol2scm ("is-grob?")))) {
2388 $$ = ly_symbol2scm ("Bottom");
2389 parser->lexer_->push_extra_token (SCM_IDENTIFIER, $1);
2392 parser->lexer_->push_extra_token (SCM_IDENTIFIER,
2399 simple_music_property_def {
2400 if (SCM_UNBNDP ($1))
2401 $$ = MAKE_SYNTAX ("void-music", @1);
2403 $$ = LOWLEVEL_MAKE_SYNTAX (ly_lily_module_constant ("property-operation"), scm_cons2 (parser->self_scm (), make_input (@$), $1));
2414 simple_string: STRING {
2419 if (scm_is_string ($1)) {
2422 parser->parser_error (@1, (_ ("simple string expected")));
2423 $$ = scm_string (SCM_EOL);
2430 $$ = scm_string_to_symbol ($1);
2434 // This is a bit of overkill but makes the same
2435 // routine responsible for all symbol interpretations.
2436 $$ = try_string_variants (ly_lily_module_constant ("symbol?"),
2438 if (SCM_UNBNDP ($$))
2440 parser->parser_error (@1, (_ ("symbol expected")));
2441 // Generate a unique symbol in case it is used
2442 // for an assignment or similar
2443 $$ = scm_make_symbol (ly_string2scm ("undefined"));
2452 // The following is a rather defensive variant of admitting
2453 // negative numbers: the grammar would permit number_factor or
2454 // even number_expression. However, function arguments allow
2455 // only this simple kind of negative number, so to have things
2456 // like \tweak and \override behave reasonably similar, it
2457 // makes sense to rule out things like -- which are rather an
2458 // accent in function argument contexts.
2461 $$ = scm_difference ($2, SCM_UNDEFINED);
2469 embedded_scm_arg_closed
2471 // for scalar_closed to be an actually closed (no lookahead)
2472 // expression, we'd need to use bare_number_closed here. It
2473 // turns out that the only use of scalar_closed in TEMPO is
2474 // not of the kind requiring the full closedness criterion.
2478 $$ = scm_difference ($2, SCM_UNDEFINED);
2487 simple_element post_events {
2488 // Let the rhythmic music iterator sort this mess out.
2489 if (scm_is_pair ($2)) {
2490 $$ = make_music_from_simple (parser, @1, $1);
2491 if (unsmob_music ($$))
2492 unsmob_music ($$)->set_property ("articulations",
2493 scm_reverse_x ($2, SCM_EOL));
2495 parser->parser_error (@1, _("music expected"));
2498 | simple_chord_elements post_events {
2499 SCM elts = ly_append2 ($1, scm_reverse_x ($2, SCM_EOL));
2502 /* why is this giving wrong start location? -ns
2504 i.set_location (@1, @2);
2505 $$ = MAKE_SYNTAX ("event-chord", i, elts);
2507 | CHORD_REPETITION optional_notemode_duration post_events {
2509 i.set_location (@1, @3);
2510 $$ = MAKE_SYNTAX ("repetition-chord", i,
2511 $2, scm_reverse_x ($3, SCM_EOL));
2513 | MULTI_MEASURE_REST optional_notemode_duration post_events {
2515 i.set_location (@1, @3);
2516 $$ = MAKE_SYNTAX ("multi-measure-rest", i, $2,
2517 scm_reverse_x ($3, SCM_EOL));
2520 | note_chord_element
2525 chord_body optional_notemode_duration post_events
2527 Music *m = unsmob_music ($1);
2528 SCM dur = unsmob_duration ($2)->smobbed_copy ();
2529 SCM es = m->get_property ("elements");
2530 SCM postevs = scm_reverse_x ($3, SCM_EOL);
2532 for (SCM s = es; scm_is_pair (s); s = scm_cdr (s))
2533 unsmob_music (scm_car (s))->set_property ("duration", dur);
2534 es = ly_append2 (es, postevs);
2536 m-> set_property ("elements", es);
2538 $$ = m->self_scm ();
2543 ANGLE_OPEN chord_body_elements ANGLE_CLOSE
2545 $$ = MAKE_SYNTAX ("event-chord", @$, scm_reverse_x ($2, SCM_EOL));
2549 chord_body_elements:
2550 /* empty */ { $$ = SCM_EOL; }
2551 | chord_body_elements chord_body_element {
2552 if (!SCM_UNBNDP ($2))
2553 $$ = scm_cons ($2, $1);
2558 pitch exclamations questions octave_check post_events
2560 bool q = to_boolean ($3);
2561 bool ex = to_boolean ($2);
2565 Music *n = MY_MAKE_MUSIC ("NoteEvent", @$);
2566 n->set_property ("pitch", $1);
2568 n->set_property ("cautionary", SCM_BOOL_T);
2570 n->set_property ("force-accidental", SCM_BOOL_T);
2572 if (scm_is_pair (post)) {
2573 SCM arts = scm_reverse_x (post, SCM_EOL);
2574 n->set_property ("articulations", arts);
2576 if (scm_is_number (check))
2578 int q = scm_to_int (check);
2579 n->set_property ("absolute-octave", scm_from_int (q-1));
2582 $$ = n->unprotect ();
2584 | DRUM_PITCH post_events {
2585 Music *n = MY_MAKE_MUSIC ("NoteEvent", @$);
2586 n->set_property ("drum-type", $1);
2588 if (scm_is_pair ($2)) {
2589 SCM arts = scm_reverse_x ($2, SCM_EOL);
2590 n->set_property ("articulations", arts);
2592 $$ = n->unprotect ();
2594 | music_function_chord_body
2596 Music *m = unsmob_music ($1);
2598 while (m && m->is_mus_type ("music-wrapper-music")) {
2599 $$ = m->get_property ("element");
2600 m = unsmob_music ($$);
2603 if (!(m && m->is_mus_type ("rhythmic-event"))) {
2604 parser->parser_error (@$, _ ("not a rhythmic event"));
2610 music_function_chord_body:
2615 // Event functions may only take closed arglists, otherwise it would
2616 // not be clear whether a following postevent should be associated
2617 // with the last argument of the event function or with the expression
2618 // for which the function call acts itself as event.
2620 music_function_call_closed:
2621 MUSIC_FUNCTION function_arglist_closed {
2622 $$ = MAKE_SYNTAX ("music-function", @$,
2627 event_function_event:
2628 EVENT_FUNCTION function_arglist_closed {
2629 $$ = MAKE_SYNTAX ("music-function", @$,
2651 | post_events post_event {
2653 if (Music *m = unsmob_music ($2))
2655 if (m->is_mus_type ("post-event-wrapper"))
2657 for (SCM p = m->get_property ("elements");
2661 $$ = scm_cons (scm_car (p), $$);
2665 $$ = scm_cons ($2, $$);
2671 post_event_nofinger:
2672 direction_less_event {
2675 | script_dir music_function_call_closed {
2677 if (!unsmob_music ($2)->is_mus_type ("post-event")) {
2678 parser->parser_error (@2, _ ("post-event expected"));
2679 $$ = SCM_UNSPECIFIED;
2680 } else if (!SCM_UNBNDP ($1))
2682 unsmob_music ($$)->set_property ("direction", $1);
2686 if (!parser->lexer_->is_lyric_state ())
2687 parser->parser_error (@1, _ ("have to be in Lyric mode for lyrics"));
2688 $$ = MY_MAKE_MUSIC ("HyphenEvent", @$)->unprotect ();
2691 if (!parser->lexer_->is_lyric_state ())
2692 parser->parser_error (@1, _ ("have to be in Lyric mode for lyrics"));
2693 $$ = MY_MAKE_MUSIC ("ExtenderEvent", @$)->unprotect ();
2695 | script_dir direction_reqd_event {
2696 if (!SCM_UNBNDP ($1))
2698 Music *m = unsmob_music ($2);
2699 m->set_property ("direction", $1);
2703 | script_dir direction_less_event {
2704 if (!SCM_UNBNDP ($1))
2706 Music *m = unsmob_music ($2);
2707 m->set_property ("direction", $1);
2714 unsmob_music ($$)->set_property ("direction", scm_from_int (UP));
2719 unsmob_music ($$)->set_property ("direction", scm_from_int (DOWN));
2730 string_number_event:
2732 Music *s = MY_MAKE_MUSIC ("StringNumberEvent", @$);
2733 s->set_property ("string-number", $1);
2734 $$ = s->unprotect ();
2738 direction_less_event:
2740 | EVENT_IDENTIFIER {
2744 Music *a = MY_MAKE_MUSIC ("TremoloEvent", @$);
2745 a->set_property ("tremolo-type", $1);
2746 $$ = a->unprotect ();
2748 | event_function_event
2751 direction_reqd_event:
2755 | script_abbreviation {
2756 SCM s = parser->lexer_->lookup_identifier ("dash" + ly_scm2string ($1));
2757 Music *a = MY_MAKE_MUSIC ("ArticulationEvent", @$);
2758 if (scm_is_string (s))
2759 a->set_property ("articulation-type", s);
2760 else parser->parser_error (@1, _ ("expecting string as script definition"));
2761 $$ = a->unprotect ();
2766 /**/ { $$ = SCM_EOL; }
2767 | '=' quotes { $$ = $2; }
2781 $$ = scm_from_int (1);
2784 $$ = scm_oneplus ($1);
2790 $$ = scm_from_int (-1);
2793 $$ = scm_oneminus ($1);
2798 NOTENAME_PITCH quotes {
2799 if (!scm_is_eq (SCM_INUM0, $2))
2801 Pitch p = *unsmob_pitch ($1);
2802 p = p.transposed (Pitch (scm_to_int ($2),0,0));
2803 $$ = p.smobbed_copy ();
2813 TONICNAME_PITCH quotes {
2814 if (!scm_is_eq (SCM_INUM0, $2))
2816 Pitch p = *unsmob_pitch ($1);
2817 p = p.transposed (Pitch (scm_to_int ($2),0,0));
2818 $$ = p.smobbed_copy ();
2828 pitch_also_in_chords:
2835 Music *t = MY_MAKE_MUSIC ("TextScriptEvent", @$);
2836 t->set_property ("text", $1);
2837 $$ = t->unprotect ();
2840 Music *t = MY_MAKE_MUSIC ("TextScriptEvent", @$);
2841 t->set_property ("text",
2842 make_simple_markup ($1));
2843 $$ = t->unprotect ();
2845 | embedded_scm_closed
2847 Music *m = unsmob_music ($1);
2848 if (m && m->is_mus_type ("post-event"))
2850 else if (Text_interface::is_markup ($1)) {
2851 Music *t = MY_MAKE_MUSIC ("TextScriptEvent", @$);
2852 t->set_property ("text", $1);
2853 $$ = t->unprotect ();
2855 parser->parser_error (@1, _ ("not an articulation"));
2861 Music *t = MY_MAKE_MUSIC ("FingeringEvent", @$);
2862 t->set_property ("digit", $1);
2863 $$ = t->unprotect ();
2867 script_abbreviation:
2869 $$ = scm_from_locale_string ("Hat");
2872 $$ = scm_from_locale_string ("Plus");
2875 $$ = scm_from_locale_string ("Dash");
2878 $$ = scm_from_locale_string ("Bang");
2881 $$ = scm_from_locale_string ("Larger");
2884 $$ = scm_from_locale_string ("Dot");
2887 $$ = scm_from_locale_string ("Underscore");
2892 '_' { $$ = scm_from_int (DOWN); }
2893 | '^' { $$ = scm_from_int (UP); }
2894 | '-' { $$ = SCM_UNDEFINED; }
2898 multiplied_duration {
2903 maybe_notemode_duration:
2907 | multiplied_duration {
2909 parser->default_duration_ = *unsmob_duration ($$);
2914 optional_notemode_duration:
2915 maybe_notemode_duration
2917 if (SCM_UNBNDP ($$))
2918 $$ = parser->default_duration_.smobbed_copy ();
2924 $$ = make_duration ($1, scm_to_int ($2));
2925 if (SCM_UNBNDP ($$))
2927 parser->parser_error (@1, _ ("not a duration"));
2928 $$ = Duration ().smobbed_copy ();
2931 | DURATION_IDENTIFIER dots {
2932 Duration *d = unsmob_duration ($1);
2933 Duration k (d->duration_log (),
2934 d->dot_count () + scm_to_int ($2));
2935 k = k.compressed (d->factor ());
2936 scm_remember_upto_here_1 ($1);
2937 $$ = k.smobbed_copy ();
2941 multiplied_duration:
2945 | multiplied_duration '*' UNSIGNED {
2946 $$ = unsmob_duration ($$)->compressed (scm_to_int ($3)).smobbed_copy ();
2948 | multiplied_duration '*' FRACTION {
2949 Rational m (scm_to_int (scm_car ($3)), scm_to_int (scm_cdr ($3)));
2951 $$ = unsmob_duration ($$)->compressed (m).smobbed_copy ();
2960 $$ = scm_oneplus ($1);
2969 if (SCM_UNBNDP (make_duration ($2)))
2970 parser->parser_error (@2, _ ("not a duration"));
2976 UNSIGNED { $$ = $1; }
2977 | STRING { $$ = $1; }
2978 | full_markup { $$ = $1; }
2981 // as an integer, it needs to be non-negative, and otherwise
2982 // it needs to be suitable as a markup.
2983 if (scm_is_integer ($1)
2984 ? scm_is_true (scm_negative_p ($1))
2985 : !Text_interface::is_markup ($1))
2987 parser->parser_error (@1, _ ("bass number expected"));
2993 figured_bass_alteration:
2994 '-' { $$ = ly_rational2scm (FLAT_ALTERATION); }
2995 | '+' { $$ = ly_rational2scm (SHARP_ALTERATION); }
2996 | '!' { $$ = scm_from_int (0); }
3001 Music *bfr = MY_MAKE_MUSIC ("BassFigureEvent", @$);
3002 $$ = bfr->unprotect ();
3005 Music *bfr = MY_MAKE_MUSIC ("BassFigureEvent", @$);
3006 $$ = bfr->self_scm ();
3008 if (scm_is_number ($1))
3009 bfr->set_property ("figure", $1);
3010 else if (Text_interface::is_markup ($1))
3011 bfr->set_property ("text", $1);
3017 unsmob_music ($1)->set_property ("bracket-stop", SCM_BOOL_T);
3019 | bass_figure figured_bass_alteration {
3020 Music *m = unsmob_music ($1);
3021 if (scm_to_double ($2)) {
3022 SCM salter = m->get_property ("alteration");
3023 SCM alter = scm_is_number (salter) ? salter : scm_from_int (0);
3024 m->set_property ("alteration",
3025 scm_sum (alter, $2));
3027 m->set_property ("alteration", scm_from_int (0));
3030 | bass_figure figured_bass_modification {
3031 Music *m = unsmob_music ($1);
3032 m->set_property ($2, SCM_BOOL_T);
3037 figured_bass_modification:
3039 $$ = ly_symbol2scm ("augmented");
3042 $$ = ly_symbol2scm ("no-continuation");
3045 $$ = ly_symbol2scm ("diminished");
3048 $$ = ly_symbol2scm ("augmented-slash");
3058 unsmob_music ($$)->set_property ("bracket-start", SCM_BOOL_T);
3066 | figure_list br_bass_figure {
3067 $$ = scm_cons ($2, $1);
3072 FIGURE_OPEN figure_list FIGURE_CLOSE {
3073 $$ = scm_reverse_x ($2, SCM_EOL);
3079 /**/ { $$ = SCM_BOOL_F; }
3080 | REST { $$ = SCM_BOOL_T; }
3084 pitch exclamations questions octave_check maybe_notemode_duration optional_rest {
3085 if (!parser->lexer_->is_note_state ())
3086 parser->parser_error (@1, _ ("have to be in Note mode for notes"));
3087 if (!SCM_UNBNDP ($2)
3089 || scm_is_number ($4)
3091 || scm_is_true ($6))
3094 if (scm_is_true ($6))
3095 n = MY_MAKE_MUSIC ("RestEvent", @$);
3097 n = MY_MAKE_MUSIC ("NoteEvent", @$);
3099 n->set_property ("pitch", $1);
3100 if (SCM_UNBNDP ($5))
3101 n->set_property ("duration",
3102 parser->default_duration_.smobbed_copy ());
3104 n->set_property ("duration", $5);
3106 if (scm_is_number ($4))
3108 int q = scm_to_int ($4);
3109 n->set_property ("absolute-octave", scm_from_int (q-1));
3112 if (to_boolean ($3))
3113 n->set_property ("cautionary", SCM_BOOL_T);
3114 if (to_boolean ($2) || to_boolean ($3))
3115 n->set_property ("force-accidental", SCM_BOOL_T);
3117 $$ = n->unprotect ();
3120 | DRUM_PITCH optional_notemode_duration {
3121 Music *n = MY_MAKE_MUSIC ("NoteEvent", @$);
3122 n->set_property ("duration", $2);
3123 n->set_property ("drum-type", $1);
3125 $$ = n->unprotect ();
3127 | RESTNAME optional_notemode_duration {
3129 if (ly_scm2string ($1) == "s") {
3131 ev = MY_MAKE_MUSIC ("SkipEvent", @$);
3134 ev = MY_MAKE_MUSIC ("RestEvent", @$);
3137 ev->set_property ("duration", $2);
3138 $$ = ev->unprotect ();
3142 simple_chord_elements:
3144 if (!parser->lexer_->is_chord_state ())
3145 parser->parser_error (@1, _ ("have to be in Chord mode for chords"));
3148 | figure_spec optional_notemode_duration {
3149 for (SCM s = $1; scm_is_pair (s); s = scm_cdr (s))
3151 unsmob_music (scm_car (s))->set_property ("duration", $2);
3159 if (!parser->lexer_->is_lyric_state ())
3160 parser->parser_error (@1, _ ("markup outside of text script or \\lyricmode"));
3164 if (!parser->lexer_->is_lyric_state ())
3165 parser->parser_error (@1, _ ("unrecognized string, not in text script or \\lyricmode"));
3171 lyric_element_music:
3172 lyric_element optional_notemode_duration post_events {
3173 $$ = MAKE_SYNTAX ("lyric-event", @$, $1, $2);
3174 if (scm_is_pair ($3))
3175 unsmob_music ($$)->set_property
3176 ("articulations", scm_reverse_x ($3, SCM_EOL));
3181 steno_tonic_pitch optional_notemode_duration {
3182 $$ = make_chord_elements (@$, $1, $2, SCM_EOL);
3184 | steno_tonic_pitch optional_notemode_duration chord_separator chord_items {
3185 SCM its = scm_reverse_x ($4, SCM_EOL);
3186 $$ = make_chord_elements (@$, $1, $2, scm_cons ($3, its));
3194 | chord_items chord_item {
3195 $$ = scm_cons ($2, $$);
3201 $$ = ly_symbol2scm ("chord-colon");
3204 $$ = ly_symbol2scm ("chord-caret");
3206 | CHORD_SLASH steno_tonic_pitch {
3207 $$ = scm_list_2 (ly_symbol2scm ("chord-slash"), $2);
3209 | CHORD_BASS steno_tonic_pitch {
3210 $$ = scm_list_2 (ly_symbol2scm ("chord-bass"), $2);
3219 $$ = scm_reverse_x ($1, SCM_EOL);
3227 step_number { $$ = scm_cons ($1, SCM_EOL); }
3228 | step_numbers '.' step_number {
3229 $$ = scm_cons ($3, $$);
3235 $$ = make_chord_step ($1, 0);
3238 $$ = make_chord_step ($1, SHARP_ALTERATION);
3240 | UNSIGNED CHORD_MINUS {
3241 $$ = make_chord_step ($1, FLAT_ALTERATION);
3249 | UNSIGNED '-' UNSIGNED {
3250 $$ = scm_cons ($1, $3);
3257 TODO: should deprecate in favor of Scheme?
3261 number_expression '+' number_term {
3262 $$ = scm_sum ($1, $3);
3264 | number_expression '-' number_term {
3265 $$ = scm_difference ($1, $3);
3274 | number_factor '*' number_factor {
3275 $$ = scm_product ($1, $3);
3277 | number_factor '/' number_factor {
3278 $$ = scm_divide ($1, $3);
3283 '-' number_factor { /* %prec UNARY_MINUS */
3284 $$ = scm_difference ($2, SCM_UNDEFINED);
3290 bare_number_common_closed
3291 | REAL NUMBER_IDENTIFIER
3293 $$ = scm_product ($1, $2);
3297 bare_number_common_closed:
3305 | UNSIGNED NUMBER_IDENTIFIER {
3306 $$ = scm_product ($1, $2);
3312 | bare_number_common_closed
3321 { $$ = SCM_UNDEFINED; }
3324 if (SCM_UNBNDP ($1))
3332 { $$ = SCM_UNDEFINED; }
3335 if (SCM_UNBNDP ($1))
3344 { parser->lexer_->push_markup_state (); }
3347 parser->lexer_->pop_state ();
3353 { parser->lexer_->push_markup_state (); }
3356 parser->lexer_->pop_state ();
3361 simple_markup_list {
3362 $$ = scm_list_2 (ly_lily_module_constant ("line-markup"), $1);
3364 | markup_head_1_list simple_markup
3366 $$ = scm_car (MAKE_SYNTAX ("composed-markup-list",
3367 @2, $1, scm_list_1 ($2)));
3377 if (Text_interface::is_markup ($1))
3378 MYBACKUP (MARKUP_IDENTIFIER, $1, @1);
3379 else if (Text_interface::is_markup_list ($1))
3380 MYBACKUP (MARKUPLIST_IDENTIFIER, $1, @1);
3382 parser->parser_error (@1, _ ("not a markup"));
3383 MYBACKUP (MARKUP_IDENTIFIER, scm_string (SCM_EOL), @1);
3390 markup_composed_list {
3393 | markup_uncomposed_list
3396 markup_uncomposed_list:
3397 markup_braced_list {
3400 | markup_command_list {
3401 $$ = scm_list_1 ($1);
3403 | markup_scm MARKUPLIST_IDENTIFIER
3413 $$ = scm_list_1 (scm_list_2 (ly_lily_module_constant ("score-lines-markup-list"), $1));
3419 SCM nn = parser->lexer_->lookup_identifier ("pitchnames");
3420 parser->lexer_->push_note_state (nn);
3421 } '{' score_body '}' {
3423 parser->lexer_->pop_state ();
3427 markup_composed_list:
3428 markup_head_1_list markup_uncomposed_list {
3429 $$ = MAKE_SYNTAX ("composed-markup-list",
3435 '{' markup_braced_list_body '}' {
3436 $$ = scm_reverse_x ($2, SCM_EOL);
3440 markup_braced_list_body:
3441 /* empty */ { $$ = SCM_EOL; }
3442 | markup_braced_list_body markup {
3443 $$ = scm_cons ($2, $1);
3445 | markup_braced_list_body simple_markup_list {
3446 $$ = scm_reverse_x ($2, $1);
3450 markup_command_list:
3451 MARKUP_LIST_FUNCTION markup_command_list_arguments {
3452 $$ = scm_cons ($1, scm_reverse_x($2, SCM_EOL));
3456 markup_command_basic_arguments:
3457 EXPECT_MARKUP_LIST markup_command_list_arguments markup_list {
3458 $$ = scm_cons ($3, $2);
3460 | EXPECT_SCM markup_command_list_arguments embedded_scm_closed {
3461 $$ = check_scheme_arg (parser, @3, $3, $2, $1);
3463 | EXPECT_NO_MORE_ARGS {
3468 markup_command_list_arguments:
3469 markup_command_basic_arguments { $$ = $1; }
3470 | EXPECT_MARKUP markup_command_list_arguments markup {
3471 $$ = scm_cons ($3, $2);
3476 MARKUP_FUNCTION EXPECT_MARKUP markup_command_list_arguments {
3477 $$ = scm_cons ($1, scm_reverse_x ($3, SCM_EOL));
3482 markup_head_1_item {
3483 $$ = scm_list_1 ($1);
3485 | markup_head_1_list markup_head_1_item {
3486 $$ = scm_cons ($2, $1);
3492 $$ = make_simple_markup ($1);
3494 | MARKUP_FUNCTION markup_command_basic_arguments {
3495 $$ = scm_cons ($1, scm_reverse_x ($2, SCM_EOL));
3497 | markup_scm MARKUP_IDENTIFIER
3503 $$ = scm_list_2 (ly_lily_module_constant ("score-markup"), $1);
3508 markup_head_1_list simple_markup
3510 $$ = scm_car (MAKE_SYNTAX ("composed-markup-list",
3511 @2, $1, scm_list_1 ($2)));
3521 Lily_parser::set_yydebug (bool x)
3527 Lily_parser::do_yyparse ()
3529 SCM retval = SCM_UNDEFINED;
3530 yyparse (this, &retval);
3540 It is a little strange to have this function in this file, but
3541 otherwise, we have to import music classes into the lexer.
3545 Lily_lexer::try_special_identifiers (SCM *destination, SCM sid)
3547 if (unsmob_book (sid)) {
3548 Book *book = unsmob_book (sid)->clone ();
3549 *destination = book->self_scm ();
3552 return BOOK_IDENTIFIER;
3553 } else if (scm_is_number (sid)) {
3555 return NUMBER_IDENTIFIER;
3556 } else if (unsmob_context_def (sid)) {
3557 Context_def *def= unsmob_context_def (sid)->clone ();
3559 *destination = def->self_scm ();
3562 return CONTEXT_DEF_IDENTIFIER;
3563 } else if (unsmob_context_mod (sid)) {
3564 *destination = unsmob_context_mod (sid)->smobbed_copy ();
3566 return CONTEXT_MOD_IDENTIFIER;
3567 } else if (Music *mus = unsmob_music (sid)) {
3568 mus = mus->clone ();
3569 *destination = mus->self_scm ();
3570 bool is_event = mus->is_mus_type ("post-event");
3572 return is_event ? EVENT_IDENTIFIER : MUSIC_IDENTIFIER;
3573 } else if (unsmob_pitch (sid)) {
3574 *destination = unsmob_pitch (sid)->smobbed_copy ();
3575 return PITCH_IDENTIFIER;
3576 } else if (unsmob_duration (sid)) {
3577 *destination = unsmob_duration (sid)->smobbed_copy ();
3578 return DURATION_IDENTIFIER;
3579 } else if (unsmob_output_def (sid)) {
3580 Output_def *p = unsmob_output_def (sid);
3583 *destination = p->self_scm ();
3585 return OUTPUT_DEF_IDENTIFIER;
3592 get_next_unique_context_id ()
3594 return scm_from_locale_string ("$uniqueContextId");
3599 get_next_unique_lyrics_context_id ()
3601 static int new_context_count;
3603 snprintf (s, sizeof (s)-1, "uniqueContext%d", new_context_count++);
3604 return scm_from_locale_string (s);
3607 // check_scheme_arg checks one argument with a given predicate for use
3608 // in an argument list and throws a syntax error if it is unusable.
3609 // The argument is prepended to the argument list in any case. After
3610 // throwing a syntax error, the argument list is terminated with #f as
3611 // its last cdr in order to mark it as uncallable while not losing
3612 // track of its total length.
3614 // There are a few special considerations: if optional argument disp
3615 // is given (otherwise it defaults to SCM_UNDEFINED), it will be used
3616 // instead of arg in a prospective error message. This is useful if
3617 // arg is not the actual argument but rather a transformation of it.
3619 // If arg itself is SCM_UNDEFINED, the predicate is considered false
3620 // and an error message using disp is produced unconditionally.
3622 SCM check_scheme_arg (Lily_parser *parser, Input loc,
3623 SCM arg, SCM args, SCM pred, SCM disp)
3625 if (SCM_UNBNDP (arg))
3626 args = scm_cons (disp, args);
3628 args = scm_cons (arg, args);
3629 if (scm_is_true (scm_call_1 (pred, arg)))
3632 scm_set_cdr_x (scm_last_pair (args), SCM_EOL);
3633 MAKE_SYNTAX ("argument-error", loc, scm_length (args), pred,
3634 SCM_UNBNDP (disp) ? arg : disp);
3635 scm_set_cdr_x (scm_last_pair (args), SCM_BOOL_F);
3639 SCM loc_on_music (Input loc, SCM arg)
3641 if (Music *m = unsmob_music (arg))
3645 return m->unprotect ();
3651 try_string_variants (SCM pred, SCM str)
3653 // a matching predicate is always ok
3654 if (scm_is_true (scm_call_1 (pred, str)))
3656 // a symbol may be interpreted as a list of symbols if it helps
3657 if (scm_is_symbol (str)) {
3658 str = scm_list_1 (str);
3659 if (scm_is_true (scm_call_1 (pred, str)))
3661 return SCM_UNDEFINED;
3664 // If this cannot be a string representation of a symbol list,
3667 if (!is_regular_identifier (str, true))
3668 return SCM_UNDEFINED;
3670 str = scm_string_split (str, SCM_MAKE_CHAR ('.'));
3671 for (SCM p = str; scm_is_pair (p); p = scm_cdr (p))
3672 scm_set_car_x (p, scm_string_to_symbol (scm_car (p)));
3674 // Let's attempt the symbol list interpretation first.
3676 if (scm_is_true (scm_call_1 (pred, str)))
3679 // If there is just one symbol in the list, we might interpret
3680 // it as a single symbol
3682 if (scm_is_null (scm_cdr (str)))
3684 str = scm_car (str);
3685 if (scm_is_true (scm_call_1 (pred, str)))
3689 return SCM_UNDEFINED;
3693 is_regular_identifier (SCM id, bool multiple)
3695 if (!scm_is_string (id))
3698 string str = ly_scm2string (id);
3700 bool middle = false;
3702 for (string::iterator it=str.begin(); it != str.end (); it++)
3705 if ((c >= 'a' && c <= 'z')
3706 || (c >= 'A' && c <= 'Z')
3709 else if (middle && (c == '-' || c == '_' || (multiple && c == '.')))
3718 make_music_from_simple (Lily_parser *parser, Input loc, SCM simple)
3720 if (unsmob_music (simple))
3722 if (parser->lexer_->is_note_state ()) {
3723 if (scm_is_symbol (simple)) {
3724 Music *n = MY_MAKE_MUSIC ("NoteEvent", loc);
3725 n->set_property ("duration", parser->default_duration_.smobbed_copy ());
3726 n->set_property ("drum-type", simple);
3727 return n->unprotect ();
3729 if (unsmob_pitch (simple)) {
3730 Music *n = MY_MAKE_MUSIC ("NoteEvent", loc);
3731 n->set_property ("duration", parser->default_duration_.smobbed_copy ());
3732 n->set_property ("pitch", simple);
3733 return n->unprotect ();
3736 } else if (parser->lexer_->is_lyric_state ()) {
3737 if (Text_interface::is_markup (simple))
3738 return MAKE_SYNTAX ("lyric-event", loc, simple,
3739 parser->default_duration_.smobbed_copy ());
3740 } else if (parser->lexer_->is_chord_state ()) {
3741 if (unsmob_pitch (simple))
3742 return make_chord_elements (loc, simple,
3743 parser->default_duration_.smobbed_copy (),
3750 make_music_with_input (SCM name, Input where)
3752 Music *m = make_music_by_name (name);
3753 m->set_spot (where);
3758 make_simple_markup (SCM a)
3764 make_duration (SCM d, int dots)
3766 int t = scm_to_int (d);
3767 if (t > 0 && (t & (t-1)) == 0)
3768 return Duration (intlog2 (t), dots).smobbed_copy ();
3770 return SCM_UNDEFINED;
3774 make_chord_step (SCM step_scm, Rational alter)
3776 int step = scm_to_int (step_scm);
3779 alter += FLAT_ALTERATION;
3783 Pitch m ((step -1) / 7, (step - 1) % 7, alter);
3784 return m.smobbed_copy ();
3789 make_chord_elements (Input loc, SCM pitch, SCM dur, SCM modification_list)
3791 SCM chord_ctor = ly_lily_module_constant ("construct-chord-elements");
3792 SCM res = scm_call_3 (chord_ctor, pitch, dur, modification_list);
3793 for (SCM s = res; scm_is_pair (s); s = scm_cdr (s))
3795 unsmob_music (scm_car (s))->set_spot (loc);
3801 yylex (YYSTYPE *s, YYLTYPE *loc, Lily_parser *parser)
3803 Lily_lexer *lex = parser->lexer_;
3807 lex->prepare_for_next_token ();
3808 return lex->yylex ();