]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/parser.yy
patch::: 1.3.85.jcn3
[lilypond.git] / lily / parser.yy
index bb7b882e36dc261637d8eb36c9ce13cde659a94a..13fd8184796d9667f048df69e233666db7156314 100644 (file)
@@ -10,6 +10,7 @@
 */
 
 #include <iostream.h>
+#include "translator-def.hh"
 #include "lily-guile.hh"
 #include "translation-property.hh"
 #include "lookup.hh"
@@ -26,7 +27,6 @@
 #include "musical-request.hh"
 #include "my-lily-parser.hh"
 #include "context-specced-music.hh"
-#include "translator-group.hh"
 #include "score.hh"
 #include "music-list.hh"
 #include "change-translator.hh"
@@ -43,6 +43,7 @@
 #include "auto-change-music.hh"
 #include "part-combine-music.hh"
 #include "output-property.hh"
+#include "chord.hh"
 
 bool
 is_duration_b (int t)
@@ -90,12 +91,11 @@ print_mudela_versions (ostream &os)
     Music *music;
     Score *score;
     Scope *scope;
-    Interval *interval;
+
     Musical_req* musreq;
     Music_output_def * outputdef;
     Musical_pitch * pitch;
     Midi_def* midi;
-    Moment *moment;
     Real real;
     Request * request;
 
@@ -106,7 +106,6 @@ of the parse stack onto the heap. */
     SCM scm;
 
     Tempo_req *tempo;
-    Translator_group* trans;
     int i;
 }
 %{
@@ -166,6 +165,7 @@ yylex (YYSTYPE *s,  void * v_l)
 %token PENALTY
 %token PROPERTY
 %token PUSHPROPERTY POPPROPERTY
+%token PUSH POP 
 %token PT_T
 %token RELATIVE
 %token REMOVE
@@ -198,14 +198,14 @@ yylex (YYSTYPE *s,  void * v_l)
 %token <pitch> CHORDMODIFIER_PITCH
 %token <id>    DURATION_IDENTIFIER
 %token <id>    IDENTIFIER
-%token <id>    TRANS_IDENTIFIER
+
 
 %token <id>    SCORE_IDENTIFIER
 %token <id>    MUSIC_OUTPUT_DEF_IDENTIFIER
 
 %token <scm>   NUMBER_IDENTIFIER
 %token <scm>   REQUEST_IDENTIFIER
-%token <scm>   MUSIC_IDENTIFIER
+%token <scm>   MUSIC_IDENTIFIER TRANSLATOR_IDENTIFIER
 %token <scm>   STRING_IDENTIFIER SCM_IDENTIFIER 
 %token <scm>   DURATION RESTNAME
 %token <scm>   STRING 
@@ -253,7 +253,7 @@ yylex (YYSTYPE *s,  void * v_l)
 %type <scm>    string bare_number number_expression
 %type <score>  score_block score_body
 
-%type <trans>  translator_spec_block translator_spec_body
+%type <scm>    translator_spec_block translator_spec_body
 %type <tempo>  tempo_request
 %type <scm> notenames_body notenames_block chordmodifiers_block
 %type <scm>    script_abbreviation
@@ -365,8 +365,6 @@ assignment:
 
 /*
  TODO: devise standard for protection in parser.
-               if (SCM_NIMP($4))
-                       scm_unprotect_object ($4);
 
   The parser stack lives on the C-stack, which means that
 all objects can be unprotected as soon as they're here.
@@ -388,13 +386,15 @@ identifier_init:
                $$ = (new Music_output_def_identifier ($1, MUSIC_OUTPUT_DEF_IDENTIFIER))->self_scm();
        }
        | translator_spec_block {
-               $$ = (new Translator_group_identifier ($1, TRANS_IDENTIFIER))->self_scm();
+               $$ = $1;
        }
        | Music  {
                $$ = $1->self_scm ();
+               scm_unprotect_object ($$);
        }
        | post_request {
                $$ = $1->self_scm ();
+               scm_unprotect_object ($$);
        }
        | explicit_duration {
                $$ = (new Duration_identifier ($1, DURATION_IDENTIFIER))->self_scm ();
@@ -418,24 +418,26 @@ translator_spec_block:
        ;
 
 translator_spec_body:
-       TRANS_IDENTIFIER        {
-               $$ = $1->access_content_Translator_group (true);
-               $$-> set_spot (THIS->here_input ());
+       TRANSLATOR_IDENTIFIER   {
+               $$ = unsmob_translator_def ($1)->clone_scm ();
+               unsmob_translator_def ($$)-> set_spot (THIS->here_input ());
        }
        | TYPE STRING semicolon {
-               Translator* t = get_translator_l (ly_scm2string ($2));
-               Translator_group * tg = dynamic_cast<Translator_group*> (t);
-
-               if (!tg)
-                       THIS->parser_error (_("Need a translator group for a context"));
-               
-               tg = dynamic_cast<Translator_group*> (t->clone ());
-               tg->set_spot (THIS->here_input ());
-               $$ = tg;
+               $$ = Translator_def::make_scm ();
+               Translator_def*td =  unsmob_translator_def ($$);
+               td->translator_group_type_ = $2;
+               td->set_spot (THIS->here_input ());
        }
        | translator_spec_body STRING '=' embedded_scm                  {
-               Translator_group* tg = $$;
-               tg->set_property (ly_scm2string ($2), $4);
+               unsmob_translator_def ($$)->add_property_assign ($2, $4);
+       }
+       | translator_spec_body STRING PUSH embedded_scm '=' embedded_scm {
+               unsmob_translator_def ($$)
+                       ->add_push_property (scm_string_to_symbol ($2), $4, $6);
+       }
+       | translator_spec_body STRING POP embedded_scm  {
+         unsmob_translator_def($$)->add_pop_property (
+               scm_string_to_symbol ($2), $4);
        }
        | translator_spec_body STRING '=' identifier_init semicolon     { 
                SCM v = gh_int2scm (0);
@@ -445,27 +447,25 @@ translator_spec_body:
                        THIS->parser_error (_("Wrong type for property value"));
 
                /* ugh*/
-               Translator_group* tg = dynamic_cast<Translator_group*> ($$);
-               
-               tg->set_property (ly_scm2string ($2), v);
+               unsmob_translator_def($$)->add_property_assign ($2, v);
        }
        | translator_spec_body NAME STRING semicolon {
-               $$->type_str_ = ly_scm2string ($3);
+               unsmob_translator_def ($$)->type_name_ = $3;
        }
        | translator_spec_body CONSISTS STRING semicolon {
-               dynamic_cast<Translator_group*> ($$)-> set_element (ly_scm2string ($3), true);
+               unsmob_translator_def ($$)->add_element ($3);
        }
        | translator_spec_body CONSISTSEND STRING semicolon {
-               dynamic_cast<Translator_group*> ($$)-> set_element (ly_scm2string ($3), true);
+               unsmob_translator_def ($$)->add_last_element ( $3);
        }
        | translator_spec_body ACCEPTS STRING semicolon {
-               dynamic_cast<Translator_group*> ($$)-> set_acceptor (ly_scm2string ($3), true);
+               unsmob_translator_def ($$)->set_acceptor ($3,true);
        }
        | translator_spec_body DENIES STRING semicolon {
-               dynamic_cast<Translator_group*> ($$)-> set_acceptor (ly_scm2string ($3), false);
+               unsmob_translator_def ($$)->set_acceptor ($3,false);
        }
        | translator_spec_body REMOVE STRING semicolon {
-               dynamic_cast<Translator_group*> ($$)-> set_element (ly_scm2string ($3), false);
+               unsmob_translator_def ($$)->remove_element ($3);
        }
        ;
 
