]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/parser.yy
* lily/modified-font-metric.cc (text_dimension): try
[lilypond.git] / lily / parser.yy
index 078c19e098b7da04e3af1e4b9fd38d28bd30ba34..d9fa443eb72823fe4d1db5321d5705a4f6f787af 100644 (file)
@@ -54,7 +54,8 @@ TODO:
 
 Music *property_op_to_music (SCM op);
 Music *context_spec_music (SCM type, SCM id, Music *m, SCM ops);
-SCM get_next_unique_context ();
+SCM get_next_unique_context_id ();
+SCM get_next_unique_lyrics_context_id ();
 
 #define YYERROR_VERBOSE 1
 
@@ -100,12 +101,26 @@ is_regular_identifier (SCM id)
   return v;
 }
 
+
+SCM
+get_first_context_id (SCM type, Music *m)
+{
+       SCM id = m->get_property ("context-id");
+       if (SCM_BOOL_T == scm_equal_p (m->get_property ("context-type"), type)
+           && scm_is_string (m->get_property ("context-id"))
+           && scm_c_string_length (id) > 0)
+       {
+               return id;
+       }
+       return SCM_EOL;
+}
+
 SCM
 make_simple_markup (SCM encoding, SCM a)
 {
-       SCM simple = ly_scheme_function ("simple-markup");
+       SCM simple = ly_lily_module_constant ("simple-markup");
        if (scm_is_symbol (encoding))
-               return scm_list_3 (ly_scheme_function ("encoded-simple-markup"),
+               return scm_list_3 (ly_lily_module_constant ("encoded-simple-markup"),
                           encoding, a);
        return scm_list_2 (simple, a);
 }
@@ -139,7 +154,7 @@ make_chord_step (int step, int alter)
 SCM
 make_chord (SCM pitch, SCM dur, SCM modification_list)
 {
-       SCM chord_ctor = ly_scheme_function ("construct-chord");
+       SCM chord_ctor = ly_lily_module_constant ("construct-chord");
        SCM ch = scm_call_3 (chord_ctor, pitch, dur, modification_list);
        scm_gc_protect_object (ch);
        return ch;
@@ -253,7 +268,6 @@ or
 %token ALTERNATIVE
 %token BAR
 %token BOOK
-%token BOOKPAPER
 %token CHANGE
 %token CHORDMODIFIERS
 %token CHORDS
@@ -277,6 +291,7 @@ or
 %token HYPHEN
 %token INVALID
 %token KEY
+%token LAYOUT
 %token LYRICS
 %token LYRICMODE
 %token MARK
@@ -285,6 +300,7 @@ or
 %token NAME
 %token NEWCONTEXT
 %token NOTEMODE
+%token OBJECTID        
 %token OCTAVE
 %token ONCE
 %token OVERRIDE SET REVERT
@@ -365,6 +381,11 @@ or
 %token <scm> MUSIC_FUNCTION_SCM_MUSIC 
 %token <scm> MUSIC_FUNCTION_SCM_MUSIC_MUSIC 
 %token <scm> MUSIC_FUNCTION_SCM_SCM_MUSIC 
+%token <scm> MUSIC_FUNCTION_MARKUP 
+%token <scm> MUSIC_FUNCTION_MARKUP_MARKUP 
+%token <scm> MUSIC_FUNCTION_MARKUP_MUSIC 
+%token <scm> MUSIC_FUNCTION_MARKUP_MUSIC_MUSIC 
+%token <scm> MUSIC_FUNCTION_MARKUP_MARKUP_MUSIC 
 
 %token DRUMS
 %token DRUMMODE
@@ -394,7 +415,7 @@ or
 %type <music>  tempo_event
 
 %type <outputdef>      output_def_body output_def_head
-%type <outputdef> output_def book_paper_block 
+%type <outputdef> output_def paper_block 
 
 %type <scm>    Music_list
 %type <scm>    chord_body_elements
@@ -423,9 +444,11 @@ or
 %type <scm>    Generic_prefix_music_scm 
 %type <scm>    lyric_element
 %type <scm>     Alternative_music
-%type <scm>    markup markup_line markup_list markup_list_body full_markup
+%type <scm>    full_markup markup_list markup_composed_list markup_braced_list markup_braced_list_body 
+%type <scm>    markup_head_1_item markup_head_1_list markup simple_markup markup_top
 %type <scm>    mode_changing_head
 %type <scm>    mode_changing_head_with_context
+%type <scm>     object_id_setting 
 
 %type <score>  score_block score_body
 
@@ -452,6 +475,11 @@ lilypond:  /* empty */
        }
        ;
 
+
+object_id_setting:
+       OBJECTID STRING { $$ = $2; } 
+       ;
+
 toplevel_expression:
        lilypond_header {
                THIS->lexer_->set_identifier (ly_symbol2scm ("$globalheader"), $1);
@@ -486,8 +514,8 @@ toplevel_expression:
                        id = ly_symbol2scm ("$defaultpaper");
                else if ($1->c_variable ("is-midi") == SCM_BOOL_T)
                        id = ly_symbol2scm ("$defaultmidi");
-               else if ($1->c_variable ("is-bookpaper") == SCM_BOOL_T)
-                       id = ly_symbol2scm ("$defaultbookpaper");
+               else if ($1->c_variable ("is-layout") == SCM_BOOL_T)
+                       id = ly_symbol2scm ("$defaultlayout");
 
                THIS->lexer_->set_identifier (id, od->self_scm ());
                scm_gc_unprotect_object (od->self_scm ());
@@ -638,31 +666,33 @@ book_block:
 
 /* FIXME:
    * Use 'handlers' like for toplevel-* stuff?
-   * grok \paper and \midi?  */
+   * grok \layout and \midi?  */
 book_body:
        {
                $$ = new Book;
                $$->set_spot (THIS->here_input ());
-               $$->bookpaper_ = dynamic_cast<Output_def*> (unsmob_output_def (THIS->lexer_->lookup_identifier ("$defaultbookpaper"))->clone ());
-               scm_gc_unprotect_object ($$->bookpaper_->self_scm ());
+               $$->paper_ = dynamic_cast<Output_def*> (unsmob_output_def (THIS->lexer_->lookup_identifier ("$defaultpaper"))->clone ());
+               scm_gc_unprotect_object ($$->paper_->self_scm ());
                $$->header_ = THIS->lexer_->lookup_identifier ("$globalheader"); 
        }
-       | book_body book_paper_block {
-               $$->bookpaper_ = $2;
+       | book_body paper_block {
+               $$->paper_ = $2;
                scm_gc_unprotect_object ($2->self_scm ());
        }
        | book_body score_block {
                Score *score = $2;
-               $$->scores_.push (score);
-               scm_gc_unprotect_object (score->self_scm ());
+               $$->add_score (score);
        }
        | book_body lilypond_header {
                $$->header_ = $2;
        }
        | book_body error {
-               $$->bookpaper_ = 0;
+               $$->paper_ = 0;
                $$->scores_.clear();
        }
+       | book_body object_id_setting {
+               $$->user_key_ = ly_scm2string ($2);
+       }
        ;
 
 score_block:
@@ -685,6 +715,9 @@ score_body:
                $$ = new Score ( *unsmob_score ($1));
                $$->set_spot (THIS->here_input ());
        }
+       | score_body object_id_setting {
+               $$->user_key_ = ly_scm2string ($2);
+       }
        | score_body Music {
                SCM m = $2->self_scm ();
                scm_gc_unprotect_object (m);
@@ -694,9 +727,9 @@ score_body:
                $$->header_ = $2;
        }
        | score_body output_def {
-               if ($2->lookup_variable (ly_symbol2scm ("is-bookpaper")) == SCM_BOOL_T)
+               if ($2->lookup_variable (ly_symbol2scm ("is-paper")) == SCM_BOOL_T)
                {
-                       THIS->parser_error (_("\\bookpaper cannot be in \\score. Use \\paper instead"));
+                       THIS->parser_error (_("\\paper cannot be in \\score. Use \\layout instead"));
                
                }
                else
@@ -715,13 +748,13 @@ score_body:
        OUTPUT DEF
 */
 
-book_paper_block:
+paper_block:
        output_def {
                $$ = $1;
-               if ($$->lookup_variable (ly_symbol2scm ("is-bookpaper")) != SCM_BOOL_T)
+               if ($$->lookup_variable (ly_symbol2scm ("is-paper")) != SCM_BOOL_T)
                {
-                       THIS->parser_error (_("Need \\bookpaper for bookpaper block."));
-                       $$ = get_bookpaper (THIS);
+                       THIS->parser_error (_("Need \\paper for paper block."));
+                       $$ = get_paper (THIS);
                }
        }
        ;
@@ -737,8 +770,8 @@ output_def:
        ;
 
 output_def_head:
-       BOOKPAPER {
-               $$ = get_bookpaper (THIS);
+       PAPER {
+               $$ = get_paper (THIS);
                $$->input_origin_ = THIS->here_input ();
                THIS->lexer_->add_scope ($$->scope_);
        }
@@ -747,8 +780,8 @@ output_def_head:
                $$ = p;
                THIS->lexer_->add_scope (p->scope_);
        }
-       | PAPER         {
-               Output_def *p = get_paper (THIS);
+       | LAYOUT        {
+               Output_def *p = get_layout (THIS);
 
                THIS->lexer_->add_scope (p->scope_);
                $$ = p;
@@ -870,7 +903,7 @@ Repeated_music:
                }
 
 
-               SCM proc = ly_scheme_function ("make-repeated-music");
+               SCM proc = ly_lily_module_constant ("make-repeated-music");
 
                SCM mus = scm_call_1 (proc, $2);
                scm_gc_protect_object (mus); // UGH.
@@ -892,7 +925,7 @@ Repeated_music:
                        we can not get durations and other stuff correct down the line, so we have to
                        add to the duration log here.
                        */
-                       SCM func = ly_scheme_function ("shift-duration-log");
+                       SCM func = ly_lily_module_constant ("shift-duration-log");
 
                        int dots = ($3 % 3) ? 0 : 1;
                        int shift = -intlog2 ((dots) ? ($3*2/3) : $3);
@@ -989,6 +1022,11 @@ Generic_prefix_music_scm:
        } embedded_scm {
                $$ = scm_list_3 ($1, make_input (THIS->pop_spot ()), $3);
        }
+       | MUSIC_FUNCTION_MARKUP {
+               THIS->push_spot ();
+       } full_markup {
+               $$ = scm_list_3 ($1, make_input (THIS->pop_spot ()), $3);
+       }
        | MUSIC_FUNCTION_MUSIC {
                THIS->push_spot (); 
        } Music {
@@ -1006,6 +1044,22 @@ Generic_prefix_music_scm:
        }  embedded_scm embedded_scm {
                $$ = scm_list_4 ($1, make_input (THIS->pop_spot ()), $3, $4);
        }
+       | MUSIC_FUNCTION_SCM_SCM_MUSIC {
+               THIS->push_spot (); 
+       }  embedded_scm embedded_scm Music {
+               $$ = scm_list_5 ($1, make_input (THIS->pop_spot ()), $3, $4, $5->self_scm ());
+       }
+       | MUSIC_FUNCTION_MARKUP_MUSIC {
+               THIS->push_spot (); 
+       }  full_markup Music {
+               $$ = scm_list_4 ($1, make_input (THIS->pop_spot ()), $3, $4->self_scm ());
+               scm_gc_unprotect_object ($4->self_scm ());
+       }
+       | MUSIC_FUNCTION_MARKUP_MARKUP {
+               THIS->push_spot (); 
+       }  full_markup full_markup {
+               $$ = scm_list_4 ($1, make_input (THIS->pop_spot ()), $3, $4);
+       }
        | MUSIC_FUNCTION_MUSIC_MUSIC {
                THIS->push_spot (); 
        }  Music  Music {
@@ -1021,6 +1075,14 @@ Generic_prefix_music_scm:
                scm_gc_unprotect_object ($5->self_scm ());
                scm_gc_unprotect_object ($4->self_scm ());
        }
+       | MUSIC_FUNCTION_MARKUP_MUSIC_MUSIC {
+               THIS->push_spot (); 
+       } full_markup Music Music {
+               $$ = scm_list_5 ($1, make_input (THIS->pop_spot ()),
+                       $3, $4->self_scm (), $5->self_scm ());
+               scm_gc_unprotect_object ($5->self_scm ());
+               scm_gc_unprotect_object ($4->self_scm ());
+       }
        ;
 
 Generic_prefix_music:
@@ -1029,28 +1091,27 @@ Generic_prefix_music:
                Input *loc = unsmob_input (scm_cadr ($1));
                SCM args = scm_cddr ($1);
                SCM sig = scm_object_property (func, ly_symbol2scm ("music-function-signature"));
-               int k = 0;
-               bool ok  = true; 
-               for (SCM s = sig, t = args;
-                       ok && scm_is_pair (s) && scm_is_pair (t);
-                       s = scm_cdr (s), t = scm_cdr (t)) {
-                       k++;
-                       if (scm_call_1 (scm_car (s), scm_car (t)) != SCM_BOOL_T)
-                       {
-                               loc->error (_f ("Argument %d failed typecheck", k));
-                               THIS->error_level_ = 1;
-                               ok = false;
-                       }
+
+               SCM type_check_proc = ly_lily_module_constant ("type-check-list");
+               bool ok  = true;
+
+               if (!to_boolean (scm_call_3  (type_check_proc, scm_cadr ($1), sig, args)))
+               {
+                       THIS->error_level_ = 1;
+                       ok = false;
                }
+
                SCM m = SCM_EOL;
-               if (ok)
-                       m = scm_apply_0 (func, scm_cdr ($1));
+               if (ok)
+                       m = scm_apply_0 (func, scm_cons (THIS->self_scm(),
+                                                        scm_cdr ($1)));
+
                if (unsmob_music (m))
                        {
                        $$ = unsmob_music (m);
                        scm_gc_protect_object (m);
                        }
-               else 
+               else
                        {
                        if (ok)
                                loc->error (_ ("Music head function should return Music object.")); 
@@ -1073,7 +1134,7 @@ Prefix_composite_music:
                $$ = context_spec_music ($2, SCM_UNDEFINED, $4, $3);
        }
        | NEWCONTEXT simple_string optional_context_mod Music {
-               $$ = context_spec_music ($2, get_next_unique_context (), $4,
+               $$ = context_spec_music ($2, get_next_unique_context_id (), $4,
                        $3);
        }
 
@@ -1111,7 +1172,7 @@ Prefix_composite_music:
        | mode_changing_head Grouped_music_list {
                if ($1 == ly_symbol2scm ("chords"))
                {
-                 Music *chm = MY_MAKE_MUSIC ("UntransposableMusic");
+                 Music *chm = MY_MAKE_MUSIC ("UnrelativableMusic");
                  chm->set_property ("element", $2->self_scm ());
                  $$ = chm;
                  scm_gc_unprotect_object ($2->self_scm ());
@@ -1123,11 +1184,11 @@ Prefix_composite_music:
                THIS->lexer_->pop_state ();
        }
        | mode_changing_head_with_context optional_context_mod Grouped_music_list {
-               $$ = context_spec_music ($1, get_next_unique_context (),
+               $$ = context_spec_music ($1, get_next_unique_context_id (),
                                         $3, $2);
                if ($1 == ly_symbol2scm ("ChordNames"))
                {
-                 Music *chm = MY_MAKE_MUSIC ("UntransposableMusic");
+                 Music *chm = MY_MAKE_MUSIC ("UnrelativableMusic");
                  chm->set_property ("element", $$->self_scm ());
                  scm_gc_unprotect_object ($$->self_scm ());
                  $$ = chm;
@@ -1237,11 +1298,15 @@ new_lyrics:
 
 re_rhythmed_music:
        Grouped_music_list new_lyrics {
-
-               SCM name = $1->get_property ("context-id");
-               //if (name == SCM_EOL)
+               Music * voice = $1;
+               SCM name = get_first_context_id (scm_makfrom0str ("Voice"), voice); 
                if (!scm_is_string (name))
-                       name = scm_makfrom0str ("");
+               {
+                       name = get_next_unique_lyrics_context_id ();
+                       voice = context_spec_music (scm_makfrom0str ("Voice"),
+                                                   name,
+                                                   voice, SCM_EOL);
+               }
 
                SCM context = scm_makfrom0str ("Lyrics");
                Music *all = MY_MAKE_MUSIC ("SimultaneousMusic");
@@ -1252,15 +1317,13 @@ re_rhythmed_music:
                        Music *music = unsmob_music (scm_car (s));
                        Music *com = make_lyric_combine_music (name, music);
                        Music *csm = context_spec_music (context,
-                               get_next_unique_context (), com, SCM_EOL);
+                               get_next_unique_context_id (), com, SCM_EOL);
                        lst = scm_cons (csm->self_scm (), lst);
                }
-               /* FIXME: only first lyric music is accepted,
-                         the rest is junked */
-               all->set_property ("elements", scm_cons ($1->self_scm (),
+               all->set_property ("elements", scm_cons (voice->self_scm (),
                        lst));
                $$ = all;
-               scm_gc_unprotect_object ($1->self_scm ());
+               scm_gc_unprotect_object (voice->self_scm ());
        }
        | LYRICSTO {
                THIS->lexer_->push_lyric_state ();
@@ -1275,7 +1338,7 @@ re_rhythmed_music:
 
 context_change:
        CHANGE STRING '=' STRING  {
-               Music*t= MY_MAKE_MUSIC ("ContextChange");
+               Music*t = MY_MAKE_MUSIC ("ContextChange");
                t-> set_property ("change-to-type", scm_string_to_symbol ($2));
                t-> set_property ("change-to-id", $4);
 
@@ -1544,7 +1607,7 @@ chord_body_element:
 
 add_quote:
        ADDQUOTE string Music {
-               SCM adder = ly_scheme_function ("add-quotable");
+               SCM adder = ly_lily_module_constant ("add-quotable");
                
                scm_call_2 (adder, $2, $3->self_scm ());
                scm_gc_unprotect_object ($3->self_scm ());
@@ -1566,14 +1629,6 @@ command_element:
 
                $$ = skip;
        }
-       | QUOTE STRING duration_length {
-               Music *quote = MY_MAKE_MUSIC ("QuoteMusic");
-               quote->set_property ("duration", $3);
-               quote->set_property ("quoted-music-name", $2);
-               quote->set_spot (THIS->here_input ());
-
-               $$ = quote;
-       }
        | OCTAVE { THIS->push_spot (); }
          pitch {
                Music *m = MY_MAKE_MUSIC ("RelativeOctaveCheck");
@@ -1606,7 +1661,7 @@ command_element:
                $$->set_spot (THIS->here_input ());
        }
        | '|'      {
-               SCM pipe =THIS->lexer_->lookup_identifier ("pipeSymbol");
+               SCM pipe = THIS->lexer_->lookup_identifier ("pipeSymbol");
 
                if (Music * m = unsmob_music (pipe))
                        $$ = m->clone ();
@@ -1644,21 +1699,21 @@ command_element:
                $$ = p;
        }
        | CLEF STRING  {
-               SCM proc = ly_scheme_function ("make-clef-set");
+               SCM proc = ly_lily_module_constant ("make-clef-set");
 
                SCM result = scm_call_1 (proc, $2);
                scm_gc_protect_object (result);
                $$ = unsmob_music (result);
        }
        | TIME_T fraction  {
-               SCM proc= ly_scheme_function ("make-time-signature-set");
+               SCM proc = ly_lily_module_constant ("make-time-signature-set");
 
                SCM result = scm_apply_2   (proc, scm_car ($2), scm_cdr ($2), SCM_EOL);
                scm_gc_protect_object (result);
                $$ = unsmob_music (result);
        }
        | MARK scalar {
-               SCM proc = ly_scheme_function ("make-mark-set");
+               SCM proc = ly_lily_module_constant ("make-mark-set");
 
                SCM result = scm_call_1 (proc, $2);
                scm_gc_protect_object (result);
@@ -1678,17 +1733,17 @@ command_req:
                $$ = $1;
        }
        | KEY DEFAULT {
-               Music *key= MY_MAKE_MUSIC ("KeyChangeEvent");
+               Music *key = MY_MAKE_MUSIC ("KeyChangeEvent");
                $$ = key;
        }
        | KEY NOTENAME_PITCH SCM_IDENTIFIER     {
 
-               Music *key= MY_MAKE_MUSIC ("KeyChangeEvent");
+               Music *key = MY_MAKE_MUSIC ("KeyChangeEvent");
                if (scm_ilength ($3) > 0)
                {               
                        key->set_property ("pitch-alist", $3);
                        key->set_property ("tonic", Pitch (0,0,0).smobbed_copy ());
-                       ((Music*)key)->transpose (* unsmob_pitch ($2));
+                       key->transpose (* unsmob_pitch ($2));
                } else {
                        THIS->parser_error (_ ("Second argument must be pitch list."));
                }
@@ -2046,12 +2101,12 @@ tremolo_type:
 bass_number:
        DIGIT   {
                $$ = scm_number_to_string (scm_int2num ($1), scm_int2num (10));
-               $$ = scm_list_2 (ly_scheme_function ("number-markup"),
+               $$ = scm_list_2 (ly_lily_module_constant ("number-markup"),
                                $$);
        }
        | UNSIGNED {
                $$ = scm_number_to_string (scm_int2num ($1), scm_int2num (10));
-               $$ = scm_list_2 (ly_scheme_function ("number-markup"),
+               $$ = scm_list_2 (ly_lily_module_constant ("number-markup"),
                                $$);
        }
        | STRING { $$ = $1; }
@@ -2213,7 +2268,7 @@ simple_element:
        | MULTI_MEASURE_REST optional_notemode_duration         {
                THIS->pop_spot ();
 
-               SCM proc = ly_scheme_function ("make-multi-measure-rest");
+               SCM proc = ly_lily_module_constant ("make-multi-measure-rest");
                SCM mus = scm_call_2 (proc, $2,
                        make_input (THIS->here_input ()));      
                scm_gc_protect_object (mus);
@@ -2409,57 +2464,90 @@ questions:
        | questions '?' { $$ ++; }
        ;
 
-
+/*
+This should be done more dynamically if possible.
+*/
 
 full_markup:
        MARKUP_IDENTIFIER {
                $$ = $1;
-       }
+       }
        | MARKUP
                { THIS->lexer_->push_markup_state (); }
-       markup
-               $$ = $3;
-                 THIS->lexer_->pop_state ();
-               }
+       markup_top {
+               $$ = $3;
+               THIS->lexer_->pop_state ();
+       }
        ;
 
+markup_top:
+       markup_list { 
+               $$ = scm_list_2 (ly_lily_module_constant ("line-markup"),  $1); 
+       }
+       | markup_head_1_list simple_markup      {
+               $$ = scm_car (scm_call_2 (ly_lily_module_constant ("map-markup-command-list"), $1, scm_list_1 ($2)));
+       }
+       | simple_markup {
+               $$ = $1;
+       }
+       ;
 
-/*
-This should be done more dynamically if possible.
-*/
-markup:
-       STRING {
-               $$ = make_simple_markup (THIS->lexer_->encoding (), $1);
+markup_list:
+       markup_composed_list {
+               $$ = $1;
        }
-       | MARKUP_HEAD_EMPTY {
-               $$ = scm_list_1 ($1);
+       | markup_braced_list {
+               $$ = $1;
        }
-       | MARKUP_HEAD_MARKUP0 markup {
-               $$ = scm_list_2 ($1, $2);
+       ;
+
+markup_composed_list:
+       markup_head_1_list markup_braced_list {
+               $$ = scm_call_2 (ly_lily_module_constant ("map-markup-command-list"), $1, $2);
+               
        }
-       | MARKUP_HEAD_MARKUP0_MARKUP1 markup markup {
-               $$ = scm_list_3 ($1, $2, $3);
+       ;
+
+markup_braced_list:
+       '{' markup_braced_list_body '}' {
+               $$ = scm_reverse_x ($2, SCM_EOL);
        }
-       | MARKUP_HEAD_SCM0_MARKUP1 SCM_T markup {
-               $$ = scm_list_3 ($1, $2, $3);
+       ;
+
+markup_braced_list_body:
+       /* empty */     {  $$ = scm_list (SCM_EOL); }
+       | markup_braced_list_body markup {
+               $$ = scm_cons ($2, $1);
        }
-       | markup_line {
-               $$ = $1;
+       | markup_braced_list_body markup_list {
+               $$ = scm_append_x (scm_list_2 (scm_reverse_x ($2, SCM_EOL), $1));
        }
-       | MARKUP_HEAD_LIST0 markup_list {
-               $$ = scm_list_2 ($1,$2);
+       ;
+
+markup_head_1_item:
+       MARKUP_HEAD_MARKUP0     {
+               $$ = scm_list_1 ($1);
        }
-       | MARKUP_HEAD_SCM0 embedded_scm {
+       | MARKUP_HEAD_SCM0_MARKUP1 embedded_scm {
                $$ = scm_list_2 ($1, $2);
        }
-       | MARKUP_HEAD_SCM0_SCM1_MARKUP2 embedded_scm embedded_scm markup {
-               $$ = scm_list_4 ($1, $2, $3, $4);
+       | MARKUP_HEAD_SCM0_SCM1_MARKUP2 embedded_scm embedded_scm       {
+               $$ = scm_list_3 ($1, $2, $3);
        }
-       | MARKUP_HEAD_SCM0_SCM1_SCM2 embedded_scm embedded_scm embedded_scm {
-               $$ = scm_list_4 ($1, $2, $3, $4);
+       ;
+
+markup_head_1_list:
+       markup_head_1_item      {
+               $$ = scm_list_1 ($1);
        }
-       | MARKUP_HEAD_SCM0_SCM1 embedded_scm embedded_scm {
-               $$ = scm_list_3 ($1, $2, $3);
+       | markup_head_1_list markup_head_1_item {
+               $$ = scm_cons ($2, $1);
+       }
+       ;
+
+simple_markup:
+       STRING {
+               $$ = make_simple_markup (THIS->lexer_->encoding (), $1);
        }
        | MARKUP_IDENTIFIER {
                $$ = $1;
@@ -2472,32 +2560,39 @@ markup:
                THIS->lexer_->push_note_state (alist_to_hashq (nn));
        } '{' score_body '}' {
                Score * sc = $4;
-               $$ = scm_list_2 (ly_scheme_function ("score-markup"), sc->self_scm ());
+               $$ = scm_list_2 (ly_lily_module_constant ("score-markup"), sc->self_scm ());
                scm_gc_unprotect_object (sc->self_scm ());
                THIS->lexer_->pop_state ();
        }
+       | MARKUP_HEAD_SCM0 embedded_scm {
+               $$ = scm_list_2 ($1, $2);
+       }
+       | MARKUP_HEAD_SCM0_SCM1_SCM2 embedded_scm embedded_scm embedded_scm {
+               $$ = scm_list_4 ($1, $2, $3, $4);
+       }
+       | MARKUP_HEAD_SCM0_SCM1 embedded_scm embedded_scm {
+               $$ = scm_list_3 ($1, $2, $3);
+       }
+       | MARKUP_HEAD_EMPTY {
+               $$ = scm_list_1 ($1);
+       }
+       | MARKUP_HEAD_LIST0 markup_list {
+               $$ = scm_list_2 ($1,$2);
+       }
+       | MARKUP_HEAD_MARKUP0_MARKUP1 markup markup {
+               $$ = scm_list_3 ($1, $2, $3);
+       }
        ;
-
-markup_list:
-       chord_open markup_list_body chord_close { $$ = scm_reverse_x ($2, SCM_EOL); }
-       ;
-
-markup_line:
-       '{' markup_list_body '}' {
-               SCM line = ly_scheme_function ("line-markup");
        
-               $$ = scm_list_2 (line, scm_reverse_x ($2, SCM_EOL));
+markup:
+       markup_head_1_list simple_markup        {
+               $$ = scm_car (scm_call_2 (ly_lily_module_constant ("map-markup-command-list"), $1, scm_list_1 ($2)));
        }
-       ;
-
-markup_list_body:
-       /**/ {  $$ = SCM_EOL; }
-       | markup_list_body markup {
-               $$ = scm_cons ($2, $1);
+       | simple_markup {
+               $$ = $1;
        }
        ;
 
-
 %%
 
 void
@@ -2661,15 +2756,18 @@ context_spec_music (SCM type, SCM id, Music *m, SCM ops)
        return csm;
 }
 
-/*
-FIXME: this should be postponed until the music hits \Score
-*/
 SCM
-get_next_unique_context ()
+get_next_unique_context_id ()
+{
+       return scm_makfrom0str ("$uniqueContextId");
+}
+
+
+SCM
+get_next_unique_lyrics_context_id ()
 {
        static int new_context_count;
-       char s[1024];
+       char s[128];
        snprintf (s, 1024, "uniqueContext%d", new_context_count++);
        return scm_makfrom0str (s);
 }
-