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 ($$))
1066 parser->parser_error (@1, _ ("music expected"));
1068 | composite_music %prec COMPOSITE
1073 | composite_music %prec COMPOSITE
1077 REPEAT simple_string unsigned_number music
1079 $$ = MAKE_SYNTAX ("repeat", @$, $2, $3, $4, SCM_EOL);
1081 | REPEAT simple_string unsigned_number music ALTERNATIVE braced_music_list
1083 $$ = MAKE_SYNTAX ("repeat", @$, $2, $3, $4, $6);
1088 SEQUENTIAL braced_music_list {
1089 $$ = MAKE_SYNTAX ("sequential-music", @$, $2);
1091 | braced_music_list {
1092 $$ = MAKE_SYNTAX ("sequential-music", @$, $1);
1097 SIMULTANEOUS braced_music_list {
1098 $$ = MAKE_SYNTAX ("simultaneous-music", @$, $2);
1100 | DOUBLE_ANGLE_OPEN music_list DOUBLE_ANGLE_CLOSE {
1101 $$ = MAKE_SYNTAX ("simultaneous-music", @$, scm_reverse_x ($2, SCM_EOL));
1107 | music_property_def
1111 context_modification:
1114 SCM nn = parser->lexer_->lookup_identifier ("pitchnames");
1115 parser->lexer_->push_note_state (nn);
1116 } '{' context_mod_list '}'
1118 parser->lexer_->pop_state ();
1121 | WITH CONTEXT_MOD_IDENTIFIER
1125 | CONTEXT_MOD_IDENTIFIER
1129 | WITH context_modification_arg
1131 if (unsmob_music ($2)) {
1132 SCM proc = parser->lexer_->lookup_identifier ("context-mod-music-handler");
1133 $2 = scm_call_2 (proc, parser->self_scm (), $2);
1135 if (unsmob_context_mod ($2))
1138 parser->parser_error (@2, _ ("not a context mod"));
1139 $$ = Context_mod ().smobbed_copy ();
1144 context_modification_arg:
1149 optional_context_mod:
1153 | context_modification
1161 $$ = Context_mod ().smobbed_copy ();
1163 | context_mod_list context_mod {
1164 if (!SCM_UNBNDP ($2))
1165 unsmob_context_mod ($1)->add_context_mod ($2);
1167 | context_mod_list CONTEXT_MOD_IDENTIFIER {
1168 Context_mod *md = unsmob_context_mod ($2);
1170 unsmob_context_mod ($1)->add_context_mods (md->get_mods ());
1172 | context_mod_list context_mod_embedded {
1173 unsmob_context_mod ($1)->add_context_mods
1174 (unsmob_context_mod ($2)->get_mods ());
1183 /* Music that can be parsed without lookahead */
1186 | complex_music_prefix closed_music
1188 $$ = FINISH_MAKE_SYNTAX ($1, @$, $2);
1190 | music_function_call_closed
1196 | grouped_music_list
1200 simultaneous_music { $$ = $1; }
1201 | sequential_music { $$ = $1; }
1204 /* Function argument lists are arguably the most complex part in the
1205 * parser. They are pretty tricky to understand because of the way
1206 * they are processed, and because of optional arguments that can be
1207 * omitted. When there are several optional arguments in a row,
1208 * omitting one automatically omits all following arguments. Optional
1209 * arguments can only be omitted when either
1211 * a) the omission is explicitly started with \default
1212 * b) the omission is implicitly started by an argument not matching
1213 * its predicate, and there is a mandatory argument later that can
1214 * "catch" the argument that does not fit.
1216 * When argument parsing starts, the lexer pushes EXPECT_SCM tokens
1217 * (corresponding to mandatory arguments and having a predicate
1218 * function as semantic value) or EXPECT_OPTIONAL EXPECT_SCM (where
1219 * the semantic value of the EXPECT_OPTIONAL token is the default to
1220 * use when the optional argument is omitted, and EXPECT_SCM again has
1221 * the argument predicate as semantic value) in reverse order to the
1222 * parser, followed by EXPECT_NO_MORE_ARGS. The argument list is then
1223 * processed inside-out while actual tokens are consumed.
1225 * This means that the argument list tokens determine the actions
1226 * taken as they arrive. The structure of the argument list is known
1227 * to the parser and stored in its parse stack when the first argument
1228 * is being parsed. What the parser does not know is which predicates
1229 * will match and whether or not \default will be appearing in the
1230 * argument list, and where.
1232 * Many of the basic nonterminals used for argument list scanning come
1233 * in a "normal" and a "closed" flavor. A closed expression is one
1234 * that can be parsed without a lookahead token. That makes it
1235 * feasible for an optional argument that may need to be skipped:
1236 * skipping can only be accomplished by pushing back the token into
1237 * the lexer, and that only works when there is no lookahead token.
1239 * Sequences of 0 or more optional arguments are scanned using either
1240 * function_arglist_backup or function_arglist_nonbackup. The first
1241 * is used when optional arguments are followed by at least one
1242 * mandatory argument: in that case optional arguments may be skipped
1243 * by either a false predicate (in which case the expression will be
1244 * pushed back as one or more tokens, preceded by a BACKUP token) or
1245 * by using \default.
1247 * If optional arguments are at the end of the argument list, they are
1248 * instead scanned using function_arglist_nonbackup: here the only
1249 * manner to enter into skipping of optional arguments is the use of
1252 * The argument list of a normal function call is parsed using
1253 * function_arglist. The part of an argument list before a mandatory
1254 * argument is parsed using function_arglist_optional.
1256 * The difference is that leading optional arguments are scanned using
1257 * function_arglist_nonbackup and function_arglist_backup,
1260 * Most other details are obvious in the rules themselves.
1264 function_arglist_nonbackup_common:
1265 EXPECT_OPTIONAL EXPECT_SCM function_arglist_nonbackup FRACTION
1267 $$ = check_scheme_arg (parser, @4, $4, $3, $2);
1269 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_closed_nonbackup post_event_nofinger
1271 $$ = check_scheme_arg (parser, @4, $4, $3, $2);
1273 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_closed_nonbackup '-' UNSIGNED
1275 SCM n = scm_difference ($5, SCM_UNDEFINED);
1276 if (scm_is_true (scm_call_1 ($2, n)))
1277 $$ = scm_cons (n, $3);
1279 Music *t = MY_MAKE_MUSIC ("FingeringEvent", @5);
1280 t->set_property ("digit", $5);
1281 $$ = check_scheme_arg (parser, @4, t->unprotect (),
1286 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_closed_nonbackup '-' REAL
1288 $$ = check_scheme_arg (parser, @4,
1289 scm_difference ($5, SCM_UNDEFINED),
1292 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_closed_nonbackup '-' NUMBER_IDENTIFIER
1294 $$ = check_scheme_arg (parser, @4,
1295 scm_difference ($5, SCM_UNDEFINED),
1300 function_arglist_closed_nonbackup:
1301 function_arglist_nonbackup_common
1302 | function_arglist_closed_common
1303 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_nonbackup embedded_scm_arg_closed
1305 $$ = check_scheme_arg (parser, @4, $4, $3, $2);
1307 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_closed_nonbackup bare_number_closed
1309 $$ = check_scheme_arg (parser, @4, $4, $3, $2);
1311 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_nonbackup SCM_IDENTIFIER
1313 $$ = check_scheme_arg (parser, @4,
1314 try_string_variants ($2, $4),
1317 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_nonbackup STRING
1319 $$ = check_scheme_arg (parser, @4,
1320 try_string_variants ($2, $4),
1323 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_nonbackup full_markup
1325 $$ = check_scheme_arg (parser, @4, $4, $3, $2);
1331 | SYMBOL_LIST '.' symbol_list_rev
1333 $$ = scm_append (scm_list_2 ($1, scm_reverse_x ($3, SCM_EOL)));
1339 | symbol_list_rev '.' symbol_list_part
1341 $$ = scm_append_x (scm_list_2 ($3, $1));
1345 // symbol_list_part delivers elements in reverse copy.
1350 SCM sym_l_p = ly_lily_module_constant ("symbol-list?");
1351 $$ = try_string_variants (sym_l_p, $1);
1352 if (SCM_UNBNDP ($$)) {
1353 parser->parser_error (@1, _("not a symbol"));
1356 $$ = scm_reverse ($$);
1361 symbol_list_element:
1367 function_arglist_nonbackup:
1368 function_arglist_nonbackup_common
1369 | function_arglist_common
1370 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_nonbackup embedded_scm_arg
1372 if (scm_is_true (scm_call_1 ($2, $4)))
1373 $$ = scm_cons ($4, $3);
1375 $$ = check_scheme_arg (parser, @4,
1376 make_music_from_simple
1380 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_closed_nonbackup bare_number_common
1382 $$ = check_scheme_arg (parser, @4, $4, $3, $2);
1384 | function_arglist_nonbackup_reparse REPARSE duration_length
1386 $$ = check_scheme_arg (parser, @3, $3, $1, $2);
1388 | function_arglist_nonbackup_reparse REPARSE bare_number_common
1390 $$ = check_scheme_arg (parser, @3, $3, $1, $2);
1392 | function_arglist_nonbackup_reparse REPARSE SCM_ARG
1394 $$ = check_scheme_arg (parser, @3, $3, $1, $2);
1396 | function_arglist_nonbackup_reparse REPARSE lyric_element_music
1398 $$ = check_scheme_arg (parser, @3, $3, $1, $2);
1400 | function_arglist_nonbackup_reparse REPARSE symbol_list_arg
1402 $$ = check_scheme_arg (parser, @3, $3, $1, $2);
1406 function_arglist_nonbackup_reparse:
1407 EXPECT_OPTIONAL EXPECT_SCM function_arglist_nonbackup SCM_IDENTIFIER
1410 SCM res = try_string_variants ($2, $4);
1411 if (!SCM_UNBNDP (res))
1412 if (scm_is_pair (res))
1413 MYREPARSE (@4, $2, SYMBOL_LIST, res);
1415 MYREPARSE (@4, $2, SCM_ARG, res);
1416 else if (scm_is_true
1418 ($2, make_music_from_simple
1420 MYREPARSE (@4, $2, STRING, $4);
1422 MYREPARSE (@4, $2, SCM_ARG, $4);
1424 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_nonbackup STRING
1427 SCM res = try_string_variants ($2, $4);
1428 if (!SCM_UNBNDP (res))
1429 if (scm_is_pair (res))
1430 MYREPARSE (@4, $2, SYMBOL_LIST, res);
1432 MYREPARSE (@4, $2, SCM_ARG, res);
1433 else if (scm_is_true
1435 ($2, make_music_from_simple
1437 MYREPARSE (@4, $2, STRING, $4);
1439 MYREPARSE (@4, $2, SCM_ARG, $4);
1441 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_nonbackup full_markup
1444 if (scm_is_true (scm_call_1 ($2, $4)))
1445 MYREPARSE (@4, $2, SCM_ARG, $4);
1446 else if (scm_is_true
1448 ($2, make_music_from_simple
1450 MYREPARSE (@4, $2, STRING, $4);
1452 MYREPARSE (@4, $2, SCM_ARG, $4);
1454 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_closed_nonbackup UNSIGNED
1457 if (scm_is_true (scm_call_1 ($2, $4)))
1458 MYREPARSE (@4, $2, REAL, $4);
1460 SCM d = make_duration ($4);
1461 if (SCM_UNBNDP (d) || scm_is_false (scm_call_1 ($2, d)))
1462 MYREPARSE (@4, $2, REAL, $4); // trigger error
1464 MYREPARSE (@4, $2, DURATION_IDENTIFIER, d);
1467 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_closed_nonbackup DURATION_IDENTIFIER {
1469 MYREPARSE (@4, $2, DURATION_IDENTIFIER, $4);
1474 function_arglist_backup:
1475 function_arglist_backup_common
1476 | function_arglist_common
1479 function_arglist_closed_backup:
1480 function_arglist_backup_common
1481 | function_arglist_closed_common
1484 function_arglist_backup_common:
1485 EXPECT_OPTIONAL EXPECT_SCM function_arglist_backup embedded_scm_arg_closed
1487 if (scm_is_true (scm_call_1 ($2, $4)))
1489 $$ = scm_cons ($4, $3);
1491 $$ = scm_cons (loc_on_music (@3, $1), $3);
1492 MYBACKUP (SCM_ARG, $4, @4);
1495 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_closed_backup post_event_nofinger
1497 if (scm_is_true (scm_call_1 ($2, $4)))
1499 $$ = scm_cons ($4, $3);
1501 $$ = scm_cons (loc_on_music (@3, $1), $3);
1502 MYBACKUP (EVENT_IDENTIFIER, $4, @4);
1505 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_backup full_markup
1507 if (scm_is_true (scm_call_1 ($2, $4)))
1508 $$ = scm_cons ($4, $3);
1510 $$ = scm_cons (loc_on_music (@3, $1), $3);
1511 MYBACKUP (LYRIC_ELEMENT, $4, @4);
1514 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_closed_backup UNSIGNED
1516 if (scm_is_true (scm_call_1 ($2, $4)))
1518 MYREPARSE (@4, $2, REAL, $4);
1521 SCM d = make_duration ($4);
1522 if (SCM_UNBNDP (d) || scm_is_false (scm_call_1 ($2, d)))
1524 $$ = scm_cons (loc_on_music (@3, $1), $3);
1525 MYBACKUP (UNSIGNED, $4, @4);
1527 MYREPARSE (@4, $2, DURATION_IDENTIFIER, d);
1532 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_closed_backup REAL
1534 if (scm_is_true (scm_call_1 ($2, $4)))
1537 MYREPARSE (@4, $2, REAL, $4);
1539 $$ = scm_cons (loc_on_music (@3, $1), $3);
1540 MYBACKUP (REAL, $4, @4);
1543 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_closed_backup NUMBER_IDENTIFIER
1545 if (scm_is_true (scm_call_1 ($2, $4)))
1547 $$ = scm_cons ($4, $3);
1549 $$ = scm_cons (loc_on_music (@3, $1), $3);
1550 MYBACKUP (NUMBER_IDENTIFIER, $4, @4);
1553 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_backup FRACTION
1555 if (scm_is_true (scm_call_1 ($2, $4)))
1557 $$ = scm_cons ($4, $3);
1559 $$ = scm_cons (loc_on_music (@3, $1), $3);
1560 MYBACKUP (FRACTION, $4, @4);
1563 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_closed_backup '-' UNSIGNED
1565 SCM n = scm_difference ($5, SCM_UNDEFINED);
1566 if (scm_is_true (scm_call_1 ($2, n))) {
1568 MYREPARSE (@5, $2, REAL, n);
1570 Music *t = MY_MAKE_MUSIC ("FingeringEvent", @5);
1571 t->set_property ("digit", $5);
1572 $$ = t->unprotect ();
1573 if (scm_is_true (scm_call_1 ($2, $$)))
1574 $$ = scm_cons ($$, $3);
1576 $$ = scm_cons (loc_on_music (@3, $1), $3);
1577 MYBACKUP (UNSIGNED, $5, @5);
1578 parser->lexer_->push_extra_token ('-');
1583 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_closed_backup '-' REAL
1585 SCM n = scm_difference ($5, SCM_UNDEFINED);
1586 if (scm_is_true (scm_call_1 ($2, n))) {
1587 MYREPARSE (@5, $2, REAL, n);
1590 $$ = scm_cons (loc_on_music (@3, $1), $3);
1591 MYBACKUP (REAL, n, @5);
1594 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_closed_backup '-' NUMBER_IDENTIFIER
1596 SCM n = scm_difference ($5, SCM_UNDEFINED);
1597 if (scm_is_true (scm_call_1 ($2, n))) {
1598 $$ = scm_cons (n, $3);
1600 $$ = scm_cons (loc_on_music (@3, $1), $3);
1601 MYBACKUP (NUMBER_IDENTIFIER, n, @5);
1604 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_backup PITCH_IDENTIFIER
1606 if (scm_is_true (scm_call_1 ($2, $4)))
1608 $$ = scm_cons ($4, $3);
1610 $$ = scm_cons (loc_on_music (@3, $1), $3);
1611 MYBACKUP (PITCH_IDENTIFIER, $4, @4);
1614 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_backup NOTENAME_PITCH
1616 if (scm_is_true (scm_call_1 ($2, $4)))
1618 MYREPARSE (@4, $2, NOTENAME_PITCH, $4);
1621 $$ = scm_cons (loc_on_music (@3, $1), $3);
1622 MYBACKUP (NOTENAME_PITCH, $4, @4);
1625 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_backup TONICNAME_PITCH
1627 if (scm_is_true (scm_call_1 ($2, $4)))
1629 MYREPARSE (@4, $2, TONICNAME_PITCH, $4);
1632 $$ = scm_cons (loc_on_music (@3, $1), $3);
1633 MYBACKUP (TONICNAME_PITCH, $4, @4);
1636 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_closed_backup DURATION_IDENTIFIER
1638 if (scm_is_true (scm_call_1 ($2, $4)))
1640 MYREPARSE (@4, $2, DURATION_IDENTIFIER, $4);
1643 $$ = scm_cons (loc_on_music (@3, $1), $3);
1644 MYBACKUP (DURATION_IDENTIFIER, $4, @4);
1647 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_backup SCM_IDENTIFIER
1649 SCM res = try_string_variants ($2, $4);
1650 if (!SCM_UNBNDP (res))
1651 if (scm_is_pair (res)) {
1653 MYREPARSE (@4, $2, SYMBOL_LIST, res);
1656 $$ = scm_cons (res, $3);
1658 $$ = scm_cons (loc_on_music (@3, $1), $3);
1659 MYBACKUP (SCM_IDENTIFIER, $4, @4);
1662 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_backup STRING
1664 SCM res = try_string_variants ($2, $4);
1665 if (!SCM_UNBNDP (res))
1666 if (scm_is_pair (res)) {
1668 MYREPARSE (@4, $2, SYMBOL_LIST, res);
1671 $$ = scm_cons (res, $3);
1673 $$ = scm_cons (loc_on_music (@3, $1), $3);
1674 MYBACKUP (STRING, $4, @4);
1677 | function_arglist_backup REPARSE bare_number_common
1679 $$ = check_scheme_arg (parser, @3,
1682 | function_arglist_backup REPARSE duration_length
1684 $$ = check_scheme_arg (parser, @3,
1687 | function_arglist_backup REPARSE symbol_list_arg
1689 $$ = check_scheme_arg (parser, @3, $3, $1, $2);
1691 | function_arglist_backup REPARSE pitch_also_in_chords
1693 $$ = check_scheme_arg (parser, @3, $3, $1, $2);
1698 function_arglist_nonbackup
1699 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_skip_nonbackup DEFAULT
1701 $$ = scm_cons (loc_on_music (@4, $1), $3);
1705 function_arglist_skip_nonbackup:
1706 function_arglist_nonbackup
1707 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_skip_nonbackup
1709 $$ = scm_cons (loc_on_music (@3, $1), $3);
1713 function_arglist_common:
1714 EXPECT_NO_MORE_ARGS {
1717 | EXPECT_SCM function_arglist_optional embedded_scm_arg
1719 if (scm_is_true (scm_call_1 ($1, $3)))
1720 $$ = scm_cons ($3, $2);
1722 $$ = check_scheme_arg (parser, @3,
1723 make_music_from_simple
1727 | EXPECT_SCM function_arglist_closed_optional bare_number_common
1729 $$ = check_scheme_arg (parser, @3,
1732 | EXPECT_SCM function_arglist_optional FRACTION
1734 $$ = check_scheme_arg (parser, @3,
1737 | EXPECT_SCM function_arglist_closed_optional post_event_nofinger
1739 $$ = check_scheme_arg (parser, @3,
1742 | EXPECT_SCM function_arglist_closed_optional '-' NUMBER_IDENTIFIER
1744 SCM n = scm_difference ($4, SCM_UNDEFINED);
1745 $$ = check_scheme_arg (parser, @4, n, $2, $1);
1747 | function_arglist_common_reparse REPARSE SCM_ARG
1749 $$ = check_scheme_arg (parser, @3,
1752 | function_arglist_common_reparse REPARSE lyric_element_music
1754 $$ = check_scheme_arg (parser, @3,
1757 | function_arglist_common_reparse REPARSE bare_number_common
1759 $$ = check_scheme_arg (parser, @3,
1762 | function_arglist_common_reparse REPARSE duration_length
1764 $$ = check_scheme_arg (parser, @3,
1767 | function_arglist_common_reparse REPARSE symbol_list_arg
1769 $$ = check_scheme_arg (parser, @3, $3, $1, $2);
1773 function_arglist_common_reparse:
1774 EXPECT_SCM function_arglist_optional SCM_IDENTIFIER
1777 SCM res = try_string_variants ($1, $3);
1778 if (!SCM_UNBNDP (res))
1779 if (scm_is_pair (res))
1780 MYREPARSE (@3, $1, SYMBOL_LIST, res);
1782 MYREPARSE (@3, $1, SCM_ARG, res);
1783 else if (scm_is_true
1785 ($1, make_music_from_simple (parser, @3, $3))))
1786 MYREPARSE (@3, $1, LYRIC_ELEMENT, $3);
1788 // This is going to flag a syntax error, we
1789 // know the predicate to be false.
1790 MYREPARSE (@3, $1, SCM_ARG, $3);
1792 | EXPECT_SCM function_arglist_optional STRING
1795 SCM res = try_string_variants ($1, $3);
1796 if (!SCM_UNBNDP (res))
1797 if (scm_is_pair (res))
1798 MYREPARSE (@3, $1, SYMBOL_LIST, res);
1800 MYREPARSE (@3, $1, SCM_ARG, res);
1801 else if (scm_is_true
1803 ($1, make_music_from_simple (parser, @3, $3))))
1804 MYREPARSE (@3, $1, LYRIC_ELEMENT, $3);
1806 // This is going to flag a syntax error, we
1807 // know the predicate to be false.
1808 MYREPARSE (@3, $1, SCM_ARG, $3);
1810 | EXPECT_SCM function_arglist_optional full_markup
1813 if (scm_is_true (scm_call_1 ($1, $3)))
1814 MYREPARSE (@3, $1, SCM_ARG, $3);
1815 else if (scm_is_true
1817 ($1, make_music_from_simple (parser, @3, $3))))
1818 MYREPARSE (@3, $1, LYRIC_ELEMENT, $3);
1820 // This is going to flag a syntax error, we
1821 // know the predicate to be false.
1822 MYREPARSE (@3, $1, SCM_ARG, $3);
1824 | EXPECT_SCM function_arglist_closed_optional UNSIGNED
1827 if (scm_is_true (scm_call_1 ($1, $3)))
1828 MYREPARSE (@3, $1, REAL, $3);
1830 SCM d = make_duration ($3);
1831 if (SCM_UNBNDP (d) || scm_is_false (scm_call_1 ($1, d)))
1832 MYREPARSE (@3, $1, REAL, $3);
1834 MYREPARSE (@3, $1, DURATION_IDENTIFIER, d);
1837 | EXPECT_SCM function_arglist_closed_optional DURATION_IDENTIFIER
1840 MYREPARSE (@3, $1, DURATION_IDENTIFIER, $3);
1842 | EXPECT_SCM function_arglist_closed_optional '-' UNSIGNED
1845 SCM n = scm_difference ($4, SCM_UNDEFINED);
1846 if (scm_is_true (scm_call_1 ($1, n)))
1847 MYREPARSE (@4, $1, REAL, n);
1849 Music *t = MY_MAKE_MUSIC ("FingeringEvent", @4);
1850 t->set_property ("digit", $4);
1851 SCM m = t->unprotect ();
1852 if (scm_is_true (scm_call_1 ($1, m)))
1853 MYREPARSE (@4, $1, SCM_ARG, m);
1855 MYREPARSE (@4, $1, SCM_ARG, $4);
1859 | EXPECT_SCM function_arglist_closed_optional '-' REAL
1862 SCM n = scm_difference ($4, SCM_UNDEFINED);
1863 MYREPARSE (@4, $1, REAL, n);
1867 function_arglist_closed:
1868 function_arglist_closed_nonbackup
1869 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_skip_nonbackup DEFAULT
1871 $$ = scm_cons (loc_on_music (@4, $1), $3);
1875 function_arglist_closed_common:
1876 EXPECT_NO_MORE_ARGS {
1879 | EXPECT_SCM function_arglist_optional embedded_scm_arg_closed
1881 $$ = check_scheme_arg (parser, @3,
1884 | EXPECT_SCM function_arglist_closed_optional bare_number_common_closed
1886 $$ = check_scheme_arg (parser, @3,
1889 | EXPECT_SCM function_arglist_closed_optional '-' NUMBER_IDENTIFIER
1891 $$ = check_scheme_arg (parser, @3,
1892 scm_difference ($4, SCM_UNDEFINED),
1895 | EXPECT_SCM function_arglist_closed_optional post_event_nofinger
1897 $$ = check_scheme_arg (parser, @3,
1900 | EXPECT_SCM function_arglist_optional FRACTION
1902 $$ = check_scheme_arg (parser, @3,
1905 | function_arglist_common_reparse REPARSE SCM_ARG
1907 $$ = check_scheme_arg (parser, @3,
1910 | function_arglist_common_reparse REPARSE bare_number_common_closed
1912 $$ = check_scheme_arg (parser, @3,
1915 | function_arglist_common_reparse REPARSE symbol_list_arg
1917 $$ = check_scheme_arg (parser, @3, $3, $1, $2);
1921 function_arglist_optional:
1922 function_arglist_backup
1923 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_skip_backup DEFAULT
1925 $$ = scm_cons (loc_on_music (@4, $1), $3);
1927 | function_arglist_skip_backup BACKUP
1930 function_arglist_skip_backup:
1931 function_arglist_backup
1932 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_skip_backup
1934 $$ = scm_cons (loc_on_music (@3, $1), $3);
1938 function_arglist_closed_optional:
1939 function_arglist_closed_backup
1940 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_skip_backup DEFAULT
1942 $$ = scm_cons (loc_on_music (@4, $1), $3);
1944 | function_arglist_skip_backup BACKUP
1947 embedded_scm_closed:
1949 | scm_function_call_closed
1952 embedded_scm_arg_closed:
1953 embedded_scm_bare_arg
1954 | scm_function_call_closed
1958 scm_function_call_closed:
1959 SCM_FUNCTION function_arglist_closed {
1960 $$ = MAKE_SYNTAX ("music-function", @$,
1965 music_function_call:
1966 MUSIC_FUNCTION function_arglist {
1967 $$ = MAKE_SYNTAX ("music-function", @$,
1974 /**/ { $$ = SCM_EOL; }
1975 | '=' simple_string {
1982 | repeated_music { $$ = $1; }
1983 | re_rhythmed_music { $$ = $1; }
1984 | complex_music_prefix music
1986 $$ = FINISH_MAKE_SYNTAX ($1, @$, $2);
1990 complex_music_prefix:
1991 CONTEXT symbol optional_id optional_context_mod {
1992 Context_mod *ctxmod = unsmob_context_mod ($4);
1995 mods = ctxmod->get_mods ();
1996 $$ = START_MAKE_SYNTAX ("context-specification", $2, $3, mods, SCM_BOOL_F);
1998 | NEWCONTEXT symbol optional_id optional_context_mod {
1999 Context_mod *ctxmod = unsmob_context_mod ($4);
2002 mods = ctxmod->get_mods ();
2003 $$ = START_MAKE_SYNTAX ("context-specification", $2, $3, mods, SCM_BOOL_T);
2008 mode_changing_head grouped_music_list {
2009 if ($1 == ly_symbol2scm ("chords"))
2011 $$ = MAKE_SYNTAX ("unrelativable-music", @$, $2);
2017 parser->lexer_->pop_state ();
2019 | mode_changing_head_with_context optional_context_mod grouped_music_list {
2020 Context_mod *ctxmod = unsmob_context_mod ($2);
2023 mods = ctxmod->get_mods ();
2024 $$ = MAKE_SYNTAX ("context-specification", @$, $1, SCM_EOL, mods, SCM_BOOL_T, $3);
2025 if ($1 == ly_symbol2scm ("ChordNames"))
2027 $$ = MAKE_SYNTAX ("unrelativable-music", @$, $$);
2029 parser->lexer_->pop_state ();
2035 SCM nn = parser->lexer_->lookup_identifier ("pitchnames");
2036 parser->lexer_->push_note_state (nn);
2038 $$ = ly_symbol2scm ("notes");
2042 SCM nn = parser->lexer_->lookup_identifier ("drumPitchNames");
2043 parser->lexer_->push_note_state (nn);
2045 $$ = ly_symbol2scm ("drums");
2048 parser->lexer_->push_figuredbass_state ();
2050 $$ = ly_symbol2scm ("figures");
2053 SCM nn = parser->lexer_->lookup_identifier ("chordmodifiers");
2054 parser->lexer_->chordmodifier_tab_ = alist_to_hashq (nn);
2055 nn = parser->lexer_->lookup_identifier ("pitchnames");
2056 parser->lexer_->push_chord_state (nn);
2057 $$ = ly_symbol2scm ("chords");
2061 { parser->lexer_->push_lyric_state ();
2062 $$ = ly_symbol2scm ("lyrics");
2066 mode_changing_head_with_context:
2068 SCM nn = parser->lexer_->lookup_identifier ("drumPitchNames");
2069 parser->lexer_->push_note_state (nn);
2071 $$ = ly_symbol2scm ("DrumStaff");
2074 parser->lexer_->push_figuredbass_state ();
2076 $$ = ly_symbol2scm ("FiguredBass");
2079 SCM nn = parser->lexer_->lookup_identifier ("chordmodifiers");
2080 parser->lexer_->chordmodifier_tab_ = alist_to_hashq (nn);
2081 nn = parser->lexer_->lookup_identifier ("pitchnames");
2082 parser->lexer_->push_chord_state (nn);
2083 $$ = ly_symbol2scm ("ChordNames");
2086 { parser->lexer_->push_lyric_state ();
2087 $$ = ly_symbol2scm ("Lyrics");
2092 ADDLYRICS { parser->lexer_->push_lyric_state (); }
2095 /* Can also use music at the expensive of two S/Rs similar to
2096 \repeat \alternative */
2097 parser->lexer_->pop_state ();
2099 $$ = scm_cons ($3, SCM_EOL);
2101 | new_lyrics ADDLYRICS {
2102 parser->lexer_->push_lyric_state ();
2104 parser->lexer_->pop_state ();
2105 $$ = scm_cons ($4, $1);
2110 composite_music new_lyrics {
2111 $$ = MAKE_SYNTAX ("add-lyrics", @$, $1, scm_reverse_x ($2, SCM_EOL));
2113 | LYRICSTO simple_string {
2114 parser->lexer_->push_lyric_state ();
2116 parser->lexer_->pop_state ();
2117 $$ = MAKE_SYNTAX ("lyric-combine", @$, $2, $4);
2122 CHANGE STRING '=' STRING {
2123 $$ = MAKE_SYNTAX ("context-change", @$, scm_string_to_symbol ($2), $4);
2130 $$ = scm_reverse_x ($1, SCM_EOL);
2132 | symbol_list_rev property_path {
2133 $$ = scm_reverse_x ($1, $2);
2139 $$ = scm_list_3 (ly_symbol2scm ("assign"), $1, $3);
2142 $$ = scm_list_2 (ly_symbol2scm ("unset"), $2);
2144 | OVERRIDE property_path '=' scalar {
2145 if (scm_ilength ($2) < 2) {
2146 parser->parser_error (@2, _("bad grob property path"));
2149 $$ = scm_cons (ly_symbol2scm ("push"),
2150 scm_cons2 (scm_car ($2),
2155 | REVERT revert_arg {
2156 $$ = scm_cons (ly_symbol2scm ("pop"), $2);
2160 // This is all quite awkward for the sake of substantial backward
2161 // compatibility while at the same time allowing a more "natural" form
2162 // of specification not separating grob specification from grob
2163 // property path. The purpose of this definition of revert_arg is to
2164 // allow the symbol list which specifies grob and property to revert
2165 // to be optionally be split into two parts after the grob (which in
2166 // this case is just the first element of the list). symbol_list_part
2167 // is only one path component, but it can be parsed without lookahead,
2168 // so we can follow it with a synthetic BACKUP token when needed. If
2169 // the first symbol_list_part already contains multiple elements (only
2170 // possible if a Scheme expression provides them), we just parse for
2171 // additional elements introduced by '.', which is what the
2172 // SYMBOL_LIST backup in connection with the immediately following
2173 // rule using symbol_list_arg does.
2175 // As long as we don't have our coffers filled with both grob and at
2176 // least one grob property specification, the rest of the required
2177 // symbol list chain may be provided either with or without a leading
2178 // dot. This is for both allowing the traditional
2179 // \revert Accidental #'color
2180 // as well as well as the "naive" form
2181 // \revert Accidental.color
2184 revert_arg_backup BACKUP symbol_list_arg
2193 if (scm_is_null ($1)
2194 || scm_is_null (scm_cdr ($1)))
2195 MYBACKUP (SCM_ARG, $1, @1);
2197 MYBACKUP (SYMBOL_LIST, scm_reverse_x ($1, SCM_EOL), @1);
2201 // revert_arg_part delivers results in reverse
2204 | revert_arg_backup BACKUP SCM_ARG '.' symbol_list_part
2206 $$ = scm_append_x (scm_list_2 ($5, $3));
2208 | revert_arg_backup BACKUP SCM_ARG symbol_list_part
2210 $$ = scm_append_x (scm_list_2 ($4, $3));
2215 CONSISTS { $$ = ly_symbol2scm ("consists"); }
2216 | REMOVE { $$ = ly_symbol2scm ("remove"); }
2218 | ACCEPTS { $$ = ly_symbol2scm ("accepts"); }
2219 | DEFAULTCHILD { $$ = ly_symbol2scm ("default-child"); }
2220 | DENIES { $$ = ly_symbol2scm ("denies"); }
2222 | ALIAS { $$ = ly_symbol2scm ("alias"); }
2223 | TYPE { $$ = ly_symbol2scm ("translator-type"); }
2224 | DESCRIPTION { $$ = ly_symbol2scm ("description"); }
2225 | NAME { $$ = ly_symbol2scm ("context-name"); }
2229 property_operation { $$ = $1; }
2230 | context_def_mod STRING {
2231 $$ = scm_list_2 ($1, $2);
2233 | context_def_mod embedded_scm
2235 if (!scm_is_string ($2)
2236 && ly_symbol2scm ("consists") != $1
2237 && ly_symbol2scm ("remove") != $1)
2240 parser->parser_error (@1, _ ("only \\consists and \\remove take non-string argument."));
2244 $$ = scm_list_2 ($1, $2);
2249 // If defined, at least two members.
2253 SCM l = scm_reverse_x ($1, SCM_EOL);
2256 (scm_object_property (scm_car (l),
2257 ly_symbol2scm ("is-grob?"))))
2258 l = scm_cons (ly_symbol2scm ("Bottom"), l);
2259 if (scm_is_null (l) || scm_is_null (scm_cdr (l))) {
2260 parser->parser_error (@1, _ ("bad grob property path"));
2267 // If defined, at least three members
2271 if (!SCM_UNBNDP ($1) && scm_is_null (scm_cddr ($1)))
2273 parser->parser_error (@1, _ ("bad grob property path"));
2277 | grob_prop_spec property_path
2279 if (!SCM_UNBNDP ($1)) {
2280 $$ = scm_append_x (scm_list_2 ($1, $2));
2281 if (scm_is_null (scm_cddr ($$))) {
2282 parser->parser_error (@$, _ ("bad grob property path"));
2290 // Exactly two elements or undefined
2294 SCM l = scm_reverse_x ($1, SCM_EOL);
2295 switch (scm_ilength (l)) {
2297 l = scm_cons (ly_symbol2scm ("Bottom"), l);
2301 parser->parser_error (@1, _ ("bad context property path"));
2308 simple_music_property_def:
2309 OVERRIDE grob_prop_path '=' scalar {
2310 if (SCM_UNBNDP ($2))
2313 $$ = scm_list_5 (scm_car ($2),
2314 ly_symbol2scm ("OverrideProperty"),
2320 | REVERT simple_revert_context revert_arg {
2321 $$ = scm_list_4 ($2,
2322 ly_symbol2scm ("RevertProperty"),
2326 | SET context_prop_spec '=' scalar {
2327 if (SCM_UNBNDP ($2))
2330 $$ = scm_list_4 (scm_car ($2),
2331 ly_symbol2scm ("PropertySet"),
2335 | UNSET context_prop_spec {
2336 if (SCM_UNBNDP ($2))
2339 $$ = scm_list_3 (scm_car ($2),
2340 ly_symbol2scm ("PropertyUnset"),
2346 // This is all quite awkward for the sake of substantial backward
2347 // compatibility while at the same time allowing a more "natural" form
2348 // of specification not separating grob specification from grob
2349 // property path. The purpose of this definition of
2350 // simple_revert_context is to allow the symbol list which specifies
2351 // grob and property to revert to be optionally be split into two
2352 // parts after the grob (which may be preceded by a context
2353 // specification, a case which we distinguish by checking whether the
2354 // first symbol is a valid grob symbol instead).
2356 // See revert_arg above for the main work horse of this arrangement.
2357 // simple_revert_context just caters for the context and delegates the
2358 // rest of the job to revert_arg.
2360 simple_revert_context:
2363 $1 = scm_reverse_x ($1, SCM_EOL);
2364 if (scm_is_null ($1)
2366 (scm_object_property (scm_car ($1),
2367 ly_symbol2scm ("is-grob?")))) {
2368 $$ = ly_symbol2scm ("Bottom");
2369 parser->lexer_->push_extra_token (SCM_IDENTIFIER, $1);
2372 parser->lexer_->push_extra_token (SCM_IDENTIFIER,
2379 simple_music_property_def {
2380 if (SCM_UNBNDP ($1))
2381 $$ = MAKE_SYNTAX ("void-music", @1);
2383 $$ = LOWLEVEL_MAKE_SYNTAX (ly_lily_module_constant ("property-operation"), scm_cons2 (parser->self_scm (), make_input (@$), $1));
2394 simple_string: STRING {
2399 if (scm_is_string ($1)) {
2402 parser->parser_error (@1, (_ ("simple string expected")));
2403 $$ = scm_string (SCM_EOL);
2410 $$ = scm_string_to_symbol ($1);
2414 // This is a bit of overkill but makes the same
2415 // routine responsible for all symbol interpretations.
2416 $$ = try_string_variants (ly_lily_module_constant ("symbol?"),
2418 if (SCM_UNBNDP ($$))
2420 parser->parser_error (@1, (_ ("symbol expected")));
2421 // Generate a unique symbol in case it is used
2422 // for an assignment or similar
2423 $$ = scm_make_symbol (ly_string2scm ("undefined"));
2432 // The following is a rather defensive variant of admitting
2433 // negative numbers: the grammar would permit number_factor or
2434 // even number_expression. However, function arguments allow
2435 // only this simple kind of negative number, so to have things
2436 // like \tweak and \override behave reasonably similar, it
2437 // makes sense to rule out things like -- which are rather an
2438 // accent in function argument contexts.
2441 $$ = scm_difference ($2, SCM_UNDEFINED);
2449 embedded_scm_arg_closed
2451 // for scalar_closed to be an actually closed (no lookahead)
2452 // expression, we'd need to use bare_number_closed here. It
2453 // turns out that the only use of scalar_closed in TEMPO is
2454 // not of the kind requiring the full closedness criterion.
2458 $$ = scm_difference ($2, SCM_UNDEFINED);
2467 simple_element post_events {
2468 // Let the rhythmic music iterator sort this mess out.
2469 if (scm_is_pair ($2)) {
2470 $$ = make_music_from_simple (parser, @1, $1);
2471 if (unsmob_music ($$))
2472 unsmob_music ($$)->set_property ("articulations",
2473 scm_reverse_x ($2, SCM_EOL));
2475 parser->parser_error (@1, _("music expected"));
2478 | simple_chord_elements post_events {
2479 SCM elts = ly_append2 ($1, scm_reverse_x ($2, SCM_EOL));
2482 /* why is this giving wrong start location? -ns
2484 i.set_location (@1, @2);
2485 $$ = MAKE_SYNTAX ("event-chord", i, elts);
2487 | CHORD_REPETITION optional_notemode_duration post_events {
2489 i.set_location (@1, @3);
2490 $$ = MAKE_SYNTAX ("repetition-chord", i,
2491 $2, scm_reverse_x ($3, SCM_EOL));
2493 | MULTI_MEASURE_REST optional_notemode_duration post_events {
2495 i.set_location (@1, @3);
2496 $$ = MAKE_SYNTAX ("multi-measure-rest", i, $2,
2497 scm_reverse_x ($3, SCM_EOL));
2500 | note_chord_element
2505 chord_body optional_notemode_duration post_events
2507 Music *m = unsmob_music ($1);
2508 SCM dur = unsmob_duration ($2)->smobbed_copy ();
2509 SCM es = m->get_property ("elements");
2510 SCM postevs = scm_reverse_x ($3, SCM_EOL);
2512 for (SCM s = es; scm_is_pair (s); s = scm_cdr (s))
2513 unsmob_music (scm_car (s))->set_property ("duration", dur);
2514 es = ly_append2 (es, postevs);
2516 m-> set_property ("elements", es);
2518 $$ = m->self_scm ();
2523 ANGLE_OPEN chord_body_elements ANGLE_CLOSE
2525 $$ = MAKE_SYNTAX ("event-chord", @$, scm_reverse_x ($2, SCM_EOL));
2529 chord_body_elements:
2530 /* empty */ { $$ = SCM_EOL; }
2531 | chord_body_elements chord_body_element {
2532 if (!SCM_UNBNDP ($2))
2533 $$ = scm_cons ($2, $1);
2538 pitch exclamations questions octave_check post_events
2540 bool q = to_boolean ($3);
2541 bool ex = to_boolean ($2);
2545 Music *n = MY_MAKE_MUSIC ("NoteEvent", @$);
2546 n->set_property ("pitch", $1);
2548 n->set_property ("cautionary", SCM_BOOL_T);
2550 n->set_property ("force-accidental", SCM_BOOL_T);
2552 if (scm_is_pair (post)) {
2553 SCM arts = scm_reverse_x (post, SCM_EOL);
2554 n->set_property ("articulations", arts);
2556 if (scm_is_number (check))
2558 int q = scm_to_int (check);
2559 n->set_property ("absolute-octave", scm_from_int (q-1));
2562 $$ = n->unprotect ();
2564 | DRUM_PITCH post_events {
2565 Music *n = MY_MAKE_MUSIC ("NoteEvent", @$);
2566 n->set_property ("drum-type", $1);
2568 if (scm_is_pair ($2)) {
2569 SCM arts = scm_reverse_x ($2, SCM_EOL);
2570 n->set_property ("articulations", arts);
2572 $$ = n->unprotect ();
2574 | music_function_chord_body
2576 Music *m = unsmob_music ($1);
2578 while (m && m->is_mus_type ("music-wrapper-music")) {
2579 $$ = m->get_property ("element");
2580 m = unsmob_music ($$);
2583 if (!(m && m->is_mus_type ("rhythmic-event"))) {
2584 parser->parser_error (@$, _ ("not a rhythmic event"));
2590 music_function_chord_body:
2595 // Event functions may only take closed arglists, otherwise it would
2596 // not be clear whether a following postevent should be associated
2597 // with the last argument of the event function or with the expression
2598 // for which the function call acts itself as event.
2600 music_function_call_closed:
2601 MUSIC_FUNCTION function_arglist_closed {
2602 $$ = MAKE_SYNTAX ("music-function", @$,
2607 event_function_event:
2608 EVENT_FUNCTION function_arglist_closed {
2609 $$ = MAKE_SYNTAX ("music-function", @$,
2631 | post_events post_event {
2633 if (Music *m = unsmob_music ($2))
2635 if (m->is_mus_type ("post-event-wrapper"))
2637 for (SCM p = m->get_property ("elements");
2641 $$ = scm_cons (scm_car (p), $$);
2645 $$ = scm_cons ($2, $$);
2651 post_event_nofinger:
2652 direction_less_event {
2655 | script_dir music_function_call_closed {
2657 if (!unsmob_music ($2)->is_mus_type ("post-event")) {
2658 parser->parser_error (@2, _ ("post-event expected"));
2659 $$ = SCM_UNSPECIFIED;
2660 } else if (!SCM_UNBNDP ($1))
2662 unsmob_music ($$)->set_property ("direction", $1);
2666 if (!parser->lexer_->is_lyric_state ())
2667 parser->parser_error (@1, _ ("have to be in Lyric mode for lyrics"));
2668 $$ = MY_MAKE_MUSIC ("HyphenEvent", @$)->unprotect ();
2671 if (!parser->lexer_->is_lyric_state ())
2672 parser->parser_error (@1, _ ("have to be in Lyric mode for lyrics"));
2673 $$ = MY_MAKE_MUSIC ("ExtenderEvent", @$)->unprotect ();
2675 | script_dir direction_reqd_event {
2676 if (!SCM_UNBNDP ($1))
2678 Music *m = unsmob_music ($2);
2679 m->set_property ("direction", $1);
2683 | script_dir direction_less_event {
2684 if (!SCM_UNBNDP ($1))
2686 Music *m = unsmob_music ($2);
2687 m->set_property ("direction", $1);
2694 unsmob_music ($$)->set_property ("direction", scm_from_int (UP));
2699 unsmob_music ($$)->set_property ("direction", scm_from_int (DOWN));
2710 string_number_event:
2712 Music *s = MY_MAKE_MUSIC ("StringNumberEvent", @$);
2713 s->set_property ("string-number", $1);
2714 $$ = s->unprotect ();
2718 direction_less_event:
2720 | EVENT_IDENTIFIER {
2724 Music *a = MY_MAKE_MUSIC ("TremoloEvent", @$);
2725 a->set_property ("tremolo-type", $1);
2726 $$ = a->unprotect ();
2728 | event_function_event
2731 direction_reqd_event:
2735 | script_abbreviation {
2736 SCM s = parser->lexer_->lookup_identifier ("dash" + ly_scm2string ($1));
2737 Music *a = MY_MAKE_MUSIC ("ArticulationEvent", @$);
2738 if (scm_is_string (s))
2739 a->set_property ("articulation-type", s);
2740 else parser->parser_error (@1, _ ("expecting string as script definition"));
2741 $$ = a->unprotect ();
2746 /**/ { $$ = SCM_EOL; }
2747 | '=' quotes { $$ = $2; }
2761 $$ = scm_from_int (1);
2764 $$ = scm_oneplus ($1);
2770 $$ = scm_from_int (-1);
2773 $$ = scm_oneminus ($1);
2778 NOTENAME_PITCH quotes {
2779 if (!scm_is_eq (SCM_INUM0, $2))
2781 Pitch p = *unsmob_pitch ($1);
2782 p = p.transposed (Pitch (scm_to_int ($2),0,0));
2783 $$ = p.smobbed_copy ();
2793 TONICNAME_PITCH quotes {
2794 if (!scm_is_eq (SCM_INUM0, $2))
2796 Pitch p = *unsmob_pitch ($1);
2797 p = p.transposed (Pitch (scm_to_int ($2),0,0));
2798 $$ = p.smobbed_copy ();
2808 pitch_also_in_chords:
2815 Music *t = MY_MAKE_MUSIC ("TextScriptEvent", @$);
2816 t->set_property ("text", $1);
2817 $$ = t->unprotect ();
2820 Music *t = MY_MAKE_MUSIC ("TextScriptEvent", @$);
2821 t->set_property ("text",
2822 make_simple_markup ($1));
2823 $$ = t->unprotect ();
2825 | embedded_scm_closed
2827 Music *m = unsmob_music ($1);
2828 if (m && m->is_mus_type ("post-event"))
2830 else if (Text_interface::is_markup ($1)) {
2831 Music *t = MY_MAKE_MUSIC ("TextScriptEvent", @$);
2832 t->set_property ("text", $1);
2833 $$ = t->unprotect ();
2835 parser->parser_error (@1, _ ("not an articulation"));
2841 Music *t = MY_MAKE_MUSIC ("FingeringEvent", @$);
2842 t->set_property ("digit", $1);
2843 $$ = t->unprotect ();
2847 script_abbreviation:
2849 $$ = scm_from_locale_string ("Hat");
2852 $$ = scm_from_locale_string ("Plus");
2855 $$ = scm_from_locale_string ("Dash");
2858 $$ = scm_from_locale_string ("Bang");
2861 $$ = scm_from_locale_string ("Larger");
2864 $$ = scm_from_locale_string ("Dot");
2867 $$ = scm_from_locale_string ("Underscore");
2872 '_' { $$ = scm_from_int (DOWN); }
2873 | '^' { $$ = scm_from_int (UP); }
2874 | '-' { $$ = SCM_UNDEFINED; }
2878 multiplied_duration {
2883 maybe_notemode_duration:
2887 | multiplied_duration {
2889 parser->default_duration_ = *unsmob_duration ($$);
2894 optional_notemode_duration:
2895 maybe_notemode_duration
2897 if (SCM_UNBNDP ($$))
2898 $$ = parser->default_duration_.smobbed_copy ();
2904 $$ = make_duration ($1, scm_to_int ($2));
2905 if (SCM_UNBNDP ($$))
2907 parser->parser_error (@1, _ ("not a duration"));
2908 $$ = Duration ().smobbed_copy ();
2911 | DURATION_IDENTIFIER dots {
2912 Duration *d = unsmob_duration ($1);
2913 Duration k (d->duration_log (),
2914 d->dot_count () + scm_to_int ($2));
2915 k = k.compressed (d->factor ());
2916 scm_remember_upto_here_1 ($1);
2917 $$ = k.smobbed_copy ();
2921 multiplied_duration:
2925 | multiplied_duration '*' UNSIGNED {
2926 $$ = unsmob_duration ($$)->compressed (scm_to_int ($3)).smobbed_copy ();
2928 | multiplied_duration '*' FRACTION {
2929 Rational m (scm_to_int (scm_car ($3)), scm_to_int (scm_cdr ($3)));
2931 $$ = unsmob_duration ($$)->compressed (m).smobbed_copy ();
2940 $$ = scm_oneplus ($1);
2949 if (SCM_UNBNDP (make_duration ($2)))
2950 parser->parser_error (@2, _ ("not a duration"));
2956 UNSIGNED { $$ = $1; }
2957 | STRING { $$ = $1; }
2958 | full_markup { $$ = $1; }
2961 // as an integer, it needs to be non-negative, and otherwise
2962 // it needs to be suitable as a markup.
2963 if (scm_is_integer ($1)
2964 ? scm_is_true (scm_negative_p ($1))
2965 : !Text_interface::is_markup ($1))
2967 parser->parser_error (@1, _ ("bass number expected"));
2973 figured_bass_alteration:
2974 '-' { $$ = ly_rational2scm (FLAT_ALTERATION); }
2975 | '+' { $$ = ly_rational2scm (SHARP_ALTERATION); }
2976 | '!' { $$ = scm_from_int (0); }
2981 Music *bfr = MY_MAKE_MUSIC ("BassFigureEvent", @$);
2982 $$ = bfr->unprotect ();
2985 Music *bfr = MY_MAKE_MUSIC ("BassFigureEvent", @$);
2986 $$ = bfr->self_scm ();
2988 if (scm_is_number ($1))
2989 bfr->set_property ("figure", $1);
2990 else if (Text_interface::is_markup ($1))
2991 bfr->set_property ("text", $1);
2997 unsmob_music ($1)->set_property ("bracket-stop", SCM_BOOL_T);
2999 | bass_figure figured_bass_alteration {
3000 Music *m = unsmob_music ($1);
3001 if (scm_to_double ($2)) {
3002 SCM salter = m->get_property ("alteration");
3003 SCM alter = scm_is_number (salter) ? salter : scm_from_int (0);
3004 m->set_property ("alteration",
3005 scm_sum (alter, $2));
3007 m->set_property ("alteration", scm_from_int (0));
3010 | bass_figure figured_bass_modification {
3011 Music *m = unsmob_music ($1);
3012 m->set_property ($2, SCM_BOOL_T);
3017 figured_bass_modification:
3019 $$ = ly_symbol2scm ("augmented");
3022 $$ = ly_symbol2scm ("no-continuation");
3025 $$ = ly_symbol2scm ("diminished");
3028 $$ = ly_symbol2scm ("augmented-slash");
3038 unsmob_music ($$)->set_property ("bracket-start", SCM_BOOL_T);
3046 | figure_list br_bass_figure {
3047 $$ = scm_cons ($2, $1);
3052 FIGURE_OPEN figure_list FIGURE_CLOSE {
3053 $$ = scm_reverse_x ($2, SCM_EOL);
3059 /**/ { $$ = SCM_BOOL_F; }
3060 | REST { $$ = SCM_BOOL_T; }
3064 pitch exclamations questions octave_check maybe_notemode_duration optional_rest {
3065 if (!parser->lexer_->is_note_state ())
3066 parser->parser_error (@1, _ ("have to be in Note mode for notes"));
3067 if (!SCM_UNBNDP ($2)
3069 || scm_is_number ($4)
3071 || scm_is_true ($6))
3074 if (scm_is_true ($6))
3075 n = MY_MAKE_MUSIC ("RestEvent", @$);
3077 n = MY_MAKE_MUSIC ("NoteEvent", @$);
3079 n->set_property ("pitch", $1);
3080 if (SCM_UNBNDP ($5))
3081 n->set_property ("duration",
3082 parser->default_duration_.smobbed_copy ());
3084 n->set_property ("duration", $5);
3086 if (scm_is_number ($4))
3088 int q = scm_to_int ($4);
3089 n->set_property ("absolute-octave", scm_from_int (q-1));
3092 if (to_boolean ($3))
3093 n->set_property ("cautionary", SCM_BOOL_T);
3094 if (to_boolean ($2) || to_boolean ($3))
3095 n->set_property ("force-accidental", SCM_BOOL_T);
3097 $$ = n->unprotect ();
3100 | DRUM_PITCH optional_notemode_duration {
3101 Music *n = MY_MAKE_MUSIC ("NoteEvent", @$);
3102 n->set_property ("duration", $2);
3103 n->set_property ("drum-type", $1);
3105 $$ = n->unprotect ();
3107 | RESTNAME optional_notemode_duration {
3109 if (ly_scm2string ($1) == "s") {
3111 ev = MY_MAKE_MUSIC ("SkipEvent", @$);
3114 ev = MY_MAKE_MUSIC ("RestEvent", @$);
3117 ev->set_property ("duration", $2);
3118 $$ = ev->unprotect ();
3122 simple_chord_elements:
3124 if (!parser->lexer_->is_chord_state ())
3125 parser->parser_error (@1, _ ("have to be in Chord mode for chords"));
3128 | figure_spec optional_notemode_duration {
3129 for (SCM s = $1; scm_is_pair (s); s = scm_cdr (s))
3131 unsmob_music (scm_car (s))->set_property ("duration", $2);
3139 if (!parser->lexer_->is_lyric_state ())
3140 parser->parser_error (@1, _ ("markup outside of text script or \\lyricmode"));
3144 if (!parser->lexer_->is_lyric_state ())
3145 parser->parser_error (@1, _ ("unrecognized string, not in text script or \\lyricmode"));
3151 lyric_element_music:
3152 lyric_element optional_notemode_duration post_events {
3153 $$ = MAKE_SYNTAX ("lyric-event", @$, $1, $2);
3154 if (scm_is_pair ($3))
3155 unsmob_music ($$)->set_property
3156 ("articulations", scm_reverse_x ($3, SCM_EOL));
3161 steno_tonic_pitch optional_notemode_duration {
3162 $$ = make_chord_elements (@$, $1, $2, SCM_EOL);
3164 | steno_tonic_pitch optional_notemode_duration chord_separator chord_items {
3165 SCM its = scm_reverse_x ($4, SCM_EOL);
3166 $$ = make_chord_elements (@$, $1, $2, scm_cons ($3, its));
3174 | chord_items chord_item {
3175 $$ = scm_cons ($2, $$);
3181 $$ = ly_symbol2scm ("chord-colon");
3184 $$ = ly_symbol2scm ("chord-caret");
3186 | CHORD_SLASH steno_tonic_pitch {
3187 $$ = scm_list_2 (ly_symbol2scm ("chord-slash"), $2);
3189 | CHORD_BASS steno_tonic_pitch {
3190 $$ = scm_list_2 (ly_symbol2scm ("chord-bass"), $2);
3199 $$ = scm_reverse_x ($1, SCM_EOL);
3207 step_number { $$ = scm_cons ($1, SCM_EOL); }
3208 | step_numbers '.' step_number {
3209 $$ = scm_cons ($3, $$);
3215 $$ = make_chord_step ($1, 0);
3218 $$ = make_chord_step ($1, SHARP_ALTERATION);
3220 | UNSIGNED CHORD_MINUS {
3221 $$ = make_chord_step ($1, FLAT_ALTERATION);
3229 | UNSIGNED '-' UNSIGNED {
3230 $$ = scm_cons ($1, $3);
3237 TODO: should deprecate in favor of Scheme?
3241 number_expression '+' number_term {
3242 $$ = scm_sum ($1, $3);
3244 | number_expression '-' number_term {
3245 $$ = scm_difference ($1, $3);
3254 | number_factor '*' number_factor {
3255 $$ = scm_product ($1, $3);
3257 | number_factor '/' number_factor {
3258 $$ = scm_divide ($1, $3);
3263 '-' number_factor { /* %prec UNARY_MINUS */
3264 $$ = scm_difference ($2, SCM_UNDEFINED);
3270 bare_number_common_closed
3271 | REAL NUMBER_IDENTIFIER
3273 $$ = scm_product ($1, $2);
3277 bare_number_common_closed:
3285 | UNSIGNED NUMBER_IDENTIFIER {
3286 $$ = scm_product ($1, $2);
3292 | bare_number_common_closed
3301 { $$ = SCM_UNDEFINED; }
3304 if (SCM_UNBNDP ($1))
3312 { $$ = SCM_UNDEFINED; }
3315 if (SCM_UNBNDP ($1))
3324 { parser->lexer_->push_markup_state (); }
3327 parser->lexer_->pop_state ();
3333 { parser->lexer_->push_markup_state (); }
3336 parser->lexer_->pop_state ();
3341 simple_markup_list {
3342 $$ = scm_list_2 (ly_lily_module_constant ("line-markup"), $1);
3344 | markup_head_1_list simple_markup
3346 $$ = scm_car (MAKE_SYNTAX ("composed-markup-list",
3347 @2, $1, scm_list_1 ($2)));
3357 if (Text_interface::is_markup ($1))
3358 MYBACKUP (MARKUP_IDENTIFIER, $1, @1);
3359 else if (Text_interface::is_markup_list ($1))
3360 MYBACKUP (MARKUPLIST_IDENTIFIER, $1, @1);
3362 parser->parser_error (@1, _ ("not a markup"));
3363 MYBACKUP (MARKUP_IDENTIFIER, scm_string (SCM_EOL), @1);
3370 markup_composed_list {
3373 | markup_uncomposed_list
3376 markup_uncomposed_list:
3377 markup_braced_list {
3380 | markup_command_list {
3381 $$ = scm_list_1 ($1);
3383 | markup_scm MARKUPLIST_IDENTIFIER
3393 $$ = scm_list_1 (scm_list_2 (ly_lily_module_constant ("score-lines-markup-list"), $1));
3399 SCM nn = parser->lexer_->lookup_identifier ("pitchnames");
3400 parser->lexer_->push_note_state (nn);
3401 } '{' score_body '}' {
3403 parser->lexer_->pop_state ();
3407 markup_composed_list:
3408 markup_head_1_list markup_uncomposed_list {
3409 $$ = MAKE_SYNTAX ("composed-markup-list",
3415 '{' markup_braced_list_body '}' {
3416 $$ = scm_reverse_x ($2, SCM_EOL);
3420 markup_braced_list_body:
3421 /* empty */ { $$ = SCM_EOL; }
3422 | markup_braced_list_body markup {
3423 $$ = scm_cons ($2, $1);
3425 | markup_braced_list_body simple_markup_list {
3426 $$ = scm_reverse_x ($2, $1);
3430 markup_command_list:
3431 MARKUP_LIST_FUNCTION markup_command_list_arguments {
3432 $$ = scm_cons ($1, scm_reverse_x($2, SCM_EOL));
3436 markup_command_basic_arguments:
3437 EXPECT_MARKUP_LIST markup_command_list_arguments markup_list {
3438 $$ = scm_cons ($3, $2);
3440 | EXPECT_SCM markup_command_list_arguments embedded_scm_closed {
3441 $$ = check_scheme_arg (parser, @3, $3, $2, $1);
3443 | EXPECT_NO_MORE_ARGS {
3448 markup_command_list_arguments:
3449 markup_command_basic_arguments { $$ = $1; }
3450 | EXPECT_MARKUP markup_command_list_arguments markup {
3451 $$ = scm_cons ($3, $2);
3456 MARKUP_FUNCTION EXPECT_MARKUP markup_command_list_arguments {
3457 $$ = scm_cons ($1, scm_reverse_x ($3, SCM_EOL));
3462 markup_head_1_item {
3463 $$ = scm_list_1 ($1);
3465 | markup_head_1_list markup_head_1_item {
3466 $$ = scm_cons ($2, $1);
3472 $$ = make_simple_markup ($1);
3474 | MARKUP_FUNCTION markup_command_basic_arguments {
3475 $$ = scm_cons ($1, scm_reverse_x ($2, SCM_EOL));
3477 | markup_scm MARKUP_IDENTIFIER
3483 $$ = scm_list_2 (ly_lily_module_constant ("score-markup"), $1);
3488 markup_head_1_list simple_markup
3490 $$ = scm_car (MAKE_SYNTAX ("composed-markup-list",
3491 @2, $1, scm_list_1 ($2)));
3501 Lily_parser::set_yydebug (bool x)
3507 Lily_parser::do_yyparse ()
3509 SCM retval = SCM_UNDEFINED;
3510 yyparse (this, &retval);
3520 It is a little strange to have this function in this file, but
3521 otherwise, we have to import music classes into the lexer.
3525 Lily_lexer::try_special_identifiers (SCM *destination, SCM sid)
3527 if (unsmob_book (sid)) {
3528 Book *book = unsmob_book (sid)->clone ();
3529 *destination = book->self_scm ();
3532 return BOOK_IDENTIFIER;
3533 } else if (scm_is_number (sid)) {
3535 return NUMBER_IDENTIFIER;
3536 } else if (unsmob_context_def (sid)) {
3537 Context_def *def= unsmob_context_def (sid)->clone ();
3539 *destination = def->self_scm ();
3542 return CONTEXT_DEF_IDENTIFIER;
3543 } else if (unsmob_context_mod (sid)) {
3544 *destination = unsmob_context_mod (sid)->smobbed_copy ();
3546 return CONTEXT_MOD_IDENTIFIER;
3547 } else if (Music *mus = unsmob_music (sid)) {
3548 mus = mus->clone ();
3549 *destination = mus->self_scm ();
3550 bool is_event = mus->is_mus_type ("post-event");
3552 return is_event ? EVENT_IDENTIFIER : MUSIC_IDENTIFIER;
3553 } else if (unsmob_pitch (sid)) {
3554 *destination = unsmob_pitch (sid)->smobbed_copy ();
3555 return PITCH_IDENTIFIER;
3556 } else if (unsmob_duration (sid)) {
3557 *destination = unsmob_duration (sid)->smobbed_copy ();
3558 return DURATION_IDENTIFIER;
3559 } else if (unsmob_output_def (sid)) {
3560 Output_def *p = unsmob_output_def (sid);
3563 *destination = p->self_scm ();
3565 return OUTPUT_DEF_IDENTIFIER;
3572 get_next_unique_context_id ()
3574 return scm_from_locale_string ("$uniqueContextId");
3579 get_next_unique_lyrics_context_id ()
3581 static int new_context_count;
3583 snprintf (s, sizeof (s)-1, "uniqueContext%d", new_context_count++);
3584 return scm_from_locale_string (s);
3587 // check_scheme_arg checks one argument with a given predicate for use
3588 // in an argument list and throws a syntax error if it is unusable.
3589 // The argument is prepended to the argument list in any case. After
3590 // throwing a syntax error, the argument list is terminated with #f as
3591 // its last cdr in order to mark it as uncallable while not losing
3592 // track of its total length.
3594 // There are a few special considerations: if optional argument disp
3595 // is given (otherwise it defaults to SCM_UNDEFINED), it will be used
3596 // instead of arg in a prospective error message. This is useful if
3597 // arg is not the actual argument but rather a transformation of it.
3599 // If arg itself is SCM_UNDEFINED, the predicate is considered false
3600 // and an error message using disp is produced unconditionally.
3602 SCM check_scheme_arg (Lily_parser *parser, Input loc,
3603 SCM arg, SCM args, SCM pred, SCM disp)
3605 if (SCM_UNBNDP (arg))
3606 args = scm_cons (disp, args);
3608 args = scm_cons (arg, args);
3609 if (scm_is_true (scm_call_1 (pred, arg)))
3612 scm_set_cdr_x (scm_last_pair (args), SCM_EOL);
3613 MAKE_SYNTAX ("argument-error", loc, scm_length (args), pred,
3614 SCM_UNBNDP (disp) ? arg : disp);
3615 scm_set_cdr_x (scm_last_pair (args), SCM_BOOL_F);
3619 SCM loc_on_music (Input loc, SCM arg)
3621 if (Music *m = unsmob_music (arg))
3625 return m->unprotect ();
3631 try_string_variants (SCM pred, SCM str)
3633 // a matching predicate is always ok
3634 if (scm_is_true (scm_call_1 (pred, str)))
3636 // a symbol may be interpreted as a list of symbols if it helps
3637 if (scm_is_symbol (str)) {
3638 str = scm_list_1 (str);
3639 if (scm_is_true (scm_call_1 (pred, str)))
3641 return SCM_UNDEFINED;
3644 // If this cannot be a string representation of a symbol list,
3647 if (!is_regular_identifier (str, true))
3648 return SCM_UNDEFINED;
3650 str = scm_string_split (str, SCM_MAKE_CHAR ('.'));
3651 for (SCM p = str; scm_is_pair (p); p = scm_cdr (p))
3652 scm_set_car_x (p, scm_string_to_symbol (scm_car (p)));
3654 // Let's attempt the symbol list interpretation first.
3656 if (scm_is_true (scm_call_1 (pred, str)))
3659 // If there is just one symbol in the list, we might interpret
3660 // it as a single symbol
3662 if (scm_is_null (scm_cdr (str)))
3664 str = scm_car (str);
3665 if (scm_is_true (scm_call_1 (pred, str)))
3669 return SCM_UNDEFINED;
3673 is_regular_identifier (SCM id, bool multiple)
3675 if (!scm_is_string (id))
3678 string str = ly_scm2string (id);
3680 bool middle = false;
3682 for (string::iterator it=str.begin(); it != str.end (); it++)
3685 if ((c >= 'a' && c <= 'z')
3686 || (c >= 'A' && c <= 'Z')
3689 else if (middle && (c == '-' || c == '_' || (multiple && c == '.')))
3698 make_music_from_simple (Lily_parser *parser, Input loc, SCM simple)
3700 if (unsmob_music (simple))
3702 if (parser->lexer_->is_note_state ()) {
3703 if (scm_is_symbol (simple)) {
3704 Music *n = MY_MAKE_MUSIC ("NoteEvent", loc);
3705 n->set_property ("duration", parser->default_duration_.smobbed_copy ());
3706 n->set_property ("drum-type", simple);
3707 return n->unprotect ();
3709 if (unsmob_pitch (simple)) {
3710 Music *n = MY_MAKE_MUSIC ("NoteEvent", loc);
3711 n->set_property ("duration", parser->default_duration_.smobbed_copy ());
3712 n->set_property ("pitch", simple);
3713 return n->unprotect ();
3716 } else if (parser->lexer_->is_lyric_state ()) {
3717 if (Text_interface::is_markup (simple))
3718 return MAKE_SYNTAX ("lyric-event", loc, simple,
3719 parser->default_duration_.smobbed_copy ());
3720 } else if (parser->lexer_->is_chord_state ()) {
3721 if (unsmob_pitch (simple))
3722 return make_chord_elements (loc, simple,
3723 parser->default_duration_.smobbed_copy (),
3730 make_music_with_input (SCM name, Input where)
3732 Music *m = make_music_by_name (name);
3733 m->set_spot (where);
3738 make_simple_markup (SCM a)
3744 make_duration (SCM d, int dots)
3746 int t = scm_to_int (d);
3747 if (t > 0 && (t & (t-1)) == 0)
3748 return Duration (intlog2 (t), dots).smobbed_copy ();
3750 return SCM_UNDEFINED;
3754 make_chord_step (SCM step_scm, Rational alter)
3756 int step = scm_to_int (step_scm);
3759 alter += FLAT_ALTERATION;
3763 Pitch m ((step -1) / 7, (step - 1) % 7, alter);
3764 return m.smobbed_copy ();
3769 make_chord_elements (Input loc, SCM pitch, SCM dur, SCM modification_list)
3771 SCM chord_ctor = ly_lily_module_constant ("construct-chord-elements");
3772 SCM res = scm_call_3 (chord_ctor, pitch, dur, modification_list);
3773 for (SCM s = res; scm_is_pair (s); s = scm_cdr (s))
3775 unsmob_music (scm_car (s))->set_spot (loc);
3781 yylex (YYSTYPE *s, YYLTYPE *loc, Lily_parser *parser)
3783 Lily_lexer *lex = parser->lexer_;
3787 lex->prepare_for_next_token ();
3788 return lex->yylex ();