2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 1997--2011 Han-Wen Nienhuys <hanwen@xs4all.nl>
5 Jan Nieuwenhuizen <janneke@gnu.org>
7 LilyPond is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
12 LilyPond is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
24 #define YYERROR_VERBOSE 1
25 #define YYPARSE_PARAM my_lily_parser
26 #define YYLEX_PARAM my_lily_parser
27 #define PARSER ((Lily_parser *) my_lily_parser)
29 #define yyerror PARSER->parser_error
31 /* We use custom location type: Input objects */
33 #define YYLLOC_DEFAULT(Current,Rhs,N) \
34 ((Current).set_location ((Rhs)[1], (Rhs)[N]))
39 /* We use SCMs to do strings, because it saves us the trouble of
40 deleting them. Let's hope that a stack overflow doesnt trigger a move
41 of the parse stack onto the heap. */
47 /* The above precedences tackle the shift/reduce problem
50 \repeat .. \alternative
52 \repeat { \repeat .. \alternative }
56 \repeat { \repeat } \alternative
59 %right FUNCTION_ARGUMENTS
60 MARKUP LYRICS_STRING MARKUP_IDENTIFIER STRING STRING_IDENTIFIER
61 SEQUENTIAL SIMULTANEOUS DOUBLE_ANGLE_OPEN MUSIC_IDENTIFIER '{'
62 PITCH_IDENTIFIER NOTENAME_PITCH TONICNAME_PITCH
63 SCM_FUNCTION SCM_IDENTIFIER SCM_TOKEN
64 UNSIGNED DURATION_IDENTIFIER
65 CHORDMODE CHORDS DRUMMODE DRUMS FIGUREMODE FIGURES LYRICMODE LYRICS
68 /* The above are the symbols that can start function arguments */
81 %{ // -*-Fundamental-*-
86 * The rules for who is protecting what are very shady. Uniformise
89 * There are too many lexical modes?
100 #include "context-def.hh"
101 #include "context-mod.hh"
102 #include "dimensions.hh"
103 #include "file-path.hh"
105 #include "international.hh"
106 #include "lily-guile.hh"
107 #include "lily-lexer.hh"
108 #include "lily-parser.hh"
112 #include "output-def.hh"
113 #include "paper-book.hh"
114 #include "scm-hash.hh"
116 #include "text-interface.hh"
124 Output_def *outputdef;
134 #define MY_MAKE_MUSIC(x, spot) make_music_with_input (ly_symbol2scm (x), spot)
137 - Don't use lily module, create a new module instead.
138 - delay application of the function
140 #define LOWLEVEL_MAKE_SYNTAX(proc, args) \
141 scm_apply_0 (proc, args)
142 /* Syntactic Sugar. */
143 #define MAKE_SYNTAX(name, location, ...) \
144 LOWLEVEL_MAKE_SYNTAX (ly_lily_module_constant (name), scm_list_n (PARSER->self_scm (), make_input (location), ##__VA_ARGS__, SCM_UNDEFINED));
146 SCM get_next_unique_context_id ();
147 SCM get_next_unique_lyrics_context_id ();
154 #define _(x) gettext (x)
158 static Music *make_music_with_input (SCM name, Input where);
159 SCM check_scheme_arg (Lily_parser *parser, Input loc, SCM fallback,
160 SCM arg, SCM args, SCM pred);
161 SCM loc_on_music (Input loc, SCM arg);
162 SCM get_first_context_id (SCM type, Music *m);
163 SCM make_chord_elements (SCM pitch, SCM dur, SCM modification_list);
164 SCM make_chord_step (int step, Rational alter);
165 SCM make_simple_markup (SCM a);
166 bool is_duration (int t);
167 bool is_regular_identifier (SCM id);
168 bool ly_input_procedure_p (SCM x);
169 int yylex (YYSTYPE *s, YYLTYPE *loc, void *v);
170 void set_music_properties (Music *p, SCM a);
174 /* The third option is an alias that will be used to display the
175 syntax error. Bison CVS now correctly handles backslash escapes.
177 FIXME: Bison needs to translate some of these, eg, STRING.
181 /* Keyword tokens with plain escaped name. */
182 %token ACCEPTS "\\accepts"
183 %token ADDLYRICS "\\addlyrics"
184 %token ALIAS "\\alias"
185 %token ALTERNATIVE "\\alternative"
187 %token BOOKPART "\\bookpart"
188 %token CHANGE "\\change"
189 %token CHORDMODE "\\chordmode"
190 %token CHORDS "\\chords"
191 %token CONSISTS "\\consists"
192 %token CONTEXT "\\context"
193 %token DEFAULT "\\default"
194 %token DEFAULTCHILD "\\defaultchild"
195 %token DENIES "\\denies"
196 %token DESCRIPTION "\\description"
197 %token DRUMMODE "\\drummode"
198 %token DRUMS "\\drums"
199 %token FIGUREMODE "\\figuremode"
200 %token FIGURES "\\figures"
201 %token GROBDESCRIPTIONS "\\grobdescriptions"
202 %token HEADER "\\header"
203 %token INVALID "\\version-error"
205 %token LAYOUT "\\layout"
206 %token LYRICMODE "\\lyricmode"
207 %token LYRICS "\\lyrics"
208 %token LYRICSTO "\\lyricsto"
210 %token MARKUP "\\markup"
211 %token MARKUPLINES "\\markuplines"
214 %token NOTEMODE "\\notemode"
216 %token OVERRIDE "\\override"
217 %token PAPER "\\paper"
218 %token REMOVE "\\remove"
219 %token REPEAT "\\repeat"
221 %token REVERT "\\revert"
222 %token SCORE "\\score"
223 %token SEQUENTIAL "\\sequential"
225 %token SIMULTANEOUS "\\simultaneous"
226 %token TEMPO "\\tempo"
227 %token TIMES "\\times"
229 %token UNSET "\\unset"
232 /* Keyword token exceptions. */
233 %token TIME_T "\\time"
234 %token NEWCONTEXT "\\new"
237 /* Other string tokens. */
239 %token CHORD_BASS "/+"
240 %token CHORD_CARET "^"
241 %token CHORD_COLON ":"
242 %token CHORD_MINUS "-"
243 %token CHORD_SLASH "/"
244 %token ANGLE_OPEN "<"
245 %token ANGLE_CLOSE ">"
246 %token DOUBLE_ANGLE_OPEN "<<"
247 %token DOUBLE_ANGLE_CLOSE ">>"
248 %token E_BACKSLASH "\\"
249 %token E_ANGLE_CLOSE "\\>"
250 %token E_CHAR "\\C[haracter]"
252 %token E_EXCLAMATION "\\!"
253 %token E_BRACKET_OPEN "\\["
255 %token E_BRACKET_CLOSE "\\]"
256 %token E_ANGLE_OPEN "\\<"
262 If we give names, Bison complains.
264 %token FIGURE_CLOSE /* "\\>" */
265 %token FIGURE_OPEN /* "\\<" */
266 %token FIGURE_SPACE "_"
269 %token CHORDMODIFIERS
271 %token MULTI_MEASURE_REST
274 %token <i> E_UNSIGNED
277 /* Artificial tokens, for more generic function syntax */
278 %token <i> EXPECT_MARKUP "markup?"
279 %token <i> EXPECT_MUSIC "ly:music?"
280 %token <i> EXPECT_PITCH "ly:pitch?"
281 %token <i> EXPECT_DURATION "ly:duration?"
282 %token <scm> EXPECT_SCM "scheme?"
283 %token <i> EXPECT_MARKUP_LIST "markup-list?"
284 %token <scm> EXPECT_OPTIONAL "optional?"
285 /* After the last argument. */
286 %token <i> EXPECT_NO_MORE_ARGS;
288 /* An artificial token for parsing embedded Lilypond */
289 %token <i> EMBEDDED_LILY "#{"
291 %token <scm> BOOK_IDENTIFIER
292 %token <scm> CHORDMODIFIER_PITCH
293 %token <scm> CHORD_MODIFIER
294 %token <scm> CHORD_REPETITION
295 %token <scm> CONTEXT_DEF_IDENTIFIER
296 %token <scm> CONTEXT_MOD_IDENTIFIER
297 %token <scm> DRUM_PITCH
298 %token <scm> PITCH_IDENTIFIER
299 %token <scm> DURATION_IDENTIFIER
300 %token <scm> EVENT_IDENTIFIER
301 %token <scm> EVENT_FUNCTION
302 %token <scm> FRACTION
303 %token <scm> LYRICS_STRING
304 %token <scm> LYRIC_MARKUP_IDENTIFIER
305 %token <scm> MARKUP_FUNCTION
306 %token <scm> MARKUP_LIST_FUNCTION
307 %token <scm> MARKUP_IDENTIFIER
308 %token <scm> MARKUPLINES_IDENTIFIER
309 %token <scm> MUSIC_FUNCTION
310 %token <scm> MUSIC_IDENTIFIER
311 %token <scm> NOTENAME_PITCH
312 %token <scm> NUMBER_IDENTIFIER
313 %token <scm> OUTPUT_DEF_IDENTIFIER
315 %token <scm> RESTNAME
316 %token <scm> SCM_FUNCTION
317 %token <scm> SCM_IDENTIFIER
318 %token <scm> SCM_TOKEN
319 %token <scm> SCORE_IDENTIFIER
321 %token <scm> STRING_IDENTIFIER
322 %token <scm> TONICNAME_PITCH
325 %type <book> book_block
326 %type <book> book_body
327 %type <book> bookpart_block
328 %type <book> bookpart_body
330 %type <i> bare_unsigned
331 %type <scm> figured_bass_alteration
333 %type <i> exclamations
334 %type <i> optional_rest
339 %type <i> tremolo_type
342 %type <scm> composite_music
343 %type <scm> grouped_music_list
344 %type <scm> braced_music_list
345 %type <scm> closed_music
347 %type <scm> complex_music
348 %type <scm> mode_changed_music
349 %type <scm> repeated_music
350 %type <scm> sequential_music
351 %type <scm> simple_music
352 %type <scm> simultaneous_music
353 %type <scm> chord_body
354 %type <scm> chord_body_element
355 %type <scm> command_element
356 %type <scm> command_event
357 %type <scm> context_modification
358 %type <scm> context_change
359 %type <scm> direction_less_event
360 %type <scm> direction_reqd_event
361 %type <scm> embedded_lilypond
362 %type <scm> event_chord
363 %type <scm> fingering
364 %type <scm> gen_text_def
365 %type <scm> music_property_def
366 %type <scm> note_chord_element
367 %type <scm> post_event
368 %type <scm> post_event_nofinger
369 %type <scm> re_rhythmed_music
370 %type <scm> simple_element
371 %type <scm> simple_music_property_def
372 %type <scm> start_symbol
373 %type <scm> string_number_event
374 %type <scm> tempo_event
376 %type <outputdef> output_def_body
377 %type <outputdef> output_def_head
378 %type <outputdef> output_def_head_with_mode_switch
379 %type <outputdef> output_def
380 %type <outputdef> paper_block
382 %type <scm> music_function_call
383 %type <scm> music_list
384 %type <scm> assignment_id
385 %type <scm> bare_number
386 %type <scm> unsigned_number
387 %type <scm> bass_figure
388 %type <scm> figured_bass_modification
389 %type <scm> br_bass_figure
390 %type <scm> bass_number
391 %type <scm> chord_body_elements
392 %type <scm> chord_item
393 %type <scm> chord_items
394 %type <scm> chord_separator
395 %type <scm> context_def_mod
396 %type <scm> context_def_spec_block
397 %type <scm> context_def_spec_body
398 %type <scm> context_mod
399 %type <scm> context_mod_list
400 %type <scm> context_prop_spec
401 %type <scm> direction_less_char
402 %type <scm> duration_length
403 %type <scm> embedded_scm
404 %type <scm> embedded_scm_bare
405 %type <scm> embedded_scm_closed
406 %type <scm> embedded_scm_chord_body
407 %type <scm> embedded_scm_event
408 %type <scm> event_function_event
409 %type <scm> figure_list
410 %type <scm> figure_spec
412 %type <scm> full_markup
413 %type <scm> full_markup_list
414 %type <scm> function_arglist
415 %type <scm> function_arglist_optional
416 %type <scm> function_arglist_keep
417 %type <scm> function_arglist_bare
418 %type <scm> function_arglist_closed
419 %type <scm> function_arglist_closed_optional
420 %type <scm> function_arglist_closed_keep
421 %type <scm> identifier_init
423 %type <scm> lilypond_header
424 %type <scm> lilypond_header_body
425 %type <scm> lyric_element
426 %type <scm> lyric_markup
428 %type <scm> markup_braced_list
429 %type <scm> markup_braced_list_body
430 %type <scm> markup_composed_list
431 %type <scm> markup_command_list
432 %type <scm> markup_command_list_arguments
433 %type <scm> markup_command_basic_arguments
434 %type <scm> markup_head_1_item
435 %type <scm> markup_head_1_list
436 %type <scm> markup_list
437 %type <scm> markup_top
438 %type <scm> mode_changing_head
439 %type <scm> mode_changing_head_with_context
440 %type <scm> multiplied_duration
441 %type <scm> music_function_event
442 %type <scm> music_function_event_arglist
443 %type <scm> music_function_chord_body
444 %type <scm> music_function_chord_body_arglist
445 %type <scm> new_chord
446 %type <scm> new_lyrics
447 %type <scm> number_expression
448 %type <scm> number_factor
449 %type <scm> number_term
450 %type <scm> octave_check
451 %type <scm> optional_context_mod
452 %type <scm> optional_id
453 %type <scm> optional_notemode_duration
455 %type <scm> pitch_also_in_chords
456 %type <scm> post_events
457 %type <scm> property_operation
458 %type <scm> property_path property_path_revved
460 %type <scm> scalar_bare
461 %type <scm> scalar_closed
462 %type <scm> scm_function_call
463 %type <scm> scm_function_call_closed
464 %type <scm> script_abbreviation
465 %type <scm> simple_chord_elements
466 %type <scm> simple_markup
467 %type <scm> simple_string
468 %type <scm> steno_duration
469 %type <scm> steno_pitch
470 %type <scm> steno_tonic_pitch
471 %type <scm> step_number
472 %type <scm> step_numbers
474 %type <scm> tempo_range
476 %type <score> score_block
477 %type <score> score_body
482 /* We don't assign precedence to / and *, because we might need varied
483 prec levels in different prods */
492 SCM nn = PARSER->lexer_->lookup_identifier ("pitchnames");
493 PARSER->lexer_->push_note_state (alist_to_hashq (nn));
494 } embedded_lilypond {
495 PARSER->lexer_->pop_state ();
496 PARSER->lexer_->set_identifier (ly_symbol2scm ("parseStringResult"), $3);
500 lilypond: /* empty */ { }
501 | lilypond toplevel_expression {
503 | lilypond assignment {
506 PARSER->error_level_ = 1;
509 PARSER->error_level_ = 1;
516 PARSER->lexer_->set_identifier (ly_symbol2scm ("$defaultheader"), $1);
520 SCM proc = PARSER->lexer_->lookup_identifier ("toplevel-book-handler");
521 scm_call_2 (proc, PARSER->self_scm (), book->self_scm ());
526 SCM proc = PARSER->lexer_->lookup_identifier ("toplevel-bookpart-handler");
527 scm_call_2 (proc, PARSER->self_scm (), bookpart->self_scm ());
528 bookpart->unprotect ();
533 SCM proc = PARSER->lexer_->lookup_identifier ("toplevel-score-handler");
534 scm_call_2 (proc, PARSER->self_scm (), score->self_scm ());
538 Music *music = unsmob_music ($1);
539 SCM proc = PARSER->lexer_->lookup_identifier ("toplevel-music-handler");
540 scm_call_2 (proc, PARSER->self_scm (), music->self_scm ());
543 SCM proc = PARSER->lexer_->lookup_identifier ("toplevel-text-handler");
544 scm_call_2 (proc, PARSER->self_scm (), scm_list_1 ($1));
547 SCM proc = PARSER->lexer_->lookup_identifier ("toplevel-text-handler");
548 scm_call_2 (proc, PARSER->self_scm (), $1);
552 Output_def * od = $1;
554 if ($1->c_variable ("is-paper") == SCM_BOOL_T)
555 id = ly_symbol2scm ("$defaultpaper");
556 else if ($1->c_variable ("is-midi") == SCM_BOOL_T)
557 id = ly_symbol2scm ("$defaultmidi");
558 else if ($1->c_variable ("is-layout") == SCM_BOOL_T)
559 id = ly_symbol2scm ("$defaultlayout");
561 PARSER->lexer_->set_identifier (id, od->self_scm ());
571 /* The generic version may end in music, or not */
579 SCM_FUNCTION function_arglist {
580 $$ = MAKE_SYNTAX ("music-function", @$,
588 $$ = MAKE_SYNTAX ("void-music", @$);
591 | music music music_list {
592 $$ = MAKE_SYNTAX ("sequential-music", @$,
593 scm_cons2 ($1, $2, scm_reverse_x ($3, SCM_EOL)));
596 PARSER->error_level_ = 1;
598 | INVALID embedded_lilypond {
599 PARSER->error_level_ = 1;
604 lilypond_header_body:
606 $$ = get_header (PARSER);
607 PARSER->lexer_->add_scope ($$);
609 | lilypond_header_body assignment {
615 HEADER '{' lilypond_header_body '}' {
616 $$ = PARSER->lexer_->remove_scope ();
625 | LYRICS_STRING { $$ = $1; }
629 assignment_id '=' identifier_init {
630 PARSER->lexer_->set_identifier ($1, $3);
632 | assignment_id property_path '=' identifier_init {
633 SCM path = scm_cons (scm_string_to_symbol ($1), $2);
634 PARSER->lexer_->set_identifier (path, $4);
637 TODO: devise standard for protection in parser.
639 The parser stack lives on the C-stack, which means that
640 all objects can be unprotected as soon as they're here.
650 $$ = $1->self_scm ();
654 $$ = $1->self_scm ();
658 $$ = $1->self_scm ();
662 $$ = $1->self_scm ();
665 | context_def_spec_block {
669 /* Hack: Create event-chord around standalone events.
670 Prevents the identifier from being interpreted as a post-event. */
671 Music *mus = unsmob_music ($1);
672 bool is_event = mus &&
673 (scm_memq (ly_symbol2scm ("event"), mus->get_property ("types"))
678 $$ = MAKE_SYNTAX ("event-chord", @$, scm_list_1 ($1));
680 | post_event_nofinger {
683 | number_expression {
698 | context_modification {
703 context_def_spec_block:
704 CONTEXT '{' context_def_spec_body '}'
710 context_def_spec_body:
712 $$ = Context_def::make_scm ();
713 unsmob_context_def ($$)->origin ()->set_spot (@$);
715 | CONTEXT_DEF_IDENTIFIER {
717 unsmob_context_def ($$)->origin ()->set_spot (@$);
719 | context_def_spec_body GROBDESCRIPTIONS embedded_scm {
720 Context_def*td = unsmob_context_def ($$);
722 for (SCM p = $3; scm_is_pair (p); p = scm_cdr (p)) {
723 SCM tag = scm_caar (p);
725 /* TODO: should make new tag "grob-definition" ? */
726 td->add_context_mod (scm_list_3 (ly_symbol2scm ("assign"),
727 tag, scm_cons (scm_cdar (p), SCM_EOL)));
730 | context_def_spec_body context_mod {
731 unsmob_context_def ($$)->add_context_mod ($2);
733 | context_def_spec_body context_modification {
734 Context_def *td = unsmob_context_def ($$);
735 SCM new_mods = unsmob_context_mod ($2)->get_mods ();
736 for (SCM m = new_mods; scm_is_pair (m); m = scm_cdr (m)) {
737 td->add_context_mod (scm_car (m));
745 BOOK '{' book_body '}' {
748 PARSER->lexer_->set_identifier (ly_symbol2scm ("$current-book"), SCM_BOOL_F);
753 * Use 'handlers' like for toplevel-* stuff?
754 * grok \layout and \midi? */
758 init_papers (PARSER);
759 $$->origin ()->set_spot (@$);
760 $$->paper_ = dynamic_cast<Output_def*> (unsmob_output_def (PARSER->lexer_->lookup_identifier ("$defaultpaper"))->clone ());
761 $$->paper_->unprotect ();
762 push_paper (PARSER, $$->paper_);
763 $$->header_ = PARSER->lexer_->lookup_identifier ("$defaultheader");
764 PARSER->lexer_->set_identifier (ly_symbol2scm ("$current-book"), $$->self_scm ());
765 PARSER->lexer_->set_identifier (ly_symbol2scm ("book-output-suffix"), SCM_BOOL_F);
766 PARSER->lexer_->set_identifier (ly_symbol2scm ("book-filename"), SCM_BOOL_F);
769 $$ = unsmob_book ($1);
771 $$->origin ()->set_spot (@$);
772 PARSER->lexer_->set_identifier (ly_symbol2scm ("$current-book"), $1);
774 | book_body paper_block {
777 set_paper (PARSER, $2);
779 | book_body bookpart_block {
781 SCM proc = PARSER->lexer_->lookup_identifier ("book-bookpart-handler");
782 scm_call_2 (proc, $$->self_scm (), bookpart->self_scm ());
783 bookpart->unprotect ();
785 | book_body score_block {
787 SCM proc = PARSER->lexer_->lookup_identifier ("book-score-handler");
788 scm_call_2 (proc, $$->self_scm (), score->self_scm ());
791 | book_body composite_music {
792 Music *music = unsmob_music ($2);
793 SCM proc = PARSER->lexer_->lookup_identifier ("book-music-handler");
794 scm_call_3 (proc, PARSER->self_scm (), $$->self_scm (), music->self_scm ());
796 | book_body full_markup {
797 SCM proc = PARSER->lexer_->lookup_identifier ("book-text-handler");
798 scm_call_2 (proc, $$->self_scm (), scm_list_1 ($2));
800 | book_body full_markup_list {
801 SCM proc = PARSER->lexer_->lookup_identifier ("book-text-handler");
802 scm_call_2 (proc, $$->self_scm (), $2);
804 | book_body lilypond_header {
807 | book_body embedded_scm { }
810 $$->scores_ = SCM_EOL;
811 $$->bookparts_ = SCM_EOL;
816 BOOKPART '{' bookpart_body '}' {
818 PARSER->lexer_->set_identifier (ly_symbol2scm ("$current-bookpart"), SCM_BOOL_F);
825 $$->origin ()->set_spot (@$);
826 PARSER->lexer_->set_identifier (ly_symbol2scm ("$current-bookpart"), $$->self_scm ());
829 $$ = unsmob_book ($1);
831 $$->origin ()->set_spot (@$);
832 PARSER->lexer_->set_identifier (ly_symbol2scm ("$current-bookpart"), $1);
834 | bookpart_body paper_block {
838 | bookpart_body score_block {
840 SCM proc = PARSER->lexer_->lookup_identifier ("bookpart-score-handler");
841 scm_call_2 (proc, $$->self_scm (), score->self_scm ());
844 | bookpart_body composite_music {
845 Music *music = unsmob_music ($2);
846 SCM proc = PARSER->lexer_->lookup_identifier ("bookpart-music-handler");
847 scm_call_3 (proc, PARSER->self_scm (), $$->self_scm (), music->self_scm ());
849 | bookpart_body full_markup {
850 SCM proc = PARSER->lexer_->lookup_identifier ("bookpart-text-handler");
851 scm_call_2 (proc, $$->self_scm (), scm_list_1 ($2));
853 | bookpart_body full_markup_list {
854 SCM proc = PARSER->lexer_->lookup_identifier ("bookpart-text-handler");
855 scm_call_2 (proc, $$->self_scm (), $2);
857 | bookpart_body lilypond_header {
860 | bookpart_body embedded_scm { }
861 | bookpart_body error {
863 $$->scores_ = SCM_EOL;
868 SCORE '{' score_body '}' {
876 SCM scorify = ly_lily_module_constant ("scorify-music");
877 SCM score = scm_call_2 (scorify, m, PARSER->self_scm ());
879 // pass ownernship to C++ again.
880 $$ = unsmob_score (score);
882 $$->origin ()->set_spot (@$);
885 $$ = unsmob_score ($1);
887 $$->origin ()->set_spot (@$);
889 | score_body lilypond_header {
892 | score_body output_def {
893 if ($2->lookup_variable (ly_symbol2scm ("is-paper")) == SCM_BOOL_T)
895 PARSER->parser_error (@2, _("\\paper cannot be used in \\score, use \\layout instead"));
900 $$->add_output_def ($2);
905 $$->error_found_ = true;
917 if ($$->lookup_variable (ly_symbol2scm ("is-paper")) != SCM_BOOL_T)
919 PARSER->parser_error (@1, _ ("need \\paper for paper block"));
921 $$ = get_paper (PARSER);
928 output_def_body '}' {
931 PARSER->lexer_->remove_scope ();
932 PARSER->lexer_->pop_state ();
938 $$ = get_paper (PARSER);
939 $$->input_origin_ = @$;
940 PARSER->lexer_->add_scope ($$->scope_);
943 Output_def *p = get_midi (PARSER);
945 PARSER->lexer_->add_scope (p->scope_);
948 Output_def *p = get_layout (PARSER);
950 PARSER->lexer_->add_scope (p->scope_);
955 output_def_head_with_mode_switch:
957 PARSER->lexer_->push_initial_state ();
963 output_def_head_with_mode_switch '{' {
965 $$->input_origin_.set_spot (@$);
967 | output_def_head_with_mode_switch '{' OUTPUT_DEF_IDENTIFIER {
970 Output_def *o = unsmob_output_def ($3);
971 o->input_origin_.set_spot (@$);
974 PARSER->lexer_->remove_scope ();
975 PARSER->lexer_->add_scope (o->scope_);
977 | output_def_body assignment {
980 | output_def_body context_def_spec_block {
981 assign_context_def ($$, $2);
983 | output_def_body error {
989 TEMPO steno_duration '=' tempo_range {
990 $$ = MAKE_SYNTAX ("tempo", @$, SCM_EOL, $2, $4);
992 | TEMPO scalar_closed steno_duration '=' tempo_range {
993 $$ = MAKE_SYNTAX ("tempo", @$, $2, $3, $5);
996 $$ = MAKE_SYNTAX ("tempo", @$, $2);
1001 The representation of a list is reversed to have efficient append. */
1007 | music_list music {
1008 $$ = scm_cons ($2, $1);
1010 | music_list embedded_scm {
1013 | music_list error {
1014 Music *m = MY_MAKE_MUSIC("Music", @$);
1016 m->set_property ("error-found", SCM_BOOL_T);
1017 $$ = scm_cons (m->self_scm (), $1);
1018 m->unprotect (); /* UGH */
1025 $$ = scm_reverse_x ($2, SCM_EOL);
1036 REPEAT simple_string unsigned_number music
1038 $$ = MAKE_SYNTAX ("repeat", @$, $2, $3, $4, SCM_EOL);
1040 | REPEAT simple_string unsigned_number music ALTERNATIVE braced_music_list
1042 $$ = MAKE_SYNTAX ("repeat", @$, $2, $3, $4, $6);
1047 SEQUENTIAL braced_music_list {
1048 $$ = MAKE_SYNTAX ("sequential-music", @$, $2);
1050 | braced_music_list {
1051 $$ = MAKE_SYNTAX ("sequential-music", @$, $1);
1056 SIMULTANEOUS braced_music_list {
1057 $$ = MAKE_SYNTAX ("simultaneous-music", @$, $2);
1059 | DOUBLE_ANGLE_OPEN music_list DOUBLE_ANGLE_CLOSE {
1060 $$ = MAKE_SYNTAX ("simultaneous-music", @$, scm_reverse_x ($2, SCM_EOL));
1066 | music_property_def
1070 context_modification:
1071 WITH { PARSER->lexer_->push_initial_state (); } '{' context_mod_list '}'
1073 PARSER->lexer_->pop_state ();
1076 | WITH CONTEXT_MOD_IDENTIFIER
1080 | CONTEXT_MOD_IDENTIFIER
1086 optional_context_mod:
1090 | context_modification
1098 $$ = Context_mod ().smobbed_copy ();
1100 | context_mod_list context_mod {
1101 unsmob_context_mod ($1)->add_context_mod ($2);
1103 | context_mod_list CONTEXT_MOD_IDENTIFIER {
1104 Context_mod *md = unsmob_context_mod ($2);
1106 unsmob_context_mod ($1)->add_context_mods (md->get_mods ());
1115 /* Music that can't be followed by additional events or durations */
1119 | grouped_music_list
1123 simultaneous_music { $$ = $1; }
1124 | sequential_music { $$ = $1; }
1127 /* An argument list. If a function \foo expects scm scm music, then the lexer expands \foo into the token sequence:
1128 MUSIC_FUNCTION EXPECT_MUSIC EXPECT_SCM EXPECT_SCM EXPECT_NO_MORE_ARGS
1129 and this rule returns the reversed list of arguments. */
1133 function_arglist_bare
1134 | EXPECT_MUSIC function_arglist_optional music
1136 $$ = scm_cons ($3, $2);
1138 | EXPECT_SCM function_arglist_optional embedded_scm
1140 $$ = check_scheme_arg (PARSER, @3, SCM_UNDEFINED, $3, $2, $1);
1144 function_arglist_optional:
1145 function_arglist_keep %prec FUNCTION_ARGUMENTS
1146 | EXPECT_OPTIONAL EXPECT_MUSIC function_arglist_optional
1148 $$ = scm_cons (loc_on_music (@3, $1), $3);
1150 | EXPECT_OPTIONAL EXPECT_PITCH function_arglist_optional
1152 $$ = scm_cons ($1, $3);
1154 | EXPECT_OPTIONAL EXPECT_DURATION function_arglist_optional
1156 $$ = scm_cons ($1, $3);
1158 | EXPECT_OPTIONAL EXPECT_MARKUP function_arglist_optional
1160 $$ = scm_cons ($1, $3);
1162 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_optional
1164 $$ = scm_cons (loc_on_music (@3, $1), $3);
1168 function_arglist_keep:
1169 EXPECT_OPTIONAL EXPECT_MARKUP function_arglist_keep full_markup {
1170 $$ = scm_cons ($4, $3);
1172 | EXPECT_OPTIONAL EXPECT_MARKUP function_arglist_keep simple_string {
1173 $$ = scm_cons ($4, $3);
1175 | EXPECT_OPTIONAL EXPECT_PITCH function_arglist_keep pitch_also_in_chords {
1176 $$ = scm_cons ($4, $3);
1178 | EXPECT_OPTIONAL EXPECT_DURATION function_arglist_closed_keep duration_length {
1179 $$ = scm_cons ($4, $3);
1181 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_keep simple_string
1183 $$ = check_scheme_arg (PARSER, @4, $1, $4, $3, $2);
1185 | EXPECT_OPTIONAL EXPECT_MUSIC function_arglist_keep closed_music
1187 $$ = scm_cons ($4, $3);
1189 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_keep embedded_scm
1191 $$ = check_scheme_arg (PARSER, @4, $1, $4, $3, $2);
1197 function_arglist_closed:
1198 function_arglist_bare
1199 | EXPECT_MUSIC function_arglist_optional closed_music
1201 $$ = scm_cons ($3, $2);
1203 | EXPECT_SCM function_arglist_optional embedded_scm_closed
1205 $$ = check_scheme_arg (PARSER, @3, SCM_UNDEFINED, $3, $2, $1);
1209 function_arglist_closed_optional:
1210 function_arglist_closed_keep %prec FUNCTION_ARGUMENTS
1211 | EXPECT_OPTIONAL EXPECT_MUSIC function_arglist_closed_optional
1213 $$ = scm_cons (loc_on_music (@3, $1), $3);
1215 | EXPECT_OPTIONAL EXPECT_PITCH function_arglist_closed_optional
1217 $$ = scm_cons ($1, $3);
1219 | EXPECT_OPTIONAL EXPECT_DURATION function_arglist_closed_optional
1221 $$ = scm_cons ($1, $3);
1223 | EXPECT_OPTIONAL EXPECT_MARKUP function_arglist_closed_optional
1225 $$ = scm_cons ($1, $3);
1227 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_closed_optional
1229 $$ = scm_cons (loc_on_music (@3, $1), $3);
1233 function_arglist_closed_keep:
1234 EXPECT_OPTIONAL EXPECT_MARKUP function_arglist_keep full_markup {
1235 $$ = scm_cons ($4, $3);
1237 | EXPECT_OPTIONAL EXPECT_MARKUP function_arglist_keep simple_string {
1238 $$ = scm_cons ($4, $3);
1240 | EXPECT_OPTIONAL EXPECT_PITCH function_arglist_keep pitch_also_in_chords {
1241 $$ = scm_cons ($4, $3);
1243 | EXPECT_OPTIONAL EXPECT_DURATION function_arglist_closed_keep duration_length {
1244 $$ = scm_cons ($4, $3);
1246 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_keep simple_string
1248 $$ = check_scheme_arg (PARSER, @4, $1, $4, $3, $2);
1250 | EXPECT_OPTIONAL EXPECT_MUSIC function_arglist_keep closed_music
1252 $$ = scm_cons ($4, $3);
1254 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_keep embedded_scm_closed
1256 $$ = check_scheme_arg (PARSER, @4, $1, $4, $3, $2);
1258 | function_arglist_closed
1261 embedded_scm_closed:
1263 | scm_function_call_closed
1266 scm_function_call_closed:
1267 SCM_FUNCTION function_arglist_closed {
1268 $$ = MAKE_SYNTAX ("music-function", @$,
1273 function_arglist_bare:
1274 EXPECT_NO_MORE_ARGS {
1277 | EXPECT_MARKUP function_arglist_optional full_markup {
1278 $$ = scm_cons ($3, $2);
1280 | EXPECT_MARKUP function_arglist_optional simple_string {
1281 $$ = scm_cons ($3, $2);
1283 | EXPECT_PITCH function_arglist_optional pitch_also_in_chords {
1284 $$ = scm_cons ($3, $2);
1286 | EXPECT_DURATION function_arglist_closed_optional duration_length {
1287 $$ = scm_cons ($3, $2);
1289 | EXPECT_SCM function_arglist_optional simple_string {
1290 $$ = check_scheme_arg (PARSER, @3, SCM_UNDEFINED, $3, $2, $1);
1294 music_function_call:
1295 MUSIC_FUNCTION function_arglist {
1296 $$ = MAKE_SYNTAX ("music-function", @$,
1303 /**/ { $$ = SCM_EOL; }
1304 | '=' simple_string {
1311 | CONTEXT simple_string optional_id optional_context_mod music {
1312 Context_mod *ctxmod = unsmob_context_mod ($4);
1315 mods = ctxmod->get_mods ();
1316 $$ = MAKE_SYNTAX ("context-specification", @$, $2, $3, mods, SCM_BOOL_F, $5);
1318 | NEWCONTEXT simple_string optional_id optional_context_mod music {
1319 Context_mod *ctxmod = unsmob_context_mod ($4);
1322 mods = ctxmod->get_mods ();
1323 $$ = MAKE_SYNTAX ("context-specification", @$, $2, $3, mods, SCM_BOOL_T, $5);
1326 | TIMES fraction music {
1327 $$ = MAKE_SYNTAX ("time-scaled-music", @$, $2, $3);
1329 | repeated_music { $$ = $1; }
1330 | re_rhythmed_music { $$ = $1; }
1334 mode_changing_head grouped_music_list {
1335 if ($1 == ly_symbol2scm ("chords"))
1337 $$ = MAKE_SYNTAX ("unrelativable-music", @$, $2);
1343 PARSER->lexer_->pop_state ();
1345 | mode_changing_head_with_context optional_context_mod grouped_music_list {
1346 Context_mod *ctxmod = unsmob_context_mod ($2);
1349 mods = ctxmod->get_mods ();
1350 $$ = MAKE_SYNTAX ("context-specification", @$, $1, SCM_EOL, mods, SCM_BOOL_T, $3);
1351 if ($1 == ly_symbol2scm ("ChordNames"))
1353 $$ = MAKE_SYNTAX ("unrelativable-music", @$, $$);
1355 PARSER->lexer_->pop_state ();
1361 SCM nn = PARSER->lexer_->lookup_identifier ("pitchnames");
1362 PARSER->lexer_->push_note_state (alist_to_hashq (nn));
1364 $$ = ly_symbol2scm ("notes");
1368 SCM nn = PARSER->lexer_->lookup_identifier ("drumPitchNames");
1369 PARSER->lexer_->push_note_state (alist_to_hashq (nn));
1371 $$ = ly_symbol2scm ("drums");
1374 PARSER->lexer_->push_figuredbass_state ();
1376 $$ = ly_symbol2scm ("figures");
1379 SCM nn = PARSER->lexer_->lookup_identifier ("chordmodifiers");
1380 PARSER->lexer_->chordmodifier_tab_ = alist_to_hashq (nn);
1381 nn = PARSER->lexer_->lookup_identifier ("pitchnames");
1382 PARSER->lexer_->push_chord_state (alist_to_hashq (nn));
1383 $$ = ly_symbol2scm ("chords");
1387 { PARSER->lexer_->push_lyric_state ();
1388 $$ = ly_symbol2scm ("lyrics");
1392 mode_changing_head_with_context:
1394 SCM nn = PARSER->lexer_->lookup_identifier ("drumPitchNames");
1395 PARSER->lexer_->push_note_state (alist_to_hashq (nn));
1397 $$ = ly_symbol2scm ("DrumStaff");
1400 PARSER->lexer_->push_figuredbass_state ();
1402 $$ = ly_symbol2scm ("FiguredBass");
1405 SCM nn = PARSER->lexer_->lookup_identifier ("chordmodifiers");
1406 PARSER->lexer_->chordmodifier_tab_ = alist_to_hashq (nn);
1407 nn = PARSER->lexer_->lookup_identifier ("pitchnames");
1408 PARSER->lexer_->push_chord_state (alist_to_hashq (nn));
1409 $$ = ly_symbol2scm ("ChordNames");
1412 { PARSER->lexer_->push_lyric_state ();
1413 $$ = ly_symbol2scm ("Lyrics");
1418 ADDLYRICS { PARSER->lexer_->push_lyric_state (); }
1421 /* Can also use music at the expensive of two S/Rs similar to
1422 \repeat \alternative */
1423 PARSER->lexer_->pop_state ();
1425 $$ = scm_cons ($3, SCM_EOL);
1427 | new_lyrics ADDLYRICS {
1428 PARSER->lexer_->push_lyric_state ();
1430 PARSER->lexer_->pop_state ();
1431 $$ = scm_cons ($4, $1);
1436 closed_music new_lyrics {
1437 $$ = MAKE_SYNTAX ("add-lyrics", @$, $1, scm_reverse_x ($2, SCM_EOL));
1439 | LYRICSTO simple_string {
1440 PARSER->lexer_->push_lyric_state ();
1442 PARSER->lexer_->pop_state ();
1443 $$ = MAKE_SYNTAX ("lyric-combine", @$, $2, $4);
1448 CHANGE STRING '=' STRING {
1449 $$ = MAKE_SYNTAX ("context-change", @$, scm_string_to_symbol ($2), $4);
1454 property_path_revved:
1455 embedded_scm_closed {
1456 $$ = scm_cons ($1, SCM_EOL);
1458 | property_path_revved embedded_scm_closed {
1459 $$ = scm_cons ($2, $1);
1464 property_path_revved {
1465 $$ = scm_reverse_x ($1, SCM_EOL);
1471 $$ = scm_list_3 (ly_symbol2scm ("assign"),
1472 scm_string_to_symbol ($1), $3);
1474 | UNSET simple_string {
1475 $$ = scm_list_2 (ly_symbol2scm ("unset"),
1476 scm_string_to_symbol ($2));
1478 | OVERRIDE simple_string property_path '=' scalar {
1479 $$ = scm_append (scm_list_2 (scm_list_3 (ly_symbol2scm ("push"),
1480 scm_string_to_symbol ($2), $5),
1483 | REVERT simple_string embedded_scm {
1484 $$ = scm_list_3 (ly_symbol2scm ("pop"),
1485 scm_string_to_symbol ($2), $3);
1490 CONSISTS { $$ = ly_symbol2scm ("consists"); }
1491 | REMOVE { $$ = ly_symbol2scm ("remove"); }
1493 | ACCEPTS { $$ = ly_symbol2scm ("accepts"); }
1494 | DEFAULTCHILD { $$ = ly_symbol2scm ("default-child"); }
1495 | DENIES { $$ = ly_symbol2scm ("denies"); }
1497 | ALIAS { $$ = ly_symbol2scm ("alias"); }
1498 | TYPE { $$ = ly_symbol2scm ("translator-type"); }
1499 | DESCRIPTION { $$ = ly_symbol2scm ("description"); }
1500 | NAME { $$ = ly_symbol2scm ("context-name"); }
1504 property_operation { $$ = $1; }
1505 | context_def_mod STRING {
1506 $$ = scm_list_2 ($1, $2);
1508 | context_def_mod embedded_scm {
1509 if (ly_symbol2scm ("consists") != $1)
1512 PARSER->parser_error (@1, _ ("only \\consists takes non-string argument."));
1516 $$ = scm_list_2 ($1, $2);
1523 if (!is_regular_identifier ($1))
1525 @$.error (_("Grob name should be alphanumeric"));
1528 $$ = scm_list_2 (ly_symbol2scm ("Bottom"),
1529 scm_string_to_symbol ($1));
1531 | simple_string '.' simple_string {
1532 $$ = scm_list_2 (scm_string_to_symbol ($1),
1533 scm_string_to_symbol ($3));
1537 simple_music_property_def:
1538 OVERRIDE context_prop_spec property_path '=' scalar {
1539 $$ = scm_append (scm_list_2 (scm_list_n (scm_car ($2),
1540 ly_symbol2scm ("OverrideProperty"),
1545 | REVERT context_prop_spec embedded_scm {
1546 $$ = scm_list_4 (scm_car ($2),
1547 ly_symbol2scm ("RevertProperty"),
1551 | SET context_prop_spec '=' scalar {
1552 $$ = scm_list_4 (scm_car ($2),
1553 ly_symbol2scm ("PropertySet"),
1557 | UNSET context_prop_spec {
1558 $$ = scm_list_3 (scm_car ($2),
1559 ly_symbol2scm ("PropertyUnset"),
1565 simple_music_property_def {
1566 $$ = LOWLEVEL_MAKE_SYNTAX (ly_lily_module_constant ("property-operation"), scm_cons (PARSER->self_scm (), scm_cons2 (make_input (@$), SCM_BOOL_F, $1)));
1568 | ONCE simple_music_property_def {
1569 $$ = LOWLEVEL_MAKE_SYNTAX (ly_lily_module_constant ("property-operation"), scm_cons (PARSER->self_scm (), scm_cons2 (make_input (@$), SCM_BOOL_T, $2)));
1577 | STRING_IDENTIFIER {
1580 | string '+' string {
1581 $$ = scm_string_append (scm_list_2 ($1, $3));
1585 simple_string: STRING {
1591 | STRING_IDENTIFIER {
1606 | embedded_scm_bare {
1621 scm_function_call_closed
1626 /* TODO: Create a special case that avoids the creation of
1627 EventChords around simple_elements that have no post_events?
1629 simple_chord_elements post_events {
1630 SCM elts = ly_append2 ($1, scm_reverse_x ($2, SCM_EOL));
1633 /* why is this giving wrong start location? -ns
1635 i.set_location (@1, @2);
1636 $$ = MAKE_SYNTAX ("event-chord", i, elts);
1638 | CHORD_REPETITION optional_notemode_duration post_events {
1640 i.set_location (@1, @3);
1641 $$ = MAKE_SYNTAX ("repetition-chord", i,
1642 PARSER->lexer_->chord_repetition_.last_chord_,
1643 PARSER->lexer_->chord_repetition_.repetition_function_,
1644 $2, scm_reverse_x ($3, SCM_EOL));
1646 | MULTI_MEASURE_REST optional_notemode_duration post_events {
1648 i.set_location (@1, @3);
1649 $$ = MAKE_SYNTAX ("multi-measure-rest", i, $2,
1650 scm_reverse_x ($3, SCM_EOL));
1653 /* note chord elements are memorized into
1654 PARSER->lexer_->chord_repetition_ so that the chord repetition
1655 mechanism copy them when a chord repetition symbol is found
1657 | note_chord_element {
1658 PARSER->lexer_->chord_repetition_.last_chord_ = $$;
1664 chord_body optional_notemode_duration post_events
1666 Music *m = unsmob_music ($1);
1667 SCM dur = unsmob_duration ($2)->smobbed_copy ();
1668 SCM es = m->get_property ("elements");
1669 SCM postevs = scm_reverse_x ($3, SCM_EOL);
1671 for (SCM s = es; scm_is_pair (s); s = scm_cdr (s))
1672 unsmob_music (scm_car (s))->set_property ("duration", dur);
1673 es = ly_append2 (es, postevs);
1675 m-> set_property ("elements", es);
1677 $$ = m->self_scm ();
1682 ANGLE_OPEN chord_body_elements ANGLE_CLOSE
1684 $$ = MAKE_SYNTAX ("event-chord", @$, scm_reverse_x ($2, SCM_EOL));
1688 chord_body_elements:
1689 /* empty */ { $$ = SCM_EOL; }
1690 | chord_body_elements chord_body_element {
1691 $$ = scm_cons ($2, $1);
1696 pitch exclamations questions octave_check post_events
1703 Music *n = MY_MAKE_MUSIC ("NoteEvent", @$);
1704 n->set_property ("pitch", $1);
1706 n->set_property ("cautionary", SCM_BOOL_T);
1707 if (ex % 2 || q % 2)
1708 n->set_property ("force-accidental", SCM_BOOL_T);
1710 if (scm_is_pair (post)) {
1711 SCM arts = scm_reverse_x (post, SCM_EOL);
1712 n->set_property ("articulations", arts);
1714 if (scm_is_number (check))
1716 int q = scm_to_int (check);
1717 n->set_property ("absolute-octave", scm_from_int (q-1));
1720 $$ = n->unprotect ();
1722 | DRUM_PITCH post_events {
1723 Music *n = MY_MAKE_MUSIC ("NoteEvent", @$);
1724 n->set_property ("drum-type", $1);
1726 if (scm_is_pair ($2)) {
1727 SCM arts = scm_reverse_x ($2, SCM_EOL);
1728 n->set_property ("articulations", arts);
1730 $$ = n->unprotect ();
1732 | music_function_chord_body
1735 /* We can't accept a music argument, not even a closed one,
1736 * immediately before chord_body_elements, otherwise a function \fun
1737 * with a signature of two music arguments can't be sorted out
1738 * properly in a construct like
1739 * <\fun { c } \fun { c } c>
1740 * The second call could be interpreted either as a chord constituent
1741 * or a music expression.
1744 music_function_chord_body_arglist:
1745 function_arglist_bare
1746 | EXPECT_MUSIC music_function_chord_body_arglist chord_body_element {
1747 $$ = scm_cons ($3, $2);
1749 | EXPECT_SCM function_arglist_optional embedded_scm_chord_body {
1750 $$ = check_scheme_arg (PARSER, @3, SCM_UNDEFINED, $3, $2, $1);
1754 embedded_scm_chord_body:
1756 | SCM_FUNCTION music_function_chord_body_arglist {
1757 $$ = MAKE_SYNTAX ("music-function", @$,
1762 music_function_chord_body:
1763 MUSIC_FUNCTION music_function_chord_body_arglist {
1764 $$ = MAKE_SYNTAX ("music-function", @$,
1769 /* We could accept a closed music argument before the post events
1770 * indicated by a trailing argument list. For symmetry with chord
1771 * bodies and in order to avoid too tricky and complex behavior, we
1772 * refrain from doing so.
1774 music_function_event_arglist:
1775 function_arglist_bare
1776 | EXPECT_MUSIC music_function_event_arglist post_event {
1777 $$ = scm_cons ($3, $2);
1779 | EXPECT_SCM function_arglist_optional embedded_scm_event {
1780 $$ = check_scheme_arg (PARSER, @3, SCM_UNDEFINED, $3, $2, $1);
1786 | SCM_FUNCTION music_function_event_arglist {
1787 $$ = MAKE_SYNTAX ("music-function", @$,
1792 music_function_event:
1793 MUSIC_FUNCTION music_function_event_arglist {
1794 $$ = MAKE_SYNTAX ("music-function", @$,
1799 event_function_event:
1800 EVENT_FUNCTION music_function_event_arglist {
1801 $$ = MAKE_SYNTAX ("music-function", @$,
1811 Music *m = MY_MAKE_MUSIC ("LigatureEvent", @$);
1812 m->set_property ("span-direction", scm_from_int (START));
1813 $$ = m->unprotect();
1816 Music *m = MY_MAKE_MUSIC ("LigatureEvent", @$);
1817 m->set_property ("span-direction", scm_from_int (STOP));
1818 $$ = m->unprotect ();
1821 $$ = MAKE_SYNTAX ("voice-separator", @$);
1824 SCM pipe = PARSER->lexer_->lookup_identifier ("pipeSymbol");
1826 Music *m = unsmob_music (pipe);
1831 $$ = m->unprotect ();
1834 $$ = MAKE_SYNTAX ("bar-check", @$);
1838 SCM proc = ly_lily_module_constant ("make-time-signature-set");
1840 $$ = scm_apply_2 (proc, scm_car ($2), scm_cdr ($2), SCM_EOL);
1843 $$ = MAKE_SYNTAX ("make-mark-set", @$, $2);
1849 $$ = MY_MAKE_MUSIC ("PesOrFlexaEvent", @$)->unprotect ();
1852 Music *m = MY_MAKE_MUSIC ("MarkEvent", @$);
1853 $$ = m->unprotect ();
1859 Music *key = MY_MAKE_MUSIC ("KeyChangeEvent", @$);
1860 $$ = key->unprotect ();
1862 | KEY NOTENAME_PITCH SCM_IDENTIFIER {
1864 Music *key = MY_MAKE_MUSIC ("KeyChangeEvent", @$);
1865 if (scm_ilength ($3) > 0)
1867 key->set_property ("pitch-alist", $3);
1868 key->set_property ("tonic", Pitch (0, 0, 0).smobbed_copy ());
1869 key->transpose (* unsmob_pitch ($2));
1871 PARSER->parser_error (@3, _ ("second argument must be pitch list"));
1874 $$ = key->unprotect ();
1883 | post_events post_event {
1884 unsmob_music ($2)->set_spot (@2);
1885 $$ = scm_cons ($2, $$);
1889 post_event_nofinger:
1890 direction_less_event {
1893 | script_dir music_function_event {
1897 unsmob_music ($$)->set_property ("direction", scm_from_int ($1));
1901 if (!PARSER->lexer_->is_lyric_state ())
1902 PARSER->parser_error (@1, _ ("have to be in Lyric mode for lyrics"));
1903 $$ = MY_MAKE_MUSIC ("HyphenEvent", @$)->unprotect ();
1906 if (!PARSER->lexer_->is_lyric_state ())
1907 PARSER->parser_error (@1, _ ("have to be in Lyric mode for lyrics"));
1908 $$ = MY_MAKE_MUSIC ("ExtenderEvent", @$)->unprotect ();
1910 | script_dir direction_reqd_event {
1913 Music *m = unsmob_music ($2);
1914 m->set_property ("direction", scm_from_int ($1));
1918 | script_dir direction_less_event {
1921 Music *m = unsmob_music ($2);
1922 m->set_property ("direction", scm_from_int ($1));
1926 | string_number_event
1931 | script_dir fingering {
1934 Music *m = unsmob_music ($2);
1935 m->set_property ("direction", scm_from_int ($1));
1941 string_number_event:
1943 Music *s = MY_MAKE_MUSIC ("StringNumberEvent", @$);
1944 s->set_property ("string-number", scm_from_int ($1));
1945 $$ = s->unprotect ();
1949 direction_less_char:
1951 $$ = ly_symbol2scm ("bracketOpenSymbol");
1954 $$ = ly_symbol2scm ("bracketCloseSymbol");
1957 $$ = ly_symbol2scm ("tildeSymbol");
1960 $$ = ly_symbol2scm ("parenthesisOpenSymbol");
1963 $$ = ly_symbol2scm ("parenthesisCloseSymbol");
1966 $$ = ly_symbol2scm ("escapedExclamationSymbol");
1969 $$ = ly_symbol2scm ("escapedParenthesisOpenSymbol");
1972 $$ = ly_symbol2scm ("escapedParenthesisCloseSymbol");
1975 $$ = ly_symbol2scm ("escapedBiggerSymbol");
1978 $$ = ly_symbol2scm ("escapedSmallerSymbol");
1982 direction_less_event:
1983 direction_less_char {
1984 SCM predefd = PARSER->lexer_->lookup_identifier_symbol ($1);
1986 if (unsmob_music (predefd))
1988 m = unsmob_music (predefd)->clone ();
1993 m = MY_MAKE_MUSIC ("Music", @$);
1995 $$ = m->unprotect ();
1997 | EVENT_IDENTIFIER {
2001 Music *a = MY_MAKE_MUSIC ("TremoloEvent", @$);
2002 a->set_property ("tremolo-type", scm_from_int ($1));
2003 $$ = a->unprotect ();
2005 | event_function_event
2008 direction_reqd_event:
2012 | script_abbreviation {
2013 SCM s = PARSER->lexer_->lookup_identifier ("dash" + ly_scm2string ($1));
2014 Music *a = MY_MAKE_MUSIC ("ArticulationEvent", @$);
2015 if (scm_is_string (s))
2016 a->set_property ("articulation-type", s);
2017 else PARSER->parser_error (@1, _ ("expecting string as script definition"));
2018 $$ = a->unprotect ();
2023 /**/ { $$ = SCM_EOL; }
2024 | '=' { $$ = scm_from_int (0); }
2025 | '=' sub_quotes { $$ = scm_from_int (-$2); }
2026 | '=' sup_quotes { $$ = scm_from_int ($2); }
2051 | NOTENAME_PITCH sup_quotes {
2052 Pitch p = *unsmob_pitch ($1);
2053 p = p.transposed (Pitch ($2,0,0));
2054 $$ = p.smobbed_copy ();
2056 | NOTENAME_PITCH sub_quotes {
2057 Pitch p =* unsmob_pitch ($1);
2058 p = p.transposed (Pitch (-$2,0,0));
2059 $$ = p.smobbed_copy ();
2071 | TONICNAME_PITCH sup_quotes {
2072 Pitch p = *unsmob_pitch ($1);
2073 p = p.transposed (Pitch ($2,0,0));
2074 $$ = p.smobbed_copy ();
2076 | TONICNAME_PITCH sub_quotes {
2077 Pitch p = *unsmob_pitch ($1);
2079 p = p.transposed (Pitch (-$2,0,0));
2080 $$ = p.smobbed_copy ();
2091 pitch_also_in_chords:
2098 Music *t = MY_MAKE_MUSIC ("TextScriptEvent", @$);
2099 t->set_property ("text", $1);
2100 $$ = t->unprotect ();
2103 Music *t = MY_MAKE_MUSIC ("TextScriptEvent", @$);
2104 t->set_property ("text",
2105 make_simple_markup ($1));
2106 $$ = t->unprotect ();
2112 Music *t = MY_MAKE_MUSIC ("FingeringEvent", @$);
2113 t->set_property ("digit", scm_from_int ($1));
2114 $$ = t->unprotect ();
2118 script_abbreviation:
2120 $$ = scm_from_locale_string ("Hat");
2123 $$ = scm_from_locale_string ("Plus");
2126 $$ = scm_from_locale_string ("Dash");
2129 $$ = scm_from_locale_string ("Bar");
2132 $$ = scm_from_locale_string ("Larger");
2135 $$ = scm_from_locale_string ("Dot");
2138 $$ = scm_from_locale_string ("Underscore");
2145 | '-' { $$ = CENTER; }
2149 multiplied_duration {
2154 optional_notemode_duration:
2156 Duration dd = PARSER->default_duration_;
2157 $$ = dd.smobbed_copy ();
2159 | multiplied_duration {
2161 PARSER->default_duration_ = *unsmob_duration ($$);
2166 bare_unsigned dots {
2168 if (!is_duration ($1))
2169 PARSER->parser_error (@1, _f ("not a duration: %d", $1));
2173 $$ = Duration (len, $2).smobbed_copy ();
2175 | DURATION_IDENTIFIER dots {
2176 Duration *d = unsmob_duration ($1);
2177 Duration k (d->duration_log (), d->dot_count () + $2);
2178 k = k.compressed (d->factor ());
2184 multiplied_duration:
2188 | multiplied_duration '*' bare_unsigned {
2189 $$ = unsmob_duration ($$)->compressed ( $3) .smobbed_copy ();
2191 | multiplied_duration '*' FRACTION {
2192 Rational m (scm_to_int (scm_car ($3)), scm_to_int (scm_cdr ($3)));
2194 $$ = unsmob_duration ($$)->compressed (m).smobbed_copy ();
2199 FRACTION { $$ = $1; }
2200 | UNSIGNED '/' UNSIGNED {
2201 $$ = scm_cons (scm_from_int ($1), scm_from_int ($3));
2218 | ':' bare_unsigned {
2219 if (!is_duration ($2))
2220 PARSER->parser_error (@2, _f ("not a duration: %d", $2));
2227 $$ = scm_from_int ($1);
2229 | STRING { $$ = $1; }
2230 | full_markup { $$ = $1; }
2233 figured_bass_alteration:
2234 '-' { $$ = ly_rational2scm (FLAT_ALTERATION); }
2235 | '+' { $$ = ly_rational2scm (SHARP_ALTERATION); }
2236 | '!' { $$ = scm_from_int (0); }
2241 Music *bfr = MY_MAKE_MUSIC ("BassFigureEvent", @$);
2242 $$ = bfr->unprotect ();
2245 Music *bfr = MY_MAKE_MUSIC ("BassFigureEvent", @$);
2246 $$ = bfr->self_scm ();
2248 if (scm_is_number ($1))
2249 bfr->set_property ("figure", $1);
2250 else if (Text_interface::is_markup ($1))
2251 bfr->set_property ("text", $1);
2257 unsmob_music ($1)->set_property ("bracket-stop", SCM_BOOL_T);
2259 | bass_figure figured_bass_alteration {
2260 Music *m = unsmob_music ($1);
2261 if (scm_to_double ($2)) {
2262 SCM salter = m->get_property ("alteration");
2263 SCM alter = scm_is_number (salter) ? salter : scm_from_int (0);
2264 m->set_property ("alteration",
2265 scm_sum (alter, $2));
2267 m->set_property ("alteration", scm_from_int (0));
2270 | bass_figure figured_bass_modification {
2271 Music *m = unsmob_music ($1);
2272 if ($2 == ly_symbol2scm ("plus"))
2274 m->set_property ("augmented", SCM_BOOL_T);
2276 else if ($2 == ly_symbol2scm ("slash"))
2278 m->set_property ("diminished", SCM_BOOL_T);
2280 else if ($2 == ly_symbol2scm ("exclamation"))
2282 m->set_property ("no-continuation", SCM_BOOL_T);
2284 else if ($2 == ly_symbol2scm ("backslash"))
2286 m->set_property ("augmented-slash", SCM_BOOL_T);
2292 figured_bass_modification:
2294 $$ = ly_symbol2scm ("plus");
2297 $$ = ly_symbol2scm ("exclamation");
2300 $$ = ly_symbol2scm ("slash");
2303 $$ = ly_symbol2scm ("backslash");
2313 unsmob_music ($$)->set_property ("bracket-start", SCM_BOOL_T);
2321 | figure_list br_bass_figure {
2322 $$ = scm_cons ($2, $1);
2327 FIGURE_OPEN figure_list FIGURE_CLOSE {
2328 $$ = scm_reverse_x ($2, SCM_EOL);
2339 pitch exclamations questions octave_check optional_notemode_duration optional_rest {
2340 if (!PARSER->lexer_->is_note_state ())
2341 PARSER->parser_error (@1, _ ("have to be in Note mode for notes"));
2345 n = MY_MAKE_MUSIC ("RestEvent", @$);
2347 n = MY_MAKE_MUSIC ("NoteEvent", @$);
2349 n->set_property ("pitch", $1);
2350 n->set_property ("duration", $5);
2352 if (scm_is_number ($4))
2354 int q = scm_to_int ($4);
2355 n->set_property ("absolute-octave", scm_from_int (q-1));
2359 n->set_property ("cautionary", SCM_BOOL_T);
2360 if ($2 % 2 || $3 % 2)
2361 n->set_property ("force-accidental", SCM_BOOL_T);
2363 $$ = n->unprotect ();
2365 | DRUM_PITCH optional_notemode_duration {
2366 Music *n = MY_MAKE_MUSIC ("NoteEvent", @$);
2367 n->set_property ("duration", $2);
2368 n->set_property ("drum-type", $1);
2370 $$ = n->unprotect ();
2372 | RESTNAME optional_notemode_duration {
2374 if (ly_scm2string ($1) == "s") {
2376 ev = MY_MAKE_MUSIC ("SkipEvent", @$);
2379 ev = MY_MAKE_MUSIC ("RestEvent", @$);
2382 ev->set_property ("duration", $2);
2383 $$ = ev->unprotect ();
2385 | lyric_element optional_notemode_duration {
2386 if (!PARSER->lexer_->is_lyric_state ())
2387 PARSER->parser_error (@1, _ ("have to be in Lyric mode for lyrics"));
2389 Music *levent = MY_MAKE_MUSIC ("LyricEvent", @$);
2390 levent->set_property ("text", $1);
2391 levent->set_property ("duration",$2);
2392 $$= levent->unprotect ();
2396 simple_chord_elements:
2398 $$ = scm_list_1 ($1);
2401 if (!PARSER->lexer_->is_chord_state ())
2402 PARSER->parser_error (@1, _ ("have to be in Chord mode for chords"));
2405 | figure_spec optional_notemode_duration {
2406 for (SCM s = $1; scm_is_pair (s); s = scm_cdr (s))
2408 unsmob_music (scm_car (s))->set_property ("duration", $2);
2424 steno_tonic_pitch optional_notemode_duration {
2425 $$ = make_chord_elements ($1, $2, SCM_EOL);
2427 | steno_tonic_pitch optional_notemode_duration chord_separator chord_items {
2428 SCM its = scm_reverse_x ($4, SCM_EOL);
2429 $$ = make_chord_elements ($1, $2, scm_cons ($3, its));
2437 | chord_items chord_item {
2438 $$ = scm_cons ($2, $$);
2444 $$ = ly_symbol2scm ("chord-colon");
2447 $$ = ly_symbol2scm ("chord-caret");
2449 | CHORD_SLASH steno_tonic_pitch {
2450 $$ = scm_list_2 (ly_symbol2scm ("chord-slash"), $2);
2452 | CHORD_BASS steno_tonic_pitch {
2453 $$ = scm_list_2 (ly_symbol2scm ("chord-bass"), $2);
2462 $$ = scm_reverse_x ($1, SCM_EOL);
2470 step_number { $$ = scm_cons ($1, SCM_EOL); }
2471 | step_numbers '.' step_number {
2472 $$ = scm_cons ($3, $$);
2478 $$ = make_chord_step ($1, 0);
2480 | bare_unsigned '+' {
2481 $$ = make_chord_step ($1, SHARP_ALTERATION);
2483 | bare_unsigned CHORD_MINUS {
2484 $$ = make_chord_step ($1, FLAT_ALTERATION);
2490 $$ = scm_from_int ($1);
2492 | bare_unsigned '~' bare_unsigned {
2493 $$ = scm_cons (scm_from_int ($1), scm_from_int ($3));
2500 TODO: should deprecate in favor of Scheme?
2504 number_expression '+' number_term {
2505 $$ = scm_sum ($1, $3);
2507 | number_expression '-' number_term {
2508 $$ = scm_difference ($1, $3);
2517 | number_factor '*' number_factor {
2518 $$ = scm_product ($1, $3);
2520 | number_factor '/' number_factor {
2521 $$ = scm_divide ($1, $3);
2526 '-' number_factor { /* %prec UNARY_MINUS */
2527 $$ = scm_difference ($2, SCM_UNDEFINED);
2535 $$ = scm_from_int ($1);
2540 | NUMBER_IDENTIFIER {
2543 | REAL NUMBER_IDENTIFIER {
2544 $$ = scm_from_double (scm_to_double ($1) *scm_to_double ($2));
2546 | UNSIGNED NUMBER_IDENTIFIER {
2547 $$ = scm_from_double ($1 *scm_to_double ($2));
2559 bare_unsigned { $$ = scm_from_int ($1); }
2560 | NUMBER_IDENTIFIER {
2567 | exclamations '!' { $$ ++; }
2572 | questions '?' { $$ ++; }
2576 This should be done more dynamically if possible.
2580 LYRIC_MARKUP_IDENTIFIER {
2584 { PARSER->lexer_->push_markup_state (); }
2587 PARSER->lexer_->pop_state ();
2592 MARKUPLINES_IDENTIFIER {
2596 { PARSER->lexer_->push_markup_state (); }
2599 PARSER->lexer_->pop_state ();
2608 { PARSER->lexer_->push_markup_state (); }
2611 PARSER->lexer_->pop_state ();
2617 $$ = scm_list_2 (ly_lily_module_constant ("line-markup"), $1);
2619 | markup_head_1_list simple_markup {
2620 $$ = scm_car (scm_call_2 (ly_lily_module_constant ("map-markup-command-list"), $1, scm_list_1 ($2)));
2628 MARKUPLINES_IDENTIFIER {
2631 | markup_composed_list {
2634 | markup_braced_list {
2637 | markup_command_list {
2638 $$ = scm_list_1 ($1);
2642 markup_composed_list:
2643 markup_head_1_list markup_braced_list {
2644 $$ = scm_call_2 (ly_lily_module_constant ("map-markup-command-list"), $1, $2);
2650 '{' markup_braced_list_body '}' {
2651 $$ = scm_reverse_x ($2, SCM_EOL);
2655 markup_braced_list_body:
2656 /* empty */ { $$ = SCM_EOL; }
2657 | markup_braced_list_body markup {
2658 $$ = scm_cons ($2, $1);
2660 | markup_braced_list_body markup_list {
2661 $$ = scm_reverse_x ($2, $1);
2665 markup_command_list:
2666 MARKUP_LIST_FUNCTION markup_command_list_arguments {
2667 $$ = scm_cons ($1, scm_reverse_x($2, SCM_EOL));
2671 markup_command_basic_arguments:
2672 EXPECT_MARKUP_LIST markup_command_list_arguments markup_list {
2673 $$ = scm_cons ($3, $2);
2675 | EXPECT_SCM markup_command_list_arguments embedded_scm_closed {
2676 $$ = check_scheme_arg (PARSER, @3, SCM_UNDEFINED, $3, $2, $1);
2678 | EXPECT_NO_MORE_ARGS {
2683 markup_command_list_arguments:
2684 markup_command_basic_arguments { $$ = $1; }
2685 | EXPECT_MARKUP markup_command_list_arguments markup {
2686 $$ = scm_cons ($3, $2);
2691 MARKUP_FUNCTION EXPECT_MARKUP markup_command_list_arguments {
2692 $$ = scm_cons ($1, scm_reverse_x ($3, SCM_EOL));
2697 markup_head_1_item {
2698 $$ = scm_list_1 ($1);
2700 | markup_head_1_list markup_head_1_item {
2701 $$ = scm_cons ($2, $1);
2707 $$ = make_simple_markup ($1);
2709 | MARKUP_IDENTIFIER {
2712 | LYRIC_MARKUP_IDENTIFIER {
2715 | STRING_IDENTIFIER {
2719 SCM nn = PARSER->lexer_->lookup_identifier ("pitchnames");
2720 PARSER->lexer_->push_note_state (alist_to_hashq (nn));
2721 } '{' score_body '}' {
2723 $$ = scm_list_2 (ly_lily_module_constant ("score-markup"), sc->self_scm ());
2725 PARSER->lexer_->pop_state ();
2727 | MARKUP_FUNCTION markup_command_basic_arguments {
2728 $$ = scm_cons ($1, scm_reverse_x ($2, SCM_EOL));
2733 markup_head_1_list simple_markup {
2734 SCM mapper = ly_lily_module_constant ("map-markup-command-list");
2735 $$ = scm_car (scm_call_2 (mapper, $1, scm_list_1 ($2)));
2745 Lily_parser::set_yydebug (bool x)
2751 Lily_parser::do_yyparse ()
2753 yyparse ((void*)this);
2762 It is a little strange to have this function in this file, but
2763 otherwise, we have to import music classes into the lexer.
2767 Lily_lexer::try_special_identifiers (SCM *destination, SCM sid)
2769 if (scm_is_string (sid)) {
2771 return STRING_IDENTIFIER;
2772 } else if (unsmob_book (sid)) {
2773 Book *book = unsmob_book (sid)->clone ();
2774 *destination = book->self_scm ();
2777 return BOOK_IDENTIFIER;
2778 } else if (scm_is_number (sid)) {
2780 return NUMBER_IDENTIFIER;
2781 } else if (unsmob_context_def (sid)) {
2782 Context_def *def= unsmob_context_def (sid)->clone ();
2784 *destination = def->self_scm ();
2787 return CONTEXT_DEF_IDENTIFIER;
2788 } else if (unsmob_context_mod (sid)) {
2789 *destination = unsmob_context_mod (sid)->smobbed_copy ();
2791 return CONTEXT_MOD_IDENTIFIER;
2792 } else if (unsmob_score (sid)) {
2793 Score *score = new Score (*unsmob_score (sid));
2794 *destination = score->self_scm ();
2796 score->unprotect ();
2797 return SCORE_IDENTIFIER;
2798 } else if (Music *mus = unsmob_music (sid)) {
2799 mus = mus->clone ();
2800 *destination = mus->self_scm ();
2801 unsmob_music (*destination)->
2802 set_property ("origin", make_input (last_input_));
2804 bool is_event = scm_memq (ly_symbol2scm ("event"), mus->get_property ("types"))
2808 return is_event ? EVENT_IDENTIFIER : MUSIC_IDENTIFIER;
2809 } else if (unsmob_pitch (sid)) {
2810 *destination = unsmob_pitch (sid)->smobbed_copy ();
2811 return PITCH_IDENTIFIER;
2812 } else if (unsmob_duration (sid)) {
2813 *destination = unsmob_duration (sid)->smobbed_copy ();
2814 return DURATION_IDENTIFIER;
2815 } else if (unsmob_output_def (sid)) {
2816 Output_def *p = unsmob_output_def (sid);
2819 *destination = p->self_scm ();
2821 return OUTPUT_DEF_IDENTIFIER;
2822 } else if (Text_interface::is_markup (sid)) {
2824 if (is_lyric_state ())
2825 return LYRIC_MARKUP_IDENTIFIER;
2826 return MARKUP_IDENTIFIER;
2827 } else if (Text_interface::is_markup_list (sid)) {
2829 return MARKUPLINES_IDENTIFIER;
2836 get_next_unique_context_id ()
2838 return scm_from_locale_string ("$uniqueContextId");
2843 get_next_unique_lyrics_context_id ()
2845 static int new_context_count;
2847 snprintf (s, sizeof (s)-1, "uniqueContext%d", new_context_count++);
2848 return scm_from_locale_string (s);
2852 SCM check_scheme_arg (Lily_parser *parser, Input loc, SCM fallback,
2853 SCM arg, SCM args, SCM pred)
2855 SCM type_check_arg = ly_lily_module_constant ("type-check-arg");
2856 if (scm_is_false (scm_call_4 (type_check_arg, make_input (loc),
2859 if (SCM_UNBNDP (fallback))
2860 fallback = SCM_BOOL_F;
2862 fallback = loc_on_music (loc, fallback);
2864 parser->error_level_ = 1;
2866 return scm_cons (fallback, args);
2868 return scm_cons (arg, args);
2871 SCM loc_on_music (Input loc, SCM arg)
2873 if (Music *m = unsmob_music (arg))
2877 return m->unprotect ();
2883 is_regular_identifier (SCM id)
2885 string str = ly_scm2string (id);
2886 char const *s = str.c_str ();
2895 v = v && isalnum (*s);
2902 make_music_with_input (SCM name, Input where)
2904 Music *m = make_music_by_name (name);
2905 m->set_spot (where);
2910 get_first_context_id (SCM type, Music *m)
2912 SCM id = m->get_property ("context-id");
2913 if (SCM_BOOL_T == scm_equal_p (m->get_property ("context-type"), type)
2914 && scm_is_string (m->get_property ("context-id"))
2915 && scm_c_string_length (id) > 0)
2923 make_simple_markup (SCM a)
2931 return t && t == 1 << intlog2 (t);
2935 set_music_properties (Music *p, SCM a)
2937 for (SCM k = a; scm_is_pair (k); k = scm_cdr (k))
2938 p->set_property (scm_caar (k), scm_cdar (k));
2943 make_chord_step (int step, Rational alter)
2946 alter += FLAT_ALTERATION;
2950 Pitch m ((step -1) / 7, (step - 1) % 7, alter);
2951 return m.smobbed_copy ();
2956 make_chord_elements (SCM pitch, SCM dur, SCM modification_list)
2958 SCM chord_ctor = ly_lily_module_constant ("construct-chord-elements");
2959 return scm_call_3 (chord_ctor, pitch, dur, modification_list);
2963 /* Todo: actually also use apply iso. call too ... */
2965 ly_input_procedure_p (SCM x)
2967 return ly_is_procedure (x)
2968 || (scm_is_pair (x) && ly_is_procedure (scm_car (x)));
2972 yylex (YYSTYPE *s, YYLTYPE *loc, void *v)
2974 Lily_parser *pars = (Lily_parser*) v;
2975 Lily_lexer *lex = pars->lexer_;
2977 lex->lexval_ = (void*) s;
2979 lex->prepare_for_next_token ();
2980 return lex->yylex ();