]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/parser.yy
* lily/source-file.cc (get_line): oops. All line numbers were off
[lilypond.git] / lily / parser.yy
index 03ad89173278691038daa74b8a5001fcb7f58178..aa0373329564df34ad42142079fdd469c3caaedc 100644 (file)
@@ -23,12 +23,10 @@ this.
 
 */
 
-#include <iostream.h>
 #include <ctype.h>
 
 #include "translator-def.hh"
 #include "lily-guile.hh"
-#include "change-iterator.hh"
 #include "misc.hh"
 #include "my-lily-lexer.hh"
 #include "paper-def.hh"
@@ -37,30 +35,16 @@ this.
 #include "file-path.hh"
 #include "warn.hh"
 #include "dimensions.hh"
-
-#include "request.hh"
 #include "my-lily-parser.hh"
-#include "context-specced-music.hh"
 #include "score.hh"
-#include "music-list.hh"
-#include "output-property-music-iterator.hh"
-#include "property-iterator.hh"
 #include "input-file-results.hh"
 #include "input.hh"
-#include "relative-music.hh"
-#include "lyric-combine-music.hh"
-#include "transposed-music.hh"
-#include "time-scaled-music.hh"
-#include "repeated-music.hh"
-#include "untransposable-music.hh"
 #include "lilypond-input-version.hh"
-#include "grace-music.hh"
-#include "part-combine-music.hh"
 #include "scm-hash.hh"
 #include "auto-change-iterator.hh"
-#include "un-relativable-music.hh"
 #include "chord.hh"
 #include "ly-modules.hh"
+#include "music-sequence.hh"
 
 bool
 regular_identifier_b (SCM id)
@@ -78,6 +62,7 @@ regular_identifier_b (SCM id)
 }
 
 
