]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/parser.yy
Fix 1259/1433: linebreaks with \breakDynamicSpan or spanners with style=#'none
[lilypond.git] / lily / parser.yy
index abcf101386d6da55e5c7f6a511afeeadb77d3eeb..6c45e5950717b12c093bc339aaad79985718052f 100644 (file)
@@ -1,7 +1,7 @@
 /*
   This file is part of LilyPond, the GNU music typesetter.
 
-  Copyright (C) 1997--2010 Han-Wen Nienhuys <hanwen@xs4all.nl>
+  Copyright (C) 1997--2011 Han-Wen Nienhuys <hanwen@xs4all.nl>
                  Jan Nieuwenhuizen <janneke@gnu.org>
 
   LilyPond is free software: you can redistribute it and/or modify
@@ -270,6 +270,8 @@ If we give names, Bison complains.
 /* Artificial tokens, for more generic function syntax */
 %token <i> EXPECT_MARKUP;
 %token <i> EXPECT_MUSIC;
+%token <i> EXPECT_PITCH;
+%token <i> EXPECT_DURATION;
 %token <i> EXPECT_SCM;
 %token <i> EXPECT_MARKUP_LIST
 /* After the last argument. */
@@ -290,6 +292,7 @@ If we give names, Bison complains.
 %token <scm> MARKUP_FUNCTION
 %token <scm> MARKUP_LIST_FUNCTION
 %token <scm> MARKUP_IDENTIFIER
+%token <scm> MARKUPLINES_IDENTIFIER
 %token <scm> MUSIC_FUNCTION
 %token <scm> MUSIC_IDENTIFIER
 %token <scm> NOTENAME_PITCH
@@ -324,6 +327,7 @@ If we give names, Bison complains.
 /* Music */
 %type <scm> composite_music
 %type <scm> grouped_music_list
+%type <scm> closed_music
 %type <scm> music
 %type <scm> prefix_composite_music
 %type <scm> repeated_music
@@ -437,6 +441,7 @@ If we give names, Bison complains.
 %type <scm> step_number
 %type <scm> step_numbers
 %type <scm> string
+%type <scm> tempo_range
 
 %type <score> score_block
 %type <score> score_body
@@ -614,6 +619,9 @@ identifier_init:
        | full_markup {
                $$ = $1;
        }
+       | full_markup_list {
+               $$ = $1;
+       }
        | DIGIT {
                $$ = scm_from_int ($1);
        }
@@ -906,20 +914,14 @@ output_def_body:
        ;
 
 tempo_event:
