]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/my-lily-parser.cc
release: 1.3.0
[lilypond.git] / lily / my-lily-parser.cc
index 86270bf7c38fc8b368f448da97e6a9c9ecb134cd..11ae2eeda45ac03929a2b17894f45bf7b3e8e4c8 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 "music-list.hh"
 #include "musical-request.hh"
 #include "command-request.hh"
+#include "lily-guile.hh"
 #include "parser.hh"
 #include "scope.hh"
 #include "file-results.hh"
 #include "midi-def.hh"
 #include "paper-def.hh"
 #include "identifier.hh"
+#include "chord.hh"
 
 My_lily_parser::My_lily_parser (Sources * source_l)
 {
@@ -27,9 +30,9 @@ My_lily_parser::My_lily_parser (Sources * source_l)
   lexer_p_ = 0;
   abbrev_beam_type_i_ = 0;
   default_duration_.durlog_i_ = 2;
-  default_abbrev_i_ = 0;
+  default_pitch_ = Musical_pitch (5*7, 0);
   error_level_i_ = 0;
-  extender_req = 0;
+
   fatal_error_i_ = 0;
   default_header_p_ =0;
 }
@@ -58,17 +61,19 @@ My_lily_parser::parse_file (String init, String s)
   *mlog << _ ("Parsing...");
 
   init_parse_b_ = false;
-  set_yydebug (!monitor->silent_b ("Parser") && check_debug);
+  set_yydebug (flower_dstream &&!flower_dstream->silent_b ("Parser"));
   lexer_p_->new_input (init, source_l_);
   do_yyparse ();
 
   if (!define_spot_array_.empty())
     {
-      warning (_ ("braces don't match"));
+      warning (_ ("Braces don't match"));
       error_level_i_ = 1;
     }
 
   inclusion_global_array = lexer_p_->filename_str_arr_;
+
+  error_level_i_ = error_level_i_ | lexer_p_->errorlevel_i_; // ugh naming.
 }
 
 void
@@ -93,26 +98,25 @@ My_lily_parser::parser_error (String s)
   exit_status_i_ = 1;
 }
 
+void
+My_lily_parser::set_last_duration (Duration const *d)
+{
+  default_duration_ = *d;
+}
+
 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)
+My_lily_parser::set_last_pitch (Musical_pitch const* p)
 {
-  default_duration_ = *d;
-
-  /* 
-     forget plet part,
-     but keep sticky plet factor within plet brackets
-    */  
-  default_duration_.plet_ = plet_;
+  default_pitch_ = *p;
 }
 
-
+// junk me
 Simultaneous_music*
 My_lily_parser::get_word_element (String s, Duration * duration_p)
 {
@@ -129,7 +133,7 @@ My_lily_parser::get_word_element (String s, Duration * duration_p)
   return velt_p;
 }
 
-
+// junk me
 Simultaneous_music *
 My_lily_parser::get_rest_element (String s,  Duration * duration_p)
 {
@@ -157,143 +161,32 @@ My_lily_parser::get_rest_element (String s,  Duration * duration_p)
   return velt_p;
 }
 
+// junk me
 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);
-
-  // too bad parser reads (default) duration via member access,
-  // this hack will do for now..
-  if (abbrev_beam_type_i_)
-    {
-      assert (!duration_p->plet_b ());
-      duration_p->set_plet (1, 2);
-    }
-  rq->duration_ = *duration_p;
-  rq->set_spot (here_input ());
-  delete duration_p ;
-  return v;
-}
-
+  Chord chord (tonic, add_arr_p, sub_arr_p, inversion_p);
 
-/*
-  UGH.
- */
-Array<Request*>*
-My_lily_parser::get_parens_request (int t)
-{
-  Array<Request*>& reqs = *new 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);
-         }
-      }
-      break;
-
-    case '>':
-    case '!':
-    case '<':
-      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 '(':
-      {
-       reqs.push (new Slur_req);
-      }
-      break;
-    default:
-      assert (false);
-      break;
-    }
+  Tonic_req* t = new Tonic_req;
+  t->pitch_ = tonic;
+  v->add_music (t);
 
-  switch (t)
+  for (int i = 0; i < chord.pitch_arr_.size (); i++)
     {
-    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;
-      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;
-      break;
-
-    default:
-      break;
+      Musical_pitch p = chord.pitch_arr_[i];
+      Note_req* n = new Note_req;
+      n->pitch_ = p;
+      n->duration_ = d;
+      v->add_music (n);
     }
 
-  for (int i = 0; i < reqs.size (); i++)
-    if (dynamic_cast<Span_dynamic_req*> (reqs[i]))
-      {
-       Span_dynamic_req* s_l= dynamic_cast<Span_dynamic_req*> (reqs[i]);
-       s_l->dynamic_dir_ = (t == '<') ? UP:DOWN;
-      }
-
-  // ugh? don't we do this in the parser too?
-  reqs[0]->set_spot (here_input());
-  return &reqs;
+  return v;
 }
 
-void
-My_lily_parser::add_requests (Simultaneous_music*v)
-{
-  for (int i = 0; i < pre_reqs.size(); i++)
-    {
-      v->add_music (pre_reqs[i]);
-    }
-  pre_reqs.clear();
-  for (int i = 0; i <post_reqs.size(); i++)
-    {
-      v->add_music (post_reqs[i]);
-    }
 
-  post_reqs.clear();
-}
 
 Input
 My_lily_parser::pop_spot()
@@ -304,15 +197,7 @@ My_lily_parser::pop_spot()
 Input
 My_lily_parser::here_input() const
 {
-  Source_file * f_l= lexer_p_->source_file_l();
-  return Input (f_l, here_ch_C());
-}
-
-void
-My_lily_parser::add_notename (String s, Musical_pitch p)
-{
-  lexer_p_->add_notename (s, p);
-
+  return  lexer_p_->here_input ();
 }
 
 Paper_def*