+
 bool
 is_duration_b (int t)
 {
@@ -111,7 +96,7 @@ make_span_req (SCM name)
 {
   static SCM proc;
   if (!proc)
-    proc = scm_c_eval_string ("old-span-request->event");
+    proc = scm_c_eval_string ("old-span-event->event");
   SCM m = scm_call_1 (proc, name);
   scm_gc_protect_object (m);
   return unsmob_music (m);
@@ -174,7 +159,6 @@ yylex (YYSTYPE *s,  void * v)
 %token ALIAS
 %token APPLY
 %token ARPEGGIO
-%token DYNAMICSCRIPT
 %token ACCEPTS
 %token ALTERNATIVE
 %token BAR
@@ -266,7 +250,7 @@ yylex (YYSTYPE *s,  void * v)
 %token <scm>   MUSIC_OUTPUT_DEF_IDENTIFIER
 
 %token <scm>   NUMBER_IDENTIFIER
-%token <scm>   REQUEST_IDENTIFIER
+%token <scm>   EVENT_IDENTIFIER
 %token <scm>   MUSIC_IDENTIFIER TRANSLATOR_IDENTIFIER
 %token <scm>   STRING_IDENTIFIER SCM_IDENTIFIER 
 %token <scm>   RESTNAME
@@ -277,10 +261,10 @@ yylex (YYSTYPE *s,  void * v)
 
 %type <outputdef> output_def
 %type <scm>    lilypond_header lilypond_header_body
-%type <music>  open_request_parens close_request_parens open_request close_request
-%type <music> request_with_dir request_that_take_dir verbose_request
+%type <music>  open_event_parens close_event_parens open_event close_event
+%type <music> event_with_dir event_that_take_dir verbose_event
 %type <i>      sub_quotes sup_quotes
-%type <music>  simple_element  request_chord command_element Simple_music  Composite_music 
+%type <music>  simple_element  event_chord command_element Simple_music  Composite_music 
 %type <music>  Repeated_music
 %type <scm>     Alternative_music
 %type <i>      tremolo_type
@@ -291,7 +275,7 @@ yylex (YYSTYPE *s,  void * v)
 %type <scm> steno_duration optional_notemode_duration multiplied_duration
 %type <scm>  verbose_duration
        
-%type <reqvec>  pre_requests post_requests
+%type <reqvec>  pre_events post_events
 %type <music> gen_text_def
 %type <scm>   steno_pitch pitch absolute_pitch
 %type <scm>   explicit_pitch steno_tonic_pitch
@@ -308,17 +292,17 @@ yylex (YYSTYPE *s,  void * v)
 %type <scm> Music_list
 %type <outputdef>  music_output_def_body
 %type <music> shorthand_command_req
-%type <music>  post_reques
+%type <music>  post_even
 %type <music> command_req verbose_command_req
 %type <music>  extender_req
 %type <music> hyphen_req
-%type <music> string_request
+%type <music> string_event
 %type <scm>    string bare_number number_expression number_term number_factor 
 
 %type <score>  score_block score_body
 
 %type <scm>    translator_spec_block translator_spec_body
-%type <music>  tempo_request
+%type <music>  tempo_event
 %type <scm> notenames_body notenames_block chordmodifiers_block
 %type <scm>    script_abbreviation
 
@@ -465,7 +449,7 @@ identifier_init:
                $$ = $1->self_scm ();
                scm_gc_unprotect_object ($$);
        }
-       | post_request {
+       | post_event {
                $$ = $1->self_scm ();
                scm_gc_unprotect_object ($$);
        }
@@ -654,7 +638,7 @@ music_output_def_body:
        | music_output_def_body STYLESHEET embedded_scm {
                dynamic_cast<Paper_def*> ($$)-> style_sheet_ = $3;
        }
-       | music_output_def_body tempo_request  {
+       | music_output_def_body tempo_event  {
                /*
                        junk this ? there already is tempo stuff in
                        music.
@@ -663,14 +647,14 @@ music_output_def_body:
                Duration *d = unsmob_duration ($2->get_mus_property ("duration"));
                Midi_def * md = dynamic_cast<Midi_def*> ($$);
                if (md)
-                       md->set_tempo (d->length_mom (), m);
+                       md->set_tempo (d->get_length (), m);
        }
        | music_output_def_body error {
 
        }
        ;
 
-tempo_request:
+tempo_event:
        TEMPO steno_duration '=' bare_unsigned  {
                $$ = MY_MAKE_MUSIC("TempoEvent");
                $$->set_mus_property ("duration", $2);
@@ -729,8 +713,15 @@ Repeated_music:
                    _("More alternatives than repeats.  Junking excess alternatives."));
                  alts = ly_truncate_list (times, alts);
                }
-               
-               Music *r = MY_MAKE_MUSIC("RepeatedMusic");
+
+
+               static SCM proc;
+               if (!proc)
+                       proc = scm_c_eval_string ("make-repeated-music");
+
+               SCM mus = scm_call_1 (proc, $2);
+               scm_gc_protect_object (mus); // UGH. 
+               Music *r =unsmob_music (mus);
                if (beg)
                        {
                        r-> set_mus_property ("element", beg->self_scm ());
@@ -739,9 +730,6 @@ Repeated_music:
                r->set_mus_property ("repeat-count", gh_int2scm (times >? 1));
 
                r-> set_mus_property ("elements",alts);
-               SCM func = scm_primitive_eval (ly_symbol2scm ("repeat-name-to-ctor"));
-               SCM result = gh_call1 (func, $2);
-
                if (gh_equal_p ($2, scm_makfrom0str ("tremolo")))
                {
                /*
@@ -754,9 +742,6 @@ Repeated_music:
                        else
                          gh_call3 (func, r->self_scm (), gh_int2scm(-intlog2 ($3)), gh_int2scm(0));
                }
-
-               set_music_properties (r, result);
-
                r->set_spot (*$4->origin ());
 
                $$ = r;
@@ -791,7 +776,7 @@ Simultaneous_music:
        ;
 
 Simple_music:
-       request_chord           { $$ = $1; }
+       event_chord             { $$ = $1; }
        | OUTPUTPROPERTY embedded_scm embedded_scm '=' embedded_scm     {
                SCM pred = $2;
                if (!gh_symbol_p ($3))
@@ -804,7 +789,7 @@ Simple_music:
                        THIS->parser_error (_ ("First argument must be a procedure taking one argument"));
                }
 
-       Music*m = MY_MAKE_MUSIC("OutputPropertySetMusic");
+               Music*m = MY_MAKE_MUSIC("OutputPropertySetMusic");
                m->set_mus_property ("predicate", pred);
                m->set_mus_property ("grob-property", $3);
                m->set_mus_property ("grob-value",  $5);
@@ -836,6 +821,7 @@ Composite_music:
        | AUTOCHANGE STRING Music       {
        Music*chm = MY_MAKE_MUSIC("AutoChangeMusic");
                chm->set_mus_property ("element", $3->self_scm ());
+               chm->set_mus_property ("iterator-ctor", Auto_change_iterator::constructor_proc);
 
                scm_gc_unprotect_object ($3->self_scm ());
                chm->set_mus_property ("what", $2); 
@@ -1074,7 +1060,6 @@ simple_property_def:
                  = gh_equal_p ($4, scm_makfrom0str ("autoBeamSettings"));
                bool itc = internal_type_checking_global_b;
                Music *t = MY_MAKE_MUSIC("OverrideProperty");
-
                t->set_mus_property ("symbol", scm_string_to_symbol ($4));
                t->set_mus_property ("pop-first", SCM_BOOL_T);
                if (autobeam)
@@ -1153,10 +1138,10 @@ scalar:
         ;
 
 
-request_chord:
-       pre_requests {
+event_chord:
+       pre_events {
                THIS->push_spot ();
-       } /*cont */ simple_element post_requests        {
+       } /*cont */ simple_element post_events  {
                Music_sequence *l = dynamic_cast<Music_sequence*> ($3);
                
                $1->concat (*$4);
@@ -1174,7 +1159,7 @@ request_chord:
 
 command_element:
        command_req {
-               $$ = MY_MAKE_MUSIC("RequestChord");
+               $$ = MY_MAKE_MUSIC("EventChord");
                $$->set_mus_property ("elements", scm_cons ($1->self_scm (), SCM_EOL));
          scm_gc_unprotect_object ($1->self_scm());
 
@@ -1186,7 +1171,7 @@ command_element:
                l->set_mus_property ("span-direction", gh_int2scm (START));
                l->set_spot (THIS->here_input ());
 
-               $$ = MY_MAKE_MUSIC("RequestChord");
+               $$ = MY_MAKE_MUSIC("EventChord");
                $$->set_mus_property ("elements", scm_cons (l->self_scm (), SCM_EOL));
          scm_gc_unprotect_object (l->self_scm());
                $$->set_spot (THIS->here_input ());
@@ -1196,7 +1181,7 @@ command_element:
                l->set_mus_property ("span-direction", gh_int2scm (STOP));
                l->set_spot (THIS->here_input ());
 
-               $$ = MY_MAKE_MUSIC("RequestChord");
+               $$ = MY_MAKE_MUSIC("EventChord");
                $$->set_mus_property ("elements", scm_cons (l->self_scm (), SCM_EOL));
                $$->set_spot (THIS->here_input ());
          scm_gc_unprotect_object (l->self_scm());
@@ -1224,7 +1209,7 @@ command_element:
                csm->set_mus_property ("context-type", scm_makfrom0str ("Timing"));
        }
        | PARTIAL duration_length       {
-               Moment m = - unsmob_duration ($2)->length_mom ();
+               Moment m = - unsmob_duration ($2)->get_length ();
                Music * p = set_property_music (ly_symbol2scm ( "measurePosition"),m.smobbed_copy ());
 
                Music * sp = MY_MAKE_MUSIC("ContextSpeccedMusic");
@@ -1235,25 +1220,13 @@ command_element:
                sp-> set_mus_property ("context-type", scm_makfrom0str ("Timing"));
        }
        | CLEF STRING  {
-               SCM func = scm_primitive_eval (ly_symbol2scm ("clef-name-to-properties"));
-               SCM result = gh_call1 (func, $2);
-
-               SCM l = SCM_EOL;
-               for (SCM s = result ; gh_pair_p (s); s = ly_cdr (s)) {
-                       Music * p = MY_MAKE_MUSIC("Music");
-                       set_music_properties (p, ly_car (s));
-                       l = scm_cons (p->self_scm (), l);
-                       scm_gc_unprotect_object (p->self_scm ());
-               }
-               Music * seq = MY_MAKE_MUSIC("SequentialMusic");
-               seq->set_mus_property ("elements", l);
+               static SCM proc ;
+               if (!proc)
+                       proc = scm_c_eval_string ("make-clef-set");
 
-               Music * sp = MY_MAKE_MUSIC("ContextSpeccedMusic");
-               sp->set_mus_property ("element", seq->self_scm ());
-               scm_gc_unprotect_object (seq->self_scm ());
-
-               $$ =sp ;
-               sp-> set_mus_property ("context-type", scm_makfrom0str ("Staff"));
+               SCM result = scm_call_1 (proc, $2);
+               scm_gc_protect_object (result);
+               $$ = unsmob_music (result);
        }
        | TIME_T fraction  {
                Music * p1 = set_property_music (ly_symbol2scm ( "timeSignatureFraction"), $2);
@@ -1356,7 +1329,7 @@ verbose_command_req:
 
                $$ = skip;
        }
-       | tempo_request {
+       | tempo_event {
                $$ = $1;
        }
        | KEY DEFAULT {
@@ -1372,25 +1345,25 @@ verbose_command_req:
        }
        ;
 
-post_requests:
+post_events:
        {
                $$ = new Link_array<Music>;
        }
-       | post_requests post_request {
+       | post_events post_event {
                $2->set_spot (THIS->here_input ());
                $$->push ($2);
        }
        ;
 
-post_request:
-       verbose_request
-       | request_with_dir
-       | close_request
-       | string_request
+post_event:
+       verbose_event
+       | event_with_dir
+       | close_event
+       | string_event
        ;
 
 
-string_request:
+string_event:
        E_UNSIGNED {
                Music * s = MY_MAKE_MUSIC("StringNumberEvent");
                s->set_mus_property ("string-number",  gh_int2scm($1));
@@ -1400,9 +1373,11 @@ string_request:
        ;
 
 
-request_that_take_dir:
+event_that_take_dir:
        gen_text_def
-       | verbose_request
+       | verbose_event
+       | close_event
+       | open_event
        | script_abbreviation {
                SCM s = THIS->lexer_->lookup_identifier ("dash" + ly_scm2string ($1));
                Music *a = MY_MAKE_MUSIC("ArticulationEvent");
@@ -1413,29 +1388,18 @@ request_that_take_dir:
        }
        ;
 
-request_with_dir:
-       script_dir request_that_take_dir        {
+event_with_dir:
+       script_dir event_that_take_dir  {
                $2->set_mus_property ("direction", gh_int2scm ($1));
                $$ = $2;
        }
        ;
        
-verbose_request:
-       REQUEST_IDENTIFIER      {
+verbose_event:
+       EVENT_IDENTIFIER        {
                $$ = unsmob_music ($1)->clone ();
                $$->set_spot (THIS->here_input ());
        }
-       | DYNAMICSCRIPT embedded_scm {
-               /*
-                       TODO: junkme, use text-type == dynamic
-               */
-               Music *d = MY_MAKE_MUSIC("TextScriptEvent");
-               SCM dyn = ly_symbol2scm ("dynamic");
-               d->set_mus_property ("text-type" , dyn);
-               d->set_mus_property ("text", $2);
-               d->set_spot (THIS->here_input ());
-               $$ = d;
-       }
        | SPANREQUEST bare_int STRING {
 
                Music * sp = make_span_req ($3);
@@ -1575,15 +1539,15 @@ hyphen_req:
        }
        ;
 
-close_request:
-       close_request_parens {
+close_event:
+       close_event_parens {
                $$ = $1;
                dynamic_cast<Music *> ($$)->set_mus_property ("span-direction", gh_int2scm (START))
 ;
        }
        ;
  
-close_request_parens:
+close_event_parens:
        '('     {
                Music * s= MY_MAKE_MUSIC("SlurEvent");
                $$ = s;
@@ -1607,15 +1571,15 @@ close_request_parens:
        ;
 
 
-open_request:
-       open_request_parens {
+open_event:
+       open_event_parens {
                $$ = $1;
                dynamic_cast<Music *> ($$)->set_mus_property ("span-direction", gh_int2scm (STOP))
 ;
        }
        ;
 
-open_request_parens:
+open_event_parens:
        E_EXCLAMATION   {
                Music *s =  MY_MAKE_MUSIC("CrescendoEvent");
                s->set_spot (THIS->here_input());
@@ -1690,11 +1654,11 @@ script_dir:
        | '-'   { $$ = CENTER; }
        ;
 
-pre_requests:
+pre_events:
        {
                $$ = new Link_array<Music>;
        }
-       | pre_requests open_request {
+       | pre_events open_event {
                $$->push ($2);
        }
        ;
@@ -1859,7 +1823,7 @@ figure_list:
 
 figure_spec:
        FIGURE_OPEN figure_list FIGURE_CLOSE {
-               Music * m = MY_MAKE_MUSIC("RequestChord");
+               Music * m = MY_MAKE_MUSIC("EventChord");
                $2 = scm_reverse_x ($2, SCM_EOL);
                m->set_mus_property ("elements",  $2);
                $$ = m->self_scm ();
@@ -1894,7 +1858,7 @@ simple_element:
                if ($2 % 2 || $3 % 2)
                        n->set_mus_property ("force-accidental", SCM_BOOL_T);
 
-               Music *v = MY_MAKE_MUSIC("RequestChord");
+               Music *v = MY_MAKE_MUSIC("EventChord");
                v->set_mus_property ("elements", scm_list_n (n->self_scm (), SCM_UNDEFINED));
                scm_gc_unprotect_object (n->self_scm());
 
@@ -1929,7 +1893,7 @@ simple_element:
                        rest_req->set_spot (i);
                        e = rest_req->self_scm ();
                    }
-               Music * velt = MY_MAKE_MUSIC("RequestChord");
+               Music * velt = MY_MAKE_MUSIC("EventChord");
                velt-> set_mus_property ("elements", scm_list_n (e,SCM_UNDEFINED));
                velt->set_spot (i);
 
@@ -1946,11 +1910,11 @@ simple_element:
 ;
                sp2-> set_mus_property ("span-direction", gh_int2scm (STOP))
 ;
-               Music *rqc1 = MY_MAKE_MUSIC("RequestChord");
+               Music *rqc1 = MY_MAKE_MUSIC("EventChord");
                rqc1->set_mus_property ("elements", scm_list_n (sp1->self_scm (), SCM_UNDEFINED));
-               Music *rqc2 = MY_MAKE_MUSIC("RequestChord");
+               Music *rqc2 = MY_MAKE_MUSIC("EventChord");
                rqc2->set_mus_property ("elements", scm_list_n (sk->self_scm (), SCM_UNDEFINED));;
-               Music *rqc3 = MY_MAKE_MUSIC("RequestChord");
+               Music *rqc3 = MY_MAKE_MUSIC("EventChord");
                rqc3->set_mus_property ("elements", scm_list_n (sp2->self_scm (), SCM_UNDEFINED));;
 
                SCM ms = scm_list_n (rqc1->self_scm (), rqc2->self_scm (), rqc3->self_scm (), SCM_UNDEFINED);
@@ -1965,7 +1929,7 @@ simple_element:
                 lreq->set_mus_property ("text", $1);
                lreq->set_mus_property ("duration",$2);
                lreq->set_spot (i);
-               Music * velt = MY_MAKE_MUSIC("RequestChord");
+               Music * velt = MY_MAKE_MUSIC("EventChord");
                velt->set_mus_property ("elements", scm_list_n (lreq->self_scm (), SCM_UNDEFINED));
 
                $$= velt;
@@ -2099,10 +2063,7 @@ number_term:
        ;
 
 number_factor:
-       '(' number_expression ')'       {
-               $$ = $2;
-       }
-       | '-'  number_factor { /* %prec UNARY_MINUS */
+       '-'  number_factor { /* %prec UNARY_MINUS */
                $$ = scm_difference ($2, SCM_UNDEFINED);
        }
        | bare_number