]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/my-lily-parser.cc
patch::: 1.1.30.mb1: Re: LilyPond 1.1.30
[lilypond.git] / lily / my-lily-parser.cc
index 86270bf7c38fc8b368f448da97e6a9c9ecb134cd..6b43a89e370a916a16d313dc06a4926b1b94dff2 100644 (file)
@@ -3,7 +3,8 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c)  1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c)  1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+       Jan Nieuwenhuizen <janneke@gnu.org>
 */
 
 #include "my-lily-parser.hh"
 #include "midi-def.hh"
 #include "paper-def.hh"
 #include "identifier.hh"
+#include "chord.hh"
 
 My_lily_parser::My_lily_parser (Sources * source_l)
 {
   first_b_ = true;
   source_l_ = source_l;
   lexer_p_ = 0;
-  abbrev_beam_type_i_ = 0;
   default_duration_.durlog_i_ = 2;
-  default_abbrev_i_ = 0;
   error_level_i_ = 0;
   extender_req = 0;
   fatal_error_i_ = 0;
@@ -93,23 +93,12 @@ My_lily_parser::parser_error (String s)
   exit_status_i_ = 1;
 }
 
-void
-My_lily_parser::set_abbrev_beam (int type_i)
-{
-  abbrev_beam_type_i_ = type_i;
-}
 
 
 void
 My_lily_parser::set_last_duration (Duration const *d)
 {
   default_duration_ = *d;
-
-  /* 
-     forget plet part,
-     but keep sticky plet factor within plet brackets
-    */  
-  default_duration_.plet_ = plet_;
 }
 
 
@@ -158,20 +147,37 @@ My_lily_parser::get_rest_element (String s,  Duration * duration_p)
 }
 
 Simultaneous_music *
-My_lily_parser::get_note_element (Note_req *rq, Duration * duration_p)
+My_lily_parser::get_chord (Musical_pitch tonic, Array<Musical_pitch>* add_arr_p, Array<Musical_pitch>* sub_arr_p, Musical_pitch* inversion_p, Duration d)
 {
   Simultaneous_music*v = new Request_chord;
   v->set_spot (here_input ());
 
-  v->add_music (rq);
+  Chord chord (tonic, add_arr_p, sub_arr_p, inversion_p);
 
-  // too bad parser reads (default) duration via member access,
-  // this hack will do for now..
-  if (abbrev_beam_type_i_)
+  Tonic_req* t = new Tonic_req;
+  t->pitch_ = tonic;
+  v->add_music (t);
+
+  for (int i = 0; i < chord.pitch_arr_.size (); i++)
     {
-      assert (!duration_p->plet_b ());
-      duration_p->set_plet (1, 2);
+      Musical_pitch p = chord.pitch_arr_[i];
+      Note_req* n = new Note_req;
+      n->pitch_ = p;
+      n->duration_ = d;
+      v->add_music (n);
     }
+
+  return v;
+}
+
+Simultaneous_music *
+My_lily_parser::get_note_element (Note_req *rq, Duration * duration_p)
+{
+  Simultaneous_music*v = new Request_chord;
+  v->set_spot (here_input ());
+
+  v->add_music (rq);
+
   rq->duration_ = *duration_p;
   rq->set_spot (here_input ());
   delete duration_p ;
@@ -182,38 +188,20 @@ My_lily_parser::get_note_element (Note_req *rq, Duration * duration_p)
 /*
   UGH.
  */
-Array<Request*>*
+Link_array<Request>*
 My_lily_parser::get_parens_request (int t)
 {
-  Array<Request*>& reqs = *new Array<Request*>;
+  Link_array<Request>& reqs = *new Link_array<Request>;
   switch (t)
     {
     case '~':
       reqs.push (new Tie_req);
       break;
-    case BEAMPLET:
-    case MAEBTELP:
-      {
-       Plet_req* p = new Plet_req;
-       p->plet_i_ = plet_.type_i_;
-       reqs.push (p);
-      }
-      /* fall through */
+
     case '[':
     case ']':
       {
-       if (!abbrev_beam_type_i_)
-         {
-           reqs.push (new Beam_req);
-         }
-       else
-         {
-           Abbreviation_beam_req* a = new Abbreviation_beam_req;
-           a->type_i_ = abbrev_beam_type_i_;
-           if (t==']')
-             abbrev_beam_type_i_ = 0;
-           reqs.push (a);
-         }
+       reqs.push (new Beam_req);
       }
       break;
 
@@ -223,14 +211,6 @@ My_lily_parser::get_parens_request (int t)
       reqs.push (new Span_dynamic_req);
       break;
 
-    case PLET:  
-    case TELP:
-      {
-       Plet_req* p = new Plet_req;
-       p->plet_i_ = plet_.type_i_;
-       reqs.push (p);
-      }
-      break;
     case ')':
     case '(':
       {
@@ -244,23 +224,17 @@ My_lily_parser::get_parens_request (int t)
 
   switch (t)
     {
-    case BEAMPLET:
-      dynamic_cast<Span_req*> (reqs.top ())->spantype = Span_req::START;
-      /* fall through */
     case '<':
     case '>':
     case '(':
     case '[':
-    case PLET:
-      dynamic_cast<Span_req*> (reqs.top ())->spantype = Span_req::START;
+      dynamic_cast<Span_req*> (reqs[0])->spantype_ = START;
       break;
-    case MAEBTELP:
-      dynamic_cast<Span_req*> (reqs.top ())->spantype = Span_req::STOP;
-      /* fall through */
+      
     case '!':
     case ')':
     case ']':
-      dynamic_cast<Span_req*> (reqs[0])->spantype = Span_req::STOP;
+      dynamic_cast<Span_req*> (reqs[0])->spantype_ = STOP;
       break;
 
     default:
@@ -308,13 +282,6 @@ My_lily_parser::here_input() const
   return Input (f_l, here_ch_C());
 }
 
-void
-My_lily_parser::add_notename (String s, Musical_pitch p)
-{
-  lexer_p_->add_notename (s, p);
-
-}
-
 Paper_def*
 My_lily_parser::default_paper_p ()
 {