X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fparser.yy;h=8ea6f1958daf8ec5d883557c7851d422ec7cb091;hb=9e781b7dc83b60a543ce218aa1a5f139f74c760f;hp=e20b9f11cc58cf3b51ed0b0bf411be0769db7198;hpb=ffaadf12aaf98a96d6f6ca1358458dff0405fe14;p=lilypond.git diff --git a/lily/parser.yy b/lily/parser.yy index e20b9f11cc..8ea6f1958d 100644 --- a/lily/parser.yy +++ b/lily/parser.yy @@ -2,7 +2,7 @@ /* This file is part of LilyPond, the GNU music typesetter. - Copyright (C) 1997--2012 Han-Wen Nienhuys + Copyright (C) 1997--2014 Han-Wen Nienhuys Jan Nieuwenhuizen LilyPond is free software: you can redistribute it and/or modify @@ -336,7 +336,6 @@ If we give names, Bison complains. %token CONTEXT_MOD_IDENTIFIER %token DRUM_PITCH %token PITCH_IDENTIFIER -%token PITCH_ARG %token DURATION_IDENTIFIER %token EVENT_IDENTIFIER %token EVENT_FUNCTION @@ -625,6 +624,11 @@ assignment: parser->lexer_->set_identifier (path, $4); $$ = SCM_UNSPECIFIED; } + | assignment_id '.' property_path '=' identifier_init { + SCM path = scm_cons (scm_string_to_symbol ($1), $3); + parser->lexer_->set_identifier (path, $5); + $$ = SCM_UNSPECIFIED; + } ; @@ -662,6 +666,7 @@ identifier_init_nonumber: | output_def | context_def_spec_block | music_assign + | pitch_or_music | FRACTION | string | embedded_scm @@ -1043,7 +1048,7 @@ output_def_head_with_mode_switch: // is still time to escape from notes mode. music_or_context_def: - music_arg + music_assign | context_def_spec_block ; @@ -1126,8 +1131,17 @@ braced_music_list: } ; -music: music_arg +music: music_assign | lyric_element_music + | pitch_or_music + { + $$ = make_music_from_simple (parser, @1, $1); + if (!unsmob_music ($$)) + { + parser->parser_error (@1, _ ("music expected")); + $$ = MAKE_SYNTAX ("void-music", @$); + } + } ; music_embedded: @@ -1182,19 +1196,8 @@ music_embedded_backup: } ; -music_arg: - simple_music - { - $$ = make_music_from_simple (parser, @1, $1); - if (!unsmob_music ($$)) - { - parser->parser_error (@1, _ ("music expected")); - $$ = MAKE_SYNTAX ("void-music", @$); - } - } - | composite_music %prec COMPOSITE - ; - +// music_assign does not need to contain lyrics: there are no +// assignments in lyricmode. music_assign: simple_music | composite_music %prec COMPOSITE @@ -1454,6 +1457,16 @@ function_arglist_nonbackup: { $$ = check_scheme_arg (parser, @4, $4, $3, $2); } + | function_arglist_nonbackup_reparse REPARSE pitch_or_music + { + if (scm_is_true (scm_call_1 ($2, $3))) + $$ = scm_cons ($3, $1); + else + $$ = check_scheme_arg (parser, @3, + make_music_from_simple + (parser, @3, $3), + $1, $2); + } | function_arglist_nonbackup_reparse REPARSE duration_length { $$ = check_scheme_arg (parser, @3, $3, $1, $2); @@ -1494,6 +1507,28 @@ function_arglist_nonbackup_reparse: else MYREPARSE (@4, $2, SCM_ARG, $4); } + | EXPECT_OPTIONAL EXPECT_SCM function_arglist_nonbackup pitch + { + $$ = $3; + if (scm_is_true + (scm_call_1 + ($2, make_music_from_simple + (parser, @4, $4)))) + MYREPARSE (@4, $2, PITCH_IDENTIFIER, $4); + else + MYREPARSE (@4, $2, SCM_ARG, $4); + } + | EXPECT_OPTIONAL EXPECT_SCM function_arglist_nonbackup steno_tonic_pitch + { + $$ = $3; + if (scm_is_true + (scm_call_1 + ($2, make_music_from_simple + (parser, @4, $4)))) + MYREPARSE (@4, $2, TONICNAME_PITCH, $4); + else + MYREPARSE (@4, $2, SCM_ARG, $4); + } | EXPECT_OPTIONAL EXPECT_SCM function_arglist_nonbackup STRING { $$ = $3; @@ -1573,6 +1608,38 @@ function_arglist_backup: MYBACKUP (EVENT_IDENTIFIER, $4, @4); } } + | EXPECT_OPTIONAL EXPECT_SCM function_arglist_backup pitch + { + if (scm_is_true + (scm_call_1 + ($2, make_music_from_simple + (parser, @4, $4)))) + { + $$ = $3; + MYREPARSE (@4, $2, PITCH_IDENTIFIER, $4); + } else if (scm_is_true (scm_call_1 ($2, $4))) + $$ = scm_cons ($4, $3); + else { + $$ = scm_cons (loc_on_music (@3, $1), $3); + MYBACKUP (PITCH_IDENTIFIER, $4, @4); + } + } + | EXPECT_OPTIONAL EXPECT_SCM function_arglist_backup steno_tonic_pitch + { + if (scm_is_true + (scm_call_1 + ($2, make_music_from_simple + (parser, @4, $4)))) + { + $$ = $3; + MYREPARSE (@4, $2, TONICNAME_PITCH, $4); + } else if (scm_is_true (scm_call_1 ($2, $4))) + $$ = scm_cons ($4, $3); + else { + $$ = scm_cons (loc_on_music (@3, $1), $3); + MYBACKUP (TONICNAME_PITCH, $4, @4); + } + } | EXPECT_OPTIONAL EXPECT_SCM function_arglist_backup full_markup { if (scm_is_true (scm_call_1 ($2, $4))) @@ -1703,7 +1770,7 @@ function_arglist_backup: MYBACKUP (STRING, $4, @4); } } - | function_arglist_backup REPARSE music_assign + | function_arglist_backup REPARSE pitch_or_music { if (scm_is_true (scm_call_1 ($2, $3))) $$ = scm_cons ($3, $1); @@ -1713,11 +1780,6 @@ function_arglist_backup: (parser, @3, $3), $1, $2); } - | function_arglist_backup REPARSE pitch_arg - { - $$ = check_scheme_arg (parser, @3, - $3, $1, $2); - } | function_arglist_backup REPARSE bare_number_common { $$ = check_scheme_arg (parser, @3, @@ -1789,6 +1851,16 @@ function_arglist_common: $$ = check_scheme_arg (parser, @3, $3, $1, $2); } + | function_arglist_common_reparse REPARSE pitch_or_music + { + if (scm_is_true (scm_call_1 ($2, $3))) + $$ = scm_cons ($3, $1); + else + $$ = check_scheme_arg (parser, @3, + make_music_from_simple + (parser, @3, $3), + $1, $2); + } | function_arglist_common_reparse REPARSE bare_number_common { $$ = check_scheme_arg (parser, @3, @@ -1824,6 +1896,28 @@ function_arglist_common_reparse: // know the predicate to be false. MYREPARSE (@3, $1, SCM_ARG, $3); } + | EXPECT_SCM function_arglist_optional pitch + { + $$ = $2; + if (scm_is_true + (scm_call_1 + ($1, make_music_from_simple + (parser, @3, $3)))) + MYREPARSE (@3, $1, PITCH_IDENTIFIER, $3); + else + MYREPARSE (@3, $1, SCM_ARG, $3); + } + | EXPECT_SCM function_arglist_optional steno_tonic_pitch + { + $$ = $2; + if (scm_is_true + (scm_call_1 + ($1, make_music_from_simple + (parser, @3, $3)))) + MYREPARSE (@3, $1, TONICNAME_PITCH, $3); + else + MYREPARSE (@3, $1, SCM_ARG, $3); + } | EXPECT_SCM function_arglist_optional STRING { $$ = $2; @@ -2381,6 +2475,7 @@ symbol: scalar: embedded_scm_arg + | pitch_or_music | SCM_IDENTIFIER | bare_number // The following is a rather defensive variant of admitting @@ -2394,40 +2489,17 @@ scalar: { $$ = scm_difference ($2, SCM_UNDEFINED); } - | STRING - | full_markup + | string ; event_chord: simple_element post_events { // Let the rhythmic music iterator sort this mess out. if (scm_is_pair ($2)) { - $$ = make_music_from_simple (parser, @1, $1); - if (unsmob_music ($$)) - unsmob_music ($$)->set_property ("articulations", - scm_reverse_x ($2, SCM_EOL)); - else - { - parser->parser_error (@1, _("music expected")); - $$ = MAKE_SYNTAX ("void-music", @1); - } + unsmob_music ($$)->set_property ("articulations", + scm_reverse_x ($2, SCM_EOL)); } } %prec ':' - | simple_chord_elements post_events { - if (scm_is_pair ($2)) { - if (unsmob_pitch ($1)) - $1 = make_chord_elements (@1, - $1, - parser->default_duration_.smobbed_copy (), - SCM_EOL); - - SCM elts = ly_append2 ($1, scm_reverse_x ($2, SCM_EOL)); - - $$ = MAKE_SYNTAX ("event-chord", @1, elts); - } else if (!unsmob_pitch ($1)) - $$ = MAKE_SYNTAX ("event-chord", @1, $1); - // A mere pitch drops through. - } %prec ':' | CHORD_REPETITION optional_notemode_duration post_events { Input i; i.set_location (@1, @3); @@ -2440,7 +2512,7 @@ event_chord: $$ = MAKE_SYNTAX ("multi-measure-rest", i, $2, scm_reverse_x ($3, SCM_EOL)); } %prec ':' - | command_element + | tempo_event | note_chord_element ; @@ -2543,19 +2615,6 @@ event_function_event: } ; -command_element: - command_event { - $$ = $1; - } - ; - -command_event: - tempo_event { - $$ = $1; - } - ; - - post_events: /* empty */ { $$ = SCM_EOL; @@ -2754,17 +2813,6 @@ pitch: } ; -pitch_arg: - PITCH_ARG quotes { - if (!scm_is_eq (SCM_INUM0, $2)) - { - Pitch p = *unsmob_pitch ($1); - p = p.transposed (Pitch (scm_to_int ($2),0,0)); - $$ = p.smobbed_copy (); - } - } - ; - gen_text_def: full_markup { Music *t = MY_MAKE_MUSIC ("TextScriptEvent", @$); @@ -3015,15 +3063,16 @@ optional_rest: | REST { $$ = SCM_BOOL_T; } ; -simple_element: - pitch exclamations questions octave_check maybe_notemode_duration optional_rest { +pitch_or_music: + pitch exclamations questions octave_check maybe_notemode_duration optional_rest post_events { if (!parser->lexer_->is_note_state ()) parser->parser_error (@1, _ ("have to be in Note mode for notes")); if (!SCM_UNBNDP ($2) || !SCM_UNBNDP ($3) || scm_is_number ($4) || !SCM_UNBNDP ($5) - || scm_is_true ($6)) + || scm_is_true ($6) + || scm_is_pair ($7)) { Music *n = 0; if (scm_is_true ($6)) @@ -3048,11 +3097,31 @@ simple_element: n->set_property ("cautionary", SCM_BOOL_T); if (to_boolean ($2) || to_boolean ($3)) n->set_property ("force-accidental", SCM_BOOL_T); - + if (scm_is_pair ($7)) + n->set_property ("articulations", + scm_reverse_x ($7, SCM_EOL)); $$ = n->unprotect (); } - } - | DRUM_PITCH optional_notemode_duration { + } %prec ':' + | simple_chord_elements post_events { + if (scm_is_pair ($2)) { + if (unsmob_pitch ($1)) + $1 = make_chord_elements (@1, + $1, + parser->default_duration_.smobbed_copy (), + SCM_EOL); + + SCM elts = ly_append2 ($1, scm_reverse_x ($2, SCM_EOL)); + + $$ = MAKE_SYNTAX ("event-chord", @1, elts); + } else if (!unsmob_pitch ($1)) + $$ = MAKE_SYNTAX ("event-chord", @1, $1); + // A mere pitch drops through. + } %prec ':' + ; + +simple_element: + DRUM_PITCH optional_notemode_duration { Music *n = MY_MAKE_MUSIC ("NoteEvent", @$); n->set_property ("duration", $2); n->set_property ("drum-type", $1);