]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/parser.yy
New upstream version 2.19.80
[lilypond.git] / lily / parser.yy
index f81dc69e9b56faa2e82b4052f86448b492c1a347..a95f44a9f2fc811a7c2fe23475b28ac01e72ce01 100644 (file)
@@ -672,7 +672,13 @@ header_block:
 */
 assignment_id:
        STRING
+       {
+               $$ = scm_string_to_symbol ($1);
+       }
        | SYMBOL
+       {
+               $$ = scm_string_to_symbol ($1);
+       }
        ;
 
 assignment:
@@ -681,15 +687,29 @@ assignment:
                 $$ = SCM_UNSPECIFIED;
        }
        | assignment_id '.' property_path '=' identifier_init {
-               SCM path = scm_cons (scm_string_to_symbol ($1), $3);
+               SCM path = scm_cons ($1, $3);
                parser->lexer_->set_identifier (path, $5);
                 $$ = SCM_UNSPECIFIED;
        }
        | assignment_id ',' property_path '=' identifier_init {
-               SCM path = scm_cons (scm_string_to_symbol ($1), $3);
+               SCM path = scm_cons ($1, $3);
                parser->lexer_->set_identifier (path, $5);
                 $$ = SCM_UNSPECIFIED;
        }
+       | markup_mode_word '=' identifier_init
+       {
+               if (scm_is_false (Lily::markup_function_p ($3)))
+               {
+                       parser->parser_error (@3, _ ("Not a markup function"));
+               } else {
+                       scm_primitive_eval
+                               (scm_list_3
+                                (Lily::define_markup_command,
+                                 scm_string_to_symbol ($1),
+                                 ly_quote_scm ($3)));
+               }
+               $$ = SCM_UNSPECIFIED;
+       }
        ;
 
 
@@ -3155,13 +3175,15 @@ post_event_nofinger:
                $$ = $1;
        }
        | script_dir music_function_call {
-               $$ = $2;
-               if (!unsmob<Music> ($2)->is_mus_type ("post-event")) {
+               Music *m = unsmob<Music> ($2);
+               if (!m->is_mus_type ("post-event")) {
                        parser->parser_error (@2, _ ("post-event expected"));
                        $$ = SCM_UNSPECIFIED;
-               } else if (!SCM_UNBNDP ($1))
-               {
-                       unsmob<Music> ($$)->set_property ("direction", $1);
+               } else {
+                       m->set_spot (parser->lexer_->override_input (@$));
+                       if (!SCM_UNBNDP ($1))
+                               m->set_property ("direction", $1);
+                       $$ = $2;
                }
        }
        | HYPHEN {
@@ -3175,36 +3197,42 @@ post_event_nofinger:
                $$ = MY_MAKE_MUSIC ("ExtenderEvent", @$)->unprotect ();
        }
        | script_dir direction_reqd_event {
-               if (!SCM_UNBNDP ($1))
-               {
-                       Music *m = unsmob<Music> ($2);
-                       m->set_property ("direction", $1);
+               if (Music *m = unsmob<Music> ($2)) {
+                       m->set_spot (parser->lexer_->override_input (@$));
+                       if (!SCM_UNBNDP ($1))
+                       {
+                               m->set_property ("direction", $1);
+                       }
                }
                $$ = $2;
        }
        | script_dir direction_less_event {
+               Music *m = unsmob<Music> ($2);
+               m->set_spot (parser->lexer_->override_input (@$));
                if (!SCM_UNBNDP ($1))
-               {
-                       Music *m = unsmob<Music> ($2);
                        m->set_property ("direction", $1);
-               }
                $$ = $2;
        }
        | '^' fingering
        {
+               Music *m = unsmob<Music> ($2);
+               m->set_spot (parser->lexer_->override_input (@$));
+               m->set_property ("direction", scm_from_int (UP));
                $$ = $2;
-               unsmob<Music> ($$)->set_property ("direction", scm_from_int (UP));
        }
        | '_' fingering
        {
+               Music *m = unsmob<Music> ($2);
+               m->set_spot (parser->lexer_->override_input (@$));
+               m->set_property ("direction", scm_from_int (DOWN));
                $$ = $2;
-               unsmob<Music> ($$)->set_property ("direction", scm_from_int (DOWN));
        }
        ;
 
 post_event:
        post_event_nofinger
        | '-' fingering {
+               unsmob<Music> ($2)->set_spot (parser->lexer_->override_input (@$));
                $$ = $2;
        }
        ;
@@ -3244,11 +3272,11 @@ direction_reqd_event:
                        Music *original = unsmob<Music> (s);
                        if (original && original->is_mus_type ("post-event")) {
                                Music *a = original->clone ();
-                               a->set_spot (parser->lexer_->override_input (@$));
+                               // origin will be set by post_event_nofinger
                                $$ = a->unprotect ();
                        } else {
                                parser->parser_error (@1, _ ("expecting string or post-event as script definition"));
-                               $$ = MY_MAKE_MUSIC ("PostEvents", @$)->unprotect ();
+                               $$ = SCM_UNSPECIFIED;
                        }
                }
        }
@@ -3357,8 +3385,10 @@ gen_text_def:
                        Music *t = MY_MAKE_MUSIC ("TextScriptEvent", @$);
                        t->set_property ("text", $1);
                        $$ = t->unprotect ();
-               } else
+               } else {
                        parser->parser_error (@1, _ ("not an articulation"));
+                       $$ = SCM_UNSPECIFIED;
+               }
        }
        ;
 
@@ -3893,11 +3923,33 @@ markup_mode:
        }
        ;
 
+// Sort-of ugly: We need this as markup of its own as well as in
+// markup function assignments, without triggering lookahead or the
+// '=' for assignments will be parsed in markup mode and not
+// recognized.  Worse: the next token following something like
+// \markup "string" would be parsed in markup mode as well.
+//
+// So we make a single production here that's used either in markup or
+// in assignment.
+
+markup_mode_word:
+       markup_mode markup_word
+       {
+               $$ = $2;
+               parser->lexer_->pop_state ();
+       }
+       ;
+
+
 full_markup:
        markup_mode markup_top {
                $$ = $2;
                parser->lexer_->pop_state ();
        }
+       | markup_mode_word
+       {
+               $$ = make_simple_markup ($1);
+       }
        ;
 
 partial_markup:
@@ -3917,7 +3969,7 @@ markup_top:
                $$ = scm_car (MAKE_SYNTAX (composed_markup_list,
                                           @2, $1, scm_list_1 ($2)));
        }
-       | simple_markup {
+       | simple_markup_noword {
                $$ = $1;
        }
        ;
@@ -4064,14 +4116,21 @@ markup_head_1_list:
        }
        ;
 
+markup_word:
+       STRING
+       | SYMBOL
+       ;
+
 simple_markup:
-       STRING {
-               $$ = make_simple_markup ($1);
-       }
-       | SYMBOL {
+       markup_word
+       {
                $$ = make_simple_markup ($1);
        }
-       | SCORE {
+       | simple_markup_noword
+       ;
+
+simple_markup_noword:
+       SCORE {
                parser->lexer_->push_note_state (Lily::pitchnames);
        } '{' score_body '}' {
                Score *sc = unsmob<Score> ($4);