]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/parser.yy
patch::: 1.3.121.jcn2
[lilypond.git] / lily / parser.yy
index c39f5ecc3213085677164bf29120b8b0730c3165..bbfaf2438a0e1bbb40796afc234d53a2a2a9cb89 100644 (file)
@@ -21,7 +21,6 @@
 #include "file-path.hh"
 #include "debug.hh"
 #include "dimensions.hh"
-#include "identifier.hh"
 #include "command-request.hh"
 #include "musical-request.hh"
 #include "my-lily-parser.hh"
@@ -42,6 +41,7 @@
 #include "grace-music.hh"
 #include "auto-change-music.hh"
 #include "part-combine-music.hh"
+#include "scm-hash.hh"
 
 #include "chord.hh"
 
@@ -95,12 +95,11 @@ print_lilypond_versions (ostream &os)
 %union {
 
     Link_array<Request> *reqvec;
-    Identifier *id;
     String * string;
     Music *music;
     Score *score;
     Scope *scope;
-
+    Scheme_hash_table *scmhash;
     Musical_req* musreq;
     Music_output_def * outputdef;
 
@@ -171,7 +170,7 @@ yylex (YYSTYPE *s,  void * v_l)
 %token MEASURES
 %token MIDI
 %token MM_T
-%token MUSICAL_PITCH
+%token PITCH
 %token NAME
 %token PITCHNAMES
 %token NOTES
@@ -215,8 +214,8 @@ yylex (YYSTYPE *s,  void * v_l)
 %token <id>    IDENTIFIER
 
 
-%token <id>    SCORE_IDENTIFIER
-%token <id>    MUSIC_OUTPUT_DEF_IDENTIFIER
+%token <scm>   SCORE_IDENTIFIER
+%token <scm>   MUSIC_OUTPUT_DEF_IDENTIFIER
 
 %token <scm>   NUMBER_IDENTIFIER
 %token <scm>   REQUEST_IDENTIFIER
@@ -229,7 +228,7 @@ yylex (YYSTYPE *s,  void * v_l)
 %token <real>   REAL
 
 %type <outputdef> output_def
-%type <scope>  lilypond_header lilypond_header_body
+%type <scmhash>        lilypond_header lilypond_header_body
 %type <request>        open_request_parens close_request_parens open_request close_request
 %type <request> request_with_dir request_that_take_dir verbose_request
 %type <i>      sub_quotes sup_quotes
@@ -246,8 +245,8 @@ yylex (YYSTYPE *s,  void * v_l)
        
 %type <reqvec>  pre_requests post_requests
 %type <request> gen_text_def
-%type <scm>   steno_musical_pitch musical_pitch absolute_musical_pitch
-%type <scm>   steno_tonic_pitch
+%type <scm>   steno_pitch pitch absolute_pitch
+%type <scm>   explicit_pitch steno_tonic_pitch
 
 %type <scm>    chord_additions chord_subtractions chord_notes chord_step
 %type <music>  chord
@@ -302,19 +301,19 @@ toplevel_expression:
                THIS->lexer_p_->chordmodifier_tab_  = $1;
        }
        | lilypond_header {
-               delete header_global_p;
-               header_global_p = $1;
+               if (global_header_p)
+                       scm_unprotect_object (global_header_p->self_scm ());
+               global_header_p = $1;
        }
        | score_block {
                score_global_array.push ($1);
+               
        }
        | output_def {
-               Identifier * id = new
-                       Music_output_def_identifier ($1, MUSIC_OUTPUT_DEF_IDENTIFIER);
                if (dynamic_cast<Paper_def*> ($1))
-                       THIS->lexer_p_->set_identifier ("$defaultpaper", id->self_scm ());
+                       THIS->lexer_p_->set_identifier ("$defaultpaper", $1->self_scm ());
                else if (dynamic_cast<Midi_def*> ($1))
-                       THIS->lexer_p_->set_identifier ("$defaultmidi", id->self_scm ());
+                       THIS->lexer_p_->set_identifier ("$defaultmidi", $1->self_scm ());
        }
        | embedded_scm {
                // junk value
@@ -357,8 +356,10 @@ notenames_body:
 
 lilypond_header_body:
        {
-               $$ = new Scope;
-               THIS->lexer_p_-> scope_l_arr_.push ($$);
+               $$ = new Scheme_hash_table;
+               
+               Scope *sc = new Scope ($$);
+               THIS->lexer_p_-> scope_l_arr_.push (sc);
        }
        | lilypond_header_body assignment semicolon { 
 
@@ -368,7 +369,7 @@ lilypond_header_body:
 lilypond_header:
        HEADER '{' lilypond_header_body '}'     {
                $$ = $3;
-               THIS->lexer_p_-> scope_l_arr_.pop ();
+               delete THIS->lexer_p_-> scope_l_arr_.pop ();
        }
        ;
 
@@ -390,9 +391,10 @@ assignment:
 all objects can be unprotected as soon as they're here.
 
 */
-               Identifier * id =unsmob_identifier ($4);
-               Input spot = THIS->pop_spot ();
-               if (id) id->set_spot (spot);
+       /*
+               Should find generic way of associating input with objects.
+       */
+               THIS->pop_spot ();
        }
        ;
 
@@ -400,10 +402,12 @@ all objects can be unprotected as soon as they're here.
 
 identifier_init:
        score_block {
-               $$ = (new Score_identifier ($1, SCORE_IDENTIFIER))->self_scm();
+               $$ = $1->self_scm ();
+               scm_unprotect_object ($$);
        }
        | output_def {
-               $$ = (new Music_output_def_identifier ($1, MUSIC_OUTPUT_DEF_IDENTIFIER))->self_scm();
+               $$ = $1->self_scm ();
+               scm_unprotect_object ($$);
        }
        | translator_spec_block {
                $$ = $1;
@@ -507,35 +511,28 @@ score_block:
                $$ = $4;
                if (!$$->def_p_arr_.size ())
                {
-                 Identifier *id =
-                       unsmob_identifier (THIS->lexer_p_->lookup_identifier ("$defaultpaper"));
-                 $$->add_output (id ? id->access_content_Music_output_def (true) : new Paper_def );
+                 Music_output_def *id =
+                       unsmob_music_output_def (THIS->lexer_p_->lookup_identifier ("$defaultpaper"));
+                 $$->add_output (id ? id->clone () :  new Paper_def );
                }
        }
-/*
-       | SCORE '{' score_body error {
-               $$ = $3
-               $$->set_spot (THIS->here_input ());
-               // THIS->here_input ().error ("SCORE INVALID");
-               $$->error ("SCORE INVALID");
-               THIS->parser_error (_f ("SCORE ERROR"));
-       }
-*/
        ;
 
 score_body:
        Music   {
                $$ = new Score;
-
+       
                $$->set_spot (THIS->here_input ());
                SCM m = $1->self_scm ();
                scm_unprotect_object (m);
                $$->music_ = m;
        }
        | SCORE_IDENTIFIER {
-               $$ = $1->access_content_Score (true);
+               $$ = new Score (*unsmob_score ($1));
+               $$->set_spot (THIS->here_input ());
        }
        | score_body lilypond_header    {
+               scm_unprotect_object ($2->self_scm ()); 
                $$->header_p_ = $2;
        }
        | score_body output_def {
@@ -559,12 +556,12 @@ output_def:
 
 music_output_def_body:
        MIDI '{'    {
-        Identifier *id = unsmob_identifier (THIS->lexer_p_->lookup_identifier ("$defaultmidi"));
+          Music_output_def *id = unsmob_music_output_def (THIS->lexer_p_->lookup_identifier ("$defaultmidi"));
 
                
         Midi_def* p =0;
        if (id)
-               p = dynamic_cast<Midi_def*> (id->access_content_Music_output_def (true));
+               p = dynamic_cast<Midi_def*> (id->clone ());
        else
                p = new Midi_def;
 
@@ -572,22 +569,25 @@ music_output_def_body:
         THIS->lexer_p_->scope_l_arr_.push (p->scope_p_);
        }
        | PAPER '{'     {
-                 Identifier *id = unsmob_identifier (THIS->lexer_p_->lookup_identifier ("$defaultpaper"));
+               Music_output_def *id = unsmob_music_output_def (THIS->lexer_p_->lookup_identifier ("$defaultpaper"));
                  Paper_def *p = 0;
                if (id)
-                       p = dynamic_cast<Paper_def*> (id->access_content_Music_output_def (true));
+                       p = dynamic_cast<Paper_def*> (id->clone ());
                else
                        p = new Paper_def;
                THIS-> lexer_p_-> scope_l_arr_.push (p->scope_p_);
                $$ = p;
        }
        | PAPER '{' MUSIC_OUTPUT_DEF_IDENTIFIER         {
-               Music_output_def *p = $3->access_content_Music_output_def (true);
+               Music_output_def *p = unsmob_music_output_def ($3);
+               p = p->clone();
                THIS->lexer_p_->scope_l_arr_.push (p->scope_p_);
                $$ = p;
        }
        | MIDI '{' MUSIC_OUTPUT_DEF_IDENTIFIER  {
-               Music_output_def *p = $3->access_content_Music_output_def (true);
+               Music_output_def *p = unsmob_music_output_def ($3);
+               p = p->clone();
+
                THIS->lexer_p_->scope_l_arr_.push (p->scope_p_);
                $$ = p;
        }
@@ -629,8 +629,6 @@ Music_list: /* empty */ {
                SCM s = $$;
                SCM c = gh_cons ($2->self_scm (), SCM_EOL);
                scm_unprotect_object ($2->self_scm ()); /* UGH */
-
-       
                if (gh_pair_p (gh_cdr (s)))
                        gh_set_cdr_x (gh_cdr (s), c); /* append */
                else
@@ -663,13 +661,30 @@ Alternative_music:
 Repeated_music:
        REPEAT STRING bare_unsigned Music Alternative_music
        {
-               Music_sequence* m = dynamic_cast <Music_sequence*> ($5);
-               if (m && $3 < m->length_i ())
+               Music_sequence* alts = dynamic_cast <Music_sequence*> ($5);
+               if (alts && $3 < alts->length_i ())
                        $5->origin ()->warning (_ ("More alternatives than repeats.  Junking excess alternatives."));
+               Music *beg = $4;
+               int times = $3;
+
+               Repeated_music * r = new Repeated_music (SCM_EOL);
+
+               if (beg)
+                       {
+                       r-> set_mus_property ("body", beg->self_scm ());
+                       scm_unprotect_object (beg->self_scm ());
+                       }
+               r->set_mus_property ("repeat-count", gh_int2scm (times >? 1));
 
+               if (alts)
+                       {
+                       alts->truncate (times);
+                       r-> set_mus_property ("alternatives", alts->self_scm ());
+                       scm_unprotect_object (alts->self_scm ());  
+                       }
                SCM func = scm_eval2 (ly_symbol2scm ("repeat-name-to-ctor"), SCM_EOL);
                SCM result = gh_call1 (func, $2);
-               Repeated_music * r = new Repeated_music ($4, $3 >? 1, m);
+
                set_music_properties (r, result);
 
                r->set_spot (*$4->origin ());
@@ -678,25 +693,31 @@ Repeated_music:
        ;
 
 Music_sequence: '{' Music_list '}'     {
-               $$ = new Music_sequence (gh_car ($2));
+               $$ = new Music_sequence (SCM_EOL);
+               $$->set_mus_property ("elements", gh_car ($2));
        }
        ;
 
 Sequential_music:
        SEQUENTIAL '{' Music_list '}'           {
-               $$ = new Sequential_music (gh_car ($3));
+               $$ = new Sequential_music (SCM_EOL);
+               $$->set_mus_property ("elements", gh_car ($3));
        }
        | '{' Music_list '}'            {
-               $$ = new Sequential_music (gh_car ($2));
+               $$ = new Sequential_music (SCM_EOL);
+               $$->set_mus_property ("elements", gh_car ($2));
        }
        ;
 
 Simultaneous_music:
        SIMULTANEOUS '{' Music_list '}'{
-               $$ = new Simultaneous_music (gh_car ($3));
+               $$ = new Simultaneous_music (SCM_EOL);
+               $$->set_mus_property ("elements", gh_car ($3));
+
        }
        | '<' Music_list '>'    {
-               $$ = new Simultaneous_music (gh_car ($2));
+               $$ = new Simultaneous_music (SCM_EOL);
+               $$->set_mus_property ("elements", gh_car ($2));
        }
        ;
 
@@ -714,7 +735,7 @@ Simple_music:
                        THIS->parser_error (_("First argument must be a procedure taking 1 argument"));
                }
 
-         Music *m = new Music;
+         Music *m = new Music (SCM_EOL);
          m->set_mus_property ("predicate", pred);
          m->set_mus_property ("symbol", $3);
          m->set_mus_property ("value",  $5);
@@ -741,7 +762,9 @@ Simple_music:
 
 Composite_music:
        CONTEXT STRING Music    {
-               Context_specced_music *csm =  new Context_specced_music ($3);
+               Context_specced_music *csm =  new Context_specced_music (SCM_EOL);
+               csm->set_mus_property ("element", $3->self_scm ());
+               scm_unprotect_object ($3->self_scm ());
 
                csm->set_mus_property ("context-type",$2);
                csm->set_mus_property ("context-id", ly_str02scm (""));
@@ -749,17 +772,25 @@ Composite_music:
                $$ = csm;
        }
        | AUTOCHANGE STRING Music       {
-               Auto_change_music * chm = new Auto_change_music ($3);
+               Auto_change_music * chm = new Auto_change_music (SCM_EOL);
+               chm->set_mus_property ("element", $3->self_scm ());
+
+               scm_unprotect_object ($3->self_scm ());
                chm->set_mus_property ("what", $2); 
 
                $$ = chm;
                chm->set_spot (*$3->origin ());
        }
        | GRACE Music {
-               $$ = new Grace_music ($2);
+               $$ = new Grace_music (SCM_EOL);
+               $$->set_mus_property ("element", $2->self_scm ());
+               scm_unprotect_object ($2->self_scm ());
+
        }
        | CONTEXT STRING '=' STRING Music {
-               Context_specced_music *csm =  new Context_specced_music ($5);
+               Context_specced_music *csm =  new Context_specced_music (SCM_EOL);
+               csm->set_mus_property ("element", $5->self_scm ());
+               scm_unprotect_object ($5->self_scm ());
 
                csm->set_mus_property ("context-type", $2);
                csm->set_mus_property ("context-id", $4);
@@ -773,24 +804,47 @@ Composite_music:
                bare_unsigned '/' bare_unsigned Music   
 
        {
-               $$ = new Time_scaled_music ($3, $5, $6);
+               int n = $3; int d = $5;
+               Music *mp = $6;
+               $$ = new Time_scaled_music (SCM_EOL);
                $$->set_spot (THIS->pop_spot ());
+
+
+               $$->set_mus_property ("element", mp->self_scm ());
+               scm_unprotect_object (mp->self_scm ());
+               $$->set_mus_property ("numerator", gh_int2scm (n));
+               $$->set_mus_property ("denominator", gh_int2scm (d));
+               $$->compress (Moment (n,d));
+
        }
        | Repeated_music                { $$ = $1; }
        | Simultaneous_music            { $$ = $1; }
        | Sequential_music              { $$ = $1; }
-       | TRANSPOSE musical_pitch Music {
-               $$ = new Transposed_music ($3, *unsmob_pitch ($2));
+       | TRANSPOSE pitch Music {
+               $$ = new Transposed_music (SCM_EOL);
+               Music *p = $3;
+               Pitch pit = *unsmob_pitch ($2);
+
+               p->transpose (pit);
+               $$->set_mus_property ("element", p->self_scm ());
+               scm_unprotect_object (p->self_scm ());
        }
        | TRANSPOSE steno_tonic_pitch Music {
-               $$ = new Transposed_music ($3, *unsmob_pitch ($2));
+               $$ = new Transposed_music (SCM_EOL);
+               Music *p = $3;
+               Pitch pit = *unsmob_pitch ($2);
+
+               p->transpose (pit);
+               $$->set_mus_property ("element", p->self_scm ());
+               scm_unprotect_object (p->self_scm ());
+       
        }
        | APPLY embedded_scm Music  {
                SCM ret = gh_call1 ($2, $3->self_scm ());
                Music *m = unsmob_music (ret);
                if (!m) {
                        THIS->parser_error ("\\apply must return a Music");
-                       m = new Music ();
+                       m = new Music (SCM_EOL);
                        }
                $$ = m;
        }
@@ -820,28 +874,49 @@ Composite_music:
        ;
 
 relative_music:
-       RELATIVE absolute_musical_pitch Music {
-               $$ = new Relative_octave_music ($3, *unsmob_pitch ($2));
+       RELATIVE absolute_pitch Music {
+               Music * p = $3;
+               Pitch pit = *unsmob_pitch ($2);
+               $$ = new Relative_octave_music (SCM_EOL);
+
+               $$->set_mus_property ("element", p->self_scm ());
+               scm_unprotect_object (p->self_scm ());
+
+               $$->set_mus_property ("last-pitch", p->to_relative_octave (pit).smobbed_copy ());
+
        }
        ;
 
 re_rhythmed_music:
        ADDLYRICS Music Music {
-               Lyric_combine_music * l = new Lyric_combine_music ($2, $3);
-               $$ = l;
+         Lyric_combine_music * l = new Lyric_combine_music (SCM_EOL);
+         l->set_mus_property ("music", $2->self_scm ());
+         l->set_mus_property ("lyrics", $3->self_scm ());
+         scm_unprotect_object ($3->self_scm ());
+         scm_unprotect_object ($2->self_scm ());
+         $$ = l;
        }
        ;
 
 part_combined_music:
        PARTCOMBINE STRING Music Music {
-               Part_combine_music * p = new Part_combine_music ($2, $3, $4);
+               Part_combine_music * p = new Part_combine_music (SCM_EOL);
+
+               p->set_mus_property ("what", $2);
+               p->set_mus_property ("one", $3->self_scm ());
+               p->set_mus_property ("two", $4->self_scm ());  
+
+               scm_unprotect_object ($3->self_scm());
+               scm_unprotect_object ($4->self_scm());  
+
+
                $$ = p;
        }
        ;
 
 translator_change:
        TRANSLATOR STRING '=' STRING  {
-               Music * t = new Music;
+               Music * t = new Music (SCM_EOL);
                t->set_mus_property ("iterator-ctor",
                        Change_iterator::constructor_cxx_function);
                t-> set_mus_property ("change-to-type", $2);
@@ -854,54 +929,66 @@ translator_change:
 
 property_def:
        PROPERTY STRING '.' STRING '='  scalar {
-               Music *t = new Music;
+               Music *t = new Music (SCM_EOL);
 
                t->set_mus_property ("iterator-ctor",
                        Property_iterator::constructor_cxx_function);
                t->set_mus_property ("symbol", scm_string_to_symbol ($4));
                t->set_mus_property ("value", $6);
 
-               Context_specced_music *csm = new Context_specced_music (t);
+               Context_specced_music *csm = new Context_specced_music (SCM_EOL);
+
+               csm->set_mus_property ("element", t->self_scm ());
+               scm_unprotect_object (t->self_scm ());
+
                $$ = csm;
                $$->set_spot (THIS->here_input ());
 
                csm-> set_mus_property ("context-type", $2);
        }
        | PROPERTY STRING '.' STRING SET embedded_scm '=' embedded_scm {
-               Music *t = new Music;
+               Music *t = new Music (SCM_EOL);
                t->set_mus_property ("iterator-ctor",
                        Push_property_iterator::constructor_cxx_function);
                t->set_mus_property ("symbols", scm_string_to_symbol ($4));
                t->set_mus_property ("pop-first", SCM_BOOL_T);
                t->set_mus_property ("grob-property", $6);
                t->set_mus_property ("grob-value", $8);
-               Context_specced_music *csm = new Context_specced_music (t);
+               Context_specced_music *csm = new Context_specced_music (SCM_EOL);
+               csm->set_mus_property ("element", t->self_scm ());
+               scm_unprotect_object (t->self_scm ());
                $$ = csm;
                $$->set_spot (THIS->here_input ());
 
                csm-> set_mus_property ("context-type", $2);
        }
        | PROPERTY STRING '.' STRING OVERRIDE embedded_scm '=' embedded_scm {
-               Music *t = new Music;
+               Music *t = new Music (SCM_EOL);
                t->set_mus_property ("iterator-ctor",
                        Push_property_iterator::constructor_cxx_function);
                t->set_mus_property ("symbols", scm_string_to_symbol ($4));
                t->set_mus_property ("grob-property", $6);
                t->set_mus_property ("grob-value", $8);
-               Context_specced_music *csm = new Context_specced_music (t);
+               Context_specced_music *csm = new Context_specced_music (SCM_EOL);
+               csm->set_mus_property ("element", t->self_scm ());
+               scm_unprotect_object (t->self_scm ());
+
                $$ = csm;
                $$->set_spot (THIS->here_input ());
 
                csm-> set_mus_property ("context-type", $2);
        }
        | PROPERTY STRING '.' STRING REVERT embedded_scm {
-               Music *t = new Music;
+               Music *t = new Music (SCM_EOL);
                t->set_mus_property ("iterator-ctor",
                        Pop_property_iterator::constructor_cxx_function);
                t->set_mus_property ("symbols", scm_string_to_symbol ($4));
                t->set_mus_property ("grob-property", $6);
 
-               Context_specced_music *csm = new Context_specced_music (t);
+               Context_specced_music *csm = new Context_specced_music (SCM_EOL);
+               csm->set_mus_property ("element", t->self_scm ());
+               scm_unprotect_object (t->self_scm ());
+
                $$ = csm;
                $$->set_spot (THIS->here_input ());
 
@@ -935,26 +1022,30 @@ request_chord:
 
 command_element:
        command_req {
-               $$ = new Request_chord (gh_cons ($1->self_scm (), SCM_EOL));
+               $$ = new Request_chord (SCM_EOL);
+               $$->set_mus_property ("elements", gh_cons ($1->self_scm (), SCM_EOL));
                $$-> set_spot (THIS->here_input ());
                $1-> set_spot (THIS->here_input ());
        }
        | BAR STRING ';'                        {
-               Music *t = new Music;
+               Music *t = new Music (SCM_EOL);
 
                t->set_mus_property ("iterator-ctor",
                        Property_iterator::constructor_cxx_function);
                t->set_mus_property ("symbol", ly_symbol2scm ("whichBar"));
                t->set_mus_property ("value", $2);
 
-               Context_specced_music *csm = new Context_specced_music (t);
+               Context_specced_music *csm = new Context_specced_music (SCM_EOL);
+               csm->set_mus_property ("element", t->self_scm ());
+               scm_unprotect_object (t->self_scm ());
+
                $$ = csm;
                $$->set_spot (THIS->here_input ());
 
                csm->set_mus_property ("context-type", ly_str02scm ("Score"));
        }
        | PARTIAL duration_length ';'   {
-               Music * p = new Music;
+               Music * p = new Music (SCM_EOL);
                p->set_mus_property ("symbol", ly_symbol2scm ( "measurePosition"));
                p->set_mus_property ("iterator-ctor",
                        Property_iterator::constructor_cxx_function);
@@ -962,7 +1053,10 @@ command_element:
                Moment m = - unsmob_duration($2)->length_mom ();
                p->set_mus_property ("value", m.smobbed_copy ());
 
-               Context_specced_music * sp = new Context_specced_music (p);
+               Context_specced_music * sp = new Context_specced_music (SCM_EOL);
+               sp->set_mus_property ("element", p->self_scm ());
+               scm_unprotect_object (p->self_scm ());
+
                $$ =sp ;
                sp-> set_mus_property ("context-type", ly_str02scm ( "Score"));
        }
@@ -972,19 +1066,23 @@ command_element:
 
                SCM l = SCM_EOL;
                for (SCM s = result ; gh_pair_p (s); s = gh_cdr (s)) {
-                       Music * p = new Music;
+                       Music * p = new Music (SCM_EOL);
                        set_music_properties(p, gh_car (s));
                        l = gh_cons (p->self_scm (), l);
                        scm_unprotect_object (p->self_scm ());
                }
-               Sequential_music * seq = new Sequential_music (l);
+               Sequential_music * seq = new Sequential_music (SCM_EOL);
+               seq->set_mus_property ("elements", l);
+
+               Context_specced_music * sp = new Context_specced_music (SCM_EOL);
+               sp->set_mus_property ("element", seq->self_scm ());
+               scm_unprotect_object (seq->self_scm ());
 
-               Context_specced_music * sp = new Context_specced_music (seq);
                $$ =sp ;
                sp-> set_mus_property("context-type", ly_str02scm("Staff"));
        }
        | TIME_T bare_unsigned '/' bare_unsigned ';' {
-               Music * p = new Music;
+               Music * p = new Music (SCM_EOL);
                p->set_mus_property ("symbol",
                        ly_symbol2scm ( "timeSignatureFraction"));
                p->set_mus_property ("iterator-ctor",
@@ -993,8 +1091,11 @@ command_element:
                p->set_mus_property ("value", gh_cons (gh_int2scm ($2),
                                                        gh_int2scm ($4)));
 
-               Context_specced_music * sp = new Context_specced_music (p);
-               $$ =sp ;
+               Context_specced_music * sp = new Context_specced_music (SCM_EOL);
+               sp->set_mus_property ("element", p->self_scm ());
+               scm_unprotect_object (p->self_scm ());
+
+               $$ = sp;
                sp-> set_mus_property ("context-type", ly_str02scm ( "Score"));
        }
        ;
@@ -1196,7 +1297,7 @@ sub_quotes:
        }
        ;
 
-steno_musical_pitch:
+steno_pitch:
        NOTENAME_PITCH  {
                $$ = $1;
        }
@@ -1236,15 +1337,22 @@ steno_tonic_pitch:
        }
        ;
 
-musical_pitch:
-       steno_musical_pitch {
+pitch:
+       steno_pitch {
+               $$ = $1;
+       }
+       | explicit_pitch {
                $$ = $1;
        }
-       | MUSICAL_PITCH embedded_scm {
-               if (!unsmob_pitch ($2))
+       ;
+
+explicit_pitch:
+       PITCH embedded_scm {
+               $$ = $2;
+               if (!unsmob_pitch ($2)) {
                        THIS->parser_error (_f ("Expecting musical-pitch value", 3));
-                Pitch m;
-               $$ = m.smobbed_copy ();
+                        $$ = Pitch ().smobbed_copy ();
+               }
        }
        ;
 
@@ -1382,8 +1490,8 @@ pre_requests:
        }
        ;
 
-absolute_musical_pitch:
-       steno_musical_pitch     {
+absolute_pitch:
+       steno_pitch     {
                $$ = $1;
        }
        ;
@@ -1392,6 +1500,9 @@ duration_length:
        steno_duration {
                $$ = $1;
        }
+       | explicit_duration {
+               $$ = $1;
+       }       
        | duration_length '*' bare_unsigned {
                $$ = unsmob_duration ($$)->compressed ( $3) .smobbed_copy ();
        }
@@ -1413,6 +1524,9 @@ optional_notemode_duration:
        | entered_notemode_duration {
                $$ = $1;
        }
+       | explicit_duration {
+               $$ = $1;
+       }       
        ;
 
 steno_duration:
@@ -1455,7 +1569,7 @@ tremolo_type:
 
 
 simple_element:
-       musical_pitch exclamations questions optional_notemode_duration {
+       pitch exclamations questions optional_notemode_duration {
                if (!THIS->lexer_p_->note_state_b ())
                        THIS->parser_error (_ ("Have to be in Note mode for notes"));
 
@@ -1469,10 +1583,11 @@ simple_element:
                if ($2 % 2 || $3 % 2)
                        n->set_mus_property ("force-accidental", SCM_BOOL_T);
 
-               Simultaneous_music*v = new Request_chord (gh_list (n->self_scm (), SCM_UNDEFINED));
+               Simultaneous_music*v = new Request_chord (SCM_EOL);
+               v->set_mus_property ("elements", gh_list (n->self_scm (), SCM_UNDEFINED));
                
 /*
-FIXME
+FIXME: location is one off, since ptich & duration don't contain origin refs. 
 */
                v->set_spot (THIS->here_input ());
                n->set_spot (THIS->here_input ());
@@ -1497,7 +1612,8 @@ FIXME
                      rest_req_p->set_spot (THIS->here_input());
                        e = rest_req_p->self_scm ();
                    }
-                 Simultaneous_music* velt_p = new Request_chord (gh_list (e,SCM_UNDEFINED));
+                 Simultaneous_music* velt_p = new Request_chord (SCM_EOL);
+               velt_p-> set_mus_property ("elements", gh_list (e,SCM_UNDEFINED));
                  velt_p->set_spot (THIS->here_input());
 
 
@@ -1514,13 +1630,17 @@ FIXME
                sp1->set_mus_property ("span-type", r);
                sp2->set_mus_property ("span-type", r);
 
-               Request_chord * rqc1 = new Request_chord (gh_list (sp1->self_scm (), SCM_UNDEFINED));
-               Request_chord * rqc2 = new Request_chord (gh_list (sk->self_scm (), SCM_UNDEFINED));;
-               Request_chord * rqc3 = new Request_chord(gh_list (sp2->self_scm (), SCM_UNDEFINED));;
+               Request_chord * rqc1 = new Request_chord (SCM_EOL);
+               rqc1->set_mus_property ("elements", gh_list (sp1->self_scm (), SCM_UNDEFINED));
+               Request_chord * rqc2 = new Request_chord (SCM_EOL);
+               rqc2->set_mus_property ("elements", gh_list (sk->self_scm (), SCM_UNDEFINED));;
+               Request_chord * rqc3 = new Request_chord(SCM_EOL);
+               rqc3->set_mus_property ("elements", gh_list (sp2->self_scm (), SCM_UNDEFINED));;
 
                SCM ms = gh_list (rqc1->self_scm (), rqc2->self_scm (), rqc3->self_scm (), SCM_UNDEFINED);
 
-               $$ = new Sequential_music (ms);
+               $$ = new Sequential_music (SCM_EOL);
+               $$->set_mus_property ("elements", ms);
        }
        | STRING { 
                THIS->remember_spot ();
@@ -1538,7 +1658,8 @@ FIXME
                 lreq_p->set_mus_property ("text", $1);
                lreq_p->set_mus_property ("duration",$3);
                lreq_p->set_spot (THIS->here_input());
-               Simultaneous_music* velt_p = new Request_chord (gh_list (lreq_p->self_scm (), SCM_UNDEFINED));
+               Simultaneous_music* velt_p = new Request_chord (SCM_EOL);
+               velt_p->set_mus_property ("elements", gh_list (lreq_p->self_scm (), SCM_UNDEFINED));
 
 
                $$= velt_p;