]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/parser.yy
* lily/parser.yy (part_combined_music): remove old PC cruft.
[lilypond.git] / lily / parser.yy
index 077578e4b3b607aed92063c15fa4be00967d7f89..a611eebca9cd7c0cea913a43a6ebaafb8b440ca2 100644 (file)
@@ -58,7 +58,7 @@ TODO:
 
 
 #include "scm-option.hh"
-#include "translator-def.hh"
+#include "context-def.hh"
 #include "lily-guile.hh"
 #include "misc.hh"
 #include "my-lily-lexer.hh"
@@ -344,6 +344,7 @@ yylex (YYSTYPE *s,  void * v)
 
 %token MARKUP
 %token <scm> MARKUP_HEAD_MARKUP0
+%token <scm> MARKUP_HEAD_EMPTY
 %token <scm> MARKUP_HEAD_MARKUP0_MARKUP1
 %token <scm> MARKUP_HEAD_SCM0
 %token <scm> MARKUP_HEAD_SCM0_MARKUP1
@@ -384,11 +385,10 @@ yylex (YYSTYPE *s,  void * v)
 %type <music>  music_property_def context_change 
 %type <scm> Music_list
 %type <scm> property_operation context_mod translator_mod optional_context_mod
-%type <outputdef>  music_output_def_body
+%type <outputdef>  music_output_def_body music_output_def_head
 %type <music> shorthand_command_req
 %type <music>  post_event tagged_post_event
 %type <music> command_req verbose_command_req
-%type <music> hyphen_req
 %type <music> string_number_event
 %type <scm>    string bare_number number_expression number_term number_factor 
 %type <score>  score_block score_body
@@ -463,10 +463,13 @@ toplevel_expression:
                scm_gc_unprotect_object (sc->self_scm());
        }
        | output_def {
+               SCM id = SCM_EOL;
                if (dynamic_cast<Paper_def*> ($1))
-                       THIS->lexer_->set_identifier (scm_makfrom0str ("$defaultpaper"), $1->self_scm ());
+                       id = scm_makfrom0str ("$defaultpaper");
                else if (dynamic_cast<Midi_def*> ($1))
-                       THIS->lexer_->set_identifier (scm_makfrom0str ("$defaultmidi"), $1->self_scm ());
+                       id = scm_makfrom0str ("$defaultmidi");
+               THIS->lexer_->set_identifier (id,   $1->self_scm ());
+               scm_gc_unprotect_object ($1->self_scm ());
        }
        ;
 
@@ -547,7 +550,6 @@ all objects can be unprotected as soon as they're here.
        ;
 
 
-
 identifier_init:
        score_block {
                $$ = $1->self_scm ();
@@ -644,7 +646,7 @@ score_body:
 
        }
        | SCORE_IDENTIFIER {
-               $$ = unsmob_score ($1);
+               $$ = new Score ( *unsmob_score ($1));
                $$->set_spot (THIS->here_input ());
        }
        | score_body lilypond_header    {
@@ -652,6 +654,7 @@ score_body:
        }
        | score_body output_def {
                $$->defs_.push ($2);
+               scm_gc_unprotect_object ($2->self_scm ());
        }
        | score_body error {
 
@@ -669,8 +672,8 @@ output_def:
        }
        ;
 