-       TEMPO steno_duration '=' bare_unsigned  {
-               $$ = MAKE_SYNTAX ("tempo", @$, SCM_BOOL_F, $2, scm_from_int ($4));
-       }
-       | TEMPO string steno_duration '=' bare_unsigned {
-               $$ = MAKE_SYNTAX ("tempo", @$, make_simple_markup($2), $3, scm_from_int ($5));
-       }
-       | TEMPO full_markup steno_duration '=' bare_unsigned    {
-               $$ = MAKE_SYNTAX ("tempo", @$, $2, $3, scm_from_int ($5));
+       TEMPO steno_duration '=' tempo_range    {
+               $$ = MAKE_SYNTAX ("tempo", @$, SCM_EOL, $2, $4);
        }
-       | TEMPO string {
-               $$ = MAKE_SYNTAX ("tempoText", @$, make_simple_markup($2) );
+       | TEMPO scalar steno_duration '=' tempo_range   {
+               $$ = MAKE_SYNTAX ("tempo", @$, $2, $3, $5);
        }
-       | TEMPO full_markup {
-               $$ = MAKE_SYNTAX ("tempoText", @$, $2 );
+       | TEMPO scalar {
+               $$ = MAKE_SYNTAX ("tempo", @$, $2);
        }
        ;
 
@@ -1055,6 +1057,12 @@ composite_music:
        | grouped_music_list { $$ = $1; }
        ;
 
+/* Music that can't be followed by additional events or durations */
+closed_music:
+       MUSIC_IDENTIFIER
+       | grouped_music_list
+       ;
+
 grouped_music_list:
        simultaneous_music              { $$ = $1; }
        | sequential_music              { $$ = $1; }
@@ -1076,12 +1084,23 @@ function_arglist_music_last:
        ;
 
 function_arglist_nonmusic_last:
-       EXPECT_MARKUP function_arglist full_markup {
+       EXPECT_NO_MORE_ARGS {
+               /* This is for 0-ary functions, so they don't need to
+                  read a lookahead token */
+               $$ = SCM_EOL;
+       }
+       | EXPECT_MARKUP function_arglist full_markup {
                $$ = scm_cons ($3, $2);
        }
        | EXPECT_MARKUP function_arglist simple_string {
                $$ = scm_cons ($3, $2);
        }
+       | EXPECT_PITCH function_arglist pitch {
+               $$ = scm_cons ($3, $2);
+       }
+       | EXPECT_DURATION function_arglist_nonmusic_last duration_length {
+               $$ = scm_cons ($3, $2);
+       }
        | EXPECT_SCM function_arglist function_scm_argument {
                $$ = scm_cons ($3, $2);
        }
@@ -1096,23 +1115,25 @@ function_arglist_nonmusic: EXPECT_NO_MORE_ARGS {
        | EXPECT_MARKUP function_arglist_nonmusic simple_string {
                $$ = scm_cons ($3, $2);
        }
+       | EXPECT_PITCH function_arglist_nonmusic pitch {
+               $$ = scm_cons ($3, $2);
+       }
+       | EXPECT_DURATION function_arglist_nonmusic duration_length {
+               $$ = scm_cons ($3, $2);
+       }
        | EXPECT_SCM function_arglist_nonmusic function_scm_argument {
                $$ = scm_cons ($3, $2);
        }
        ;
 
-function_arglist: EXPECT_NO_MORE_ARGS {
-               /* This is for 0-ary functions, so they don't need to
-                  read a lookahead token */
-               $$ = SCM_EOL;
-       }
-       | function_arglist_music_last
+function_arglist:
+       function_arglist_music_last
        | function_arglist_nonmusic_last
        ;
 
 generic_prefix_music_scm:
        MUSIC_FUNCTION function_arglist {
-               $$ = ly_append2 (scm_list_2 ($1, make_input (@$)), scm_reverse_x ($2, SCM_EOL));
+               $$ = scm_cons ($1, scm_cons (make_input (@$), scm_reverse_x ($2, SCM_EOL)));
        }
        ;
 
@@ -1254,7 +1275,7 @@ relative_music:
 new_lyrics:
        ADDLYRICS { PARSER->lexer_->push_lyric_state (); }
        /*cont */
-       grouped_music_list {
+       closed_music {
        /* Can also use music at the expensive of two S/Rs similar to
            \repeat \alternative */
                PARSER->lexer_->pop_state ();
@@ -1263,14 +1284,14 @@ new_lyrics:
        }
        | new_lyrics ADDLYRICS {
                PARSER->lexer_->push_lyric_state ();
-       } grouped_music_list {
+       } closed_music {
                PARSER->lexer_->pop_state ();
                $$ = scm_cons ($4, $1);
        }
        ;
 
 re_rhythmed_music:
-       grouped_music_list new_lyrics {
+       closed_music new_lyrics {
                $$ = MAKE_SYNTAX ("add-lyrics", @$, $1, scm_reverse_x ($2, SCM_EOL));
        }
        | LYRICSTO simple_string {
@@ -1433,7 +1454,7 @@ simple_string: STRING {
 scalar: string {
                $$ = $1;
        }
-       | LYRICS_STRING {
+       | lyric_element {
                $$ = $1;
        }
        | bare_number {
@@ -1549,7 +1570,6 @@ chord_body_element:
        }
        | DRUM_PITCH post_events {
                Music *n = MY_MAKE_MUSIC ("NoteEvent", @$);
-               n->set_property ("duration", $2);
                n->set_property ("drum-type", $1);
 
                if (scm_is_pair ($2)) {
@@ -1577,10 +1597,10 @@ music_function_chord_body:
           but it's more consistent with music_function_event if we
           prohibit it here too */
        music_function_identifier_musicless_prefix EXPECT_MUSIC function_arglist_nonmusic chord_body_element {
-               $$ = ly_append2 (scm_list_2 ($1, make_input (@$)), scm_reverse_x ($3, scm_list_1 ($4)));
+               $$ = scm_cons ($1, scm_cons (make_input (@$), scm_reverse_x ($3, scm_list_1 ($4))));
        }
        | music_function_identifier_musicless_prefix function_arglist_nonmusic {
-               $$ = ly_append2 (scm_list_2 ($1, make_input (@$)), scm_reverse_x ($2, SCM_EOL));
+               $$ = scm_cons ($1, scm_cons (make_input (@$), scm_reverse_x ($2, SCM_EOL)));
        }
        ;
 
@@ -1589,10 +1609,10 @@ music_function_event:
           restriction we get a shift/reduce conflict from e.g.
           c8-\partcombine c8 -. */
        music_function_identifier_musicless_prefix EXPECT_MUSIC function_arglist_nonmusic post_event {
-               $$ = ly_append2 (scm_list_2 ($1, make_input (@$)), scm_reverse_x ($3, scm_list_1 ($4)));
+               $$ = scm_cons ($1, scm_cons (make_input (@$), scm_reverse_x ($3, scm_list_1 ($4))));
        }
        | music_function_identifier_musicless_prefix function_arglist_nonmusic {
-               $$ = ly_append2 (scm_list_2 ($1, make_input (@$)), scm_reverse_x ($2, SCM_EOL));
+               $$ = scm_cons ($1, scm_cons (make_input (@$), scm_reverse_x ($2, SCM_EOL)));
        }
        ;
 
@@ -1690,8 +1710,12 @@ post_event:
        direction_less_event {
                $$ = $1;
        }
-       | '-' music_function_event {
+       | script_dir music_function_event {
                $$ = run_music_function (PARSER, $2);
+               if ($1)
+               {
+                       unsmob_music ($$)->set_property ("direction", scm_from_int ($1));
+               }
        }
        | HYPHEN {
                if (!PARSER->lexer_->is_lyric_state ())
@@ -2274,6 +2298,15 @@ step_number:
        }
        ;
 
+tempo_range:
+       bare_unsigned {
+               $$ = scm_from_int ($1);
+       }
+       | bare_unsigned '~' bare_unsigned {
+               $$ = scm_cons (scm_from_int ($1), scm_from_int ($3));
+       }
+       ;
+
 /*
        UTILITIES
 
@@ -2345,7 +2378,6 @@ unsigned_number:
        }
        ;
 
-
 exclamations:
                { $$ = 0; }
        | exclamations '!'      { $$ ++; }
@@ -2373,7 +2405,10 @@ lyric_markup:
        ;
 
 full_markup_list:
-       MARKUPLINES
+       MARKUPLINES_IDENTIFIER {
+               $$ = $1;
+       }
+       | MARKUPLINES
                { PARSER->lexer_->push_markup_state (); }
        markup_list {
                $$ = $3;
@@ -2406,7 +2441,10 @@ markup_top:
        ;
 
 markup_list:
-       markup_composed_list {
+       MARKUPLINES_IDENTIFIER {
+               $$ = $1;
+       }
+       | markup_composed_list {
                $$ = $1;
        }
        | markup_braced_list {
@@ -2599,6 +2637,9 @@ Lily_lexer::try_special_identifiers (SCM *destination, SCM sid)
                if (is_lyric_state ())
                        return LYRIC_MARKUP_IDENTIFIER;
                return MARKUP_IDENTIFIER;
+       } else if (Text_interface::is_markup_list (sid)) {
+               *destination = sid;
+               return MARKUPLINES_IDENTIFIER;
        }
 
        return -1;