@@ -492,7 +492,7 @@ score_body:
 
                $$->set_spot (THIS->here_input ());
                SCM m = $1->self_scm ();
-//             scm_unprotect_object (m);
+               scm_unprotect_object (m);
                $$->music_ = m;
        }
        | SCORE_IDENTIFIER {
@@ -558,7 +558,7 @@ music_output_def_body:
 
        }
        | music_output_def_body translator_spec_block   {
-               $$-> assign_translator ($2);
+               $$->assign_translator ($2);
        }
        | music_output_def_body tempo_request semicolon {
                /*
@@ -593,7 +593,7 @@ Music_list: /* empty */ {
        | Music_list Music {
                SCM s = $$;
                SCM c = gh_cons ($2->self_scm (), SCM_EOL);
-//             scm_unprotect_object ($2->self_scm ()); /* UGH */
+               scm_unprotect_object ($2->self_scm ()); /* UGH */
 
        
                if (gh_pair_p (gh_cdr (s)))
@@ -682,17 +682,18 @@ Simple_music:
        }
        | MUSIC_IDENTIFIER { $$ = unsmob_music ($1)->clone (); }
        | property_def
-       | PUSHPROPERTY embedded_scm embedded_scm embedded_scm {
+/*     | PUSHPROPERTY embedded_scm embedded_scm embedded_scm {
                $$ = new Push_translation_property;
                $$->set_mus_property ("symbols", $2);
                $$->set_mus_property ("element-property", $3);
                $$->set_mus_property ("element-value", $4);
        }
-       | POPPROPERTY  embedded_scm embedded_scm {
+       | POPPROPERTY embedded_scm embedded_scm {
                $$ = new Pop_translation_property;
                $$->set_mus_property ("symbols", $2);
                $$->set_mus_property ("element-property", $3);
        }
+*/
        | translator_change
        | Simple_music '*' bare_unsigned '/' bare_unsigned      {
                $$ = $1;
@@ -823,6 +824,23 @@ property_def:
 
                csm-> translator_type_str_ = ly_scm2string ($2);
        }
+       | PROPERTY STRING '.' STRING PUSH embedded_scm '=' embedded_scm {
+               Push_translation_property *t = new Push_translation_property;
+
+               t->set_mus_property ("symbols", scm_string_to_symbol ($4));
+               t->set_mus_property ("element-property", $6);
+               t->set_mus_property ("element-value", $8);
+               Context_specced_music *csm = new Context_specced_music (t);
+               $$ = csm;
+               $$->set_spot (THIS->here_input ());
+
+               csm-> translator_type_str_ = ly_scm2string ($2);
+       }
+       | PROPERTY STRING POP embedded_scm {
+               $$ = new Pop_translation_property;
+               $$->set_mus_property ("symbols", scm_string_to_symbol ($2));
+               $$->set_mus_property ("element-property", $4);
+       }
        ;
 
 scalar:
@@ -1383,7 +1401,8 @@ simple_element:
 
 chord:
        steno_tonic_pitch optional_notemode_duration chord_additions chord_subtractions chord_inversion chord_bass {
-                $$ = THIS->get_chord (*$1, $3, $4, $5, $6, *$2);
+                $$ = get_chord (*$1, $3, $4, $5, $6, *$2);
+               $$->set_spot (THIS->here_input ());
         };
 
 chord_additions: