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 %right ':' UNSIGNED REAL
85 /* The above are needed for collecting tremoli greedily, and together
86 with the next rule for putting together numbers and units
89 %nonassoc NUMBER_IDENTIFIER
101 %{ // -*-Fundamental-*-
106 * The rules for who is protecting what are very shady. Uniformise
109 * There are too many lexical modes?
120 #include "context-def.hh"
121 #include "context-mod.hh"
122 #include "dimensions.hh"
123 #include "file-path.hh"
125 #include "international.hh"
126 #include "lily-guile.hh"
127 #include "lily-lexer.hh"
128 #include "lily-parser.hh"
132 #include "output-def.hh"
133 #include "paper-book.hh"
134 #include "scm-hash.hh"
136 #include "text-interface.hh"
140 Lily_parser::parser_error (Input const *i, Lily_parser *parser, SCM *, const string &s)
142 parser->parser_error (*i, s);
145 #define MYBACKUP(Token, Value, Location) \
147 if (yychar == YYEMPTY) \
150 parser->lexer_->push_extra_token (Token, Value); \
151 parser->lexer_->push_extra_token (BACKUP); \
153 parser->parser_error \
154 (Location, _("Too much lookahead")); \
159 #define MYREPARSE(Location, Pred, Token, Value) \
161 if (yychar == YYEMPTY) \
163 parser->lexer_->push_extra_token (Token, Value); \
164 parser->lexer_->push_extra_token (REPARSE, \
167 parser->parser_error \
168 (Location, _("Too much lookahead")); \
177 #define MY_MAKE_MUSIC(x, spot) \
178 make_music_with_input (ly_symbol2scm (x), \
179 parser->lexer_->override_input (spot))
182 - Don't use lily module, create a new module instead.
183 - delay application of the function
185 #define LOWLEVEL_MAKE_SYNTAX(proc, args) \
186 scm_apply_0 (proc, args)
187 /* Syntactic Sugar. */
188 #define MAKE_SYNTAX(name, location, ...) \
189 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))
190 #define START_MAKE_SYNTAX(name, ...) \
191 scm_list_n (ly_lily_module_constant (name) , ##__VA_ARGS__, SCM_UNDEFINED)
192 #define FINISH_MAKE_SYNTAX(start, location, ...) \
193 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)))))
195 SCM get_next_unique_context_id ();
196 SCM get_next_unique_lyrics_context_id ();
203 #define _(x) gettext (x)
207 static Music *make_music_with_input (SCM name, Input where);
208 SCM check_scheme_arg (Lily_parser *parser, Input loc,
209 SCM arg, SCM args, SCM pred, SCM disp = SCM_UNDEFINED);
210 SCM make_music_from_simple (Lily_parser *parser, Input loc, SCM pitch);
211 SCM loc_on_music (Input loc, SCM arg);
212 SCM make_chord_elements (Input loc, SCM pitch, SCM dur, SCM modification_list);
213 SCM make_chord_step (SCM step, Rational alter);
214 SCM make_simple_markup (SCM a);
215 SCM make_duration (SCM t, int dots = 0);
216 bool is_regular_identifier (SCM id, bool multiple=false);
217 SCM try_string_variants (SCM pred, SCM str);
218 int yylex (YYSTYPE *s, YYLTYPE *loc, Lily_parser *parser);
222 /* The third option is an alias that will be used to display the
223 syntax error. Bison CVS now correctly handles backslash escapes.
225 FIXME: Bison needs to translate some of these, eg, STRING.
229 /* Keyword tokens with plain escaped name. */
230 %token END_OF_FILE 0 "end of input"
231 %token ACCEPTS "\\accepts"
232 %token ADDLYRICS "\\addlyrics"
233 %token ALIAS "\\alias"
234 %token ALTERNATIVE "\\alternative"
236 %token BOOKPART "\\bookpart"
237 %token CHANGE "\\change"
238 %token CHORDMODE "\\chordmode"
239 %token CHORDS "\\chords"
240 %token CONSISTS "\\consists"
241 %token CONTEXT "\\context"
242 %token DEFAULT "\\default"
243 %token DEFAULTCHILD "\\defaultchild"
244 %token DENIES "\\denies"
245 %token DESCRIPTION "\\description"
246 %token DRUMMODE "\\drummode"
247 %token DRUMS "\\drums"
248 %token FIGUREMODE "\\figuremode"
249 %token FIGURES "\\figures"
250 %token HEADER "\\header"
251 %token INVALID "\\version-error"
252 %token LAYOUT "\\layout"
253 %token LYRICMODE "\\lyricmode"
254 %token LYRICS "\\lyrics"
255 %token LYRICSTO "\\lyricsto"
256 %token MARKUP "\\markup"
257 %token MARKUPLIST "\\markuplist"
260 %token NOTEMODE "\\notemode"
261 %token OVERRIDE "\\override"
262 %token PAPER "\\paper"
263 %token REMOVE "\\remove"
264 %token REPEAT "\\repeat"
266 %token REVERT "\\revert"
267 %token SCORE "\\score"
268 %token SEQUENTIAL "\\sequential"
270 %token SIMULTANEOUS "\\simultaneous"
271 %token TEMPO "\\tempo"
273 %token UNSET "\\unset"
276 /* Keyword token exceptions. */
277 %token NEWCONTEXT "\\new"
280 /* Other string tokens. */
282 %token CHORD_BASS "/+"
283 %token CHORD_CARET "^"
284 %token CHORD_COLON ":"
285 %token CHORD_MINUS "-"
286 %token CHORD_SLASH "/"
287 %token ANGLE_OPEN "<"
288 %token ANGLE_CLOSE ">"
289 %token DOUBLE_ANGLE_OPEN "<<"
290 %token DOUBLE_ANGLE_CLOSE ">>"
291 %token E_BACKSLASH "\\"
292 %token E_EXCLAMATION "\\!"
297 If we give names, Bison complains.
299 %token FIGURE_CLOSE /* "\\>" */
300 %token FIGURE_OPEN /* "\\<" */
301 %token FIGURE_SPACE "_"
304 %token MULTI_MEASURE_REST
310 /* Artificial tokens, for more generic function syntax */
311 %token EXPECT_MARKUP "markup?"
312 %token EXPECT_SCM "scheme?"
313 %token BACKUP "(backed-up?)"
314 %token REPARSE "(reparsed?)"
315 %token EXPECT_MARKUP_LIST "markup-list?"
316 %token EXPECT_OPTIONAL "optional?"
317 /* After the last argument. */
318 %token EXPECT_NO_MORE_ARGS;
320 /* An artificial token for parsing embedded Lilypond */
321 %token EMBEDDED_LILY "#{"
323 %token BOOK_IDENTIFIER
324 %token CHORD_MODIFIER
325 %token CHORD_REPETITION
326 %token CONTEXT_DEF_IDENTIFIER
327 %token CONTEXT_MOD_IDENTIFIER
329 %token PITCH_IDENTIFIER
330 %token DURATION_IDENTIFIER
331 %token EVENT_IDENTIFIER
332 %token EVENT_FUNCTION
335 %token MARKUP_FUNCTION
336 %token MARKUP_LIST_FUNCTION
337 %token MARKUP_IDENTIFIER
338 %token MARKUPLIST_IDENTIFIER
339 %token MUSIC_FUNCTION
340 %token MUSIC_IDENTIFIER
341 %token NOTENAME_PITCH
342 %token NUMBER_IDENTIFIER
343 %token OUTPUT_DEF_IDENTIFIER
348 %token SCM_IDENTIFIER
352 %token TONICNAME_PITCH
356 /* We don't assign precedence to / and *, because we might need varied
357 prec levels in different prods */
366 SCM nn = parser->lexer_->lookup_identifier ("pitchnames");
367 parser->lexer_->push_note_state (nn);
368 } embedded_lilypond {
369 parser->lexer_->pop_state ();
374 lilypond: /* empty */ { $$ = SCM_UNSPECIFIED; }
375 | lilypond toplevel_expression {
377 | lilypond assignment {
380 parser->error_level_ = 1;
383 parser->error_level_ = 1;
390 parser->lexer_->add_scope (get_header (parser));
392 parser->lexer_->set_identifier (ly_symbol2scm ("$defaultheader"), $2);
395 SCM proc = parser->lexer_->lookup_identifier ("toplevel-book-handler");
396 scm_call_2 (proc, parser->self_scm (), $1);
399 SCM proc = parser->lexer_->lookup_identifier ("toplevel-bookpart-handler");
400 scm_call_2 (proc, parser->self_scm (), $1);
403 SCM proc = parser->lexer_->lookup_identifier ("toplevel-score-handler");
404 scm_call_2 (proc, parser->self_scm (), $1);
407 SCM proc = parser->lexer_->lookup_identifier ("toplevel-music-handler");
408 scm_call_2 (proc, parser->self_scm (), $1);
411 SCM proc = parser->lexer_->lookup_identifier ("toplevel-text-handler");
412 scm_call_2 (proc, parser->self_scm (), scm_list_1 ($1));
415 SCM proc = parser->lexer_->lookup_identifier ("toplevel-text-handler");
416 scm_call_2 (proc, parser->self_scm (), $1);
419 // Evaluate and ignore #xxx, as opposed to \xxx
420 parser->lexer_->eval_scm_token ($1);
422 | embedded_scm_active
424 SCM out = SCM_UNDEFINED;
425 if (Text_interface::is_markup ($1))
426 out = scm_list_1 ($1);
427 else if (Text_interface::is_markup_list ($1))
429 if (scm_is_pair (out))
431 SCM proc = parser->lexer_->lookup_identifier ("toplevel-text-handler");
432 scm_call_2 (proc, parser->self_scm (), out);
433 } else if (!scm_is_eq ($1, SCM_UNSPECIFIED))
434 parser->parser_error (@1, _("bad expression type"));
438 Output_def * od = unsmob_output_def ($1);
440 if (od->c_variable ("is-paper") == SCM_BOOL_T)
441 id = ly_symbol2scm ("$defaultpaper");
442 else if (od->c_variable ("is-midi") == SCM_BOOL_T)
443 id = ly_symbol2scm ("$defaultmidi");
444 else if (od->c_variable ("is-layout") == SCM_BOOL_T)
445 id = ly_symbol2scm ("$defaultlayout");
447 parser->lexer_->set_identifier (id, $1);
454 $$ = parser->lexer_->eval_scm_token ($1);
464 embedded_scm_bare_arg:
468 $$ = parser->lexer_->eval_scm_token ($1);
471 | context_modification
473 | context_def_spec_block
479 /* The generic version may end in music, or not */
486 /* embedded_scm_arg is _not_ casting pitches to music by default, this
487 * has to be done by the function itself. Note that this may cause
488 * the results of scm_function_call or embedded_scm_bare_arg to be
489 * turned into music from pitches as well. Note that this creates a
490 * distinctly awkward situation for calculated drum pitches. Those
491 * are at the current point of time rejected as music constituents as
492 * they can't be distinguished from "proper" symbols.
496 embedded_scm_bare_arg
502 SCM_FUNCTION function_arglist {
503 $$ = MAKE_SYNTAX ("music-function", @$,
511 // FIXME: @$ does not contain a useful source location
512 // for empty rules, and the only token in the whole
513 // production, EMBEDDED_LILY, is synthetic and also
514 // contains no source location.
515 $$ = MAKE_SYNTAX ("void-music", @$);
518 | music_embedded music_embedded music_list {
519 $3 = scm_reverse_x ($3, SCM_EOL);
520 if (unsmob_music ($2))
521 $3 = scm_cons ($2, $3);
522 if (unsmob_music ($1))
523 $3 = scm_cons ($1, $3);
524 $$ = MAKE_SYNTAX ("sequential-music", @$, $3);
527 parser->error_level_ = 1;
528 $$ = SCM_UNSPECIFIED;
530 | INVALID embedded_lilypond {
531 parser->error_level_ = 1;
537 lilypond_header_body:
538 /* empty */ { $$ = SCM_UNSPECIFIED; }
539 | lilypond_header_body assignment {
542 | lilypond_header_body embedded_scm {
548 HEADER '{' lilypond_header_body '}' {
549 $$ = parser->lexer_->remove_scope ();
561 assignment_id '=' identifier_init {
562 parser->lexer_->set_identifier ($1, $3);
563 $$ = SCM_UNSPECIFIED;
565 | assignment_id property_path '=' identifier_init {
566 SCM path = scm_cons (scm_string_to_symbol ($1), $2);
567 parser->lexer_->set_identifier (path, $4);
568 $$ = SCM_UNSPECIFIED;
578 | context_def_spec_block
580 | post_event_nofinger post_events
582 $$ = scm_reverse_x ($2, SCM_EOL);
583 if (Music *m = unsmob_music ($1))
585 if (m->is_mus_type ("post-event-wrapper"))
587 (scm_list_2 (m->get_property ("elements"),
590 $$ = scm_cons ($1, $$);
593 && scm_is_null (scm_cdr ($$)))
597 Music * m = MY_MAKE_MUSIC ("PostEvents", @$);
598 m->set_property ("elements", $$);
599 $$ = m->unprotect ();
607 | context_modification
610 context_def_spec_block:
611 CONTEXT '{' context_def_spec_body '}'
614 unsmob_context_def ($$)->origin ()->set_spot (@$);
622 SCM nn = parser->lexer_->lookup_identifier ("pitchnames");
623 parser->lexer_->push_note_state (nn);
627 parser->lexer_->pop_state ();
632 context_mod_embedded:
635 if (unsmob_music ($1)) {
636 SCM proc = parser->lexer_->lookup_identifier ("context-mod-music-handler");
637 $1 = scm_call_2 (proc, parser->self_scm (), $1);
639 if (unsmob_context_mod ($1))
642 parser->parser_error (@1, _ ("not a context mod"));
643 $$ = Context_mod ().smobbed_copy ();
649 context_def_spec_body:
651 $$ = Context_def::make_scm ();
653 | CONTEXT_DEF_IDENTIFIER {
656 | context_def_spec_body context_mod {
657 if (!SCM_UNBNDP ($2))
658 unsmob_context_def ($$)->add_context_mod ($2);
660 | context_def_spec_body context_modification {
661 Context_def *td = unsmob_context_def ($$);
662 SCM new_mods = unsmob_context_mod ($2)->get_mods ();
663 for (SCM m = new_mods; scm_is_pair (m); m = scm_cdr (m)) {
664 td->add_context_mod (scm_car (m));
667 | context_def_spec_body context_mod_embedded {
668 Context_def *td = unsmob_context_def ($$);
669 SCM new_mods = unsmob_context_mod ($2)->get_mods ();
670 for (SCM m = new_mods; scm_is_pair (m); m = scm_cdr (m)) {
671 td->add_context_mod (scm_car (m));
679 BOOK '{' book_body '}' {
681 unsmob_book ($$)->origin ()->set_spot (@$);
683 parser->lexer_->set_identifier (ly_symbol2scm ("$current-book"), SCM_BOOL_F);
688 * Use 'handlers' like for toplevel-* stuff?
689 * grok \layout and \midi? */
692 Book *book = new Book;
693 init_papers (parser);
694 book->paper_ = dynamic_cast<Output_def*> (unsmob_output_def (parser->lexer_->lookup_identifier ("$defaultpaper"))->clone ());
695 book->paper_->unprotect ();
696 push_paper (parser, book->paper_);
697 book->header_ = get_header (parser);
698 $$ = book->unprotect ();
699 parser->lexer_->set_identifier (ly_symbol2scm ("$current-book"), $$);
702 parser->lexer_->set_identifier (ly_symbol2scm ("$current-book"), $1);
704 | book_body paper_block {
705 unsmob_book ($1)->paper_ = unsmob_output_def ($2);
706 set_paper (parser, unsmob_output_def ($2));
708 | book_body bookpart_block {
709 SCM proc = parser->lexer_->lookup_identifier ("book-bookpart-handler");
710 scm_call_2 (proc, $1, $2);
712 | book_body score_block {
713 SCM proc = parser->lexer_->lookup_identifier ("book-score-handler");
714 scm_call_2 (proc, $1, $2);
716 | book_body composite_music {
717 SCM proc = parser->lexer_->lookup_identifier ("book-music-handler");
718 scm_call_3 (proc, parser->self_scm (), $1, $2);
720 | book_body full_markup {
721 SCM proc = parser->lexer_->lookup_identifier ("book-text-handler");
722 scm_call_2 (proc, $1, scm_list_1 ($2));
724 | book_body full_markup_list {
725 SCM proc = parser->lexer_->lookup_identifier ("book-text-handler");
726 scm_call_2 (proc, $1, $2);
728 | book_body SCM_TOKEN {
729 // Evaluate and ignore #xxx, as opposed to \xxx
730 parser->lexer_->eval_scm_token ($2);
732 | book_body embedded_scm_active
734 SCM out = SCM_UNDEFINED;
735 if (Text_interface::is_markup ($2))
736 out = scm_list_1 ($2);
737 else if (Text_interface::is_markup_list ($2))
739 if (scm_is_pair (out))
741 SCM proc = parser->lexer_->lookup_identifier ("book-text-handler");
742 scm_call_2 (proc, $1, out);
743 } else if (!scm_is_eq ($2, SCM_UNSPECIFIED))
744 parser->parser_error (@2, _("bad expression type"));
748 parser->lexer_->add_scope (unsmob_book ($1)->header_);
751 Book *book = unsmob_book ($1);
753 book->scores_ = SCM_EOL;
754 book->bookparts_ = SCM_EOL;
759 BOOKPART '{' bookpart_body '}' {
761 unsmob_book ($$)->origin ()->set_spot (@$);
762 parser->lexer_->set_identifier (ly_symbol2scm ("$current-bookpart"), SCM_BOOL_F);
768 Book *book = new Book;
769 $$ = book->unprotect ();
770 parser->lexer_->set_identifier (ly_symbol2scm ("$current-bookpart"), $$);
773 parser->lexer_->set_identifier (ly_symbol2scm ("$current-bookpart"), $1);
775 | bookpart_body paper_block {
776 unsmob_book ($$)->paper_ = unsmob_output_def ($2);
778 | bookpart_body score_block {
779 SCM proc = parser->lexer_->lookup_identifier ("bookpart-score-handler");
780 scm_call_2 (proc, $1, $2);
782 | bookpart_body composite_music {
783 SCM proc = parser->lexer_->lookup_identifier ("bookpart-music-handler");
784 scm_call_3 (proc, parser->self_scm (), $1, $2);
786 | bookpart_body full_markup {
787 SCM proc = parser->lexer_->lookup_identifier ("bookpart-text-handler");
788 scm_call_2 (proc, $1, scm_list_1 ($2));
790 | bookpart_body full_markup_list {
791 SCM proc = parser->lexer_->lookup_identifier ("bookpart-text-handler");
792 scm_call_2 (proc, $1, $2);
794 | bookpart_body SCM_TOKEN {
795 // Evaluate and ignore #xxx, as opposed to \xxx
796 parser->lexer_->eval_scm_token ($2);
798 | bookpart_body embedded_scm_active
800 SCM out = SCM_UNDEFINED;
801 if (Text_interface::is_markup ($2))
802 out = scm_list_1 ($2);
803 else if (Text_interface::is_markup_list ($2))
805 if (scm_is_pair (out))
807 SCM proc = parser->lexer_->lookup_identifier ("bookpart-text-handler");
808 scm_call_2 (proc, $1, out);
809 } else if (!scm_is_eq ($2, SCM_UNSPECIFIED))
810 parser->parser_error (@2, _("bad expression type"));
814 Book *book = unsmob_book ($1);
815 if (!ly_is_module (book->header_))
816 book->header_ = ly_make_module (false);
817 parser->lexer_->add_scope (book->header_);
819 | bookpart_body error {
820 Book *book = unsmob_book ($1);
822 book->scores_ = SCM_EOL;
827 SCORE '{' score_body '}' {
834 SCM scorify = ly_lily_module_constant ("scorify-music");
835 $$ = scm_call_2 (scorify, $1, parser->self_scm ());
837 unsmob_score ($$)->origin ()->set_spot (@$);
839 | embedded_scm_active {
841 if (unsmob_score ($1))
842 score = new Score (*unsmob_score ($1));
845 parser->parser_error (@1, _("score expected"));
847 unsmob_score ($$)->origin ()->set_spot (@$);
848 $$ = score->unprotect ();
852 Score *score = unsmob_score ($1);
853 if (!ly_is_module (score->get_header ()))
854 score->set_header (ly_make_module (false));
855 parser->lexer_->add_scope (score->get_header ());
857 | score_body output_def {
858 Output_def *od = unsmob_output_def ($2);
859 if (od->lookup_variable (ly_symbol2scm ("is-paper")) == SCM_BOOL_T)
861 parser->parser_error (@2, _("\\paper cannot be used in \\score, use \\layout instead"));
866 unsmob_score ($1)->add_output_def (od);
870 unsmob_score ($$)->error_found_ = true;
881 Output_def *od = unsmob_output_def ($1);
883 if (od->lookup_variable (ly_symbol2scm ("is-paper")) != SCM_BOOL_T)
885 parser->parser_error (@1, _ ("need \\paper for paper block"));
886 $$ = get_paper (parser)->unprotect ();
893 output_def_body '}' {
896 parser->lexer_->remove_scope ();
897 parser->lexer_->pop_state ();
903 Output_def *p = get_paper (parser);
904 p->input_origin_ = @$;
905 parser->lexer_->add_scope (p->scope_);
906 $$ = p->unprotect ();
909 Output_def *p = get_midi (parser);
910 $$ = p->unprotect ();
911 parser->lexer_->add_scope (p->scope_);
914 Output_def *p = get_layout (parser);
916 parser->lexer_->add_scope (p->scope_);
917 $$ = p->unprotect ();
921 output_def_head_with_mode_switch:
923 parser->lexer_->push_initial_state ();
928 // We need this weird nonterminal because both music as well as a
929 // context definition can start with \context and the difference is
930 // only apparent after looking at the next token. If it is '{', there
931 // is still time to escape from notes mode.
933 music_or_context_def:
935 | context_def_spec_block
939 output_def_head_with_mode_switch '{' {
941 unsmob_output_def ($$)->input_origin_.set_spot (@$);
943 | output_def_head_with_mode_switch '{' OUTPUT_DEF_IDENTIFIER {
944 Output_def *o = unsmob_output_def ($3);
945 o->input_origin_.set_spot (@$);
947 parser->lexer_->remove_scope ();
948 parser->lexer_->add_scope (o->scope_);
950 | output_def_body assignment {
953 | output_def_body embedded_scm {
958 SCM nn = parser->lexer_->lookup_identifier ("pitchnames");
959 parser->lexer_->push_note_state (nn);
960 } music_or_context_def
962 parser->lexer_->pop_state ();
963 if (unsmob_context_def ($3))
964 assign_context_def (unsmob_output_def ($1), $3);
967 SCM proc = parser->lexer_->lookup_identifier
968 ("output-def-music-handler");
969 scm_call_3 (proc, parser->self_scm (),
973 | output_def_body error {
979 TEMPO steno_duration '=' tempo_range {
980 $$ = MAKE_SYNTAX ("tempo", @$, SCM_EOL, $2, $4);
982 | TEMPO scalar_closed steno_duration '=' tempo_range {
983 $$ = MAKE_SYNTAX ("tempo", @$, $2, $3, $5);
986 $$ = MAKE_SYNTAX ("tempo", @$, $2);
991 The representation of a list is reversed to have efficient append. */
997 | music_list music_embedded {
998 if (unsmob_music ($2))
999 $$ = scm_cons ($2, $1);
1001 | music_list error {
1002 Music *m = MY_MAKE_MUSIC("Music", @$);
1004 m->set_property ("error-found", SCM_BOOL_T);
1005 $$ = scm_cons (m->self_scm (), $1);
1006 m->unprotect (); /* UGH */
1013 $$ = scm_reverse_x ($2, SCM_EOL);
1018 | lyric_element_music
1024 if (unsmob_music ($1)->is_mus_type ("post-event")) {
1025 parser->parser_error (@1, _ ("unexpected post-event"));
1026 $$ = SCM_UNSPECIFIED;
1029 | music_embedded_backup
1033 | music_embedded_backup BACKUP lyric_element_music
1039 music_embedded_backup:
1042 if (scm_is_eq ($1, SCM_UNSPECIFIED))
1044 else if (Music *m = unsmob_music ($1)) {
1045 if (m->is_mus_type ("post-event")) {
1046 parser->parser_error
1047 (@1, _ ("unexpected post-event"));
1048 $$ = SCM_UNSPECIFIED;
1051 } else if (parser->lexer_->is_lyric_state ()
1052 && Text_interface::is_markup ($1))
1053 MYBACKUP (LYRIC_ELEMENT, $1, @1);
1055 @$.warning (_ ("Ignoring non-music expression"));
1064 $$ = make_music_from_simple (parser, @1, $1);
1065 if (!unsmob_music ($$))
1067 parser->parser_error (@1, _ ("music expected"));
1068 $$ = MAKE_SYNTAX ("void-music", @$);
1071 | composite_music %prec COMPOSITE
1076 | composite_music %prec COMPOSITE
1080 REPEAT simple_string unsigned_number music
1082 $$ = MAKE_SYNTAX ("repeat", @$, $2, $3, $4, SCM_EOL);
1084 | REPEAT simple_string unsigned_number music ALTERNATIVE braced_music_list
1086 $$ = MAKE_SYNTAX ("repeat", @$, $2, $3, $4, $6);
1091 SEQUENTIAL braced_music_list {
1092 $$ = MAKE_SYNTAX ("sequential-music", @$, $2);
1094 | braced_music_list {
1095 $$ = MAKE_SYNTAX ("sequential-music", @$, $1);
1100 SIMULTANEOUS braced_music_list {
1101 $$ = MAKE_SYNTAX ("simultaneous-music", @$, $2);
1103 | DOUBLE_ANGLE_OPEN music_list DOUBLE_ANGLE_CLOSE {
1104 $$ = MAKE_SYNTAX ("simultaneous-music", @$, scm_reverse_x ($2, SCM_EOL));
1110 | music_property_def
1114 context_modification:
1117 SCM nn = parser->lexer_->lookup_identifier ("pitchnames");
1118 parser->lexer_->push_note_state (nn);
1119 } '{' context_mod_list '}'
1121 parser->lexer_->pop_state ();
1124 | WITH CONTEXT_MOD_IDENTIFIER
1128 | CONTEXT_MOD_IDENTIFIER
1132 | WITH context_modification_arg
1134 if (unsmob_music ($2)) {
1135 SCM proc = parser->lexer_->lookup_identifier ("context-mod-music-handler");
1136 $2 = scm_call_2 (proc, parser->self_scm (), $2);
1138 if (unsmob_context_mod ($2))
1141 parser->parser_error (@2, _ ("not a context mod"));
1142 $$ = Context_mod ().smobbed_copy ();
1147 context_modification_arg:
1152 optional_context_mod:
1156 | context_modification
1164 $$ = Context_mod ().smobbed_copy ();
1166 | context_mod_list context_mod {
1167 if (!SCM_UNBNDP ($2))
1168 unsmob_context_mod ($1)->add_context_mod ($2);
1170 | context_mod_list CONTEXT_MOD_IDENTIFIER {
1171 Context_mod *md = unsmob_context_mod ($2);
1173 unsmob_context_mod ($1)->add_context_mods (md->get_mods ());
1175 | context_mod_list context_mod_embedded {
1176 unsmob_context_mod ($1)->add_context_mods
1177 (unsmob_context_mod ($2)->get_mods ());
1186 /* Music that can be parsed without lookahead */
1189 | complex_music_prefix closed_music
1191 $$ = FINISH_MAKE_SYNTAX ($1, @$, $2);
1193 | music_function_call_closed
1199 | grouped_music_list
1203 simultaneous_music { $$ = $1; }
1204 | sequential_music { $$ = $1; }
1207 /* Function argument lists are arguably the most complex part in the
1208 * parser. They are pretty tricky to understand because of the way
1209 * they are processed, and because of optional arguments that can be
1210 * omitted. When there are several optional arguments in a row,
1211 * omitting one automatically omits all following arguments. Optional
1212 * arguments can only be omitted when either
1214 * a) the omission is explicitly started with \default
1215 * b) the omission is implicitly started by an argument not matching
1216 * its predicate, and there is a mandatory argument later that can
1217 * "catch" the argument that does not fit.
1219 * When argument parsing starts, the lexer pushes EXPECT_SCM tokens
1220 * (corresponding to mandatory arguments and having a predicate
1221 * function as semantic value) or EXPECT_OPTIONAL EXPECT_SCM (where
1222 * the semantic value of the EXPECT_OPTIONAL token is the default to
1223 * use when the optional argument is omitted, and EXPECT_SCM again has
1224 * the argument predicate as semantic value) in reverse order to the
1225 * parser, followed by EXPECT_NO_MORE_ARGS. The argument list is then
1226 * processed inside-out while actual tokens are consumed.
1228 * This means that the argument list tokens determine the actions
1229 * taken as they arrive. The structure of the argument list is known
1230 * to the parser and stored in its parse stack when the first argument
1231 * is being parsed. What the parser does not know is which predicates
1232 * will match and whether or not \default will be appearing in the
1233 * argument list, and where.
1235 * Many of the basic nonterminals used for argument list scanning come
1236 * in a "normal" and a "closed" flavor. A closed expression is one
1237 * that can be parsed without a lookahead token. That makes it
1238 * feasible for an optional argument that may need to be skipped:
1239 * skipping can only be accomplished by pushing back the token into
1240 * the lexer, and that only works when there is no lookahead token.
1242 * Sequences of 0 or more optional arguments are scanned using either
1243 * function_arglist_backup or function_arglist_nonbackup. The first
1244 * is used when optional arguments are followed by at least one
1245 * mandatory argument: in that case optional arguments may be skipped
1246 * by either a false predicate (in which case the expression will be
1247 * pushed back as one or more tokens, preceded by a BACKUP token) or
1248 * by using \default.
1250 * If optional arguments are at the end of the argument list, they are
1251 * instead scanned using function_arglist_nonbackup: here the only
1252 * manner to enter into skipping of optional arguments is the use of
1255 * The argument list of a normal function call is parsed using
1256 * function_arglist. The part of an argument list before a mandatory
1257 * argument is parsed using function_arglist_optional.
1259 * The difference is that leading optional arguments are scanned using
1260 * function_arglist_nonbackup and function_arglist_backup,
1263 * Most other details are obvious in the rules themselves.
1267 function_arglist_nonbackup_common:
1268 EXPECT_OPTIONAL EXPECT_SCM function_arglist_nonbackup FRACTION
1270 $$ = check_scheme_arg (parser, @4, $4, $3, $2);
1272 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_closed_nonbackup post_event_nofinger
1274 $$ = check_scheme_arg (parser, @4, $4, $3, $2);
1276 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_closed_nonbackup '-' UNSIGNED
1278 SCM n = scm_difference ($5, SCM_UNDEFINED);
1279 if (scm_is_true (scm_call_1 ($2, n)))
1280 $$ = scm_cons (n, $3);
1282 Music *t = MY_MAKE_MUSIC ("FingeringEvent", @5);
1283 t->set_property ("digit", $5);
1284 $$ = check_scheme_arg (parser, @4, t->unprotect (),
1289 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_closed_nonbackup '-' REAL
1291 $$ = check_scheme_arg (parser, @4,
1292 scm_difference ($5, SCM_UNDEFINED),
1295 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_closed_nonbackup '-' NUMBER_IDENTIFIER
1297 $$ = check_scheme_arg (parser, @4,
1298 scm_difference ($5, SCM_UNDEFINED),
1303 function_arglist_closed_nonbackup:
1304 function_arglist_nonbackup_common
1305 | function_arglist_closed_common
1306 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_nonbackup embedded_scm_arg_closed
1308 $$ = check_scheme_arg (parser, @4, $4, $3, $2);
1310 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_closed_nonbackup bare_number_closed
1312 $$ = check_scheme_arg (parser, @4, $4, $3, $2);
1314 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_nonbackup SCM_IDENTIFIER
1316 $$ = check_scheme_arg (parser, @4,
1317 try_string_variants ($2, $4),
1320 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_nonbackup STRING
1322 $$ = check_scheme_arg (parser, @4,
1323 try_string_variants ($2, $4),
1326 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_nonbackup full_markup
1328 $$ = check_scheme_arg (parser, @4, $4, $3, $2);
1334 | SYMBOL_LIST '.' symbol_list_rev
1336 $$ = scm_append (scm_list_2 ($1, scm_reverse_x ($3, SCM_EOL)));
1342 | symbol_list_rev '.' symbol_list_part
1344 $$ = scm_append_x (scm_list_2 ($3, $1));
1348 // symbol_list_part delivers elements in reverse copy.
1353 SCM sym_l_p = ly_lily_module_constant ("symbol-list?");
1354 $$ = try_string_variants (sym_l_p, $1);
1355 if (SCM_UNBNDP ($$)) {
1356 parser->parser_error (@1, _("not a symbol"));
1359 $$ = scm_reverse ($$);
1364 symbol_list_element:
1370 function_arglist_nonbackup:
1371 function_arglist_nonbackup_common
1372 | function_arglist_common
1373 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_nonbackup embedded_scm_arg
1375 if (scm_is_true (scm_call_1 ($2, $4)))
1376 $$ = scm_cons ($4, $3);
1378 $$ = check_scheme_arg (parser, @4,
1379 make_music_from_simple
1383 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_closed_nonbackup bare_number_common
1385 $$ = check_scheme_arg (parser, @4, $4, $3, $2);
1387 | function_arglist_nonbackup_reparse REPARSE duration_length
1389 $$ = check_scheme_arg (parser, @3, $3, $1, $2);
1391 | function_arglist_nonbackup_reparse REPARSE bare_number_common
1393 $$ = check_scheme_arg (parser, @3, $3, $1, $2);
1395 | function_arglist_nonbackup_reparse REPARSE SCM_ARG
1397 $$ = check_scheme_arg (parser, @3, $3, $1, $2);
1399 | function_arglist_nonbackup_reparse REPARSE lyric_element_music
1401 $$ = check_scheme_arg (parser, @3, $3, $1, $2);
1403 | function_arglist_nonbackup_reparse REPARSE symbol_list_arg
1405 $$ = check_scheme_arg (parser, @3, $3, $1, $2);
1409 function_arglist_nonbackup_reparse:
1410 EXPECT_OPTIONAL EXPECT_SCM function_arglist_nonbackup SCM_IDENTIFIER
1413 SCM res = try_string_variants ($2, $4);
1414 if (!SCM_UNBNDP (res))
1415 if (scm_is_pair (res))
1416 MYREPARSE (@4, $2, SYMBOL_LIST, res);
1418 MYREPARSE (@4, $2, SCM_ARG, res);
1419 else if (scm_is_true
1421 ($2, make_music_from_simple
1423 MYREPARSE (@4, $2, STRING, $4);
1425 MYREPARSE (@4, $2, SCM_ARG, $4);
1427 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_nonbackup STRING
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 full_markup
1447 if (scm_is_true (scm_call_1 ($2, $4)))
1448 MYREPARSE (@4, $2, SCM_ARG, $4);
1449 else if (scm_is_true
1451 ($2, make_music_from_simple
1453 MYREPARSE (@4, $2, STRING, $4);
1455 MYREPARSE (@4, $2, SCM_ARG, $4);
1457 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_closed_nonbackup UNSIGNED
1460 if (scm_is_true (scm_call_1 ($2, $4)))
1461 MYREPARSE (@4, $2, REAL, $4);
1463 SCM d = make_duration ($4);
1464 if (SCM_UNBNDP (d) || scm_is_false (scm_call_1 ($2, d)))
1465 MYREPARSE (@4, $2, REAL, $4); // trigger error
1467 MYREPARSE (@4, $2, DURATION_IDENTIFIER, d);
1470 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_closed_nonbackup DURATION_IDENTIFIER {
1472 MYREPARSE (@4, $2, DURATION_IDENTIFIER, $4);
1477 function_arglist_backup:
1478 function_arglist_backup_common
1479 | function_arglist_common
1482 function_arglist_closed_backup:
1483 function_arglist_backup_common
1484 | function_arglist_closed_common
1487 function_arglist_backup_common:
1488 EXPECT_OPTIONAL EXPECT_SCM function_arglist_backup embedded_scm_arg_closed
1490 if (scm_is_true (scm_call_1 ($2, $4)))
1492 $$ = scm_cons ($4, $3);
1494 $$ = scm_cons (loc_on_music (@3, $1), $3);
1495 MYBACKUP (SCM_ARG, $4, @4);
1498 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_closed_backup post_event_nofinger
1500 if (scm_is_true (scm_call_1 ($2, $4)))
1502 $$ = scm_cons ($4, $3);
1504 $$ = scm_cons (loc_on_music (@3, $1), $3);
1505 MYBACKUP (EVENT_IDENTIFIER, $4, @4);
1508 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_backup full_markup
1510 if (scm_is_true (scm_call_1 ($2, $4)))
1511 $$ = scm_cons ($4, $3);
1513 $$ = scm_cons (loc_on_music (@3, $1), $3);
1514 MYBACKUP (LYRIC_ELEMENT, $4, @4);
1517 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_closed_backup UNSIGNED
1519 if (scm_is_true (scm_call_1 ($2, $4)))
1521 MYREPARSE (@4, $2, REAL, $4);
1524 SCM d = make_duration ($4);
1525 if (SCM_UNBNDP (d) || scm_is_false (scm_call_1 ($2, d)))
1527 $$ = scm_cons (loc_on_music (@3, $1), $3);
1528 MYBACKUP (UNSIGNED, $4, @4);
1530 MYREPARSE (@4, $2, DURATION_IDENTIFIER, d);
1535 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_closed_backup REAL
1537 if (scm_is_true (scm_call_1 ($2, $4)))
1540 MYREPARSE (@4, $2, REAL, $4);
1542 $$ = scm_cons (loc_on_music (@3, $1), $3);
1543 MYBACKUP (REAL, $4, @4);
1546 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_closed_backup NUMBER_IDENTIFIER
1548 if (scm_is_true (scm_call_1 ($2, $4)))
1550 $$ = scm_cons ($4, $3);
1552 $$ = scm_cons (loc_on_music (@3, $1), $3);
1553 MYBACKUP (NUMBER_IDENTIFIER, $4, @4);
1556 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_backup FRACTION
1558 if (scm_is_true (scm_call_1 ($2, $4)))
1560 $$ = scm_cons ($4, $3);
1562 $$ = scm_cons (loc_on_music (@3, $1), $3);
1563 MYBACKUP (FRACTION, $4, @4);
1566 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_closed_backup '-' UNSIGNED
1568 SCM n = scm_difference ($5, SCM_UNDEFINED);
1569 if (scm_is_true (scm_call_1 ($2, n))) {
1571 MYREPARSE (@5, $2, REAL, n);
1573 Music *t = MY_MAKE_MUSIC ("FingeringEvent", @5);
1574 t->set_property ("digit", $5);
1575 $$ = t->unprotect ();
1576 if (scm_is_true (scm_call_1 ($2, $$)))
1577 $$ = scm_cons ($$, $3);
1579 $$ = scm_cons (loc_on_music (@3, $1), $3);
1580 MYBACKUP (UNSIGNED, $5, @5);
1581 parser->lexer_->push_extra_token ('-');
1586 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_closed_backup '-' REAL
1588 SCM n = scm_difference ($5, SCM_UNDEFINED);
1589 if (scm_is_true (scm_call_1 ($2, n))) {
1590 MYREPARSE (@5, $2, REAL, n);
1593 $$ = scm_cons (loc_on_music (@3, $1), $3);
1594 MYBACKUP (REAL, n, @5);
1597 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_closed_backup '-' NUMBER_IDENTIFIER
1599 SCM n = scm_difference ($5, SCM_UNDEFINED);
1600 if (scm_is_true (scm_call_1 ($2, n))) {
1601 $$ = scm_cons (n, $3);
1603 $$ = scm_cons (loc_on_music (@3, $1), $3);
1604 MYBACKUP (NUMBER_IDENTIFIER, n, @5);
1607 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_backup PITCH_IDENTIFIER
1609 if (scm_is_true (scm_call_1 ($2, $4)))
1611 $$ = scm_cons ($4, $3);
1613 $$ = scm_cons (loc_on_music (@3, $1), $3);
1614 MYBACKUP (PITCH_IDENTIFIER, $4, @4);
1617 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_backup NOTENAME_PITCH
1619 if (scm_is_true (scm_call_1 ($2, $4)))
1621 MYREPARSE (@4, $2, NOTENAME_PITCH, $4);
1624 $$ = scm_cons (loc_on_music (@3, $1), $3);
1625 MYBACKUP (NOTENAME_PITCH, $4, @4);
1628 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_backup TONICNAME_PITCH
1630 if (scm_is_true (scm_call_1 ($2, $4)))
1632 MYREPARSE (@4, $2, TONICNAME_PITCH, $4);
1635 $$ = scm_cons (loc_on_music (@3, $1), $3);
1636 MYBACKUP (TONICNAME_PITCH, $4, @4);
1639 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_closed_backup DURATION_IDENTIFIER
1641 if (scm_is_true (scm_call_1 ($2, $4)))
1643 MYREPARSE (@4, $2, DURATION_IDENTIFIER, $4);
1646 $$ = scm_cons (loc_on_music (@3, $1), $3);
1647 MYBACKUP (DURATION_IDENTIFIER, $4, @4);
1650 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_backup SCM_IDENTIFIER
1652 SCM res = try_string_variants ($2, $4);
1653 if (!SCM_UNBNDP (res))
1654 if (scm_is_pair (res)) {
1656 MYREPARSE (@4, $2, SYMBOL_LIST, res);
1659 $$ = scm_cons (res, $3);
1661 $$ = scm_cons (loc_on_music (@3, $1), $3);
1662 MYBACKUP (SCM_IDENTIFIER, $4, @4);
1665 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_backup STRING
1667 SCM res = try_string_variants ($2, $4);
1668 if (!SCM_UNBNDP (res))
1669 if (scm_is_pair (res)) {
1671 MYREPARSE (@4, $2, SYMBOL_LIST, res);
1674 $$ = scm_cons (res, $3);
1676 $$ = scm_cons (loc_on_music (@3, $1), $3);
1677 MYBACKUP (STRING, $4, @4);
1680 | function_arglist_backup REPARSE bare_number_common
1682 $$ = check_scheme_arg (parser, @3,
1685 | function_arglist_backup REPARSE duration_length
1687 $$ = check_scheme_arg (parser, @3,
1690 | function_arglist_backup REPARSE symbol_list_arg
1692 $$ = check_scheme_arg (parser, @3, $3, $1, $2);
1694 | function_arglist_backup REPARSE pitch_also_in_chords
1696 $$ = check_scheme_arg (parser, @3, $3, $1, $2);
1701 function_arglist_nonbackup
1702 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_skip_nonbackup DEFAULT
1704 $$ = scm_cons (loc_on_music (@4, $1), $3);
1708 function_arglist_skip_nonbackup:
1709 function_arglist_nonbackup
1710 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_skip_nonbackup
1712 $$ = scm_cons (loc_on_music (@3, $1), $3);
1716 function_arglist_common:
1717 EXPECT_NO_MORE_ARGS {
1720 | EXPECT_SCM function_arglist_optional embedded_scm_arg
1722 if (scm_is_true (scm_call_1 ($1, $3)))
1723 $$ = scm_cons ($3, $2);
1725 $$ = check_scheme_arg (parser, @3,
1726 make_music_from_simple
1730 | EXPECT_SCM function_arglist_closed_optional bare_number_common
1732 $$ = check_scheme_arg (parser, @3,
1735 | EXPECT_SCM function_arglist_optional FRACTION
1737 $$ = check_scheme_arg (parser, @3,
1740 | EXPECT_SCM function_arglist_closed_optional post_event_nofinger
1742 $$ = check_scheme_arg (parser, @3,
1745 | EXPECT_SCM function_arglist_closed_optional '-' NUMBER_IDENTIFIER
1747 SCM n = scm_difference ($4, SCM_UNDEFINED);
1748 $$ = check_scheme_arg (parser, @4, n, $2, $1);
1750 | function_arglist_common_reparse REPARSE SCM_ARG
1752 $$ = check_scheme_arg (parser, @3,
1755 | function_arglist_common_reparse REPARSE lyric_element_music
1757 $$ = check_scheme_arg (parser, @3,
1760 | function_arglist_common_reparse REPARSE bare_number_common
1762 $$ = check_scheme_arg (parser, @3,
1765 | function_arglist_common_reparse REPARSE duration_length
1767 $$ = check_scheme_arg (parser, @3,
1770 | function_arglist_common_reparse REPARSE symbol_list_arg
1772 $$ = check_scheme_arg (parser, @3, $3, $1, $2);
1776 function_arglist_common_reparse:
1777 EXPECT_SCM function_arglist_optional SCM_IDENTIFIER
1780 SCM res = try_string_variants ($1, $3);
1781 if (!SCM_UNBNDP (res))
1782 if (scm_is_pair (res))
1783 MYREPARSE (@3, $1, SYMBOL_LIST, res);
1785 MYREPARSE (@3, $1, SCM_ARG, res);
1786 else if (scm_is_true
1788 ($1, make_music_from_simple (parser, @3, $3))))
1789 MYREPARSE (@3, $1, LYRIC_ELEMENT, $3);
1791 // This is going to flag a syntax error, we
1792 // know the predicate to be false.
1793 MYREPARSE (@3, $1, SCM_ARG, $3);
1795 | EXPECT_SCM function_arglist_optional STRING
1798 SCM res = try_string_variants ($1, $3);
1799 if (!SCM_UNBNDP (res))
1800 if (scm_is_pair (res))
1801 MYREPARSE (@3, $1, SYMBOL_LIST, res);
1803 MYREPARSE (@3, $1, SCM_ARG, res);
1804 else if (scm_is_true
1806 ($1, make_music_from_simple (parser, @3, $3))))
1807 MYREPARSE (@3, $1, LYRIC_ELEMENT, $3);
1809 // This is going to flag a syntax error, we
1810 // know the predicate to be false.
1811 MYREPARSE (@3, $1, SCM_ARG, $3);
1813 | EXPECT_SCM function_arglist_optional full_markup
1816 if (scm_is_true (scm_call_1 ($1, $3)))
1817 MYREPARSE (@3, $1, SCM_ARG, $3);
1818 else if (scm_is_true
1820 ($1, make_music_from_simple (parser, @3, $3))))
1821 MYREPARSE (@3, $1, LYRIC_ELEMENT, $3);
1823 // This is going to flag a syntax error, we
1824 // know the predicate to be false.
1825 MYREPARSE (@3, $1, SCM_ARG, $3);
1827 | EXPECT_SCM function_arglist_closed_optional UNSIGNED
1830 if (scm_is_true (scm_call_1 ($1, $3)))
1831 MYREPARSE (@3, $1, REAL, $3);
1833 SCM d = make_duration ($3);
1834 if (SCM_UNBNDP (d) || scm_is_false (scm_call_1 ($1, d)))
1835 MYREPARSE (@3, $1, REAL, $3);
1837 MYREPARSE (@3, $1, DURATION_IDENTIFIER, d);
1840 | EXPECT_SCM function_arglist_closed_optional DURATION_IDENTIFIER
1843 MYREPARSE (@3, $1, DURATION_IDENTIFIER, $3);
1845 | EXPECT_SCM function_arglist_closed_optional '-' UNSIGNED
1848 SCM n = scm_difference ($4, SCM_UNDEFINED);
1849 if (scm_is_true (scm_call_1 ($1, n)))
1850 MYREPARSE (@4, $1, REAL, n);
1852 Music *t = MY_MAKE_MUSIC ("FingeringEvent", @4);
1853 t->set_property ("digit", $4);
1854 SCM m = t->unprotect ();
1855 if (scm_is_true (scm_call_1 ($1, m)))
1856 MYREPARSE (@4, $1, SCM_ARG, m);
1858 MYREPARSE (@4, $1, SCM_ARG, $4);
1862 | EXPECT_SCM function_arglist_closed_optional '-' REAL
1865 SCM n = scm_difference ($4, SCM_UNDEFINED);
1866 MYREPARSE (@4, $1, REAL, n);
1870 function_arglist_closed:
1871 function_arglist_closed_nonbackup
1872 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_skip_nonbackup DEFAULT
1874 $$ = scm_cons (loc_on_music (@4, $1), $3);
1878 function_arglist_closed_common:
1879 EXPECT_NO_MORE_ARGS {
1882 | EXPECT_SCM function_arglist_optional embedded_scm_arg_closed
1884 $$ = check_scheme_arg (parser, @3,
1887 | EXPECT_SCM function_arglist_closed_optional bare_number_common_closed
1889 $$ = check_scheme_arg (parser, @3,
1892 | EXPECT_SCM function_arglist_closed_optional '-' NUMBER_IDENTIFIER
1894 $$ = check_scheme_arg (parser, @3,
1895 scm_difference ($4, SCM_UNDEFINED),
1898 | EXPECT_SCM function_arglist_closed_optional post_event_nofinger
1900 $$ = check_scheme_arg (parser, @3,
1903 | EXPECT_SCM function_arglist_optional FRACTION
1905 $$ = check_scheme_arg (parser, @3,
1908 | function_arglist_common_reparse REPARSE SCM_ARG
1910 $$ = check_scheme_arg (parser, @3,
1913 | function_arglist_common_reparse REPARSE bare_number_common_closed
1915 $$ = check_scheme_arg (parser, @3,
1918 | function_arglist_common_reparse REPARSE symbol_list_arg
1920 $$ = check_scheme_arg (parser, @3, $3, $1, $2);
1924 function_arglist_optional:
1925 function_arglist_backup
1926 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_skip_backup DEFAULT
1928 $$ = scm_cons (loc_on_music (@4, $1), $3);
1930 | function_arglist_skip_backup BACKUP
1933 function_arglist_skip_backup:
1934 function_arglist_backup
1935 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_skip_backup
1937 $$ = scm_cons (loc_on_music (@3, $1), $3);
1941 function_arglist_closed_optional:
1942 function_arglist_closed_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 embedded_scm_closed:
1952 | scm_function_call_closed
1955 embedded_scm_arg_closed:
1956 embedded_scm_bare_arg
1957 | scm_function_call_closed
1961 scm_function_call_closed:
1962 SCM_FUNCTION function_arglist_closed {
1963 $$ = MAKE_SYNTAX ("music-function", @$,
1968 music_function_call:
1969 MUSIC_FUNCTION function_arglist {
1970 $$ = MAKE_SYNTAX ("music-function", @$,
1977 /**/ { $$ = SCM_EOL; }
1978 | '=' simple_string {
1985 | repeated_music { $$ = $1; }
1986 | re_rhythmed_music { $$ = $1; }
1987 | complex_music_prefix music
1989 $$ = FINISH_MAKE_SYNTAX ($1, @$, $2);
1993 complex_music_prefix:
1994 CONTEXT symbol optional_id optional_context_mod {
1995 Context_mod *ctxmod = unsmob_context_mod ($4);
1998 mods = ctxmod->get_mods ();
1999 $$ = START_MAKE_SYNTAX ("context-specification", $2, $3, mods, SCM_BOOL_F);
2001 | NEWCONTEXT symbol optional_id optional_context_mod {
2002 Context_mod *ctxmod = unsmob_context_mod ($4);
2005 mods = ctxmod->get_mods ();
2006 $$ = START_MAKE_SYNTAX ("context-specification", $2, $3, mods, SCM_BOOL_T);
2011 mode_changing_head grouped_music_list {
2012 if ($1 == ly_symbol2scm ("chords"))
2014 $$ = MAKE_SYNTAX ("unrelativable-music", @$, $2);
2020 parser->lexer_->pop_state ();
2022 | mode_changing_head_with_context optional_context_mod grouped_music_list {
2023 Context_mod *ctxmod = unsmob_context_mod ($2);
2026 mods = ctxmod->get_mods ();
2027 $$ = MAKE_SYNTAX ("context-specification", @$, $1, SCM_EOL, mods, SCM_BOOL_T, $3);
2028 if ($1 == ly_symbol2scm ("ChordNames"))
2030 $$ = MAKE_SYNTAX ("unrelativable-music", @$, $$);
2032 parser->lexer_->pop_state ();
2038 SCM nn = parser->lexer_->lookup_identifier ("pitchnames");
2039 parser->lexer_->push_note_state (nn);
2041 $$ = ly_symbol2scm ("notes");
2045 SCM nn = parser->lexer_->lookup_identifier ("drumPitchNames");
2046 parser->lexer_->push_note_state (nn);
2048 $$ = ly_symbol2scm ("drums");
2051 parser->lexer_->push_figuredbass_state ();
2053 $$ = ly_symbol2scm ("figures");
2056 SCM nn = parser->lexer_->lookup_identifier ("chordmodifiers");
2057 parser->lexer_->chordmodifier_tab_ = alist_to_hashq (nn);
2058 nn = parser->lexer_->lookup_identifier ("pitchnames");
2059 parser->lexer_->push_chord_state (nn);
2060 $$ = ly_symbol2scm ("chords");
2064 { parser->lexer_->push_lyric_state ();
2065 $$ = ly_symbol2scm ("lyrics");
2069 mode_changing_head_with_context:
2071 SCM nn = parser->lexer_->lookup_identifier ("drumPitchNames");
2072 parser->lexer_->push_note_state (nn);
2074 $$ = ly_symbol2scm ("DrumStaff");
2077 parser->lexer_->push_figuredbass_state ();
2079 $$ = ly_symbol2scm ("FiguredBass");
2082 SCM nn = parser->lexer_->lookup_identifier ("chordmodifiers");
2083 parser->lexer_->chordmodifier_tab_ = alist_to_hashq (nn);
2084 nn = parser->lexer_->lookup_identifier ("pitchnames");
2085 parser->lexer_->push_chord_state (nn);
2086 $$ = ly_symbol2scm ("ChordNames");
2089 { parser->lexer_->push_lyric_state ();
2090 $$ = ly_symbol2scm ("Lyrics");
2095 ADDLYRICS { parser->lexer_->push_lyric_state (); }
2098 /* Can also use music at the expensive of two S/Rs similar to
2099 \repeat \alternative */
2100 parser->lexer_->pop_state ();
2102 $$ = scm_cons ($3, SCM_EOL);
2104 | new_lyrics ADDLYRICS {
2105 parser->lexer_->push_lyric_state ();
2107 parser->lexer_->pop_state ();
2108 $$ = scm_cons ($4, $1);
2113 composite_music new_lyrics {
2114 $$ = MAKE_SYNTAX ("add-lyrics", @$, $1, scm_reverse_x ($2, SCM_EOL));
2116 | LYRICSTO simple_string {
2117 parser->lexer_->push_lyric_state ();
2119 parser->lexer_->pop_state ();
2120 $$ = MAKE_SYNTAX ("lyric-combine", @$, $2, $4);
2125 CHANGE STRING '=' STRING {
2126 $$ = MAKE_SYNTAX ("context-change", @$, scm_string_to_symbol ($2), $4);
2133 $$ = scm_reverse_x ($1, SCM_EOL);
2135 | symbol_list_rev property_path {
2136 $$ = scm_reverse_x ($1, $2);
2142 $$ = scm_list_3 (ly_symbol2scm ("assign"), $1, $3);
2145 $$ = scm_list_2 (ly_symbol2scm ("unset"), $2);
2147 | OVERRIDE property_path '=' scalar {
2148 if (scm_ilength ($2) < 2) {
2149 parser->parser_error (@2, _("bad grob property path"));
2152 $$ = scm_cons (ly_symbol2scm ("push"),
2153 scm_cons2 (scm_car ($2),
2158 | REVERT revert_arg {
2159 $$ = scm_cons (ly_symbol2scm ("pop"), $2);
2163 // This is all quite awkward for the sake of substantial backward
2164 // compatibility while at the same time allowing a more "natural" form
2165 // of specification not separating grob specification from grob
2166 // property path. The purpose of this definition of revert_arg is to
2167 // allow the symbol list which specifies grob and property to revert
2168 // to be optionally be split into two parts after the grob (which in
2169 // this case is just the first element of the list). symbol_list_part
2170 // is only one path component, but it can be parsed without lookahead,
2171 // so we can follow it with a synthetic BACKUP token when needed. If
2172 // the first symbol_list_part already contains multiple elements (only
2173 // possible if a Scheme expression provides them), we just parse for
2174 // additional elements introduced by '.', which is what the
2175 // SYMBOL_LIST backup in connection with the immediately following
2176 // rule using symbol_list_arg does.
2178 // As long as we don't have our coffers filled with both grob and at
2179 // least one grob property specification, the rest of the required
2180 // symbol list chain may be provided either with or without a leading
2181 // dot. This is for both allowing the traditional
2182 // \revert Accidental #'color
2183 // as well as well as the "naive" form
2184 // \revert Accidental.color
2187 revert_arg_backup BACKUP symbol_list_arg
2196 if (scm_is_null ($1)
2197 || scm_is_null (scm_cdr ($1)))
2198 MYBACKUP (SCM_ARG, $1, @1);
2200 MYBACKUP (SYMBOL_LIST, scm_reverse_x ($1, SCM_EOL), @1);
2204 // revert_arg_part delivers results in reverse
2207 | revert_arg_backup BACKUP SCM_ARG '.' symbol_list_part
2209 $$ = scm_append_x (scm_list_2 ($5, $3));
2211 | revert_arg_backup BACKUP SCM_ARG symbol_list_part
2213 $$ = scm_append_x (scm_list_2 ($4, $3));
2218 CONSISTS { $$ = ly_symbol2scm ("consists"); }
2219 | REMOVE { $$ = ly_symbol2scm ("remove"); }
2221 | ACCEPTS { $$ = ly_symbol2scm ("accepts"); }
2222 | DEFAULTCHILD { $$ = ly_symbol2scm ("default-child"); }
2223 | DENIES { $$ = ly_symbol2scm ("denies"); }
2225 | ALIAS { $$ = ly_symbol2scm ("alias"); }
2226 | TYPE { $$ = ly_symbol2scm ("translator-type"); }
2227 | DESCRIPTION { $$ = ly_symbol2scm ("description"); }
2228 | NAME { $$ = ly_symbol2scm ("context-name"); }
2232 property_operation { $$ = $1; }
2233 | context_def_mod STRING {
2234 $$ = scm_list_2 ($1, $2);
2236 | context_def_mod embedded_scm
2238 if (!scm_is_string ($2)
2239 && ly_symbol2scm ("consists") != $1
2240 && ly_symbol2scm ("remove") != $1)
2243 parser->parser_error (@1, _ ("only \\consists and \\remove take non-string argument."));
2247 $$ = scm_list_2 ($1, $2);
2252 // If defined, at least two members.
2256 SCM l = scm_reverse_x ($1, SCM_EOL);
2259 (scm_object_property (scm_car (l),
2260 ly_symbol2scm ("is-grob?"))))
2261 l = scm_cons (ly_symbol2scm ("Bottom"), l);
2262 if (scm_is_null (l) || scm_is_null (scm_cdr (l))) {
2263 parser->parser_error (@1, _ ("bad grob property path"));
2270 // If defined, at least three members
2274 if (!SCM_UNBNDP ($1) && scm_is_null (scm_cddr ($1)))
2276 parser->parser_error (@1, _ ("bad grob property path"));
2280 | grob_prop_spec property_path
2282 if (!SCM_UNBNDP ($1)) {
2283 $$ = scm_append_x (scm_list_2 ($1, $2));
2284 if (scm_is_null (scm_cddr ($$))) {
2285 parser->parser_error (@$, _ ("bad grob property path"));
2293 // Exactly two elements or undefined
2297 SCM l = scm_reverse_x ($1, SCM_EOL);
2298 switch (scm_ilength (l)) {
2300 l = scm_cons (ly_symbol2scm ("Bottom"), l);
2304 parser->parser_error (@1, _ ("bad context property path"));
2311 simple_music_property_def:
2312 OVERRIDE grob_prop_path '=' scalar {
2313 if (SCM_UNBNDP ($2))
2316 $$ = scm_list_5 (scm_car ($2),
2317 ly_symbol2scm ("OverrideProperty"),
2323 | REVERT simple_revert_context revert_arg {
2324 $$ = scm_list_4 ($2,
2325 ly_symbol2scm ("RevertProperty"),
2329 | SET context_prop_spec '=' scalar {
2330 if (SCM_UNBNDP ($2))
2333 $$ = scm_list_4 (scm_car ($2),
2334 ly_symbol2scm ("PropertySet"),
2338 | UNSET context_prop_spec {
2339 if (SCM_UNBNDP ($2))
2342 $$ = scm_list_3 (scm_car ($2),
2343 ly_symbol2scm ("PropertyUnset"),
2349 // This is all quite awkward for the sake of substantial backward
2350 // compatibility while at the same time allowing a more "natural" form
2351 // of specification not separating grob specification from grob
2352 // property path. The purpose of this definition of
2353 // simple_revert_context is to allow the symbol list which specifies
2354 // grob and property to revert to be optionally be split into two
2355 // parts after the grob (which may be preceded by a context
2356 // specification, a case which we distinguish by checking whether the
2357 // first symbol is a valid grob symbol instead).
2359 // See revert_arg above for the main work horse of this arrangement.
2360 // simple_revert_context just caters for the context and delegates the
2361 // rest of the job to revert_arg.
2363 simple_revert_context:
2366 $1 = scm_reverse_x ($1, SCM_EOL);
2367 if (scm_is_null ($1)
2369 (scm_object_property (scm_car ($1),
2370 ly_symbol2scm ("is-grob?")))) {
2371 $$ = ly_symbol2scm ("Bottom");
2372 parser->lexer_->push_extra_token (SCM_IDENTIFIER, $1);
2375 parser->lexer_->push_extra_token (SCM_IDENTIFIER,
2382 simple_music_property_def {
2383 if (SCM_UNBNDP ($1))
2384 $$ = MAKE_SYNTAX ("void-music", @1);
2386 $$ = LOWLEVEL_MAKE_SYNTAX (ly_lily_module_constant ("property-operation"), scm_cons2 (parser->self_scm (), make_input (@$), $1));
2397 simple_string: STRING {
2402 if (scm_is_string ($1)) {
2405 parser->parser_error (@1, (_ ("simple string expected")));
2406 $$ = scm_string (SCM_EOL);
2413 $$ = scm_string_to_symbol ($1);
2417 // This is a bit of overkill but makes the same
2418 // routine responsible for all symbol interpretations.
2419 $$ = try_string_variants (ly_lily_module_constant ("symbol?"),
2421 if (SCM_UNBNDP ($$))
2423 parser->parser_error (@1, (_ ("symbol expected")));
2424 // Generate a unique symbol in case it is used
2425 // for an assignment or similar
2426 $$ = scm_make_symbol (ly_string2scm ("undefined"));
2435 // The following is a rather defensive variant of admitting
2436 // negative numbers: the grammar would permit number_factor or
2437 // even number_expression. However, function arguments allow
2438 // only this simple kind of negative number, so to have things
2439 // like \tweak and \override behave reasonably similar, it
2440 // makes sense to rule out things like -- which are rather an
2441 // accent in function argument contexts.
2444 $$ = scm_difference ($2, SCM_UNDEFINED);
2452 embedded_scm_arg_closed
2454 // for scalar_closed to be an actually closed (no lookahead)
2455 // expression, we'd need to use bare_number_closed here. It
2456 // turns out that the only use of scalar_closed in TEMPO is
2457 // not of the kind requiring the full closedness criterion.
2461 $$ = scm_difference ($2, SCM_UNDEFINED);
2470 simple_element post_events {
2471 // Let the rhythmic music iterator sort this mess out.
2472 if (scm_is_pair ($2)) {
2473 $$ = make_music_from_simple (parser, @1, $1);
2474 if (unsmob_music ($$))
2475 unsmob_music ($$)->set_property ("articulations",
2476 scm_reverse_x ($2, SCM_EOL));
2479 parser->parser_error (@1, _("music expected"));
2480 $$ = MAKE_SYNTAX ("void-music", @1);
2484 | simple_chord_elements post_events {
2485 SCM elts = ly_append2 ($1, scm_reverse_x ($2, SCM_EOL));
2488 /* why is this giving wrong start location? -ns
2490 i.set_location (@1, @2);
2491 $$ = MAKE_SYNTAX ("event-chord", i, elts);
2493 | CHORD_REPETITION optional_notemode_duration post_events {
2495 i.set_location (@1, @3);
2496 $$ = MAKE_SYNTAX ("repetition-chord", i,
2497 $2, scm_reverse_x ($3, SCM_EOL));
2499 | MULTI_MEASURE_REST optional_notemode_duration post_events {
2501 i.set_location (@1, @3);
2502 $$ = MAKE_SYNTAX ("multi-measure-rest", i, $2,
2503 scm_reverse_x ($3, SCM_EOL));
2506 | note_chord_element
2511 chord_body optional_notemode_duration post_events
2513 Music *m = unsmob_music ($1);
2514 SCM dur = unsmob_duration ($2)->smobbed_copy ();
2515 SCM es = m->get_property ("elements");
2516 SCM postevs = scm_reverse_x ($3, SCM_EOL);
2518 for (SCM s = es; scm_is_pair (s); s = scm_cdr (s))
2519 unsmob_music (scm_car (s))->set_property ("duration", dur);
2520 es = ly_append2 (es, postevs);
2522 m-> set_property ("elements", es);
2524 $$ = m->self_scm ();
2529 ANGLE_OPEN chord_body_elements ANGLE_CLOSE
2531 $$ = MAKE_SYNTAX ("event-chord", @$, scm_reverse_x ($2, SCM_EOL));
2535 chord_body_elements:
2536 /* empty */ { $$ = SCM_EOL; }
2537 | chord_body_elements chord_body_element {
2538 if (!SCM_UNBNDP ($2))
2539 $$ = scm_cons ($2, $1);
2544 pitch exclamations questions octave_check post_events
2546 bool q = to_boolean ($3);
2547 bool ex = to_boolean ($2);
2551 Music *n = MY_MAKE_MUSIC ("NoteEvent", @$);
2552 n->set_property ("pitch", $1);
2554 n->set_property ("cautionary", SCM_BOOL_T);
2556 n->set_property ("force-accidental", SCM_BOOL_T);
2558 if (scm_is_pair (post)) {
2559 SCM arts = scm_reverse_x (post, SCM_EOL);
2560 n->set_property ("articulations", arts);
2562 if (scm_is_number (check))
2564 int q = scm_to_int (check);
2565 n->set_property ("absolute-octave", scm_from_int (q-1));
2568 $$ = n->unprotect ();
2570 | DRUM_PITCH post_events {
2571 Music *n = MY_MAKE_MUSIC ("NoteEvent", @$);
2572 n->set_property ("drum-type", $1);
2574 if (scm_is_pair ($2)) {
2575 SCM arts = scm_reverse_x ($2, SCM_EOL);
2576 n->set_property ("articulations", arts);
2578 $$ = n->unprotect ();
2580 | music_function_chord_body
2582 Music *m = unsmob_music ($1);
2584 while (m && m->is_mus_type ("music-wrapper-music")) {
2585 $$ = m->get_property ("element");
2586 m = unsmob_music ($$);
2589 if (!(m && m->is_mus_type ("rhythmic-event"))) {
2590 parser->parser_error (@$, _ ("not a rhythmic event"));
2596 music_function_chord_body:
2601 // Event functions may only take closed arglists, otherwise it would
2602 // not be clear whether a following postevent should be associated
2603 // with the last argument of the event function or with the expression
2604 // for which the function call acts itself as event.
2606 music_function_call_closed:
2607 MUSIC_FUNCTION function_arglist_closed {
2608 $$ = MAKE_SYNTAX ("music-function", @$,
2613 event_function_event:
2614 EVENT_FUNCTION function_arglist_closed {
2615 $$ = MAKE_SYNTAX ("music-function", @$,
2637 | post_events post_event {
2639 if (Music *m = unsmob_music ($2))
2641 if (m->is_mus_type ("post-event-wrapper"))
2643 for (SCM p = m->get_property ("elements");
2647 $$ = scm_cons (scm_car (p), $$);
2651 $$ = scm_cons ($2, $$);
2657 post_event_nofinger:
2658 direction_less_event {
2661 | script_dir music_function_call_closed {
2663 if (!unsmob_music ($2)->is_mus_type ("post-event")) {
2664 parser->parser_error (@2, _ ("post-event expected"));
2665 $$ = SCM_UNSPECIFIED;
2666 } else if (!SCM_UNBNDP ($1))
2668 unsmob_music ($$)->set_property ("direction", $1);
2672 if (!parser->lexer_->is_lyric_state ())
2673 parser->parser_error (@1, _ ("have to be in Lyric mode for lyrics"));
2674 $$ = MY_MAKE_MUSIC ("HyphenEvent", @$)->unprotect ();
2677 if (!parser->lexer_->is_lyric_state ())
2678 parser->parser_error (@1, _ ("have to be in Lyric mode for lyrics"));
2679 $$ = MY_MAKE_MUSIC ("ExtenderEvent", @$)->unprotect ();
2681 | script_dir direction_reqd_event {
2682 if (!SCM_UNBNDP ($1))
2684 Music *m = unsmob_music ($2);
2685 m->set_property ("direction", $1);
2689 | script_dir direction_less_event {
2690 if (!SCM_UNBNDP ($1))
2692 Music *m = unsmob_music ($2);
2693 m->set_property ("direction", $1);
2700 unsmob_music ($$)->set_property ("direction", scm_from_int (UP));
2705 unsmob_music ($$)->set_property ("direction", scm_from_int (DOWN));
2716 string_number_event:
2718 Music *s = MY_MAKE_MUSIC ("StringNumberEvent", @$);
2719 s->set_property ("string-number", $1);
2720 $$ = s->unprotect ();
2724 direction_less_event:
2726 | EVENT_IDENTIFIER {
2730 Music *a = MY_MAKE_MUSIC ("TremoloEvent", @$);
2731 a->set_property ("tremolo-type", $1);
2732 $$ = a->unprotect ();
2734 | event_function_event
2737 direction_reqd_event:
2741 | script_abbreviation {
2742 SCM s = parser->lexer_->lookup_identifier ("dash" + ly_scm2string ($1));
2743 Music *a = MY_MAKE_MUSIC ("ArticulationEvent", @$);
2744 if (scm_is_string (s))
2745 a->set_property ("articulation-type", s);
2746 else parser->parser_error (@1, _ ("expecting string as script definition"));
2747 $$ = a->unprotect ();
2752 /**/ { $$ = SCM_EOL; }
2753 | '=' quotes { $$ = $2; }
2767 $$ = scm_from_int (1);
2770 $$ = scm_oneplus ($1);
2776 $$ = scm_from_int (-1);
2779 $$ = scm_oneminus ($1);
2784 NOTENAME_PITCH quotes {
2785 if (!scm_is_eq (SCM_INUM0, $2))
2787 Pitch p = *unsmob_pitch ($1);
2788 p = p.transposed (Pitch (scm_to_int ($2),0,0));
2789 $$ = p.smobbed_copy ();
2799 TONICNAME_PITCH quotes {
2800 if (!scm_is_eq (SCM_INUM0, $2))
2802 Pitch p = *unsmob_pitch ($1);
2803 p = p.transposed (Pitch (scm_to_int ($2),0,0));
2804 $$ = p.smobbed_copy ();
2814 pitch_also_in_chords:
2821 Music *t = MY_MAKE_MUSIC ("TextScriptEvent", @$);
2822 t->set_property ("text", $1);
2823 $$ = t->unprotect ();
2826 Music *t = MY_MAKE_MUSIC ("TextScriptEvent", @$);
2827 t->set_property ("text",
2828 make_simple_markup ($1));
2829 $$ = t->unprotect ();
2831 | embedded_scm_closed
2833 Music *m = unsmob_music ($1);
2834 if (m && m->is_mus_type ("post-event"))
2836 else if (Text_interface::is_markup ($1)) {
2837 Music *t = MY_MAKE_MUSIC ("TextScriptEvent", @$);
2838 t->set_property ("text", $1);
2839 $$ = t->unprotect ();
2841 parser->parser_error (@1, _ ("not an articulation"));
2847 Music *t = MY_MAKE_MUSIC ("FingeringEvent", @$);
2848 t->set_property ("digit", $1);
2849 $$ = t->unprotect ();
2853 script_abbreviation:
2855 $$ = scm_from_locale_string ("Hat");
2858 $$ = scm_from_locale_string ("Plus");
2861 $$ = scm_from_locale_string ("Dash");
2864 $$ = scm_from_locale_string ("Bang");
2867 $$ = scm_from_locale_string ("Larger");
2870 $$ = scm_from_locale_string ("Dot");
2873 $$ = scm_from_locale_string ("Underscore");
2878 '_' { $$ = scm_from_int (DOWN); }
2879 | '^' { $$ = scm_from_int (UP); }
2880 | '-' { $$ = SCM_UNDEFINED; }
2884 multiplied_duration {
2889 maybe_notemode_duration:
2893 | multiplied_duration {
2895 parser->default_duration_ = *unsmob_duration ($$);
2900 optional_notemode_duration:
2901 maybe_notemode_duration
2903 if (SCM_UNBNDP ($$))
2904 $$ = parser->default_duration_.smobbed_copy ();
2910 $$ = make_duration ($1, scm_to_int ($2));
2911 if (SCM_UNBNDP ($$))
2913 parser->parser_error (@1, _ ("not a duration"));
2914 $$ = Duration ().smobbed_copy ();
2917 | DURATION_IDENTIFIER dots {
2918 Duration *d = unsmob_duration ($1);
2919 Duration k (d->duration_log (),
2920 d->dot_count () + scm_to_int ($2));
2921 k = k.compressed (d->factor ());
2922 scm_remember_upto_here_1 ($1);
2923 $$ = k.smobbed_copy ();
2927 multiplied_duration:
2931 | multiplied_duration '*' UNSIGNED {
2932 $$ = unsmob_duration ($$)->compressed (scm_to_int ($3)).smobbed_copy ();
2934 | multiplied_duration '*' FRACTION {
2935 Rational m (scm_to_int (scm_car ($3)), scm_to_int (scm_cdr ($3)));
2937 $$ = unsmob_duration ($$)->compressed (m).smobbed_copy ();
2946 $$ = scm_oneplus ($1);
2955 if (SCM_UNBNDP (make_duration ($2)))
2956 parser->parser_error (@2, _ ("not a duration"));
2962 UNSIGNED { $$ = $1; }
2963 | STRING { $$ = $1; }
2964 | full_markup { $$ = $1; }
2967 // as an integer, it needs to be non-negative, and otherwise
2968 // it needs to be suitable as a markup.
2969 if (scm_is_integer ($1)
2970 ? scm_is_true (scm_negative_p ($1))
2971 : !Text_interface::is_markup ($1))
2973 parser->parser_error (@1, _ ("bass number expected"));
2979 figured_bass_alteration:
2980 '-' { $$ = ly_rational2scm (FLAT_ALTERATION); }
2981 | '+' { $$ = ly_rational2scm (SHARP_ALTERATION); }
2982 | '!' { $$ = scm_from_int (0); }
2987 Music *bfr = MY_MAKE_MUSIC ("BassFigureEvent", @$);
2988 $$ = bfr->unprotect ();
2991 Music *bfr = MY_MAKE_MUSIC ("BassFigureEvent", @$);
2992 $$ = bfr->self_scm ();
2994 if (scm_is_number ($1))
2995 bfr->set_property ("figure", $1);
2996 else if (Text_interface::is_markup ($1))
2997 bfr->set_property ("text", $1);
3003 unsmob_music ($1)->set_property ("bracket-stop", SCM_BOOL_T);
3005 | bass_figure figured_bass_alteration {
3006 Music *m = unsmob_music ($1);
3007 if (scm_to_double ($2)) {
3008 SCM salter = m->get_property ("alteration");
3009 SCM alter = scm_is_number (salter) ? salter : scm_from_int (0);
3010 m->set_property ("alteration",
3011 scm_sum (alter, $2));
3013 m->set_property ("alteration", scm_from_int (0));
3016 | bass_figure figured_bass_modification {
3017 Music *m = unsmob_music ($1);
3018 m->set_property ($2, SCM_BOOL_T);
3023 figured_bass_modification:
3025 $$ = ly_symbol2scm ("augmented");
3028 $$ = ly_symbol2scm ("no-continuation");
3031 $$ = ly_symbol2scm ("diminished");
3034 $$ = ly_symbol2scm ("augmented-slash");
3044 unsmob_music ($$)->set_property ("bracket-start", SCM_BOOL_T);
3052 | figure_list br_bass_figure {
3053 $$ = scm_cons ($2, $1);
3058 FIGURE_OPEN figure_list FIGURE_CLOSE {
3059 $$ = scm_reverse_x ($2, SCM_EOL);
3065 /**/ { $$ = SCM_BOOL_F; }
3066 | REST { $$ = SCM_BOOL_T; }
3070 pitch exclamations questions octave_check maybe_notemode_duration optional_rest {
3071 if (!parser->lexer_->is_note_state ())
3072 parser->parser_error (@1, _ ("have to be in Note mode for notes"));
3073 if (!SCM_UNBNDP ($2)
3075 || scm_is_number ($4)
3077 || scm_is_true ($6))
3080 if (scm_is_true ($6))
3081 n = MY_MAKE_MUSIC ("RestEvent", @$);
3083 n = MY_MAKE_MUSIC ("NoteEvent", @$);
3085 n->set_property ("pitch", $1);
3086 if (SCM_UNBNDP ($5))
3087 n->set_property ("duration",
3088 parser->default_duration_.smobbed_copy ());
3090 n->set_property ("duration", $5);
3092 if (scm_is_number ($4))
3094 int q = scm_to_int ($4);
3095 n->set_property ("absolute-octave", scm_from_int (q-1));
3098 if (to_boolean ($3))
3099 n->set_property ("cautionary", SCM_BOOL_T);
3100 if (to_boolean ($2) || to_boolean ($3))
3101 n->set_property ("force-accidental", SCM_BOOL_T);
3103 $$ = n->unprotect ();
3106 | DRUM_PITCH optional_notemode_duration {
3107 Music *n = MY_MAKE_MUSIC ("NoteEvent", @$);
3108 n->set_property ("duration", $2);
3109 n->set_property ("drum-type", $1);
3111 $$ = n->unprotect ();
3113 | RESTNAME optional_notemode_duration {
3115 if (ly_scm2string ($1) == "s") {
3117 ev = MY_MAKE_MUSIC ("SkipEvent", @$);
3120 ev = MY_MAKE_MUSIC ("RestEvent", @$);
3123 ev->set_property ("duration", $2);
3124 $$ = ev->unprotect ();
3128 simple_chord_elements:
3130 if (!parser->lexer_->is_chord_state ())
3131 parser->parser_error (@1, _ ("have to be in Chord mode for chords"));
3134 | figure_spec optional_notemode_duration {
3135 for (SCM s = $1; scm_is_pair (s); s = scm_cdr (s))
3137 unsmob_music (scm_car (s))->set_property ("duration", $2);
3145 if (!parser->lexer_->is_lyric_state ())
3146 parser->parser_error (@1, _ ("markup outside of text script or \\lyricmode"));
3150 if (!parser->lexer_->is_lyric_state ())
3151 parser->parser_error (@1, _ ("unrecognized string, not in text script or \\lyricmode"));
3157 lyric_element_music:
3158 lyric_element optional_notemode_duration post_events {
3159 $$ = MAKE_SYNTAX ("lyric-event", @$, $1, $2);
3160 if (scm_is_pair ($3))
3161 unsmob_music ($$)->set_property
3162 ("articulations", scm_reverse_x ($3, SCM_EOL));
3167 steno_tonic_pitch optional_notemode_duration {
3168 $$ = make_chord_elements (@$, $1, $2, SCM_EOL);
3170 | steno_tonic_pitch optional_notemode_duration chord_separator chord_items {
3171 SCM its = scm_reverse_x ($4, SCM_EOL);
3172 $$ = make_chord_elements (@$, $1, $2, scm_cons ($3, its));
3180 | chord_items chord_item {
3181 $$ = scm_cons ($2, $$);
3187 $$ = ly_symbol2scm ("chord-colon");
3190 $$ = ly_symbol2scm ("chord-caret");
3192 | CHORD_SLASH steno_tonic_pitch {
3193 $$ = scm_list_2 (ly_symbol2scm ("chord-slash"), $2);
3195 | CHORD_BASS steno_tonic_pitch {
3196 $$ = scm_list_2 (ly_symbol2scm ("chord-bass"), $2);
3205 $$ = scm_reverse_x ($1, SCM_EOL);
3213 step_number { $$ = scm_cons ($1, SCM_EOL); }
3214 | step_numbers '.' step_number {
3215 $$ = scm_cons ($3, $$);
3221 $$ = make_chord_step ($1, 0);
3224 $$ = make_chord_step ($1, SHARP_ALTERATION);
3226 | UNSIGNED CHORD_MINUS {
3227 $$ = make_chord_step ($1, FLAT_ALTERATION);
3235 | UNSIGNED '-' UNSIGNED {
3236 $$ = scm_cons ($1, $3);
3243 TODO: should deprecate in favor of Scheme?
3247 number_expression '+' number_term {
3248 $$ = scm_sum ($1, $3);
3250 | number_expression '-' number_term {
3251 $$ = scm_difference ($1, $3);
3260 | number_factor '*' number_factor {
3261 $$ = scm_product ($1, $3);
3263 | number_factor '/' number_factor {
3264 $$ = scm_divide ($1, $3);
3269 '-' number_factor { /* %prec UNARY_MINUS */
3270 $$ = scm_difference ($2, SCM_UNDEFINED);
3276 bare_number_common_closed
3277 | REAL NUMBER_IDENTIFIER
3279 $$ = scm_product ($1, $2);
3283 bare_number_common_closed:
3291 | UNSIGNED NUMBER_IDENTIFIER {
3292 $$ = scm_product ($1, $2);
3298 | bare_number_common_closed
3307 { $$ = SCM_UNDEFINED; }
3310 if (SCM_UNBNDP ($1))
3318 { $$ = SCM_UNDEFINED; }
3321 if (SCM_UNBNDP ($1))
3330 { parser->lexer_->push_markup_state (); }
3333 parser->lexer_->pop_state ();
3339 { parser->lexer_->push_markup_state (); }
3342 parser->lexer_->pop_state ();
3347 simple_markup_list {
3348 $$ = scm_list_2 (ly_lily_module_constant ("line-markup"), $1);
3350 | markup_head_1_list simple_markup
3352 $$ = scm_car (MAKE_SYNTAX ("composed-markup-list",
3353 @2, $1, scm_list_1 ($2)));
3363 if (Text_interface::is_markup ($1))
3364 MYBACKUP (MARKUP_IDENTIFIER, $1, @1);
3365 else if (Text_interface::is_markup_list ($1))
3366 MYBACKUP (MARKUPLIST_IDENTIFIER, $1, @1);
3368 parser->parser_error (@1, _ ("not a markup"));
3369 MYBACKUP (MARKUP_IDENTIFIER, scm_string (SCM_EOL), @1);
3376 markup_composed_list {
3379 | markup_uncomposed_list
3382 markup_uncomposed_list:
3383 markup_braced_list {
3386 | markup_command_list {
3387 $$ = scm_list_1 ($1);
3389 | markup_scm MARKUPLIST_IDENTIFIER
3399 $$ = scm_list_1 (scm_list_2 (ly_lily_module_constant ("score-lines-markup-list"), $1));
3405 SCM nn = parser->lexer_->lookup_identifier ("pitchnames");
3406 parser->lexer_->push_note_state (nn);
3407 } '{' score_body '}' {
3409 parser->lexer_->pop_state ();
3413 markup_composed_list:
3414 markup_head_1_list markup_uncomposed_list {
3415 $$ = MAKE_SYNTAX ("composed-markup-list",
3421 '{' markup_braced_list_body '}' {
3422 $$ = scm_reverse_x ($2, SCM_EOL);
3426 markup_braced_list_body:
3427 /* empty */ { $$ = SCM_EOL; }
3428 | markup_braced_list_body markup {
3429 $$ = scm_cons ($2, $1);
3431 | markup_braced_list_body simple_markup_list {
3432 $$ = scm_reverse_x ($2, $1);
3436 markup_command_list:
3437 MARKUP_LIST_FUNCTION markup_command_list_arguments {
3438 $$ = scm_cons ($1, scm_reverse_x($2, SCM_EOL));
3442 markup_command_basic_arguments:
3443 EXPECT_MARKUP_LIST markup_command_list_arguments markup_list {
3444 $$ = scm_cons ($3, $2);
3446 | EXPECT_SCM markup_command_list_arguments embedded_scm_closed {
3447 $$ = check_scheme_arg (parser, @3, $3, $2, $1);
3449 | EXPECT_NO_MORE_ARGS {
3454 markup_command_list_arguments:
3455 markup_command_basic_arguments { $$ = $1; }
3456 | EXPECT_MARKUP markup_command_list_arguments markup {
3457 $$ = scm_cons ($3, $2);
3462 MARKUP_FUNCTION EXPECT_MARKUP markup_command_list_arguments {
3463 $$ = scm_cons ($1, scm_reverse_x ($3, SCM_EOL));
3468 markup_head_1_item {
3469 $$ = scm_list_1 ($1);
3471 | markup_head_1_list markup_head_1_item {
3472 $$ = scm_cons ($2, $1);
3478 $$ = make_simple_markup ($1);
3480 | MARKUP_FUNCTION markup_command_basic_arguments {
3481 $$ = scm_cons ($1, scm_reverse_x ($2, SCM_EOL));
3483 | markup_scm MARKUP_IDENTIFIER
3489 $$ = scm_list_2 (ly_lily_module_constant ("score-markup"), $1);
3494 markup_head_1_list simple_markup
3496 $$ = scm_car (MAKE_SYNTAX ("composed-markup-list",
3497 @2, $1, scm_list_1 ($2)));
3507 Lily_parser::set_yydebug (bool x)
3513 Lily_parser::do_yyparse ()
3515 SCM retval = SCM_UNDEFINED;
3516 yyparse (this, &retval);
3526 It is a little strange to have this function in this file, but
3527 otherwise, we have to import music classes into the lexer.
3531 Lily_lexer::try_special_identifiers (SCM *destination, SCM sid)
3533 if (unsmob_book (sid)) {
3534 Book *book = unsmob_book (sid)->clone ();
3535 *destination = book->self_scm ();
3538 return BOOK_IDENTIFIER;
3539 } else if (scm_is_number (sid)) {
3541 return NUMBER_IDENTIFIER;
3542 } else if (unsmob_context_def (sid)) {
3543 Context_def *def= unsmob_context_def (sid)->clone ();
3545 *destination = def->self_scm ();
3548 return CONTEXT_DEF_IDENTIFIER;
3549 } else if (unsmob_context_mod (sid)) {
3550 *destination = unsmob_context_mod (sid)->smobbed_copy ();
3552 return CONTEXT_MOD_IDENTIFIER;
3553 } else if (Music *mus = unsmob_music (sid)) {
3554 mus = mus->clone ();
3555 *destination = mus->self_scm ();
3556 bool is_event = mus->is_mus_type ("post-event");
3558 return is_event ? EVENT_IDENTIFIER : MUSIC_IDENTIFIER;
3559 } else if (unsmob_pitch (sid)) {
3560 *destination = unsmob_pitch (sid)->smobbed_copy ();
3561 return PITCH_IDENTIFIER;
3562 } else if (unsmob_duration (sid)) {
3563 *destination = unsmob_duration (sid)->smobbed_copy ();
3564 return DURATION_IDENTIFIER;
3565 } else if (unsmob_output_def (sid)) {
3566 Output_def *p = unsmob_output_def (sid);
3569 *destination = p->self_scm ();
3571 return OUTPUT_DEF_IDENTIFIER;
3578 get_next_unique_context_id ()
3580 return scm_from_locale_string ("$uniqueContextId");
3585 get_next_unique_lyrics_context_id ()
3587 static int new_context_count;
3589 snprintf (s, sizeof (s)-1, "uniqueContext%d", new_context_count++);
3590 return scm_from_locale_string (s);
3593 // check_scheme_arg checks one argument with a given predicate for use
3594 // in an argument list and throws a syntax error if it is unusable.
3595 // The argument is prepended to the argument list in any case. After
3596 // throwing a syntax error, the argument list is terminated with #f as
3597 // its last cdr in order to mark it as uncallable while not losing
3598 // track of its total length.
3600 // There are a few special considerations: if optional argument disp
3601 // is given (otherwise it defaults to SCM_UNDEFINED), it will be used
3602 // instead of arg in a prospective error message. This is useful if
3603 // arg is not the actual argument but rather a transformation of it.
3605 // If arg itself is SCM_UNDEFINED, the predicate is considered false
3606 // and an error message using disp is produced unconditionally.
3608 SCM check_scheme_arg (Lily_parser *parser, Input loc,
3609 SCM arg, SCM args, SCM pred, SCM disp)
3611 if (SCM_UNBNDP (arg))
3612 args = scm_cons (disp, args);
3614 args = scm_cons (arg, args);
3615 if (scm_is_true (scm_call_1 (pred, arg)))
3618 scm_set_cdr_x (scm_last_pair (args), SCM_EOL);
3619 MAKE_SYNTAX ("argument-error", loc, scm_length (args), pred,
3620 SCM_UNBNDP (disp) ? arg : disp);
3621 scm_set_cdr_x (scm_last_pair (args), SCM_BOOL_F);
3625 SCM loc_on_music (Input loc, SCM arg)
3627 if (Music *m = unsmob_music (arg))
3631 return m->unprotect ();
3637 try_string_variants (SCM pred, SCM str)
3639 // a matching predicate is always ok
3640 if (scm_is_true (scm_call_1 (pred, str)))
3642 // a symbol may be interpreted as a list of symbols if it helps
3643 if (scm_is_symbol (str)) {
3644 str = scm_list_1 (str);
3645 if (scm_is_true (scm_call_1 (pred, str)))
3647 return SCM_UNDEFINED;
3650 // If this cannot be a string representation of a symbol list,
3653 if (!is_regular_identifier (str, true))
3654 return SCM_UNDEFINED;
3656 str = scm_string_split (str, SCM_MAKE_CHAR ('.'));
3657 for (SCM p = str; scm_is_pair (p); p = scm_cdr (p))
3658 scm_set_car_x (p, scm_string_to_symbol (scm_car (p)));
3660 // Let's attempt the symbol list interpretation first.
3662 if (scm_is_true (scm_call_1 (pred, str)))
3665 // If there is just one symbol in the list, we might interpret
3666 // it as a single symbol
3668 if (scm_is_null (scm_cdr (str)))
3670 str = scm_car (str);
3671 if (scm_is_true (scm_call_1 (pred, str)))
3675 return SCM_UNDEFINED;
3679 is_regular_identifier (SCM id, bool multiple)
3681 if (!scm_is_string (id))
3684 string str = ly_scm2string (id);
3686 bool middle = false;
3688 for (string::iterator it=str.begin(); it != str.end (); it++)
3691 if ((c >= 'a' && c <= 'z')
3692 || (c >= 'A' && c <= 'Z')
3695 else if (middle && (c == '-' || c == '_' || (multiple && c == '.')))
3704 make_music_from_simple (Lily_parser *parser, Input loc, SCM simple)
3706 if (unsmob_music (simple))
3708 if (parser->lexer_->is_note_state ()) {
3709 if (scm_is_symbol (simple)) {
3710 Music *n = MY_MAKE_MUSIC ("NoteEvent", loc);
3711 n->set_property ("duration", parser->default_duration_.smobbed_copy ());
3712 n->set_property ("drum-type", simple);
3713 return n->unprotect ();
3715 if (unsmob_pitch (simple)) {
3716 Music *n = MY_MAKE_MUSIC ("NoteEvent", loc);
3717 n->set_property ("duration", parser->default_duration_.smobbed_copy ());
3718 n->set_property ("pitch", simple);
3719 return n->unprotect ();
3722 } else if (parser->lexer_->is_lyric_state ()) {
3723 if (Text_interface::is_markup (simple))
3724 return MAKE_SYNTAX ("lyric-event", loc, simple,
3725 parser->default_duration_.smobbed_copy ());
3726 } else if (parser->lexer_->is_chord_state ()) {
3727 if (unsmob_pitch (simple))
3728 return make_chord_elements (loc, simple,
3729 parser->default_duration_.smobbed_copy (),
3736 make_music_with_input (SCM name, Input where)
3738 Music *m = make_music_by_name (name);
3739 m->set_spot (where);
3744 make_simple_markup (SCM a)
3750 make_duration (SCM d, int dots)
3752 int t = scm_to_int (d);
3753 if (t > 0 && (t & (t-1)) == 0)
3754 return Duration (intlog2 (t), dots).smobbed_copy ();
3756 return SCM_UNDEFINED;
3760 make_chord_step (SCM step_scm, Rational alter)
3762 int step = scm_to_int (step_scm);
3765 alter += FLAT_ALTERATION;
3769 Pitch m ((step -1) / 7, (step - 1) % 7, alter);
3770 return m.smobbed_copy ();
3775 make_chord_elements (Input loc, SCM pitch, SCM dur, SCM modification_list)
3777 SCM chord_ctor = ly_lily_module_constant ("construct-chord-elements");
3778 SCM res = scm_call_3 (chord_ctor, pitch, dur, modification_list);
3779 for (SCM s = res; scm_is_pair (s); s = scm_cdr (s))
3781 unsmob_music (scm_car (s))->set_spot (loc);
3787 yylex (YYSTYPE *s, YYLTYPE *loc, Lily_parser *parser)
3789 Lily_lexer *lex = parser->lexer_;
3793 lex->prepare_for_next_token ();
3794 return lex->yylex ();