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 E_UNSIGNED EVENT_IDENTIFIER EVENT_FUNCTION '^' '_'
84 HYPHEN EXTENDER DURATION_IDENTIFIER '!'
86 /* The above are needed for collecting tremoli and other items (that
87 could otherwise be interpreted as belonging to the next function
88 argument) greedily, and together with the next rule will serve to
89 join numbers and units greedily instead of allowing them into
90 separate function arguments
93 %nonassoc NUMBER_IDENTIFIER
105 %{ // -*-Fundamental-*-
110 * The rules for who is protecting what are very shady. Uniformise
113 * There are too many lexical modes?
124 #include "context-def.hh"
125 #include "context-mod.hh"
126 #include "dimensions.hh"
127 #include "file-path.hh"
129 #include "international.hh"
130 #include "lily-guile.hh"
131 #include "lily-lexer.hh"
132 #include "lily-parser.hh"
136 #include "output-def.hh"
137 #include "paper-book.hh"
138 #include "scm-hash.hh"
140 #include "text-interface.hh"
144 Lily_parser::parser_error (Input const *i, Lily_parser *parser, SCM *, const string &s)
146 parser->parser_error (*i, s);
149 // The following are somewhat precarious constructs as they may change
150 // the value of the lookahead token. That implies that the lookahead
151 // token must not yet have made an impact on the state stack other
152 // than causing the reduction of the current rule, or switching the
153 // lookahead token while Bison is mulling it over will cause trouble.
155 #define MYBACKUP(Token, Value, Location) \
157 if (yychar != YYEMPTY) \
158 parser->lexer_->push_extra_token \
159 (yylloc, yychar, yylval); \
161 parser->lexer_->push_extra_token \
162 (Location, Token, Value); \
163 parser->lexer_->push_extra_token (Location, BACKUP); \
168 #define MYREPARSE(Location, Pred, Token, Value) \
170 if (yychar != YYEMPTY) \
171 parser->lexer_->push_extra_token \
172 (yylloc, yychar, yylval); \
173 parser->lexer_->push_extra_token \
174 (Location, Token, Value); \
175 parser->lexer_->push_extra_token \
176 (Location, REPARSE, Pred); \
185 #define MY_MAKE_MUSIC(x, spot) \
186 make_music_with_input (ly_symbol2scm (x), \
187 parser->lexer_->override_input (spot))
190 - Don't use lily module, create a new module instead.
191 - delay application of the function
193 #define LOWLEVEL_MAKE_SYNTAX(proc, args) \
194 scm_apply_0 (proc, args)
195 /* Syntactic Sugar. */
196 #define MAKE_SYNTAX(name, location, ...) \
197 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))
198 #define START_MAKE_SYNTAX(name, ...) \
199 scm_list_n (ly_lily_module_constant (name) , ##__VA_ARGS__, SCM_UNDEFINED)
200 #define FINISH_MAKE_SYNTAX(start, location, ...) \
201 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)))))
203 SCM get_next_unique_context_id ();
204 SCM get_next_unique_lyrics_context_id ();
211 #define _(x) gettext (x)
215 static Music *make_music_with_input (SCM name, Input where);
216 SCM check_scheme_arg (Lily_parser *parser, Input loc,
217 SCM arg, SCM args, SCM pred, SCM disp = SCM_UNDEFINED);
218 SCM make_music_from_simple (Lily_parser *parser, Input loc, SCM pitch);
219 SCM loc_on_music (Input loc, SCM arg);
220 SCM make_chord_elements (Input loc, SCM pitch, SCM dur, SCM modification_list);
221 SCM make_chord_step (SCM step, Rational alter);
222 SCM make_simple_markup (SCM a);
223 SCM make_duration (SCM t, int dots = 0);
224 bool is_regular_identifier (SCM id, bool multiple=false);
225 SCM try_string_variants (SCM pred, SCM str);
226 int yylex (YYSTYPE *s, YYLTYPE *loc, Lily_parser *parser);
230 /* The third option is an alias that will be used to display the
231 syntax error. Bison CVS now correctly handles backslash escapes.
233 FIXME: Bison needs to translate some of these, eg, STRING.
237 /* Keyword tokens with plain escaped name. */
238 %token END_OF_FILE 0 "end of input"
239 %token ACCEPTS "\\accepts"
240 %token ADDLYRICS "\\addlyrics"
241 %token ALIAS "\\alias"
242 %token ALTERNATIVE "\\alternative"
244 %token BOOKPART "\\bookpart"
245 %token CHANGE "\\change"
246 %token CHORDMODE "\\chordmode"
247 %token CHORDS "\\chords"
248 %token CONSISTS "\\consists"
249 %token CONTEXT "\\context"
250 %token DEFAULT "\\default"
251 %token DEFAULTCHILD "\\defaultchild"
252 %token DENIES "\\denies"
253 %token DESCRIPTION "\\description"
254 %token DRUMMODE "\\drummode"
255 %token DRUMS "\\drums"
256 %token FIGUREMODE "\\figuremode"
257 %token FIGURES "\\figures"
258 %token HEADER "\\header"
259 %token INVALID "\\version-error"
260 %token LAYOUT "\\layout"
261 %token LYRICMODE "\\lyricmode"
262 %token LYRICS "\\lyrics"
263 %token LYRICSTO "\\lyricsto"
264 %token MARKUP "\\markup"
265 %token MARKUPLIST "\\markuplist"
268 %token NOTEMODE "\\notemode"
269 %token OVERRIDE "\\override"
270 %token PAPER "\\paper"
271 %token REMOVE "\\remove"
272 %token REPEAT "\\repeat"
274 %token REVERT "\\revert"
275 %token SCORE "\\score"
276 %token SCORELINES "\\score-lines"
277 %token SEQUENTIAL "\\sequential"
279 %token SIMULTANEOUS "\\simultaneous"
280 %token TEMPO "\\tempo"
282 %token UNSET "\\unset"
285 /* Keyword token exceptions. */
286 %token NEWCONTEXT "\\new"
289 /* Other string tokens. */
291 %token CHORD_BASS "/+"
292 %token CHORD_CARET "^"
293 %token CHORD_COLON ":"
294 %token CHORD_MINUS "-"
295 %token CHORD_SLASH "/"
296 %token ANGLE_OPEN "<"
297 %token ANGLE_CLOSE ">"
298 %token DOUBLE_ANGLE_OPEN "<<"
299 %token DOUBLE_ANGLE_CLOSE ">>"
300 %token E_BACKSLASH "\\"
301 %token E_EXCLAMATION "\\!"
306 If we give names, Bison complains.
308 %token FIGURE_CLOSE /* "\\>" */
309 %token FIGURE_OPEN /* "\\<" */
310 %token FIGURE_SPACE "_"
313 %token MULTI_MEASURE_REST
319 /* Artificial tokens, for more generic function syntax */
320 %token EXPECT_MARKUP "markup?"
321 %token EXPECT_SCM "scheme?"
322 %token BACKUP "(backed-up?)"
323 %token REPARSE "(reparsed?)"
324 %token EXPECT_MARKUP_LIST "markup-list?"
325 %token EXPECT_OPTIONAL "optional?"
326 /* After the last argument. */
327 %token EXPECT_NO_MORE_ARGS;
329 /* An artificial token for parsing embedded Lilypond */
330 %token EMBEDDED_LILY "#{"
332 %token BOOK_IDENTIFIER
333 %token CHORD_MODIFIER
334 %token CHORD_REPETITION
335 %token CONTEXT_DEF_IDENTIFIER
336 %token CONTEXT_MOD_IDENTIFIER
338 %token PITCH_IDENTIFIER
340 %token DURATION_IDENTIFIER
341 %token EVENT_IDENTIFIER
342 %token EVENT_FUNCTION
345 %token MARKUP_FUNCTION
346 %token MARKUP_LIST_FUNCTION
347 %token MARKUP_IDENTIFIER
348 %token MARKUPLIST_IDENTIFIER
349 %token MUSIC_FUNCTION
350 %token MUSIC_IDENTIFIER
351 %token NOTENAME_PITCH
352 %token NUMBER_IDENTIFIER
353 %token OUTPUT_DEF_IDENTIFIER
358 %token SCM_IDENTIFIER
362 %token TONICNAME_PITCH
366 /* We don't assign precedence to / and *, because we might need varied
367 prec levels in different prods */
376 SCM nn = parser->lexer_->lookup_identifier ("pitchnames");
377 parser->lexer_->push_note_state (nn);
378 } embedded_lilypond {
379 parser->lexer_->pop_state ();
384 lilypond: /* empty */ { $$ = SCM_UNSPECIFIED; }
385 | lilypond toplevel_expression {
387 | lilypond assignment {
390 parser->error_level_ = 1;
393 parser->error_level_ = 1;
400 parser->lexer_->add_scope (get_header (parser));
402 parser->lexer_->set_identifier (ly_symbol2scm ("$defaultheader"), $2);
405 SCM proc = parser->lexer_->lookup_identifier ("toplevel-book-handler");
406 scm_call_2 (proc, parser->self_scm (), $1);
409 SCM proc = parser->lexer_->lookup_identifier ("toplevel-bookpart-handler");
410 scm_call_2 (proc, parser->self_scm (), $1);
413 SCM proc = parser->lexer_->lookup_identifier
414 (unsmob_book($1)->paper_
415 ? "toplevel-book-handler"
416 : "toplevel-bookpart-handler");
417 scm_call_2 (proc, parser->self_scm (), $1);
420 SCM proc = parser->lexer_->lookup_identifier ("toplevel-score-handler");
421 scm_call_2 (proc, parser->self_scm (), $1);
424 SCM proc = parser->lexer_->lookup_identifier ("toplevel-music-handler");
425 scm_call_2 (proc, parser->self_scm (), $1);
428 SCM proc = parser->lexer_->lookup_identifier ("toplevel-text-handler");
429 scm_call_2 (proc, parser->self_scm (), scm_list_1 ($1));
432 SCM proc = parser->lexer_->lookup_identifier ("toplevel-text-handler");
433 scm_call_2 (proc, parser->self_scm (), $1);
436 // Evaluate and ignore #xxx, as opposed to \xxx
437 parser->lexer_->eval_scm_token ($1);
439 | embedded_scm_active
441 SCM out = SCM_UNDEFINED;
442 if (Text_interface::is_markup ($1))
443 out = scm_list_1 ($1);
444 else if (Text_interface::is_markup_list ($1))
446 if (scm_is_pair (out))
448 SCM proc = parser->lexer_->lookup_identifier ("toplevel-text-handler");
449 scm_call_2 (proc, parser->self_scm (), out);
450 } else if (unsmob_score ($1))
452 SCM proc = parser->lexer_->lookup_identifier ("toplevel-score-handler");
453 scm_call_2 (proc, parser->self_scm (), $1);
454 } else if (!scm_is_eq ($1, SCM_UNSPECIFIED))
455 parser->parser_error (@1, _("bad expression type"));
459 Output_def * od = unsmob_output_def ($1);
461 if (od->c_variable ("is-paper") == SCM_BOOL_T)
462 id = ly_symbol2scm ("$defaultpaper");
463 else if (od->c_variable ("is-midi") == SCM_BOOL_T)
464 id = ly_symbol2scm ("$defaultmidi");
465 else if (od->c_variable ("is-layout") == SCM_BOOL_T)
466 id = ly_symbol2scm ("$defaultlayout");
468 parser->lexer_->set_identifier (id, $1);
475 $$ = parser->lexer_->eval_scm_token ($1);
485 embedded_scm_bare_arg:
489 $$ = parser->lexer_->eval_scm_token ($1);
493 | context_modification
495 | context_def_spec_block
501 /* The generic version may end in music, or not */
508 /* embedded_scm_arg is _not_ casting pitches to music by default, this
509 * has to be done by the function itself. Note that this may cause
510 * the results of scm_function_call or embedded_scm_bare_arg to be
511 * turned into music from pitches as well. Note that this creates a
512 * distinctly awkward situation for calculated drum pitches. Those
513 * are at the current point of time rejected as music constituents as
514 * they can't be distinguished from "proper" symbols.
518 embedded_scm_bare_arg
524 SCM_FUNCTION function_arglist {
525 $$ = MAKE_SYNTAX ("music-function", @$,
530 embedded_lilypond_number:
531 '-' embedded_lilypond_number
533 $$ = scm_difference ($2, SCM_UNDEFINED);
536 | UNSIGNED NUMBER_IDENTIFIER
538 $$ = scm_product ($1, $2);
545 // FIXME: @$ does not contain a useful source location
546 // for empty rules, and the only token in the whole
547 // production, EMBEDDED_LILY, is synthetic and also
548 // contains no source location.
549 $$ = MAKE_SYNTAX ("void-music", @$);
551 | identifier_init_nonumber
552 | embedded_lilypond_number
553 | post_event post_events
555 $$ = scm_reverse_x ($2, SCM_EOL);
556 if (Music *m = unsmob_music ($1))
558 if (m->is_mus_type ("post-event-wrapper"))
560 (scm_list_2 (m->get_property ("elements"),
563 $$ = scm_cons ($1, $$);
566 && scm_is_null (scm_cdr ($$)))
570 Music * m = MY_MAKE_MUSIC ("PostEvents", @$);
571 m->set_property ("elements", $$);
572 $$ = m->unprotect ();
575 | multiplied_duration
576 | music_embedded music_embedded music_list {
577 $3 = scm_reverse_x ($3, SCM_EOL);
578 if (unsmob_music ($2))
579 $3 = scm_cons ($2, $3);
580 if (unsmob_music ($1))
581 $3 = scm_cons ($1, $3);
582 $$ = MAKE_SYNTAX ("sequential-music", @$, $3);
585 parser->error_level_ = 1;
586 $$ = SCM_UNSPECIFIED;
588 | INVALID embedded_lilypond {
589 parser->error_level_ = 1;
595 lilypond_header_body:
596 /* empty */ { $$ = SCM_UNSPECIFIED; }
597 | lilypond_header_body assignment {
600 | lilypond_header_body embedded_scm {
606 HEADER '{' lilypond_header_body '}' {
607 $$ = parser->lexer_->remove_scope ();
619 assignment_id '=' identifier_init {
620 parser->lexer_->set_identifier ($1, $3);
621 $$ = SCM_UNSPECIFIED;
623 | assignment_id property_path '=' identifier_init {
624 SCM path = scm_cons (scm_string_to_symbol ($1), $2);
625 parser->lexer_->set_identifier (path, $4);
626 $$ = SCM_UNSPECIFIED;
632 identifier_init_nonumber
634 | post_event_nofinger post_events
636 $$ = scm_reverse_x ($2, SCM_EOL);
637 if (Music *m = unsmob_music ($1))
639 if (m->is_mus_type ("post-event-wrapper"))
641 (scm_list_2 (m->get_property ("elements"),
644 $$ = scm_cons ($1, $$);
647 && scm_is_null (scm_cdr ($$)))
651 Music * m = MY_MAKE_MUSIC ("PostEvents", @$);
652 m->set_property ("elements", $$);
653 $$ = m->unprotect ();
658 identifier_init_nonumber:
663 | context_def_spec_block
669 | context_modification
672 context_def_spec_block:
673 CONTEXT '{' context_def_spec_body '}'
676 unsmob_context_def ($$)->origin ()->set_spot (@$);
684 SCM nn = parser->lexer_->lookup_identifier ("pitchnames");
685 parser->lexer_->push_note_state (nn);
689 parser->lexer_->pop_state ();
694 context_mod_embedded:
697 if (unsmob_music ($1)) {
698 SCM proc = parser->lexer_->lookup_identifier ("context-mod-music-handler");
699 $1 = scm_call_2 (proc, parser->self_scm (), $1);
701 if (unsmob_context_mod ($1))
704 parser->parser_error (@1, _ ("not a context mod"));
705 $$ = Context_mod ().smobbed_copy ();
711 context_def_spec_body:
713 $$ = Context_def::make_scm ();
715 | CONTEXT_DEF_IDENTIFIER {
718 | context_def_spec_body context_mod {
719 if (!SCM_UNBNDP ($2))
720 unsmob_context_def ($$)->add_context_mod ($2);
722 | context_def_spec_body context_modification {
723 Context_def *td = unsmob_context_def ($$);
724 SCM new_mods = unsmob_context_mod ($2)->get_mods ();
725 for (SCM m = new_mods; scm_is_pair (m); m = scm_cdr (m)) {
726 td->add_context_mod (scm_car (m));
729 | context_def_spec_body context_mod_embedded {
730 Context_def *td = unsmob_context_def ($$);
731 SCM new_mods = unsmob_context_mod ($2)->get_mods ();
732 for (SCM m = new_mods; scm_is_pair (m); m = scm_cdr (m)) {
733 td->add_context_mod (scm_car (m));
741 BOOK '{' book_body '}' {
743 unsmob_book ($$)->origin ()->set_spot (@$);
745 parser->lexer_->set_identifier (ly_symbol2scm ("$current-book"), SCM_BOOL_F);
750 * Use 'handlers' like for toplevel-* stuff?
751 * grok \layout and \midi? */
754 Book *book = new Book;
755 init_papers (parser);
756 book->paper_ = dynamic_cast<Output_def*> (unsmob_output_def (parser->lexer_->lookup_identifier ("$defaultpaper"))->clone ());
757 book->paper_->unprotect ();
758 push_paper (parser, book->paper_);
759 book->header_ = get_header (parser);
760 $$ = book->unprotect ();
761 parser->lexer_->set_identifier (ly_symbol2scm ("$current-book"), $$);
764 parser->lexer_->set_identifier (ly_symbol2scm ("$current-book"), $1);
766 | book_body paper_block {
767 unsmob_book ($1)->paper_ = unsmob_output_def ($2);
768 set_paper (parser, unsmob_output_def ($2));
770 | book_body bookpart_block {
771 SCM proc = parser->lexer_->lookup_identifier ("book-bookpart-handler");
772 scm_call_2 (proc, $1, $2);
774 | book_body score_block {
775 SCM proc = parser->lexer_->lookup_identifier ("book-score-handler");
776 scm_call_2 (proc, $1, $2);
778 | book_body composite_music {
779 SCM proc = parser->lexer_->lookup_identifier ("book-music-handler");
780 scm_call_3 (proc, parser->self_scm (), $1, $2);
782 | book_body full_markup {
783 SCM proc = parser->lexer_->lookup_identifier ("book-text-handler");
784 scm_call_2 (proc, $1, scm_list_1 ($2));
786 | book_body full_markup_list {
787 SCM proc = parser->lexer_->lookup_identifier ("book-text-handler");
788 scm_call_2 (proc, $1, $2);
790 | book_body SCM_TOKEN {
791 // Evaluate and ignore #xxx, as opposed to \xxx
792 parser->lexer_->eval_scm_token ($2);
794 | book_body embedded_scm_active
796 SCM out = SCM_UNDEFINED;
797 if (Text_interface::is_markup ($2))
798 out = scm_list_1 ($2);
799 else if (Text_interface::is_markup_list ($2))
801 if (scm_is_pair (out))
803 SCM proc = parser->lexer_->lookup_identifier ("book-text-handler");
804 scm_call_2 (proc, $1, out);
805 } else if (unsmob_score ($2))
807 SCM proc = parser->lexer_->lookup_identifier ("book-score-handler");
808 scm_call_2 (proc, $1, $2);
809 } else if (!scm_is_eq ($2, SCM_UNSPECIFIED))
810 parser->parser_error (@2, _("bad expression type"));
814 parser->lexer_->add_scope (unsmob_book ($1)->header_);
817 Book *book = unsmob_book ($1);
819 book->scores_ = SCM_EOL;
820 book->bookparts_ = SCM_EOL;
825 BOOKPART '{' bookpart_body '}' {
827 unsmob_book ($$)->origin ()->set_spot (@$);
828 parser->lexer_->set_identifier (ly_symbol2scm ("$current-bookpart"), SCM_BOOL_F);
834 Book *book = new Book;
835 $$ = book->unprotect ();
836 parser->lexer_->set_identifier (ly_symbol2scm ("$current-bookpart"), $$);
839 parser->lexer_->set_identifier (ly_symbol2scm ("$current-bookpart"), $1);
841 | bookpart_body paper_block {
842 unsmob_book ($$)->paper_ = unsmob_output_def ($2);
844 | bookpart_body score_block {
845 SCM proc = parser->lexer_->lookup_identifier ("bookpart-score-handler");
846 scm_call_2 (proc, $1, $2);
848 | bookpart_body composite_music {
849 SCM proc = parser->lexer_->lookup_identifier ("bookpart-music-handler");
850 scm_call_3 (proc, parser->self_scm (), $1, $2);
852 | bookpart_body full_markup {
853 SCM proc = parser->lexer_->lookup_identifier ("bookpart-text-handler");
854 scm_call_2 (proc, $1, scm_list_1 ($2));
856 | bookpart_body full_markup_list {
857 SCM proc = parser->lexer_->lookup_identifier ("bookpart-text-handler");
858 scm_call_2 (proc, $1, $2);
860 | bookpart_body SCM_TOKEN {
861 // Evaluate and ignore #xxx, as opposed to \xxx
862 parser->lexer_->eval_scm_token ($2);
864 | bookpart_body embedded_scm_active
866 SCM out = SCM_UNDEFINED;
867 if (Text_interface::is_markup ($2))
868 out = scm_list_1 ($2);
869 else if (Text_interface::is_markup_list ($2))
871 if (scm_is_pair (out))
873 SCM proc = parser->lexer_->lookup_identifier ("bookpart-text-handler");
874 scm_call_2 (proc, $1, out);
875 } else if (unsmob_score ($2))
877 SCM proc = parser->lexer_->lookup_identifier ("bookpart-score-handler");
878 scm_call_2 (proc, $1, $2);
879 } else if (!scm_is_eq ($2, SCM_UNSPECIFIED))
880 parser->parser_error (@2, _("bad expression type"));
884 Book *book = unsmob_book ($1);
885 if (!ly_is_module (book->header_))
886 book->header_ = ly_make_module (false);
887 parser->lexer_->add_scope (book->header_);
889 | bookpart_body error {
890 Book *book = unsmob_book ($1);
892 book->scores_ = SCM_EOL;
897 SCORE '{' score_body '}' {
898 unsmob_score ($3)->origin ()->set_spot (@$);
910 if (!scm_is_pair ($1)
911 || !ly_is_module (scm_car ($1)))
912 $1 = scm_cons (ly_make_module (false), $1);
913 parser->lexer_->add_scope (scm_car ($1));
918 | score_headers output_def
920 Output_def *od = unsmob_output_def ($2);
921 if (od->lookup_variable (ly_symbol2scm ("is-paper")) == SCM_BOOL_T)
923 parser->parser_error (@2, _("\\paper cannot be used in \\score, use \\layout instead"));
928 if (scm_is_pair ($1) && ly_is_module (scm_car ($1)))
929 scm_set_cdr_x ($1, scm_cons ($2, scm_cdr ($1)));
931 $$ = scm_cons ($2, $1);
939 score_headers music {
940 SCM scorify = ly_lily_module_constant ("scorify-music");
941 $$ = scm_call_2 (scorify, $2, parser->self_scm ());
943 if (scm_is_pair ($1) && ly_is_module (scm_car ($1)))
945 unsmob_score ($$)->set_header (scm_car ($1));
948 for (SCM p = scm_reverse_x ($1, SCM_EOL);
949 scm_is_pair (p); p = scm_cdr (p))
952 add_output_def (unsmob_output_def (scm_car (p)));
955 | embedded_scm_active {
956 if (!unsmob_score ($1))
958 $$ = (new Score)->unprotect ();
959 parser->parser_error (@1, _("score expected"));
964 Score *score = unsmob_score ($1);
965 if (!ly_is_module (score->get_header ()))
966 score->set_header (ly_make_module (false));
967 parser->lexer_->add_scope (score->get_header ());
969 | score_body output_def {
970 Output_def *od = unsmob_output_def ($2);
971 if (od->lookup_variable (ly_symbol2scm ("is-paper")) == SCM_BOOL_T)
973 parser->parser_error (@2, _("\\paper cannot be used in \\score, use \\layout instead"));
978 unsmob_score ($1)->add_output_def (od);
982 unsmob_score ($$)->error_found_ = true;
993 Output_def *od = unsmob_output_def ($1);
995 if (od->lookup_variable (ly_symbol2scm ("is-paper")) != SCM_BOOL_T)
997 parser->parser_error (@1, _ ("need \\paper for paper block"));
998 $$ = get_paper (parser)->unprotect ();
1005 output_def_body '}' {
1008 parser->lexer_->remove_scope ();
1009 parser->lexer_->pop_state ();
1015 Output_def *p = get_paper (parser);
1016 p->input_origin_ = @$;
1017 parser->lexer_->add_scope (p->scope_);
1018 $$ = p->unprotect ();
1021 Output_def *p = get_midi (parser);
1022 $$ = p->unprotect ();
1023 parser->lexer_->add_scope (p->scope_);
1026 Output_def *p = get_layout (parser);
1028 parser->lexer_->add_scope (p->scope_);
1029 $$ = p->unprotect ();
1033 output_def_head_with_mode_switch:
1035 parser->lexer_->push_initial_state ();
1040 // We need this weird nonterminal because both music as well as a
1041 // context definition can start with \context and the difference is
1042 // only apparent after looking at the next token. If it is '{', there
1043 // is still time to escape from notes mode.
1045 music_or_context_def:
1047 | context_def_spec_block
1051 output_def_head_with_mode_switch '{' {
1053 unsmob_output_def ($$)->input_origin_.set_spot (@$);
1055 | output_def_head_with_mode_switch '{' OUTPUT_DEF_IDENTIFIER {
1056 Output_def *o = unsmob_output_def ($3);
1057 o->input_origin_.set_spot (@$);
1058 $$ = o->self_scm ();
1059 parser->lexer_->remove_scope ();
1060 parser->lexer_->add_scope (o->scope_);
1062 | output_def_body assignment {
1065 | output_def_body embedded_scm {
1070 SCM nn = parser->lexer_->lookup_identifier ("pitchnames");
1071 parser->lexer_->push_note_state (nn);
1072 } music_or_context_def
1074 parser->lexer_->pop_state ();
1075 if (unsmob_context_def ($3))
1076 assign_context_def (unsmob_output_def ($1), $3);
1079 SCM proc = parser->lexer_->lookup_identifier
1080 ("output-def-music-handler");
1081 scm_call_3 (proc, parser->self_scm (),
1085 | output_def_body error {
1091 TEMPO steno_duration '=' tempo_range {
1092 $$ = MAKE_SYNTAX ("tempo", @$, SCM_EOL, $2, $4);
1094 | TEMPO scalar steno_duration '=' tempo_range {
1095 $$ = MAKE_SYNTAX ("tempo", @$, $2, $3, $5);
1098 $$ = MAKE_SYNTAX ("tempo", @$, $2);
1103 The representation of a list is reversed to have efficient append. */
1109 | music_list music_embedded {
1110 if (unsmob_music ($2))
1111 $$ = scm_cons ($2, $1);
1113 | music_list error {
1114 Music *m = MY_MAKE_MUSIC("Music", @$);
1116 m->set_property ("error-found", SCM_BOOL_T);
1117 $$ = scm_cons (m->self_scm (), $1);
1118 m->unprotect (); /* UGH */
1125 $$ = scm_reverse_x ($2, SCM_EOL);
1130 | lyric_element_music
1136 if (unsmob_music ($1)->is_mus_type ("post-event")) {
1137 parser->parser_error (@1, _ ("unexpected post-event"));
1138 $$ = SCM_UNSPECIFIED;
1141 | music_embedded_backup
1145 | music_embedded_backup BACKUP lyric_element_music
1149 | multiplied_duration post_events
1151 Music *n = MY_MAKE_MUSIC ("NoteEvent", @$);
1153 parser->default_duration_ = *unsmob_duration ($1);
1154 n->set_property ("duration", $1);
1156 if (scm_is_pair ($2))
1157 n->set_property ("articulations",
1158 scm_reverse_x ($2, SCM_EOL));
1159 $$ = n->unprotect ();
1163 music_embedded_backup:
1166 if (scm_is_eq ($1, SCM_UNSPECIFIED))
1168 else if (Music *m = unsmob_music ($1)) {
1169 if (m->is_mus_type ("post-event")) {
1170 parser->parser_error
1171 (@1, _ ("unexpected post-event"));
1172 $$ = SCM_UNSPECIFIED;
1175 } else if (parser->lexer_->is_lyric_state ()
1176 && Text_interface::is_markup ($1))
1177 MYBACKUP (LYRIC_ELEMENT, $1, @1);
1179 @$.warning (_ ("Ignoring non-music expression"));
1188 $$ = make_music_from_simple (parser, @1, $1);
1189 if (!unsmob_music ($$))
1191 parser->parser_error (@1, _ ("music expected"));
1192 $$ = MAKE_SYNTAX ("void-music", @$);
1195 | composite_music %prec COMPOSITE
1200 | composite_music %prec COMPOSITE
1204 REPEAT simple_string unsigned_number music
1206 $$ = MAKE_SYNTAX ("repeat", @$, $2, $3, $4, SCM_EOL);
1208 | REPEAT simple_string unsigned_number music ALTERNATIVE braced_music_list
1210 $$ = MAKE_SYNTAX ("repeat", @$, $2, $3, $4, $6);
1215 SEQUENTIAL braced_music_list {
1216 $$ = MAKE_SYNTAX ("sequential-music", @$, $2);
1218 | braced_music_list {
1219 $$ = MAKE_SYNTAX ("sequential-music", @$, $1);
1224 SIMULTANEOUS braced_music_list {
1225 $$ = MAKE_SYNTAX ("simultaneous-music", @$, $2);
1227 | DOUBLE_ANGLE_OPEN music_list DOUBLE_ANGLE_CLOSE {
1228 $$ = MAKE_SYNTAX ("simultaneous-music", @$, scm_reverse_x ($2, SCM_EOL));
1234 | music_property_def
1238 context_modification:
1241 SCM nn = parser->lexer_->lookup_identifier ("pitchnames");
1242 parser->lexer_->push_note_state (nn);
1243 } '{' context_mod_list '}'
1245 parser->lexer_->pop_state ();
1248 | WITH CONTEXT_MOD_IDENTIFIER
1252 | CONTEXT_MOD_IDENTIFIER
1256 | WITH context_modification_arg
1258 if (unsmob_music ($2)) {
1259 SCM proc = parser->lexer_->lookup_identifier ("context-mod-music-handler");
1260 $2 = scm_call_2 (proc, parser->self_scm (), $2);
1262 if (unsmob_context_mod ($2))
1265 parser->parser_error (@2, _ ("not a context mod"));
1266 $$ = Context_mod ().smobbed_copy ();
1271 context_modification_arg:
1276 optional_context_mod:
1280 | context_modification
1288 $$ = Context_mod ().smobbed_copy ();
1290 | context_mod_list context_mod {
1291 if (!SCM_UNBNDP ($2))
1292 unsmob_context_mod ($1)->add_context_mod ($2);
1294 | context_mod_list CONTEXT_MOD_IDENTIFIER {
1295 Context_mod *md = unsmob_context_mod ($2);
1297 unsmob_context_mod ($1)->add_context_mods (md->get_mods ());
1299 | context_mod_list context_mod_embedded {
1300 unsmob_context_mod ($1)->add_context_mods
1301 (unsmob_context_mod ($2)->get_mods ());
1313 | grouped_music_list
1317 simultaneous_music { $$ = $1; }
1318 | sequential_music { $$ = $1; }
1321 /* Function argument lists are arguably the most complex part in the
1322 * parser. They are pretty tricky to understand because of the way
1323 * they are processed, and because of optional arguments that can be
1324 * omitted. When there are several optional arguments in a row,
1325 * omitting one automatically omits all following arguments. Optional
1326 * arguments can only be omitted when either
1328 * a) the omission is explicitly started with \default
1329 * b) the omission is implicitly started by an argument not matching
1330 * its predicate, and there is a mandatory argument later that can
1331 * "catch" the argument that does not fit.
1333 * When argument parsing starts, the lexer pushes EXPECT_SCM tokens
1334 * (corresponding to mandatory arguments and having a predicate
1335 * function as semantic value) or EXPECT_OPTIONAL EXPECT_SCM (where
1336 * the semantic value of the EXPECT_OPTIONAL token is the default to
1337 * use when the optional argument is omitted, and EXPECT_SCM again has
1338 * the argument predicate as semantic value) in reverse order to the
1339 * parser, followed by EXPECT_NO_MORE_ARGS. The argument list is then
1340 * processed inside-out while actual tokens are consumed.
1342 * This means that the argument list tokens determine the actions
1343 * taken as they arrive. The structure of the argument list is known
1344 * to the parser and stored in its parse stack when the first argument
1345 * is being parsed. What the parser does not know is which predicates
1346 * will match and whether or not \default will be appearing in the
1347 * argument list, and where.
1349 * Sequences of 0 or more optional arguments are scanned using either
1350 * function_arglist_backup or function_arglist_nonbackup. The first
1351 * is used when optional arguments are followed by at least one
1352 * mandatory argument: in that case optional arguments may be skipped
1353 * by either a false predicate (in which case the expression will be
1354 * pushed back as one or more tokens, preceded by a BACKUP token) or
1355 * by using \default.
1357 * If optional arguments are at the end of the argument list, they are
1358 * instead scanned using function_arglist_nonbackup: here the only
1359 * manner to enter into skipping of optional arguments is the use of
1362 * The argument list of a normal function call is parsed using
1363 * function_arglist. The part of an argument list before a mandatory
1364 * argument is parsed using function_arglist_optional.
1366 * The difference is that leading optional arguments are scanned using
1367 * function_arglist_nonbackup and function_arglist_backup,
1370 * Most other details are obvious in the rules themselves.
1374 function_arglist_nonbackup_common:
1375 EXPECT_OPTIONAL EXPECT_SCM function_arglist_nonbackup post_event_nofinger
1377 $$ = check_scheme_arg (parser, @4, $4, $3, $2);
1379 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_nonbackup '-' UNSIGNED
1381 SCM n = scm_difference ($5, SCM_UNDEFINED);
1382 if (scm_is_true (scm_call_1 ($2, n)))
1383 $$ = scm_cons (n, $3);
1385 Music *t = MY_MAKE_MUSIC ("FingeringEvent", @5);
1386 t->set_property ("digit", $5);
1387 $$ = check_scheme_arg (parser, @4, t->unprotect (),
1392 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_nonbackup '-' REAL
1394 $$ = check_scheme_arg (parser, @4,
1395 scm_difference ($5, SCM_UNDEFINED),
1398 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_nonbackup '-' NUMBER_IDENTIFIER
1400 $$ = check_scheme_arg (parser, @4,
1401 scm_difference ($5, SCM_UNDEFINED),
1408 | SYMBOL_LIST '.' symbol_list_rev
1410 $$ = scm_append (scm_list_2 ($1, scm_reverse_x ($3, SCM_EOL)));
1416 | symbol_list_rev '.' symbol_list_part
1418 $$ = scm_append_x (scm_list_2 ($3, $1));
1422 // symbol_list_part delivers elements in reverse copy.
1427 SCM sym_l_p = ly_lily_module_constant ("symbol-list?");
1428 $$ = try_string_variants (sym_l_p, $1);
1429 if (SCM_UNBNDP ($$)) {
1430 parser->parser_error (@1, _("not a symbol"));
1433 $$ = scm_reverse ($$);
1438 symbol_list_element:
1444 function_arglist_nonbackup:
1445 function_arglist_nonbackup_common
1446 | function_arglist_common
1447 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_nonbackup embedded_scm_arg
1449 if (scm_is_true (scm_call_1 ($2, $4)))
1450 $$ = scm_cons ($4, $3);
1452 $$ = check_scheme_arg (parser, @4,
1453 make_music_from_simple
1457 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_nonbackup bare_number_common
1459 $$ = check_scheme_arg (parser, @4, $4, $3, $2);
1461 | function_arglist_nonbackup_reparse REPARSE duration_length
1463 $$ = check_scheme_arg (parser, @3, $3, $1, $2);
1465 | function_arglist_nonbackup_reparse REPARSE bare_number_common
1467 $$ = check_scheme_arg (parser, @3, $3, $1, $2);
1469 | function_arglist_nonbackup_reparse REPARSE SCM_ARG
1471 $$ = check_scheme_arg (parser, @3, $3, $1, $2);
1473 | function_arglist_nonbackup_reparse REPARSE lyric_element_music
1475 $$ = check_scheme_arg (parser, @3, $3, $1, $2);
1477 | function_arglist_nonbackup_reparse REPARSE symbol_list_arg
1479 $$ = check_scheme_arg (parser, @3, $3, $1, $2);
1483 function_arglist_nonbackup_reparse:
1484 EXPECT_OPTIONAL EXPECT_SCM function_arglist_nonbackup SCM_IDENTIFIER
1487 SCM res = try_string_variants ($2, $4);
1488 if (!SCM_UNBNDP (res))
1489 if (scm_is_pair (res))
1490 MYREPARSE (@4, $2, SYMBOL_LIST, res);
1492 MYREPARSE (@4, $2, SCM_ARG, res);
1493 else if (scm_is_true
1495 ($2, make_music_from_simple
1497 MYREPARSE (@4, $2, STRING, $4);
1499 MYREPARSE (@4, $2, SCM_ARG, $4);
1501 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_nonbackup STRING
1504 SCM res = try_string_variants ($2, $4);
1505 if (!SCM_UNBNDP (res))
1506 if (scm_is_pair (res))
1507 MYREPARSE (@4, $2, SYMBOL_LIST, res);
1509 MYREPARSE (@4, $2, SCM_ARG, res);
1510 else if (scm_is_true
1512 ($2, make_music_from_simple
1514 MYREPARSE (@4, $2, STRING, $4);
1516 MYREPARSE (@4, $2, SCM_ARG, $4);
1518 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_nonbackup full_markup
1521 if (scm_is_true (scm_call_1 ($2, $4)))
1522 MYREPARSE (@4, $2, SCM_ARG, $4);
1523 else if (scm_is_true
1525 ($2, make_music_from_simple
1527 MYREPARSE (@4, $2, STRING, $4);
1529 MYREPARSE (@4, $2, SCM_ARG, $4);
1531 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_nonbackup UNSIGNED
1534 if (scm_is_true (scm_call_1 ($2, $4)))
1535 MYREPARSE (@4, $2, REAL, $4);
1537 SCM d = make_duration ($4);
1538 if (SCM_UNBNDP (d) || scm_is_false (scm_call_1 ($2, d)))
1539 MYREPARSE (@4, $2, REAL, $4); // trigger error
1541 MYREPARSE (@4, $2, DURATION_IDENTIFIER, d);
1544 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_nonbackup DURATION_IDENTIFIER {
1546 MYREPARSE (@4, $2, DURATION_IDENTIFIER, $4);
1551 // function_arglist_backup can't occur at the end of an argument
1553 function_arglist_backup:
1554 function_arglist_common
1555 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_backup embedded_scm_arg
1557 if (scm_is_true (scm_call_1 ($2, $4)))
1558 $$ = scm_cons ($4, $3);
1560 $$ = make_music_from_simple (parser, @4, $4);
1561 if (scm_is_true (scm_call_1 ($2, $$)))
1562 $$ = scm_cons ($$, $3);
1565 $$ = scm_cons (loc_on_music (@3, $1), $3);
1566 MYBACKUP (SCM_ARG, $4, @4);
1570 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_backup post_event_nofinger
1572 if (scm_is_true (scm_call_1 ($2, $4)))
1574 $$ = scm_cons ($4, $3);
1576 $$ = scm_cons (loc_on_music (@3, $1), $3);
1577 MYBACKUP (EVENT_IDENTIFIER, $4, @4);
1580 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_backup full_markup
1582 if (scm_is_true (scm_call_1 ($2, $4)))
1583 $$ = scm_cons ($4, $3);
1585 $$ = scm_cons (loc_on_music (@3, $1), $3);
1586 MYBACKUP (LYRIC_ELEMENT, $4, @4);
1589 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_backup UNSIGNED
1591 if (scm_is_true (scm_call_1 ($2, $4)))
1593 MYREPARSE (@4, $2, REAL, $4);
1596 SCM d = make_duration ($4);
1597 if (SCM_UNBNDP (d) || scm_is_false (scm_call_1 ($2, d)))
1599 $$ = scm_cons (loc_on_music (@3, $1), $3);
1600 MYBACKUP (UNSIGNED, $4, @4);
1602 MYREPARSE (@4, $2, DURATION_IDENTIFIER, d);
1607 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_backup REAL
1609 if (scm_is_true (scm_call_1 ($2, $4)))
1612 MYREPARSE (@4, $2, REAL, $4);
1614 $$ = scm_cons (loc_on_music (@3, $1), $3);
1615 MYBACKUP (REAL, $4, @4);
1618 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_backup NUMBER_IDENTIFIER
1620 if (scm_is_true (scm_call_1 ($2, $4)))
1622 $$ = scm_cons ($4, $3);
1624 $$ = scm_cons (loc_on_music (@3, $1), $3);
1625 MYBACKUP (NUMBER_IDENTIFIER, $4, @4);
1628 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_backup '-' UNSIGNED
1630 SCM n = scm_difference ($5, SCM_UNDEFINED);
1631 if (scm_is_true (scm_call_1 ($2, n))) {
1633 MYREPARSE (@5, $2, REAL, n);
1635 Music *t = MY_MAKE_MUSIC ("FingeringEvent", @5);
1636 t->set_property ("digit", $5);
1637 $$ = t->unprotect ();
1638 if (scm_is_true (scm_call_1 ($2, $$)))
1639 $$ = scm_cons ($$, $3);
1641 $$ = scm_cons (loc_on_music (@3, $1), $3);
1642 MYBACKUP (UNSIGNED, $5, @5);
1643 parser->lexer_->push_extra_token (@4, '-');
1648 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_backup '-' REAL
1650 SCM n = scm_difference ($5, SCM_UNDEFINED);
1651 if (scm_is_true (scm_call_1 ($2, n))) {
1652 MYREPARSE (@5, $2, REAL, n);
1655 $$ = scm_cons (loc_on_music (@3, $1), $3);
1656 MYBACKUP (REAL, n, @5);
1659 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_backup '-' NUMBER_IDENTIFIER
1661 SCM n = scm_difference ($5, SCM_UNDEFINED);
1662 if (scm_is_true (scm_call_1 ($2, n))) {
1663 $$ = scm_cons (n, $3);
1665 $$ = scm_cons (loc_on_music (@3, $1), $3);
1666 MYBACKUP (NUMBER_IDENTIFIER, n, @5);
1669 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_backup DURATION_IDENTIFIER
1671 if (scm_is_true (scm_call_1 ($2, $4)))
1673 MYREPARSE (@4, $2, DURATION_IDENTIFIER, $4);
1676 $$ = scm_cons (loc_on_music (@3, $1), $3);
1677 MYBACKUP (DURATION_IDENTIFIER, $4, @4);
1680 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_backup SCM_IDENTIFIER
1682 SCM res = try_string_variants ($2, $4);
1683 if (!SCM_UNBNDP (res))
1684 if (scm_is_pair (res)) {
1686 MYREPARSE (@4, $2, SYMBOL_LIST, res);
1689 $$ = scm_cons (res, $3);
1691 $$ = scm_cons (loc_on_music (@3, $1), $3);
1692 MYBACKUP (SCM_IDENTIFIER, $4, @4);
1695 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_backup STRING
1697 SCM res = try_string_variants ($2, $4);
1698 if (!SCM_UNBNDP (res))
1699 if (scm_is_pair (res)) {
1701 MYREPARSE (@4, $2, SYMBOL_LIST, res);
1704 $$ = scm_cons (res, $3);
1706 $$ = scm_cons (loc_on_music (@3, $1), $3);
1707 MYBACKUP (STRING, $4, @4);
1710 | function_arglist_backup REPARSE music_assign
1712 if (scm_is_true (scm_call_1 ($2, $3)))
1713 $$ = scm_cons ($3, $1);
1715 $$ = check_scheme_arg (parser, @3,
1716 make_music_from_simple
1720 | function_arglist_backup REPARSE pitch_arg
1722 $$ = check_scheme_arg (parser, @3,
1725 | function_arglist_backup REPARSE bare_number_common
1727 $$ = check_scheme_arg (parser, @3,
1730 | function_arglist_backup REPARSE duration_length
1732 $$ = check_scheme_arg (parser, @3,
1735 | function_arglist_backup REPARSE symbol_list_arg
1737 $$ = check_scheme_arg (parser, @3, $3, $1, $2);
1742 function_arglist_nonbackup
1743 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_skip_nonbackup DEFAULT
1745 $$ = scm_cons (loc_on_music (@4, $1), $3);
1749 function_arglist_skip_nonbackup:
1750 function_arglist_nonbackup
1751 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_skip_nonbackup
1753 $$ = scm_cons (loc_on_music (@3, $1), $3);
1757 function_arglist_common:
1758 EXPECT_NO_MORE_ARGS {
1761 | EXPECT_SCM function_arglist_optional embedded_scm_arg
1763 if (scm_is_true (scm_call_1 ($1, $3)))
1764 $$ = scm_cons ($3, $2);
1766 $$ = check_scheme_arg (parser, @3,
1767 make_music_from_simple
1771 | EXPECT_SCM function_arglist_optional bare_number_common
1773 $$ = check_scheme_arg (parser, @3,
1776 | EXPECT_SCM function_arglist_optional post_event_nofinger
1778 $$ = check_scheme_arg (parser, @3,
1781 | EXPECT_SCM function_arglist_optional '-' NUMBER_IDENTIFIER
1783 SCM n = scm_difference ($4, SCM_UNDEFINED);
1784 $$ = check_scheme_arg (parser, @4, n, $2, $1);
1786 | function_arglist_common_reparse REPARSE SCM_ARG
1788 $$ = check_scheme_arg (parser, @3,
1791 | function_arglist_common_reparse REPARSE lyric_element_music
1793 $$ = check_scheme_arg (parser, @3,
1796 | function_arglist_common_reparse REPARSE bare_number_common
1798 $$ = check_scheme_arg (parser, @3,
1801 | function_arglist_common_reparse REPARSE duration_length
1803 $$ = check_scheme_arg (parser, @3,
1806 | function_arglist_common_reparse REPARSE symbol_list_arg
1808 $$ = check_scheme_arg (parser, @3, $3, $1, $2);
1812 function_arglist_common_reparse:
1813 EXPECT_SCM function_arglist_optional SCM_IDENTIFIER
1816 SCM res = try_string_variants ($1, $3);
1817 if (!SCM_UNBNDP (res))
1818 if (scm_is_pair (res))
1819 MYREPARSE (@3, $1, SYMBOL_LIST, res);
1821 MYREPARSE (@3, $1, SCM_ARG, res);
1822 else if (scm_is_true
1824 ($1, make_music_from_simple (parser, @3, $3))))
1825 MYREPARSE (@3, $1, LYRIC_ELEMENT, $3);
1827 // This is going to flag a syntax error, we
1828 // know the predicate to be false.
1829 MYREPARSE (@3, $1, SCM_ARG, $3);
1831 | EXPECT_SCM function_arglist_optional STRING
1834 SCM res = try_string_variants ($1, $3);
1835 if (!SCM_UNBNDP (res))
1836 if (scm_is_pair (res))
1837 MYREPARSE (@3, $1, SYMBOL_LIST, res);
1839 MYREPARSE (@3, $1, SCM_ARG, res);
1840 else if (scm_is_true
1842 ($1, make_music_from_simple (parser, @3, $3))))
1843 MYREPARSE (@3, $1, LYRIC_ELEMENT, $3);
1845 // This is going to flag a syntax error, we
1846 // know the predicate to be false.
1847 MYREPARSE (@3, $1, SCM_ARG, $3);
1849 | EXPECT_SCM function_arglist_optional full_markup
1852 if (scm_is_true (scm_call_1 ($1, $3)))
1853 MYREPARSE (@3, $1, SCM_ARG, $3);
1854 else if (scm_is_true
1856 ($1, make_music_from_simple (parser, @3, $3))))
1857 MYREPARSE (@3, $1, LYRIC_ELEMENT, $3);
1859 // This is going to flag a syntax error, we
1860 // know the predicate to be false.
1861 MYREPARSE (@3, $1, SCM_ARG, $3);
1863 | EXPECT_SCM function_arglist_optional UNSIGNED
1866 if (scm_is_true (scm_call_1 ($1, $3)))
1867 MYREPARSE (@3, $1, REAL, $3);
1869 SCM d = make_duration ($3);
1870 if (SCM_UNBNDP (d) || scm_is_false (scm_call_1 ($1, d)))
1871 MYREPARSE (@3, $1, REAL, $3);
1873 MYREPARSE (@3, $1, DURATION_IDENTIFIER, d);
1876 | EXPECT_SCM function_arglist_optional DURATION_IDENTIFIER
1879 MYREPARSE (@3, $1, DURATION_IDENTIFIER, $3);
1881 | EXPECT_SCM function_arglist_optional '-' UNSIGNED
1884 SCM n = scm_difference ($4, SCM_UNDEFINED);
1885 if (scm_is_true (scm_call_1 ($1, n)))
1886 MYREPARSE (@4, $1, REAL, n);
1888 Music *t = MY_MAKE_MUSIC ("FingeringEvent", @4);
1889 t->set_property ("digit", $4);
1890 SCM m = t->unprotect ();
1891 if (scm_is_true (scm_call_1 ($1, m)))
1892 MYREPARSE (@4, $1, SCM_ARG, m);
1894 MYREPARSE (@4, $1, SCM_ARG, $4);
1898 | EXPECT_SCM function_arglist_optional '-' REAL
1901 SCM n = scm_difference ($4, SCM_UNDEFINED);
1902 MYREPARSE (@4, $1, REAL, n);
1906 function_arglist_optional:
1907 function_arglist_backup
1908 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_skip_backup DEFAULT
1910 $$ = scm_cons (loc_on_music (@4, $1), $3);
1912 | function_arglist_skip_backup BACKUP
1915 function_arglist_skip_backup:
1916 function_arglist_backup
1917 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_skip_backup
1919 $$ = scm_cons (loc_on_music (@3, $1), $3);
1923 music_function_call:
1924 MUSIC_FUNCTION function_arglist {
1925 $$ = MAKE_SYNTAX ("music-function", @$,
1932 /**/ { $$ = SCM_EOL; }
1933 | '=' simple_string {
1940 | repeated_music { $$ = $1; }
1941 | re_rhythmed_music { $$ = $1; }
1942 | complex_music_prefix music
1944 $$ = FINISH_MAKE_SYNTAX ($1, @$, $2);
1948 complex_music_prefix:
1949 CONTEXT symbol optional_id optional_context_mod {
1950 Context_mod *ctxmod = unsmob_context_mod ($4);
1953 mods = ctxmod->get_mods ();
1954 $$ = START_MAKE_SYNTAX ("context-specification", $2, $3, mods, SCM_BOOL_F);
1956 | NEWCONTEXT symbol optional_id optional_context_mod {
1957 Context_mod *ctxmod = unsmob_context_mod ($4);
1960 mods = ctxmod->get_mods ();
1961 $$ = START_MAKE_SYNTAX ("context-specification", $2, $3, mods, SCM_BOOL_T);
1966 mode_changing_head grouped_music_list {
1967 if ($1 == ly_symbol2scm ("chords"))
1969 $$ = MAKE_SYNTAX ("unrelativable-music", @$, $2);
1975 parser->lexer_->pop_state ();
1977 | mode_changing_head_with_context optional_context_mod grouped_music_list {
1978 Context_mod *ctxmod = unsmob_context_mod ($2);
1981 mods = ctxmod->get_mods ();
1982 $$ = MAKE_SYNTAX ("context-specification", @$, $1, SCM_EOL, mods, SCM_BOOL_T, $3);
1983 if ($1 == ly_symbol2scm ("ChordNames"))
1985 $$ = MAKE_SYNTAX ("unrelativable-music", @$, $$);
1987 parser->lexer_->pop_state ();
1993 SCM nn = parser->lexer_->lookup_identifier ("pitchnames");
1994 parser->lexer_->push_note_state (nn);
1996 $$ = ly_symbol2scm ("notes");
2000 SCM nn = parser->lexer_->lookup_identifier ("drumPitchNames");
2001 parser->lexer_->push_note_state (nn);
2003 $$ = ly_symbol2scm ("drums");
2006 parser->lexer_->push_figuredbass_state ();
2008 $$ = ly_symbol2scm ("figures");
2011 SCM nn = parser->lexer_->lookup_identifier ("chordmodifiers");
2012 parser->lexer_->chordmodifier_tab_ = alist_to_hashq (nn);
2013 nn = parser->lexer_->lookup_identifier ("pitchnames");
2014 parser->lexer_->push_chord_state (nn);
2015 $$ = ly_symbol2scm ("chords");
2019 { parser->lexer_->push_lyric_state ();
2020 $$ = ly_symbol2scm ("lyrics");
2024 mode_changing_head_with_context:
2026 SCM nn = parser->lexer_->lookup_identifier ("drumPitchNames");
2027 parser->lexer_->push_note_state (nn);
2029 $$ = ly_symbol2scm ("DrumStaff");
2032 parser->lexer_->push_figuredbass_state ();
2034 $$ = ly_symbol2scm ("FiguredBass");
2037 SCM nn = parser->lexer_->lookup_identifier ("chordmodifiers");
2038 parser->lexer_->chordmodifier_tab_ = alist_to_hashq (nn);
2039 nn = parser->lexer_->lookup_identifier ("pitchnames");
2040 parser->lexer_->push_chord_state (nn);
2041 $$ = ly_symbol2scm ("ChordNames");
2044 { parser->lexer_->push_lyric_state ();
2045 $$ = ly_symbol2scm ("Lyrics");
2050 ADDLYRICS { parser->lexer_->push_lyric_state (); }
2053 /* Can also use music at the expensive of two S/Rs similar to
2054 \repeat \alternative */
2055 parser->lexer_->pop_state ();
2057 $$ = scm_cons ($3, SCM_EOL);
2059 | new_lyrics ADDLYRICS {
2060 parser->lexer_->push_lyric_state ();
2062 parser->lexer_->pop_state ();
2063 $$ = scm_cons ($4, $1);
2068 composite_music new_lyrics {
2069 $$ = MAKE_SYNTAX ("add-lyrics", @$, $1, scm_reverse_x ($2, SCM_EOL));
2071 | LYRICSTO simple_string {
2072 parser->lexer_->push_lyric_state ();
2074 parser->lexer_->pop_state ();
2075 $$ = MAKE_SYNTAX ("lyric-combine", @$, $2, $4);
2080 CHANGE symbol '=' simple_string {
2081 $$ = MAKE_SYNTAX ("context-change", @$, $2, $4);
2088 $$ = scm_reverse_x ($1, SCM_EOL);
2090 | symbol_list_rev property_path {
2091 $$ = scm_reverse_x ($1, $2);
2097 $$ = scm_list_3 (ly_symbol2scm ("assign"), $1, $3);
2100 $$ = scm_list_2 (ly_symbol2scm ("unset"), $2);
2102 | OVERRIDE property_path '=' scalar {
2103 if (scm_ilength ($2) < 2) {
2104 parser->parser_error (@2, _("bad grob property path"));
2107 $$ = scm_cons (ly_symbol2scm ("push"),
2108 scm_cons2 (scm_car ($2),
2113 | REVERT revert_arg {
2114 $$ = scm_cons (ly_symbol2scm ("pop"), $2);
2118 // This is all quite awkward for the sake of substantial backward
2119 // compatibility while at the same time allowing a more "natural" form
2120 // of specification not separating grob specification from grob
2121 // property path. The purpose of this definition of revert_arg is to
2122 // allow the symbol list which specifies grob and property to revert
2123 // to be optionally be split into two parts after the grob (which in
2124 // this case is just the first element of the list). symbol_list_part
2125 // is only one path component, but it can be parsed without lookahead,
2126 // so we can follow it with a synthetic BACKUP token when needed. If
2127 // the first symbol_list_part already contains multiple elements (only
2128 // possible if a Scheme expression provides them), we just parse for
2129 // additional elements introduced by '.', which is what the
2130 // SYMBOL_LIST backup in connection with the immediately following
2131 // rule using symbol_list_arg does.
2133 // As long as we don't have our coffers filled with both grob and at
2134 // least one grob property specification, the rest of the required
2135 // symbol list chain may be provided either with or without a leading
2136 // dot. This is for both allowing the traditional
2137 // \revert Accidental #'color
2138 // as well as well as the "naive" form
2139 // \revert Accidental.color
2142 revert_arg_backup BACKUP symbol_list_arg
2151 if (scm_is_null ($1)
2152 || scm_is_null (scm_cdr ($1)))
2153 MYBACKUP (SCM_ARG, $1, @1);
2155 MYBACKUP (SYMBOL_LIST, scm_reverse_x ($1, SCM_EOL), @1);
2159 // revert_arg_part delivers results in reverse
2162 | revert_arg_backup BACKUP SCM_ARG '.' symbol_list_part
2164 $$ = scm_append_x (scm_list_2 ($5, $3));
2166 | revert_arg_backup BACKUP SCM_ARG symbol_list_part
2168 $$ = scm_append_x (scm_list_2 ($4, $3));
2173 CONSISTS { $$ = ly_symbol2scm ("consists"); }
2174 | REMOVE { $$ = ly_symbol2scm ("remove"); }
2176 | ACCEPTS { $$ = ly_symbol2scm ("accepts"); }
2177 | DEFAULTCHILD { $$ = ly_symbol2scm ("default-child"); }
2178 | DENIES { $$ = ly_symbol2scm ("denies"); }
2180 | ALIAS { $$ = ly_symbol2scm ("alias"); }
2181 | TYPE { $$ = ly_symbol2scm ("translator-type"); }
2182 | DESCRIPTION { $$ = ly_symbol2scm ("description"); }
2183 | NAME { $$ = ly_symbol2scm ("context-name"); }
2187 property_operation { $$ = $1; }
2188 | context_def_mod STRING {
2189 $$ = scm_list_2 ($1, $2);
2191 | context_def_mod embedded_scm
2193 if (!scm_is_string ($2)
2194 && ly_symbol2scm ("consists") != $1
2195 && ly_symbol2scm ("remove") != $1)
2198 parser->parser_error (@1, _ ("only \\consists and \\remove take non-string argument."));
2202 $$ = scm_list_2 ($1, $2);
2207 // If defined, at least two members.
2211 SCM l = scm_reverse_x ($1, SCM_EOL);
2214 (scm_object_property (scm_car (l),
2215 ly_symbol2scm ("is-grob?"))))
2216 l = scm_cons (ly_symbol2scm ("Bottom"), l);
2217 if (scm_is_null (l) || scm_is_null (scm_cdr (l))) {
2218 parser->parser_error (@1, _ ("bad grob property path"));
2225 // If defined, at least three members
2229 if (!SCM_UNBNDP ($1) && scm_is_null (scm_cddr ($1)))
2231 parser->parser_error (@1, _ ("bad grob property path"));
2235 | grob_prop_spec property_path
2237 if (!SCM_UNBNDP ($1)) {
2238 $$ = scm_append_x (scm_list_2 ($1, $2));
2239 if (scm_is_null (scm_cddr ($$))) {
2240 parser->parser_error (@$, _ ("bad grob property path"));
2248 // Exactly two elements or undefined
2252 SCM l = scm_reverse_x ($1, SCM_EOL);
2253 switch (scm_ilength (l)) {
2255 l = scm_cons (ly_symbol2scm ("Bottom"), l);
2259 parser->parser_error (@1, _ ("bad context property path"));
2266 simple_music_property_def:
2267 OVERRIDE grob_prop_path '=' scalar {
2268 if (SCM_UNBNDP ($2))
2271 $$ = scm_list_5 (scm_car ($2),
2272 ly_symbol2scm ("OverrideProperty"),
2278 | REVERT simple_revert_context revert_arg {
2279 $$ = scm_list_4 ($2,
2280 ly_symbol2scm ("RevertProperty"),
2284 | SET context_prop_spec '=' scalar {
2285 if (SCM_UNBNDP ($2))
2288 $$ = scm_list_4 (scm_car ($2),
2289 ly_symbol2scm ("PropertySet"),
2293 | UNSET context_prop_spec {
2294 if (SCM_UNBNDP ($2))
2297 $$ = scm_list_3 (scm_car ($2),
2298 ly_symbol2scm ("PropertyUnset"),
2304 // This is all quite awkward for the sake of substantial backward
2305 // compatibility while at the same time allowing a more "natural" form
2306 // of specification not separating grob specification from grob
2307 // property path. The purpose of this definition of
2308 // simple_revert_context is to allow the symbol list which specifies
2309 // grob and property to revert to be optionally be split into two
2310 // parts after the grob (which may be preceded by a context
2311 // specification, a case which we distinguish by checking whether the
2312 // first symbol is a valid grob symbol instead).
2314 // See revert_arg above for the main work horse of this arrangement.
2315 // simple_revert_context just caters for the context and delegates the
2316 // rest of the job to revert_arg.
2318 simple_revert_context:
2321 $1 = scm_reverse_x ($1, SCM_EOL);
2322 if (scm_is_null ($1)
2324 (scm_object_property (scm_car ($1),
2325 ly_symbol2scm ("is-grob?")))) {
2326 $$ = ly_symbol2scm ("Bottom");
2327 parser->lexer_->push_extra_token (@1, SCM_IDENTIFIER, $1);
2330 parser->lexer_->push_extra_token (@1, SCM_IDENTIFIER,
2337 simple_music_property_def {
2338 if (SCM_UNBNDP ($1))
2339 $$ = MAKE_SYNTAX ("void-music", @1);
2341 $$ = LOWLEVEL_MAKE_SYNTAX (ly_lily_module_constant ("property-operation"), scm_cons2 (parser->self_scm (), make_input (@$), $1));
2352 simple_string: STRING {
2357 if (scm_is_string ($1)) {
2360 parser->parser_error (@1, (_ ("simple string expected")));
2361 $$ = scm_string (SCM_EOL);
2368 $$ = scm_string_to_symbol ($1);
2372 // This is a bit of overkill but makes the same
2373 // routine responsible for all symbol interpretations.
2374 $$ = try_string_variants (ly_lily_module_constant ("symbol?"),
2376 if (SCM_UNBNDP ($$))
2378 parser->parser_error (@1, (_ ("symbol expected")));
2379 // Generate a unique symbol in case it is used
2380 // for an assignment or similar
2381 $$ = scm_make_symbol (ly_string2scm ("undefined"));
2390 // The following is a rather defensive variant of admitting
2391 // negative numbers: the grammar would permit number_factor or
2392 // even number_expression. However, function arguments allow
2393 // only this simple kind of negative number, so to have things
2394 // like \tweak and \override behave reasonably similar, it
2395 // makes sense to rule out things like -- which are rather an
2396 // accent in function argument contexts.
2399 $$ = scm_difference ($2, SCM_UNDEFINED);
2406 simple_element post_events {
2407 // Let the rhythmic music iterator sort this mess out.
2408 if (scm_is_pair ($2)) {
2409 $$ = make_music_from_simple (parser, @1, $1);
2410 if (unsmob_music ($$))
2411 unsmob_music ($$)->set_property ("articulations",
2412 scm_reverse_x ($2, SCM_EOL));
2415 parser->parser_error (@1, _("music expected"));
2416 $$ = MAKE_SYNTAX ("void-music", @1);
2420 | simple_chord_elements post_events {
2421 if (scm_is_pair ($2)) {
2422 if (unsmob_pitch ($1))
2423 $1 = make_chord_elements (@1,
2425 parser->default_duration_.smobbed_copy (),
2428 SCM elts = ly_append2 ($1, scm_reverse_x ($2, SCM_EOL));
2430 $$ = MAKE_SYNTAX ("event-chord", @1, elts);
2431 } else if (!unsmob_pitch ($1))
2432 $$ = MAKE_SYNTAX ("event-chord", @1, $1);
2433 // A mere pitch drops through.
2435 | CHORD_REPETITION optional_notemode_duration post_events {
2437 i.set_location (@1, @3);
2438 $$ = MAKE_SYNTAX ("repetition-chord", i,
2439 $2, scm_reverse_x ($3, SCM_EOL));
2441 | MULTI_MEASURE_REST optional_notemode_duration post_events {
2443 i.set_location (@1, @3);
2444 $$ = MAKE_SYNTAX ("multi-measure-rest", i, $2,
2445 scm_reverse_x ($3, SCM_EOL));
2448 | note_chord_element
2453 chord_body optional_notemode_duration post_events
2455 Music *m = unsmob_music ($1);
2456 SCM dur = unsmob_duration ($2)->smobbed_copy ();
2457 SCM es = m->get_property ("elements");
2458 SCM postevs = scm_reverse_x ($3, SCM_EOL);
2460 for (SCM s = es; scm_is_pair (s); s = scm_cdr (s))
2461 unsmob_music (scm_car (s))->set_property ("duration", dur);
2462 es = ly_append2 (es, postevs);
2464 m-> set_property ("elements", es);
2466 $$ = m->self_scm ();
2471 ANGLE_OPEN chord_body_elements ANGLE_CLOSE
2473 $$ = MAKE_SYNTAX ("event-chord", @$, scm_reverse_x ($2, SCM_EOL));
2477 chord_body_elements:
2478 /* empty */ { $$ = SCM_EOL; }
2479 | chord_body_elements chord_body_element {
2480 if (!SCM_UNBNDP ($2))
2481 $$ = scm_cons ($2, $1);
2486 pitch exclamations questions octave_check post_events
2488 bool q = to_boolean ($3);
2489 bool ex = to_boolean ($2);
2493 Music *n = MY_MAKE_MUSIC ("NoteEvent", @$);
2494 n->set_property ("pitch", $1);
2496 n->set_property ("cautionary", SCM_BOOL_T);
2498 n->set_property ("force-accidental", SCM_BOOL_T);
2500 if (scm_is_pair (post)) {
2501 SCM arts = scm_reverse_x (post, SCM_EOL);
2502 n->set_property ("articulations", arts);
2504 if (scm_is_number (check))
2506 int q = scm_to_int (check);
2507 n->set_property ("absolute-octave", scm_from_int (q-1));
2510 $$ = n->unprotect ();
2512 | DRUM_PITCH post_events {
2513 Music *n = MY_MAKE_MUSIC ("NoteEvent", @$);
2514 n->set_property ("drum-type", $1);
2516 if (scm_is_pair ($2)) {
2517 SCM arts = scm_reverse_x ($2, SCM_EOL);
2518 n->set_property ("articulations", arts);
2520 $$ = n->unprotect ();
2522 | music_function_chord_body
2524 Music *m = unsmob_music ($1);
2526 while (m && m->is_mus_type ("music-wrapper-music")) {
2527 $$ = m->get_property ("element");
2528 m = unsmob_music ($$);
2531 if (!(m && m->is_mus_type ("rhythmic-event"))) {
2532 parser->parser_error (@$, _ ("not a rhythmic event"));
2538 music_function_chord_body:
2543 event_function_event:
2544 EVENT_FUNCTION function_arglist {
2545 $$ = MAKE_SYNTAX ("music-function", @$,
2567 | post_events post_event {
2569 if (Music *m = unsmob_music ($2))
2571 if (m->is_mus_type ("post-event-wrapper"))
2573 for (SCM p = m->get_property ("elements");
2577 $$ = scm_cons (scm_car (p), $$);
2581 $$ = scm_cons ($2, $$);
2587 post_event_nofinger:
2588 direction_less_event {
2591 | script_dir music_function_call {
2593 if (!unsmob_music ($2)->is_mus_type ("post-event")) {
2594 parser->parser_error (@2, _ ("post-event expected"));
2595 $$ = SCM_UNSPECIFIED;
2596 } else if (!SCM_UNBNDP ($1))
2598 unsmob_music ($$)->set_property ("direction", $1);
2602 if (!parser->lexer_->is_lyric_state ())
2603 parser->parser_error (@1, _ ("have to be in Lyric mode for lyrics"));
2604 $$ = MY_MAKE_MUSIC ("HyphenEvent", @$)->unprotect ();
2607 if (!parser->lexer_->is_lyric_state ())
2608 parser->parser_error (@1, _ ("have to be in Lyric mode for lyrics"));
2609 $$ = MY_MAKE_MUSIC ("ExtenderEvent", @$)->unprotect ();
2611 | script_dir direction_reqd_event {
2612 if (!SCM_UNBNDP ($1))
2614 Music *m = unsmob_music ($2);
2615 m->set_property ("direction", $1);
2619 | script_dir direction_less_event {
2620 if (!SCM_UNBNDP ($1))
2622 Music *m = unsmob_music ($2);
2623 m->set_property ("direction", $1);
2630 unsmob_music ($$)->set_property ("direction", scm_from_int (UP));
2635 unsmob_music ($$)->set_property ("direction", scm_from_int (DOWN));
2646 string_number_event:
2648 Music *s = MY_MAKE_MUSIC ("StringNumberEvent", @$);
2649 s->set_property ("string-number", $1);
2650 $$ = s->unprotect ();
2654 direction_less_event:
2656 | EVENT_IDENTIFIER {
2660 Music *a = MY_MAKE_MUSIC ("TremoloEvent", @$);
2661 a->set_property ("tremolo-type", $1);
2662 $$ = a->unprotect ();
2664 | event_function_event
2667 direction_reqd_event:
2671 | script_abbreviation {
2672 SCM s = parser->lexer_->lookup_identifier ("dash" + ly_scm2string ($1));
2673 if (scm_is_string (s)) {
2674 Music *a = MY_MAKE_MUSIC ("ArticulationEvent", @$);
2675 a->set_property ("articulation-type", s);
2676 $$ = a->unprotect ();
2678 Music *original = unsmob_music (s);
2679 if (original && original->is_mus_type ("post-event")) {
2680 Music *a = original->clone ();
2681 a->set_spot (parser->lexer_->override_input (@$));
2682 $$ = a->unprotect ();
2684 parser->parser_error (@1, _ ("expecting string or post-event as script definition"));
2685 $$ = MY_MAKE_MUSIC ("PostEvents", @$)->unprotect ();
2692 /**/ { $$ = SCM_EOL; }
2693 | '=' quotes { $$ = $2; }
2707 $$ = scm_from_int (1);
2710 $$ = scm_oneplus ($1);
2716 $$ = scm_from_int (-1);
2719 $$ = scm_oneminus ($1);
2724 NOTENAME_PITCH quotes {
2725 if (!scm_is_eq (SCM_INUM0, $2))
2727 Pitch p = *unsmob_pitch ($1);
2728 p = p.transposed (Pitch (scm_to_int ($2),0,0));
2729 $$ = p.smobbed_copy ();
2739 TONICNAME_PITCH quotes {
2740 if (!scm_is_eq (SCM_INUM0, $2))
2742 Pitch p = *unsmob_pitch ($1);
2743 p = p.transposed (Pitch (scm_to_int ($2),0,0));
2744 $$ = p.smobbed_copy ();
2751 | PITCH_IDENTIFIER quotes {
2752 if (!scm_is_eq (SCM_INUM0, $2))
2754 Pitch p = *unsmob_pitch ($1);
2755 p = p.transposed (Pitch (scm_to_int ($2),0,0));
2756 $$ = p.smobbed_copy ();
2763 if (!scm_is_eq (SCM_INUM0, $2))
2765 Pitch p = *unsmob_pitch ($1);
2766 p = p.transposed (Pitch (scm_to_int ($2),0,0));
2767 $$ = p.smobbed_copy ();
2774 Music *t = MY_MAKE_MUSIC ("TextScriptEvent", @$);
2775 t->set_property ("text", $1);
2776 $$ = t->unprotect ();
2779 Music *t = MY_MAKE_MUSIC ("TextScriptEvent", @$);
2780 t->set_property ("text",
2781 make_simple_markup ($1));
2782 $$ = t->unprotect ();
2786 Music *m = unsmob_music ($1);
2787 if (m && m->is_mus_type ("post-event"))
2789 else if (Text_interface::is_markup ($1)) {
2790 Music *t = MY_MAKE_MUSIC ("TextScriptEvent", @$);
2791 t->set_property ("text", $1);
2792 $$ = t->unprotect ();
2794 parser->parser_error (@1, _ ("not an articulation"));
2800 Music *t = MY_MAKE_MUSIC ("FingeringEvent", @$);
2801 t->set_property ("digit", $1);
2802 $$ = t->unprotect ();
2806 script_abbreviation:
2808 $$ = scm_from_locale_string ("Hat");
2811 $$ = scm_from_locale_string ("Plus");
2814 $$ = scm_from_locale_string ("Dash");
2817 $$ = scm_from_locale_string ("Bang");
2820 $$ = scm_from_locale_string ("Larger");
2823 $$ = scm_from_locale_string ("Dot");
2826 $$ = scm_from_locale_string ("Underscore");
2831 '_' { $$ = scm_from_int (DOWN); }
2832 | '^' { $$ = scm_from_int (UP); }
2833 | '-' { $$ = SCM_UNDEFINED; }
2837 multiplied_duration {
2842 maybe_notemode_duration:
2846 | multiplied_duration {
2848 parser->default_duration_ = *unsmob_duration ($$);
2853 optional_notemode_duration:
2854 maybe_notemode_duration
2856 if (SCM_UNBNDP ($$))
2857 $$ = parser->default_duration_.smobbed_copy ();
2863 $$ = make_duration ($1, scm_to_int ($2));
2864 if (SCM_UNBNDP ($$))
2866 parser->parser_error (@1, _ ("not a duration"));
2867 $$ = Duration ().smobbed_copy ();
2870 | DURATION_IDENTIFIER dots {
2871 Duration *d = unsmob_duration ($1);
2872 Duration k (d->duration_log (),
2873 d->dot_count () + scm_to_int ($2));
2874 k = k.compressed (d->factor ());
2875 scm_remember_upto_here_1 ($1);
2876 $$ = k.smobbed_copy ();
2880 multiplied_duration:
2884 | multiplied_duration '*' UNSIGNED {
2885 $$ = unsmob_duration ($$)->compressed (scm_to_int ($3)).smobbed_copy ();
2887 | multiplied_duration '*' FRACTION {
2888 Rational m (scm_to_int (scm_car ($3)), scm_to_int (scm_cdr ($3)));
2890 $$ = unsmob_duration ($$)->compressed (m).smobbed_copy ();
2899 $$ = scm_oneplus ($1);
2908 if (SCM_UNBNDP (make_duration ($2)))
2909 parser->parser_error (@2, _ ("not a duration"));
2915 UNSIGNED { $$ = $1; }
2916 | STRING { $$ = $1; }
2917 | full_markup { $$ = $1; }
2920 // as an integer, it needs to be non-negative, and otherwise
2921 // it needs to be suitable as a markup.
2922 if (scm_is_integer ($1)
2923 ? scm_is_true (scm_negative_p ($1))
2924 : !Text_interface::is_markup ($1))
2926 parser->parser_error (@1, _ ("bass number expected"));
2932 figured_bass_alteration:
2933 '-' { $$ = ly_rational2scm (FLAT_ALTERATION); }
2934 | '+' { $$ = ly_rational2scm (SHARP_ALTERATION); }
2935 | '!' { $$ = scm_from_int (0); }
2940 Music *bfr = MY_MAKE_MUSIC ("BassFigureEvent", @$);
2941 $$ = bfr->unprotect ();
2944 Music *bfr = MY_MAKE_MUSIC ("BassFigureEvent", @$);
2945 $$ = bfr->self_scm ();
2947 if (scm_is_number ($1))
2948 bfr->set_property ("figure", $1);
2949 else if (Text_interface::is_markup ($1))
2950 bfr->set_property ("text", $1);
2956 unsmob_music ($1)->set_property ("bracket-stop", SCM_BOOL_T);
2958 | bass_figure figured_bass_alteration {
2959 Music *m = unsmob_music ($1);
2960 if (scm_to_double ($2)) {
2961 SCM salter = m->get_property ("alteration");
2962 SCM alter = scm_is_number (salter) ? salter : scm_from_int (0);
2963 m->set_property ("alteration",
2964 scm_sum (alter, $2));
2966 m->set_property ("alteration", scm_from_int (0));
2969 | bass_figure figured_bass_modification {
2970 Music *m = unsmob_music ($1);
2971 m->set_property ($2, SCM_BOOL_T);
2976 figured_bass_modification:
2978 $$ = ly_symbol2scm ("augmented");
2981 $$ = ly_symbol2scm ("no-continuation");
2984 $$ = ly_symbol2scm ("diminished");
2987 $$ = ly_symbol2scm ("augmented-slash");
2997 unsmob_music ($$)->set_property ("bracket-start", SCM_BOOL_T);
3005 | figure_list br_bass_figure {
3006 $$ = scm_cons ($2, $1);
3011 FIGURE_OPEN figure_list FIGURE_CLOSE {
3012 $$ = scm_reverse_x ($2, SCM_EOL);
3018 /**/ { $$ = SCM_BOOL_F; }
3019 | REST { $$ = SCM_BOOL_T; }
3023 pitch exclamations questions octave_check maybe_notemode_duration optional_rest {
3024 if (!parser->lexer_->is_note_state ())
3025 parser->parser_error (@1, _ ("have to be in Note mode for notes"));
3026 if (!SCM_UNBNDP ($2)
3028 || scm_is_number ($4)
3030 || scm_is_true ($6))
3033 if (scm_is_true ($6))
3034 n = MY_MAKE_MUSIC ("RestEvent", @$);
3036 n = MY_MAKE_MUSIC ("NoteEvent", @$);
3038 n->set_property ("pitch", $1);
3039 if (SCM_UNBNDP ($5))
3040 n->set_property ("duration",
3041 parser->default_duration_.smobbed_copy ());
3043 n->set_property ("duration", $5);
3045 if (scm_is_number ($4))
3047 int q = scm_to_int ($4);
3048 n->set_property ("absolute-octave", scm_from_int (q-1));
3051 if (to_boolean ($3))
3052 n->set_property ("cautionary", SCM_BOOL_T);
3053 if (to_boolean ($2) || to_boolean ($3))
3054 n->set_property ("force-accidental", SCM_BOOL_T);
3056 $$ = n->unprotect ();
3059 | DRUM_PITCH optional_notemode_duration {
3060 Music *n = MY_MAKE_MUSIC ("NoteEvent", @$);
3061 n->set_property ("duration", $2);
3062 n->set_property ("drum-type", $1);
3064 $$ = n->unprotect ();
3066 | RESTNAME optional_notemode_duration {
3068 if (ly_scm2string ($1) == "s") {
3070 ev = MY_MAKE_MUSIC ("SkipEvent", @$);
3073 ev = MY_MAKE_MUSIC ("RestEvent", @$);
3076 ev->set_property ("duration", $2);
3077 $$ = ev->unprotect ();
3081 // Can return a single pitch rather than a list.
3082 simple_chord_elements:
3084 if (!parser->lexer_->is_chord_state ())
3085 parser->parser_error (@1, _ ("have to be in Chord mode for chords"));
3088 | figure_spec optional_notemode_duration {
3089 for (SCM s = $1; scm_is_pair (s); s = scm_cdr (s))
3091 unsmob_music (scm_car (s))->set_property ("duration", $2);
3099 if (!parser->lexer_->is_lyric_state ())
3100 parser->parser_error (@1, _ ("markup outside of text script or \\lyricmode"));
3104 if (!parser->lexer_->is_lyric_state ())
3105 parser->parser_error (@1, _ ("unrecognized string, not in text script or \\lyricmode"));
3111 lyric_element_music:
3112 lyric_element optional_notemode_duration post_events {
3113 $$ = MAKE_SYNTAX ("lyric-event", @$, $1, $2);
3114 if (scm_is_pair ($3))
3115 unsmob_music ($$)->set_property
3116 ("articulations", scm_reverse_x ($3, SCM_EOL));
3120 // Can return a single pitch rather than a list.
3122 steno_tonic_pitch maybe_notemode_duration {
3123 if (SCM_UNBNDP ($2))
3126 $$ = make_chord_elements (@$, $1, $2, SCM_EOL);
3128 | steno_tonic_pitch optional_notemode_duration chord_separator chord_items {
3129 SCM its = scm_reverse_x ($4, SCM_EOL);
3130 $$ = make_chord_elements (@$, $1, $2, scm_cons ($3, its));
3138 | chord_items chord_item {
3139 $$ = scm_cons ($2, $$);
3145 $$ = ly_symbol2scm ("chord-colon");
3148 $$ = ly_symbol2scm ("chord-caret");
3150 | CHORD_SLASH steno_tonic_pitch {
3151 $$ = scm_list_2 (ly_symbol2scm ("chord-slash"), $2);
3153 | CHORD_BASS steno_tonic_pitch {
3154 $$ = scm_list_2 (ly_symbol2scm ("chord-bass"), $2);
3163 $$ = scm_reverse_x ($1, SCM_EOL);
3171 step_number { $$ = scm_cons ($1, SCM_EOL); }
3172 | step_numbers '.' step_number {
3173 $$ = scm_cons ($3, $$);
3179 $$ = make_chord_step ($1, 0);
3182 $$ = make_chord_step ($1, SHARP_ALTERATION);
3184 | UNSIGNED CHORD_MINUS {
3185 $$ = make_chord_step ($1, FLAT_ALTERATION);
3193 | unsigned_number '-' unsigned_number {
3194 $$ = scm_cons ($1, $3);
3201 TODO: should deprecate in favor of Scheme?
3205 number_expression '+' number_term {
3206 $$ = scm_sum ($1, $3);
3208 | number_expression '-' number_term {
3209 $$ = scm_difference ($1, $3);
3218 | number_factor '*' number_factor {
3219 $$ = scm_product ($1, $3);
3221 | number_factor '/' number_factor {
3222 $$ = scm_divide ($1, $3);
3227 '-' number_factor { /* %prec UNARY_MINUS */
3228 $$ = scm_difference ($2, SCM_UNDEFINED);
3234 bare_number_common_closed
3235 | REAL NUMBER_IDENTIFIER
3237 $$ = scm_product ($1, $2);
3241 bare_number_common_closed:
3249 | UNSIGNED NUMBER_IDENTIFIER {
3250 $$ = scm_product ($1, $2);
3258 if (!scm_is_integer ($1)
3259 || scm_is_true (scm_negative_p ($1)))
3261 parser->parser_error (@1, _("not an unsigned integer"));
3267 if (!scm_is_integer ($1)
3268 || scm_is_true (scm_negative_p ($1)))
3270 parser->parser_error (@1, _("not an unsigned integer"));
3277 { $$ = SCM_UNDEFINED; }
3280 if (SCM_UNBNDP ($1))
3288 // This precedence rule is rather weird. It triggers when '!' is
3289 // encountered after a pitch, and is used for deciding whether to save
3290 // this instead for a figure modification. This should not actually
3291 // occur in practice as pitches and figures are generated in different
3292 // modes. Using a greedy (%right) precedence makes sure that we don't
3293 // get stuck in a wrong interpretation.
3294 { $$ = SCM_UNDEFINED; } %prec ':'
3297 if (SCM_UNBNDP ($1))
3306 { parser->lexer_->push_markup_state (); }
3309 parser->lexer_->pop_state ();
3315 { parser->lexer_->push_markup_state (); }
3318 parser->lexer_->pop_state ();
3324 $$ = scm_list_2 (ly_lily_module_constant ("line-markup"), $1);
3326 | markup_head_1_list simple_markup
3328 $$ = scm_car (MAKE_SYNTAX ("composed-markup-list",
3329 @2, $1, scm_list_1 ($2)));
3339 if (Text_interface::is_markup ($1))
3340 MYBACKUP (MARKUP_IDENTIFIER, $1, @1);
3341 else if (Text_interface::is_markup_list ($1))
3342 MYBACKUP (MARKUPLIST_IDENTIFIER, $1, @1);
3344 parser->parser_error (@1, _ ("not a markup"));
3345 MYBACKUP (MARKUP_IDENTIFIER, scm_string (SCM_EOL), @1);
3352 markup_composed_list {
3355 | markup_uncomposed_list
3358 markup_uncomposed_list:
3359 markup_braced_list {
3362 | markup_command_list {
3363 $$ = scm_list_1 ($1);
3365 | markup_scm MARKUPLIST_IDENTIFIER
3370 SCM nn = parser->lexer_->lookup_identifier ("pitchnames");
3371 parser->lexer_->push_note_state (nn);
3372 } '{' score_body '}' {
3373 unsmob_score ($4)->origin ()->set_spot (@$);
3374 $$ = scm_list_1 (scm_list_2 (ly_lily_module_constant ("score-lines-markup-list"), $4));
3375 parser->lexer_->pop_state ();
3379 markup_composed_list:
3380 markup_head_1_list markup_uncomposed_list {
3381 $$ = MAKE_SYNTAX ("composed-markup-list",
3387 '{' markup_braced_list_body '}' {
3388 $$ = scm_reverse_x ($2, SCM_EOL);
3392 markup_braced_list_body:
3393 /* empty */ { $$ = SCM_EOL; }
3394 | markup_braced_list_body markup {
3395 $$ = scm_cons ($2, $1);
3397 | markup_braced_list_body markup_list {
3398 $$ = scm_reverse_x ($2, $1);
3402 markup_command_list:
3403 MARKUP_LIST_FUNCTION markup_command_list_arguments {
3404 $$ = scm_cons ($1, scm_reverse_x($2, SCM_EOL));
3408 markup_command_basic_arguments:
3409 EXPECT_MARKUP_LIST markup_command_list_arguments markup_list {
3410 $$ = scm_cons ($3, $2);
3412 | EXPECT_SCM markup_command_list_arguments embedded_scm {
3413 $$ = check_scheme_arg (parser, @3, $3, $2, $1);
3415 | EXPECT_NO_MORE_ARGS {
3420 markup_command_list_arguments:
3421 markup_command_basic_arguments { $$ = $1; }
3422 | EXPECT_MARKUP markup_command_list_arguments markup {
3423 $$ = scm_cons ($3, $2);
3428 MARKUP_FUNCTION EXPECT_MARKUP markup_command_list_arguments {
3429 $$ = scm_cons ($1, scm_reverse_x ($3, SCM_EOL));
3434 markup_head_1_item {
3435 $$ = scm_list_1 ($1);
3437 | markup_head_1_list markup_head_1_item {
3438 $$ = scm_cons ($2, $1);
3444 $$ = make_simple_markup ($1);
3447 SCM nn = parser->lexer_->lookup_identifier ("pitchnames");
3448 parser->lexer_->push_note_state (nn);
3449 } '{' score_body '}' {
3450 unsmob_score ($4)->origin ()->set_spot (@$);
3451 $$ = scm_list_2 (ly_lily_module_constant ("score-markup"), $4);
3452 parser->lexer_->pop_state ();
3454 | MARKUP_FUNCTION markup_command_basic_arguments {
3455 $$ = scm_cons ($1, scm_reverse_x ($2, SCM_EOL));
3457 | markup_scm MARKUP_IDENTIFIER
3464 markup_head_1_list simple_markup
3466 $$ = scm_car (MAKE_SYNTAX ("composed-markup-list",
3467 @2, $1, scm_list_1 ($2)));
3477 Lily_parser::set_yydebug (bool x)
3483 Lily_parser::do_yyparse ()
3485 SCM retval = SCM_UNDEFINED;
3486 yyparse (this, &retval);
3496 It is a little strange to have this function in this file, but
3497 otherwise, we have to import music classes into the lexer.
3501 Lily_lexer::try_special_identifiers (SCM *destination, SCM sid)
3503 if (unsmob_book (sid)) {
3504 Book *book = unsmob_book (sid)->clone ();
3505 *destination = book->self_scm ();
3508 return BOOK_IDENTIFIER;
3509 } else if (scm_is_number (sid)) {
3511 return NUMBER_IDENTIFIER;
3512 } else if (unsmob_context_def (sid)) {
3513 Context_def *def= unsmob_context_def (sid)->clone ();
3515 *destination = def->self_scm ();
3518 return CONTEXT_DEF_IDENTIFIER;
3519 } else if (unsmob_context_mod (sid)) {
3520 *destination = unsmob_context_mod (sid)->smobbed_copy ();
3522 return CONTEXT_MOD_IDENTIFIER;
3523 } else if (Music *mus = unsmob_music (sid)) {
3524 mus = mus->clone ();
3525 *destination = mus->self_scm ();
3526 bool is_event = mus->is_mus_type ("post-event");
3528 return is_event ? EVENT_IDENTIFIER : MUSIC_IDENTIFIER;
3529 } else if (unsmob_pitch (sid)) {
3530 *destination = unsmob_pitch (sid)->smobbed_copy ();
3531 return PITCH_IDENTIFIER;
3532 } else if (unsmob_duration (sid)) {
3533 *destination = unsmob_duration (sid)->smobbed_copy ();
3534 return DURATION_IDENTIFIER;
3535 } else if (unsmob_output_def (sid)) {
3536 Output_def *p = unsmob_output_def (sid);
3539 *destination = p->self_scm ();
3541 return OUTPUT_DEF_IDENTIFIER;
3542 } else if (unsmob_score (sid)) {
3543 *destination = unsmob_score (sid)->clone ()->unprotect ();
3544 return SCM_IDENTIFIER;
3551 get_next_unique_context_id ()
3553 return scm_from_locale_string ("$uniqueContextId");
3558 get_next_unique_lyrics_context_id ()
3560 static int new_context_count;
3562 snprintf (s, sizeof (s)-1, "uniqueContext%d", new_context_count++);
3563 return scm_from_locale_string (s);
3566 // check_scheme_arg checks one argument with a given predicate for use
3567 // in an argument list and throws a syntax error if it is unusable.
3568 // The argument is prepended to the argument list in any case. After
3569 // throwing a syntax error, the argument list is terminated with #f as
3570 // its last cdr in order to mark it as uncallable while not losing
3571 // track of its total length.
3573 // There are a few special considerations: if optional argument disp
3574 // is given (otherwise it defaults to SCM_UNDEFINED), it will be used
3575 // instead of arg in a prospective error message. This is useful if
3576 // arg is not the actual argument but rather a transformation of it.
3578 // If arg itself is SCM_UNDEFINED, the predicate is considered false
3579 // and an error message using disp is produced unconditionally.
3581 SCM check_scheme_arg (Lily_parser *parser, Input loc,
3582 SCM arg, SCM args, SCM pred, SCM disp)
3584 if (SCM_UNBNDP (arg))
3585 args = scm_cons (disp, args);
3587 args = scm_cons (arg, args);
3588 if (scm_is_true (scm_call_1 (pred, arg)))
3591 scm_set_cdr_x (scm_last_pair (args), SCM_EOL);
3592 MAKE_SYNTAX ("argument-error", loc, scm_length (args), pred,
3593 SCM_UNBNDP (disp) ? arg : disp);
3594 scm_set_cdr_x (scm_last_pair (args), SCM_BOOL_F);
3598 SCM loc_on_music (Input loc, SCM arg)
3600 if (Music *m = unsmob_music (arg))
3604 return m->unprotect ();
3610 try_string_variants (SCM pred, SCM str)
3612 // a matching predicate is always ok
3613 if (scm_is_true (scm_call_1 (pred, str)))
3615 // a symbol may be interpreted as a list of symbols if it helps
3616 if (scm_is_symbol (str)) {
3617 str = scm_list_1 (str);
3618 if (scm_is_true (scm_call_1 (pred, str)))
3620 return SCM_UNDEFINED;
3623 // If this cannot be a string representation of a symbol list,
3626 if (!is_regular_identifier (str, true))
3627 return SCM_UNDEFINED;
3629 str = scm_string_split (str, SCM_MAKE_CHAR ('.'));
3630 for (SCM p = str; scm_is_pair (p); p = scm_cdr (p))
3631 scm_set_car_x (p, scm_string_to_symbol (scm_car (p)));
3633 // Let's attempt the symbol list interpretation first.
3635 if (scm_is_true (scm_call_1 (pred, str)))
3638 // If there is just one symbol in the list, we might interpret
3639 // it as a single symbol
3641 if (scm_is_null (scm_cdr (str)))
3643 str = scm_car (str);
3644 if (scm_is_true (scm_call_1 (pred, str)))
3648 return SCM_UNDEFINED;
3652 is_regular_identifier (SCM id, bool multiple)
3654 if (!scm_is_string (id))
3657 string str = ly_scm2string (id);
3659 bool middle = false;
3661 for (string::iterator it=str.begin(); it != str.end (); it++)
3664 if ((c >= 'a' && c <= 'z')
3665 || (c >= 'A' && c <= 'Z')
3668 else if (middle && (c == '-' || c == '_' || (multiple && c == '.')))
3677 make_music_from_simple (Lily_parser *parser, Input loc, SCM simple)
3679 if (unsmob_music (simple))
3681 if (parser->lexer_->is_note_state ()) {
3682 if (scm_is_symbol (simple)) {
3683 Music *n = MY_MAKE_MUSIC ("NoteEvent", loc);
3684 n->set_property ("duration", parser->default_duration_.smobbed_copy ());
3685 n->set_property ("drum-type", simple);
3686 return n->unprotect ();
3688 if (unsmob_pitch (simple)) {
3689 Music *n = MY_MAKE_MUSIC ("NoteEvent", loc);
3690 n->set_property ("duration", parser->default_duration_.smobbed_copy ());
3691 n->set_property ("pitch", simple);
3692 return n->unprotect ();
3695 } else if (parser->lexer_->is_lyric_state ()) {
3696 if (Text_interface::is_markup (simple))
3697 return MAKE_SYNTAX ("lyric-event", loc, simple,
3698 parser->default_duration_.smobbed_copy ());
3699 } else if (parser->lexer_->is_chord_state ()) {
3700 if (unsmob_pitch (simple))
3704 make_chord_elements (loc, simple,
3705 parser->default_duration_.smobbed_copy (),
3712 make_music_with_input (SCM name, Input where)
3714 Music *m = make_music_by_name (name);
3715 m->set_spot (where);
3720 make_simple_markup (SCM a)
3726 make_duration (SCM d, int dots)
3728 int t = scm_to_int (d);
3729 if (t > 0 && (t & (t-1)) == 0)
3730 return Duration (intlog2 (t), dots).smobbed_copy ();
3732 return SCM_UNDEFINED;
3736 make_chord_step (SCM step_scm, Rational alter)
3738 int step = scm_to_int (step_scm);
3741 alter += FLAT_ALTERATION;
3745 Pitch m ((step -1) / 7, (step - 1) % 7, alter);
3746 return m.smobbed_copy ();
3751 make_chord_elements (Input loc, SCM pitch, SCM dur, SCM modification_list)
3753 SCM chord_ctor = ly_lily_module_constant ("construct-chord-elements");
3754 SCM res = scm_call_3 (chord_ctor, pitch, dur, modification_list);
3755 for (SCM s = res; scm_is_pair (s); s = scm_cdr (s))
3757 unsmob_music (scm_car (s))->set_spot (loc);
3763 yylex (YYSTYPE *s, YYLTYPE *loc, Lily_parser *parser)
3765 Lily_lexer *lex = parser->lexer_;
3769 int tok = lex->pop_extra_token ();
3772 lex->prepare_for_next_token ();
3773 return lex->yylex ();