-music_output_def_body:
-       MIDI '{'    {
+music_output_def_head:
+       MIDI    {
                Music_output_def *id = unsmob_music_output_def (THIS->lexer_->lookup_identifier ("$defaultmidi"));
 
 
@@ -683,7 +686,7 @@ music_output_def_body:
                $$ = p;
                THIS->lexer_->add_scope (p->scope_);
        }
-       | PAPER '{'     {
+       | PAPER         {
                Music_output_def *id = unsmob_music_output_def (THIS->lexer_->lookup_identifier ("$defaultpaper"));
                  Paper_def *p = 0;
                if (id)
@@ -694,16 +697,17 @@ music_output_def_body:
                THIS->lexer_->add_scope (p->scope_);
                $$ = p;
        }
-       | PAPER '{' MUSIC_OUTPUT_DEF_IDENTIFIER         {
-               Music_output_def * o =  unsmob_music_output_def ($3);
-               $$ =o;
+       ;
 
-               THIS->lexer_->add_scope (o->scope_);
+
+music_output_def_body:
+       music_output_def_head '{' { 
+               
        }
-       | MIDI '{' MUSIC_OUTPUT_DEF_IDENTIFIER  {
+       | music_output_def_head '{' MUSIC_OUTPUT_DEF_IDENTIFIER         {
                Music_output_def * o =  unsmob_music_output_def ($3);
                $$ = o;
-
+               THIS->lexer_->remove_scope ();
                THIS->lexer_->add_scope (o->scope_);
        }
        | music_output_def_body assignment  {
@@ -711,7 +715,6 @@ music_output_def_body:
        }
        | music_output_def_body translator_spec_block   {
                $$->assign_translator ($2);
-
        }
        | music_output_def_body tempo_event  {
                /*
@@ -723,6 +726,7 @@ music_output_def_body:
                Midi_def * md = dynamic_cast<Midi_def*> ($$);
                if (md)
                        md->set_tempo (d->get_length (), m);
+               scm_gc_unprotect_object ($2->self_scm ());
        }
        | music_output_def_body error {
 
@@ -1109,15 +1113,17 @@ re_rhythmed_music:
        ;
 
 part_combined_music:
-       PARTCOMBINE STRING Music Music {
-               Music * p= MY_MAKE_MUSIC("PartCombineMusic");
-               p->set_mus_property ("what", scm_string_to_symbol ($2));
-               p->set_mus_property ("elements", gh_list ($3->self_scm (),$4->self_scm (), SCM_UNDEFINED));  
+       PARTCOMBINE Music Music {
+               static SCM proc;
+               if (!proc)
+                       proc = scm_c_eval_string ("make-part-combine-music");
 
+               SCM res = scm_call_1 (proc, gh_list ($2->self_scm (),
+                       $3->self_scm (), SCM_UNDEFINED));  
                scm_gc_unprotect_object ($3->self_scm ());
-               scm_gc_unprotect_object ($4->self_scm ());  
-
-               $$ = p;
+               scm_gc_unprotect_object ($2->self_scm ());
+               $$ = unsmob_music (res);
+               scm_gc_protect_object (res);
        }
        ;
 
@@ -1390,6 +1396,15 @@ command_element:
                scm_gc_protect_object (result);
                $$ = unsmob_music (result);
        }
+       | MARK scalar {
+               static SCM proc;
+               if (!proc)
+                       proc = scm_c_eval_string ("make-mark-set");
+
+               SCM result = scm_call_1 (proc, $2);
+               scm_gc_protect_object (result);
+               $$ = unsmob_music (result);
+       }
        ;
 
 command_req:
@@ -1398,10 +1413,7 @@ command_req:
        ;
 
 shorthand_command_req:
-       hyphen_req {
-               $$ = $1;
-       }
-       | BREATHE {
+       BREATHE {
                $$ = MY_MAKE_MUSIC("BreathingSignEvent");
        }
        | E_TILDE {
@@ -1414,11 +1426,7 @@ verbose_command_req:
                Music * m = MY_MAKE_MUSIC("MarkEvent");
                $$ = m;
        }
-       | MARK scalar {
-               Music *m = MY_MAKE_MUSIC("MarkEvent");
-               m->set_mus_property ("label", $2);
-               $$ = m;
-       }
+       
        | SKIP duration_length {
                Music * skip = MY_MAKE_MUSIC("SkipEvent");
                skip->set_mus_property ("duration", $2);
@@ -1476,6 +1484,11 @@ post_event:
        direction_less_event {
                $$ = $1;
        }
+       | HYPHEN {
+               if (!THIS->lexer_->lyric_state_b ())
+                       THIS->parser_error (_ ("Have to be in Lyric mode for lyrics"));
+               $$ = MY_MAKE_MUSIC("HyphenEvent");
+       }
        | EXTENDER {
                if (!THIS->lexer_->lyric_state_b ())
                        THIS->parser_error (_ ("Have to be in Lyric mode for lyrics"));
@@ -1641,14 +1654,6 @@ pitch_also_in_chords:
        | steno_tonic_pitch
        ;
 
-hyphen_req:
-       HYPHEN {
-               if (!THIS->lexer_->lyric_state_b ())
-                       THIS->parser_error (_ ("Have to be in Lyric mode for lyrics"));
-               $$ = MY_MAKE_MUSIC("HyphenEvent");
-       }
-       ;
-
 close_event:
        '('     {
                Music * s= MY_MAKE_MUSIC("SlurEvent");
@@ -1987,6 +1992,8 @@ simple_element:
                velt->set_mus_property ("elements", scm_list_n (ev->self_scm (),SCM_UNDEFINED));
                velt->set_spot (i);
 
+               scm_gc_unprotect_object (ev->self_scm());
+
                $$ = velt;
        }
        | MULTI_MEASURE_REST optional_notemode_duration         {
@@ -2222,6 +2229,9 @@ markup:
        STRING {
                $$ = make_simple_markup ($1);
        }
+       | MARKUP_HEAD_EMPTY {
+               $$ = scm_list_n ($1, SCM_UNDEFINED);
+       }
        | MARKUP_HEAD_MARKUP0 markup {
                $$ = scm_list_n ($1, $2, SCM_UNDEFINED);
        }
@@ -2246,6 +2256,9 @@ markup:
        | MARKUP_HEAD_SCM0_SCM1_SCM2 embedded_scm embedded_scm embedded_scm {
                $$ = scm_list_n ($1, $2, $3, $4, SCM_UNDEFINED);
        }
+       | MARKUP_HEAD_SCM0_SCM1 embedded_scm embedded_scm {
+               $$ = scm_list_n ($1, $2, $3, SCM_UNDEFINED);
+       }
        | MARKUP_IDENTIFIER {
                $$ = $1;
        }