]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/parser.yy
release: 1.5.33
[lilypond.git] / lily / parser.yy
index f5425dc2ef69462145804df25f8e29dd93472bf0..4f3942169454d53111fd74a13ebe0de890c7b797 100644 (file)
@@ -242,6 +242,7 @@ yylex (YYSTYPE *s,  void * v_l)
 
 /* escaped */
 %token E_CHAR E_EXCLAMATION E_SMALLER E_BIGGER E_OPEN E_CLOSE E_TILDE
+%token E_BACKSLASH
 %token CHORD_BASS CHORD_COLON CHORD_MINUS CHORD_CARET 
 
 %type <i>      exclamations questions dots
@@ -284,7 +285,7 @@ yylex (YYSTYPE *s,  void * v_l)
 %type <scm>    identifier_init 
 
 %type <scm> steno_duration optional_notemode_duration multiplied_duration
-%type <scm>  explicit_duration
+%type <scm>  verbose_duration
        
 %type <reqvec>  pre_requests post_requests
 %type <request> gen_text_def
@@ -468,7 +469,7 @@ identifier_init:
                $$ = $1->self_scm ();
                scm_gc_unprotect_object ($$);
        }
-       | explicit_duration {
+       | verbose_duration {
                $$ = $1;
        }
        | number_expression {
@@ -1091,15 +1092,16 @@ request_chord:
                THIS->push_spot ();
        } /*cont */ simple_element post_requests        {
                Music_sequence *l = dynamic_cast<Music_sequence*> ($3);
-               if (l) {
-                       for (int i=0; i < $1->size (); i++)
-                               l->append_music ($1->elem (i));
-                       for (int i=0; i < $4->size (); i++)
-                               l->append_music ($4->elem (i));
-                       }
-               else
-                       programming_error ("Need Sequence to add music to");
+               
+               $1->concat (*$4);
+               for (int i=0; i < $1->size (); i++) {
+                 Music * m = $1->elem (i);
+                 l->append_music (m);
+               }
                $$ = $3;
+
+               delete $1;
+               delete $4;
        }
        | command_element
        ;
@@ -1111,6 +1113,16 @@ command_element:
                $$-> set_spot (THIS->here_input ());
                $1-> set_spot (THIS->here_input ());
        }
+       | E_BACKSLASH {
+               $$ = new Music (gh_list (gh_cons (ly_symbol2scm ("name"), ly_symbol2scm ("separator")), SCM_UNDEFINED));
+               $$->set_spot (THIS->here_input ());
+       }
+       | '|'      {
+
+               extern Music * get_barcheck();
+               $$ = get_barcheck ();
+               $$->set_spot (THIS->here_input ());
+       }
        | BAR STRING                    {
                Music *t = set_property_music (ly_symbol2scm ("whichBar"), $2);
 
@@ -1205,9 +1217,6 @@ shorthand_command_req:
        | hyphen_req {
                $$ = $1;
        }
-       | '|'                           {
-               $$ = new Barcheck_req;
-       }
        | '~'   {
                $$ = new Tie_req;
        }
@@ -1216,6 +1225,9 @@ shorthand_command_req:
                b->set_span_dir (START);
                b->set_mus_property ("span-type", ly_str02scm ("beam"));
                $$ =b;
+
+
+               THIS->last_beam_start_ = b->self_scm ();
        }
        | ']'           {
                Span_req*b= new Span_req;
@@ -1250,8 +1262,6 @@ verbose_command_req:
 
        }
        | PENALTY SCM_T         {
-
-               
                Break_req * b = new Break_req;
                SCM s = $2;
                if (!gh_number_p (s))
@@ -1333,7 +1343,8 @@ verbose_request:
                        TODO: junkme, use text-type == dynamic
                */
                Text_script_req *d = new Text_script_req;
-               d->set_mus_property ("text-type" , ly_symbol2scm ("dynamic"));
+               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;
@@ -1449,7 +1460,7 @@ explicit_pitch:
        }
        ;
 
-explicit_duration:
+verbose_duration:
        DURATION embedded_scm   {
                $$ = $2;
                if (!unsmob_duration ($2))
@@ -1548,9 +1559,9 @@ gen_text_def:
        | DIGIT {
                String ds = to_str ($1);
                Text_script_req* t = new Text_script_req;
-
+               SCM finger = ly_symbol2scm ("finger");
                t->set_mus_property ("text",  ly_str02scm (ds.ch_C ()));
-               t->set_mus_property ("text-type" , ly_symbol2scm ("finger"));
+               t->set_mus_property ("text-type" , finger);
                t->set_spot (THIS->here_input ());
                $$ = t;
        }
@@ -1577,7 +1588,6 @@ script_abbreviation:
        }
        ;
 
-
 script_dir:
        '_'     { $$ = DOWN; }
        | '^'   { $$ = UP; }
@@ -1603,20 +1613,27 @@ duration_length:
        multiplied_duration {
                $$ = $1;
        }
-       | explicit_duration {
+       | verbose_duration {
                $$ = $1;
        }       
        ;
 
 optional_notemode_duration:
        {
-               $$ = THIS->default_duration_.smobbed_copy ();
+               Duration dd = THIS->default_duration_;
+               $$ = dd.smobbed_copy ();
+
+               THIS->beam_check ($$);
        }
        | multiplied_duration   {
                $$ = $1;
+               THIS->default_duration_ = *unsmob_duration ($$);
+
+               THIS->beam_check ($$);
        }
-       | explicit_duration {
+       | verbose_duration {
                $$ = $1;
+               THIS->default_duration_ = *unsmob_duration ($$);
        }       
        ;
 
@@ -1629,15 +1646,11 @@ steno_duration:
                        l =  intlog2 ($1);
 
                $$ = Duration (l, $2).smobbed_copy ();
-
-               THIS->set_last_duration (unsmob_duration ($$));
        }
        | DURATION_IDENTIFIER dots      {
                Duration *d =unsmob_duration ($1);
                Duration k (d->duration_log (),d->dot_count () + $2);
                $$ = k.smobbed_copy ();
-
-               THIS->set_last_duration (unsmob_duration ($$));
        }
        ;
 
@@ -2070,3 +2083,24 @@ My_lily_parser::do_yyparse ()
 }
 
 
+/*
+Should make this optional?    It will also complain when you do
+
+       [s4]
+
+which is entirely legitimate.
+
+Or we can scrap it. Barchecks should detect wrong durations, and
+skipTypesetting speeds it up a lot.
+*/
+void
+My_lily_parser::beam_check (SCM dur)
+{
+  Duration *d = unsmob_duration (dur);
+  if (unsmob_music (last_beam_start_) && d->duration_log () <= 2)
+    {
+      Music * m = unsmob_music (last_beam_start_);
+      m->origin ()->warning (_("Suspect duration found following this beam"));
+    }
+  last_beam_start_ = SCM_EOL;
+}