]> git.donarmstrong.com Git - lilypond.git/commitdiff
patch::: 1.1.6.jcn1: pats
authorJan Nieuwenhuizen <janneke@gnu.org>
Tue, 17 Nov 1998 08:07:48 +0000 (09:07 +0100)
committerJan Nieuwenhuizen <janneke@gnu.org>
Tue, 17 Nov 1998 08:07:48 +0000 (09:07 +0100)
pl6.jcn1
- repeat/alternative music layout

16 files changed:
NEWS
VERSION
input/test/repeat.fly [new file with mode: 0644]
lily/bar-engraver.cc
lily/include/lily-proto.hh
lily/include/music-wrapper-iterator.hh
lily/include/repeated-music-iterator.hh [new file with mode: 0644]
lily/include/repeated-music.hh [new file with mode: 0644]
lily/include/voice-iterator.hh
lily/music-iterator.cc
lily/music-wrapper-iterator.cc
lily/music.cc
lily/my-lily-lexer.cc
lily/parser.yy
lily/repeated-music-iterator.cc [new file with mode: 0644]
lily/repeated-music.cc [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index b340ce878b4513f7f783a76301ee2843973eb2ef..d3c1f271a64e3e3a2a9da53580155abe8f6a6f4b 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,4 +1,8 @@
+pl6.jcn1
+       - repeat/alternative music layout
 
+********
+1.1.6
 
 pl5.szmulewicz1
        - rtti stuff
diff --git a/VERSION b/VERSION
index 9fa405bb94a8e0dcb234c7b1b16d94a8e894ca60..ed84e68a2de040096ac1989a136544bd6e6baeb7 100644 (file)
--- a/VERSION
+++ b/VERSION
@@ -2,7 +2,7 @@ PACKAGE_NAME=LilyPond
 MAJOR_VERSION=1
 MINOR_VERSION=1
 PATCH_LEVEL=6
-MY_PATCH_LEVEL=
+MY_PATCH_LEVEL=jcn1
 
 # use the above to send patches: MY_PATCH_LEVEL is always empty for a
 # released version.
diff --git a/input/test/repeat.fly b/input/test/repeat.fly
new file mode 100644 (file)
index 0000000..f3ab2c0
--- /dev/null
@@ -0,0 +1,2 @@
+% a'' b c d \repeat 2 { { c c c c } } \alternative { { e e e e } { e e e g } } c c c c
+a'' b c d \repeat 2 { { c c c c } } \alternative { { e e e e } } c c c c
index b9896b4ad32c0b8149778337787e540d9eed779c..a0c361907cc1bada5e3082ffb66d32837b9501bc 100644 (file)
@@ -13,6 +13,7 @@
 #include "command-request.hh"
 #include "time-description.hh"
 #include "engraver-group.hh"
+#include "repeated-music.hh"
 
 Bar_engraver::Bar_engraver()
 {
@@ -32,6 +33,13 @@ Bar_engraver::do_try_music (Music*r_l)
 
       return true;
     }
+  else if (Repeated_music * m = dynamic_cast<Repeated_music *> (r_l))
+    {
+      if (bar_req_l_ && bar_req_l_->equal_b (b)) // huh?
+        return false;
+      bar_req_l_ = new Bar_req ("|:");
+        return true;
+    }
   
   return false;
 
index 52f3674b5229c4a42d8ab85bdec88cdfa8f54df5..6febb7f55a839b0d7f12c61cf9aa1b87d873e8ea 100644 (file)
 #define LILY_PROTO_HH
 #include "proto.hh"
 
-
 struct Absolute_dynamic_req;
 struct Abbreviation;
-struct Abbreviation_req;
+struct Abbreviation_beam; 
 struct Abbreviation_beam_req;
 struct Abbreviation_beam_engraver;
-struct Axis_group_element;
-struct Axis_group;
-struct Translator_group;
-struct Translator;
-struct Abbreviation_beam; 
+struct Abbreviation_req;
+struct Atom;
 struct Audio_element;
 struct Audio_column;
 struct Audio_item;
@@ -28,10 +24,10 @@ struct Audio_key;
 struct Audio_time_signature;
 struct Audio_note;
 struct Audio_note_off;
-struct Performance;
 struct Audio_staff;
 struct Audio_tempo;
-struct Atom;
+struct Axis_group_element;
+struct Axis_group;
 struct Bar;
 struct Bar_column_engraver;
 struct Bar_column;
@@ -120,10 +116,6 @@ struct Lyric_req;
 struct My_lily_lexer;
 struct Measure_grouping_req;
 struct Melodic_req;
-struct Time_signature;
-struct Time_signature_change_req;
-struct Time_signature_engraver;
-struct Time_signature_performer;
 struct Midi_def;
 struct Midi_duration;
 struct Midi_header;
@@ -167,6 +159,7 @@ struct Paper_outputter;
 struct Paper_score;
 struct Paper_stream;
 struct Partial_measure_req;
+struct Performance;
 struct Performer;
 struct Plet;
 struct Plet_engraver;
@@ -181,6 +174,8 @@ struct Request;
 struct Request_column;
 struct Engraver;
 struct Relative_octave_music;
+struct Repeated_music;
+struct Repeated_music_iterator;
 struct Rest;
 struct Rest_collision;
 struct Rest_collision_engraver;
@@ -222,7 +217,6 @@ struct Stem;
 struct Stem_beam_engraver;
 struct Stem_req;
 struct String;
-struct Atom;
 struct Symtable;
 struct Symtables;
 struct Super_element;
@@ -238,6 +232,12 @@ struct Tie;
 struct Tie_engraver;
 struct Tie_req;
 struct Time_description;
+struct Time_signature;
+struct Time_signature_change_req;
+struct Time_signature_engraver;
+struct Time_signature_performer;
+struct Translator;
+struct Translator_group;
 struct Timing_req;
 struct Vertical_brace;
 struct Vertical_spanner;
index 02a4e97fa0089fd9a415054bb6308957d3190f31..cae63b2096ccab8e3a3789f980daa4202bebe9b0 100644 (file)
 
 class Music_wrapper_iterator : public Music_iterator
 {
-  Music_iterator *child_iter_p_;
-  Music_wrapper *music_wrapper_l();
 public:
   Music_wrapper_iterator ();
-  ~Music_wrapper_iterator ();
+
+protected:
+  virtual ~Music_wrapper_iterator ();
+
   virtual void do_print () const;
   virtual void construct_children  () ;
   virtual void do_process_and_next (Moment) ;
   virtual Moment next_moment () const;
+
+protected:
+  virtual Music_wrapper *music_wrapper_l () const;
   virtual bool ok () const;
-  
+
+private:
+  Music_iterator *child_iter_p_;
 };
 
 #endif /* MUSIC_WRAPPER_ITERATOR_HH */
diff --git a/lily/include/repeated-music-iterator.hh b/lily/include/repeated-music-iterator.hh
new file mode 100644 (file)
index 0000000..ebc356d
--- /dev/null
@@ -0,0 +1,35 @@
+/*   
+  repeated-music-iterator.hh -- declare Repeated_music_iterator
+  
+  source file of the GNU LilyPond music typesetter
+  
+  (c) 1998 Jan Nieuwenhuizen <janneke@gnu.org>
+  
+ */
+
+#ifndef REPEATED_MUSIC_ITERATOR_HH
+#define REPEATED_MUSIC_ITERATOR_HH
+
+#include "music-wrapper-iterator.hh"
+#include "voice-iterator.hh"
+
+class Repeated_music_iterator : public virtual Music_wrapper_iterator, public virtual Sequential_music_iterator
+{
+public:
+  Repeated_music_iterator();
+
+protected:
+  ~Repeated_music_iterator ();
+
+  virtual Music_wrapper *music_wrapper_l () const;
+  virtual Sequential_music* sequential_music_l() const;
+  virtual bool ok () const;
+  virtual void do_process_and_next (Moment);
+  virtual void construct_children ();
+  virtual void start_next_element ();
+  virtual void leave_element ();
+};
+
+
+#endif /* REPEATED_MUSIC_ITERATOR_HH */
+
diff --git a/lily/include/repeated-music.hh b/lily/include/repeated-music.hh
new file mode 100644 (file)
index 0000000..4f105cc
--- /dev/null
@@ -0,0 +1,37 @@
+/*   
+  repeated-music.hh -- declare Repeated_music
+  
+  source file of the GNU LilyPond music typesetter
+  
+  (c) 1998 Jan Nieuwenhuizen <janneke@gnu.org>
+  
+ */
+
+#ifndef REPEATED_MUSIC_HH
+#define REPEATED_MUSIC_HH
+
+#include "music-list.hh"
+
+/**
+   Repeats and voltas
+ */
+class Repeated_music : public Music
+{
+public:
+  int repeats_i_;
+  Music_wrapper* repeat_p_;
+  Sequential_music* alternative_p_;
+
+  Repeated_music (Music_wrapper *, int n, Sequential_music*);
+  Repeated_music (Repeated_music const& s);
+  virtual ~Repeated_music ();
+  
+  virtual void do_print () const;
+  virtual void transpose (Musical_pitch p);
+  virtual Moment duration () const;
+
+  VIRTUAL_COPY_CONS(Music);
+};
+
+#endif /* REPEATED_MUSIC_HH */
+
index ce9613b3aad34a8fc906efcbfa450bc8fbbe09c6..38f8b91473e873deaf3a4fafae512030bcd9ee22 100644 (file)
@@ -4,36 +4,37 @@
   source file of the GNU LilyPond music typesetter
 
   (c)  1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-*/
-
 
-#ifndef Sequential_music_ITER_HH
-#define Sequential_music_ITER_HH
+*/
 
+#ifndef SEQUENTIAL_MUSIC_ITER_HH
+#define SEQUENTIAL_MUSIC_ITER_HH
 
 #include "music-iterator.hh"
 #include "pcursor.hh"
 
 class Sequential_music_iterator :  public Music_iterator
 {
-  Moment here_mom_;
-  PCursor<Music*> *cursor_p_;
-  Music_iterator * iter_p_;
-  void start_next_element();
-  void leave_element();
-  void set_Sequential_music_translator();
-protected:
-  Sequential_music * sequential_music_l() const;
 public:
   Sequential_music_iterator ();
   
 protected:
+  virtual ~Sequential_music_iterator();    
+
+  virtual Sequential_music* sequential_music_l() const;
   virtual void do_print() const;
   virtual void construct_children();
-  ~Sequential_music_iterator();    
   virtual void do_process_and_next (Moment);
   virtual Moment next_moment() const;
   virtual bool ok() const;
+  virtual void start_next_element();
+  virtual void leave_element();
+
+private:
+  Moment here_mom_;
+  PCursor<Music*> *cursor_p_;
+  Music_iterator * iter_p_;
+  void set_Sequential_music_translator();
 };
 
-#endif // Sequential_music_ITER_HH
+#endif // SEQUENTIAL_MUSIC_ITER_HH
index 43891b05605675e9025f0ecc810b6a7e943e9a10..f78dc6eaa51e82d92362abe4c8c9df03b64eaecf 100644 (file)
 #include "music-wrapper-iterator.hh"
 #include "compressed-music-iterator.hh"
 #include "compressed-music.hh"
-
-
-
-
-
+#include "repeated-music.hh"
+#include "repeated-music-iterator.hh"
 
 void
 Music_iterator::do_print() const
@@ -150,6 +147,10 @@ Music_iterator::static_get_iterator_p (Music const *m, Translator_group *report_
     p = new Compressed_music_iterator;
   else if (dynamic_cast<Music_wrapper  const *> (m))
     p = new Music_wrapper_iterator;
+  else if (dynamic_cast<Repeated_music const *> (m))
+    p = new Repeated_music_iterator;
+  else
+    assert (0);
 
   p->music_l_ = m;
   if (m->translator_type_str_.length_i ())
index d5ed47629c241bc482e4a7bde8338bfca3355d8d..e282bded8c60b7c1c43635810cfff418e9ee2b31 100644 (file)
@@ -36,10 +36,11 @@ Music_wrapper_iterator::~Music_wrapper_iterator ()
 }
 
 Music_wrapper*
-Music_wrapper_iterator::music_wrapper_l ()
+Music_wrapper_iterator::music_wrapper_l () const
 {
   return (Music_wrapper*) music_l_;
 }
+
 bool
 Music_wrapper_iterator::ok () const
 {
index 316cbff1d95e7d8db5ff655c852fe62d38ed6617..8d7ce5cb881c3d4acbbc54613875fb0c86529329 100644 (file)
 #include "debug.hh"
 #include "musical-pitch.hh"
 
+Music::Music()
+{
+}
+
+void    
+Music::compress (Moment)
+{
+}
+
+void
+Music::do_print() const
+{
+}
+
 Moment
 Music::duration () const
 {
@@ -32,34 +46,14 @@ Music::print() const
 #endif
 }
 
-void
-Music::transpose (Musical_pitch )
-{
-  
-}
-
-void
-Music::do_print() const
-{
-}
-
-
-
-
-
-
-  
-Music::Music()
-{
-}
-
 Musical_pitch
 Music::to_relative_octave (Musical_pitch m)
 {
   return m;
 }
 
-void    
-Music::compress (Moment)
+void
+Music::transpose (Musical_pitch )
 {
 }
+
index 61c1cd028c64b7d704c73a327394dc4d0c843afa..7b47c2e3d6f7f041b4a376834be3337c35c94326 100644 (file)
 static Keyword_ent the_key_tab[]={
   {"absdynamic", ABSDYNAMIC},
   {"accepts", ACCEPTS},
+  {"alternative", ALTERNATIVE},
   {"bar", BAR},
   {"cadenza", CADENZA},
   {"clef", CLEF},
   {"cm", CM_T},
   {"consists", CONSISTS},
   {"duration", DURATION},
-//  {"_", EXTENDER},
   {"font", FONT},
   {"grouping", GROUPING},
   {"header", HEADER},
@@ -56,6 +56,7 @@ static Keyword_ent the_key_tab[]={
   {"pt", PT_T},
   {"relative", RELATIVE},
   {"remove", REMOVE},
+  {"repeat", REPEAT},
   {"scm", SCM_T},
   {"scmfile", SCMFILE},
   {"score", SCORE},
index 344abe68b2acccafb7a12273210f2b43168cfd24..449c7cc122759c3992042be0defa4bdf8f296ed5 100644 (file)
@@ -43,6 +43,7 @@
 #include "relative-music.hh"
 #include "transposed-music.hh"
 #include "compressed-music.hh"
+#include "repeated-music.hh"
 
 // mmm
 Mudela_version oldest_version ("1.0.7");
@@ -158,6 +159,7 @@ yylex (YYSTYPE *s,  void * v_l)
 
 %token ABSDYNAMIC
 %token ACCEPTS
+%token ALTERNATIVE
 %token BAR
 %token BEAMPLET
 %token CADENZA
@@ -194,6 +196,7 @@ yylex (YYSTYPE *s,  void * v_l)
 %token PT_T
 %token RELATIVE
 %token REMOVE
+%token REPEAT
 %token SCM_T
 %token SCMFILE
 %token SCORE
@@ -247,6 +250,7 @@ yylex (YYSTYPE *s,  void * v_l)
 %type <i>      open_plet_parens close_plet_parens
 %type <i>      sub_quotes sup_quotes
 %type <music>  simple_element  request_chord command_element Simple_music  Composite_music
+%type <music>  Alternative_music Repeated_music
 %type <i>      abbrev_type
 %type <i>      int unsigned
 %type <i>      script_dir
@@ -731,6 +735,22 @@ Music:
        | Composite_music
        ;
 
+Alternative_music: {
+               Music_list* m = new Music_list;
+               $$ = new Sequential_music (m);
+       }
+       | ALTERNATIVE '{' Music_list '}'                {
+               $$ = new Sequential_music ($3);
+       }
+       ;
+
+Repeated_music: REPEAT unsigned '{' Music '}' Alternative_music        {
+               Music_wrapper *w= new Music_wrapper ($4);
+               Sequential_music* s = (Sequential_music*)$6;
+               $$ = new Repeated_music (w, $2, s);
+       }
+       ;
+
 Sequential_music: '{' Music_list '}'           {
                $$ = new Sequential_music ($2);
        }
@@ -766,6 +786,7 @@ Composite_music:
                $$ = new Compressed_music ($2, $4, $5);
 
        }
+       | Repeated_music                { $$ = $1; }
        | Simultaneous_music            { $$ = $1; }
        | Sequential_music              { $$ = $1; }
        | TRANSPOSE musical_pitch Music {
diff --git a/lily/repeated-music-iterator.cc b/lily/repeated-music-iterator.cc
new file mode 100644 (file)
index 0000000..67803eb
--- /dev/null
@@ -0,0 +1,69 @@
+/*   
+  repeated-music-iterator.cc --  implement Repeated_music_iterator
+  
+  source file of the GNU LilyPond music typesetter
+  
+  (c) 1998 Jan Nieuwenhuizen <janneke@gnu.org>
+  
+ */
+
+#include "repeated-music-iterator.hh"
+#include "repeated-music.hh"
+#include "musical-request.hh"
+#include "translator-group.hh"
+#include "command-request.hh"
+
+Repeated_music_iterator::Repeated_music_iterator ()
+{
+}
+
+Repeated_music_iterator::~Repeated_music_iterator ()
+{
+}
+
+void
+Repeated_music_iterator::construct_children ()
+{
+  Music_wrapper_iterator::construct_children ();
+  // Sequential_music_iterator::construct_children ();
+}
+
+void
+Repeated_music_iterator::do_process_and_next (Moment m)
+{
+  if (Music_wrapper_iterator::ok ())
+    Music_wrapper_iterator::do_process_and_next (m);
+//  else
+    //Sequential_music_iterator::do_process_and_next (m);
+}
+
+Music_wrapper*
+Repeated_music_iterator::music_wrapper_l () const
+{
+  return ((Repeated_music*)Music_wrapper_iterator::music_l_)->repeat_p_;
+}
+
+bool
+Repeated_music_iterator::ok () const
+{
+  return Music_wrapper_iterator::ok (); // || Sequential_music_iterator:: ok();
+}
+
+Sequential_music*
+Repeated_music_iterator::sequential_music_l () const
+{
+  return ((Repeated_music*)Sequential_music_iterator::music_l_)->alternative_p_;
+}
+
+void
+Repeated_music_iterator::start_next_element ()
+{
+  // Sequential_music_iterator::start_next_element ();
+}
+
+void
+Repeated_music_iterator::leave_element ()
+{
+  // Sequential_music_iterator::leave_element ();
+}
+
diff --git a/lily/repeated-music.cc b/lily/repeated-music.cc
new file mode 100644 (file)
index 0000000..ab6aad0
--- /dev/null
@@ -0,0 +1,64 @@
+/*   
+  repeated-music.cc --  implement Repeated_music
+  
+  source file of the GNU LilyPond music typesetter
+  
+  (c) 1998 Jan Nieuwenhuizen <janneke@gnu.org>
+  
+ */
+
+#include "repeated-music.hh"
+#include "music-wrapper.hh"
+#include "music-list.hh"
+
+Repeated_music::Repeated_music (Music_wrapper *r, int n, Sequential_music* a)
+{
+  repeats_i_ = n;
+  repeat_p_ = r;
+  alternative_p_ = a;
+}
+
+Repeated_music::~Repeated_music ()
+{
+  delete repeat_p_;
+  delete alternative_p_;
+}
+
+Repeated_music::Repeated_music (Repeated_music const& s)
+  : Music (s)
+{
+#if 0
+ // urg?
+  repeat_p_ = (Music_wrapper*)(s.repeat_p_) ? s.repeat_p_->clone () : 0;
+  alternative_p_ = (Sequential_music*)(s.alternative_p_) ? s.alternative_p_->clone () : 0;
+#endif 
+}
+
+void
+Repeated_music::do_print () const
+{
+  if (repeat_p_)
+    repeat_p_->print ();
+  if (alternative_p_)
+    alternative_p_->print ();
+}
+
+void
+Repeated_music::transpose (Musical_pitch p)
+{
+  if (repeat_p_)
+    repeat_p_->transpose (p);
+  if (alternative_p_)
+    alternative_p_->transpose (p);
+}
+
+Moment
+Repeated_music::duration () const
+{
+  Moment m;
+  if (repeat_p_)
+    m += repeat_p_->duration ();
+  if (alternative_p_)
+    m += alternative_p_->duration ();
+  return m;
+}