]> git.donarmstrong.com Git - lilypond.git/commitdiff
lilypond-0.1.11
authorfred <fred>
Sun, 24 Mar 2002 19:56:07 +0000 (19:56 +0000)
committerfred <fred>
Sun, 24 Mar 2002 19:56:07 +0000 (19:56 +0000)
lily/include/text-item.hh
lily/my-lily-parser.cc
lily/parser.y
lily/stem-grav.cc [new file with mode: 0644]
lily/text-def.cc
lily/text-item.cc
lily/text-spanner.cc
lily/tie.cc
lily/voice-group-gravs.cc

index 45436405401352897085df8b73715e42120e5a75..ba7ae59db60e656b8ffab3f0761268909f19bb91 100644 (file)
@@ -24,14 +24,14 @@ public:
     
     /* ***************/
 
-    Text_item (General_script_def*,int dir=0);
+    Text_item (General_script_def*,Direction dir=0);
     virtual ~Text_item();
     DECLARE_MY_RUNTIME_TYPEINFO;
 
 protected:
     General_script_def * tdef_p_;
 
-    virtual Interval symbol_height()const;
+    virtual Interval symbol_height() const;
 
     virtual Molecule* brew_molecule_p() const;
     virtual void do_pre_processing();
index eb5d2f0d82c25cacedad75f8b05dd11698b1b440..0b1121190a80b5f57b14ad5d9076cd606c0c9d17 100644 (file)
@@ -33,7 +33,7 @@ My_lily_parser::set_debug()
 #ifndef NPRINT
   String s = "";
   if (init_parse_b_) 
-       s = "Init";
+    s = "Init";
   set_yydebug (!monitor->silence (s+"Parser") && check_debug);
   lexer_p_->set_debug (!monitor->silence (s+"Lexer") && check_debug);
 #endif
@@ -46,10 +46,10 @@ My_lily_parser::print_declarations()
   String s = "";
   
   if (init_parse_b_) 
-       s = "Init";
+    s = "Init";
   if (!monitor->silence (s+"Declarations") && check_debug) 
     {
-       lexer_p_->print_declarations (init_parse_b_);
+      lexer_p_->print_declarations (init_parse_b_);
     }
 #endif   
 }
@@ -69,14 +69,14 @@ My_lily_parser::parse_file (String init, String s)
   print_declarations();
 
   init_parse_b_ = false;
-    set_debug();
+  set_debug();
   lexer_p_->new_input (s , source_l_);
   do_yyparse();
   print_declarations();
 
   
   if (!define_spot_array_.empty())
-       warning ("Braces don't match.");
+    warning ("Braces don't match.");
 }
 
 My_lily_parser::~My_lily_parser()
@@ -92,7 +92,7 @@ My_lily_parser::remember_spot()
 }
 
 char const * 
-My_lily_parser::here_ch_C()const
+My_lily_parser::here_ch_C() const
 {
   return lexer_p_->here_ch_C();
 }
@@ -101,8 +101,8 @@ void
 My_lily_parser::parser_error (String s)
 {
   here_input().error (s);
-  if ( fatal_error_i_)
-       exit (fatal_error_i_);
+  if (fatal_error_i_)
+    exit (fatal_error_i_);
   error_level_i_ = 1;
 }
 
@@ -125,7 +125,7 @@ void
 My_lily_parser::set_last_duration (Duration const *d)
 {
   if (last_duration_mode_b_)
-       default_duration_ = *d;
+    default_duration_ = *d;
 }
 
 
@@ -151,25 +151,22 @@ My_lily_parser::get_rest_element (String s,  Duration * duration_p)
   Chord* velt_p = new Request_chord;
   velt_p->set_spot (here_input());
 
-  if (s=="s") { /* Space */
-       Skip_req * skip_p = new Skip_req;
-       skip_p->duration_ = *duration_p;
+  if (s=="s")
+    { /* Space */
+    Skip_req * skip_p = new Skip_req;
+    skip_p->duration_ = *duration_p;
 
-       skip_p->set_spot (here_input());
-       velt_p->add (skip_p);
+    skip_p->set_spot (here_input());
+    velt_p->add (skip_p);
     }
   else 
     {
-       Rest_req * rest_req_p = new Rest_req;
-       rest_req_p->duration_ = *duration_p;
-       rest_req_p->set_spot (here_input());
+      Rest_req * rest_req_p = new Rest_req;
+      rest_req_p->duration_ = *duration_p;
+      rest_req_p->set_spot (here_input());
        
-       velt_p->add (rest_req_p);
+      velt_p->add (rest_req_p);
     }
-  Stem_req * stem_p = new Stem_req;
-  stem_p->duration_ = *duration_p;
-  stem_p->set_spot ( here_input());
-  velt_p->add (stem_p);
 
   delete duration_p;
   return velt_p;
@@ -183,15 +180,6 @@ My_lily_parser::get_note_element (Note_req *rq, Duration * duration_p)
 
   v->add (rq);
   
-  if (duration_p->durlog_i_ >= 1) 
-    {
-       Stem_req * stem_req_p = new Stem_req();
-       stem_req_p->duration_ = *duration_p;
-       
-       stem_req_p->set_spot (here_input());
-       v->add (stem_req_p);
-    }
-
   rq->set_duration (*duration_p);
   rq->set_spot (here_input());
   delete duration_p ;
@@ -205,57 +193,57 @@ My_lily_parser::get_parens_request (char c)
   switch (c) 
     {
 
-  case '~':
-       req_p = new Tie_req;
-       break;
-  case '[':
-  case ']':
-  {
+    case '~':
+      req_p = new Tie_req;
+      break;
+    case '[':
+    case ']':
+      {
        Beam_req*b = new Beam_req;
        int p_i=plet_.type_i_ ; // ugh . Should junk?
        if (p_i!= 1)
-           b->nplet = p_i;
+         b->nplet = p_i;
        req_p = b;
-    }
-  break;
-
-  case '>':
-  case '!':
-  case '<':
-       req_p = new Span_dynamic_req;
-       break;
+      }
+    break;
+
+    case '>':
+    case '!':
+    case '<':
+      req_p = new Span_dynamic_req;
+      break;
   
-  case ')':
-  case '(':
-       req_p = new Slur_req;
-       break;
-  default:
-       assert (false);
-       break;
+    case ')':
+    case '(':
+      req_p = new Slur_req;
+      break;
+    default:
+      assert (false);
+      break;
     }
   
   switch (c) 
     {
-  case '<':
-  case '>':
-  case '(':
-  case '[':
-       req_p->span()->spantype = Span_req::START;
-       break;
-  case '!':
-  case ')':
-  case ']':
-       req_p->span()->spantype = Span_req::STOP;
-       break;
+    case '<':
+    case '>':
+    case '(':
+    case '[':
+      req_p->span()->spantype = Span_req::START;
+      break;
+    case '!':
+    case ')':
+    case ']':
+      req_p->span()->spantype = Span_req::STOP;
+      break;
        
-  default:
-       break;
+    default:
+      break;
     }
 
-   if (req_p->musical()->span_dynamic ()) 
-   {
-       Span_dynamic_req* s_l= (req_p->musical()->span_dynamic ()) ;
-       s_l->dynamic_dir_i_ = (c == '<') ? 1:-1;
+  if (req_p->musical()->span_dynamic ()) 
+    {
+      Span_dynamic_req* s_l= (req_p->musical()->span_dynamic ()) ;
+      s_l->dynamic_dir_ = (c == '<') ? UP:DOWN;
     }
 
   req_p->set_spot (here_input());
@@ -281,12 +269,12 @@ My_lily_parser::add_requests (Chord*v)
 {
   for (int i = 0; i < pre_reqs.size(); i++) 
     {
-       v->add (pre_reqs[i]);
+      v->add (pre_reqs[i]);
     }
   pre_reqs.clear();
   for (int i = 0; i <post_reqs.size(); i++) 
     {
-       v->add (post_reqs[i]);
+      v->add (post_reqs[i]);
     }
   post_reqs.clear();
 }
@@ -298,7 +286,7 @@ My_lily_parser::pop_spot()
 }
 
 Input
-My_lily_parser::here_input()const
+My_lily_parser::here_input() const
 {
   Source_file * f_l= lexer_p_->source_file_l();
   return Input (f_l, here_ch_C());
index 288d1407f1219f2c62ef0de670f282bf4111f31f..a8612c44d41416ae975a989b6ba5fb6b088b565b 100644 (file)
@@ -59,7 +59,7 @@
     Box *box;
     Chord * chord;
     Duration *duration;
-    Identifier *id;    
+    Identifier *id;
     Input_translator* itrans;
     Music *music;
     Music_list *musiclist;
@@ -68,6 +68,7 @@
     Interval *interval;
     Lookup*lookup;
     Melodic_req * melreq;
+    Music_output_def * outputdef;
     Midi_def* midi;
     Moment *moment;
     Note_req *notereq;
 }
 %{
 
-int 
+int
 yylex(YYSTYPE *s,  void * v_l)
 {
        My_lily_parser   *pars_l = (My_lily_parser*) v_l;
        My_lily_lexer * lex_l = pars_l->lexer_p_;
-       
+
        lex_l->lexval_l = (void*) s;
        return lex_l->yylex();
 }
@@ -163,7 +164,7 @@ yylex(YYSTYPE *s,  void * v_l)
 %token <melreq>        NOTENAME_ID
 %token <id>    DURATION_IDENTIFIER
 %token <id>    IDENTIFIER
-%token <id>    MELODIC_REQUEST_IDENTIFIER 
+%token <id>    MELODIC_REQUEST_IDENTIFIER
 %token <id>    MUSIC_IDENTIFIER
 %token <id>    VOICE_IDENTIFIER
 %token <id>    POST_REQUEST_IDENTIFIER
@@ -176,14 +177,14 @@ yylex(YYSTYPE *s,  void * v_l)
 %token <id>    MIDI_IDENTIFIER
 %token <id>    PAPER_IDENTIFIER
 %token <id>    REQUEST_IDENTIFIER
-%token <real>  REAL 
+%token <real>  REAL
 %token <string>        DURATION RESTNAME
-%token <string>        STRING 
+%token <string>        STRING
 %token <string> FIELDNAME RECORDLINE
-%token <i>     POST_QUOTES 
+%token <i>     POST_QUOTES
 %token <i>     PRE_QUOTES
 
-
+%type <outputdef> output_def
 %type <header>         mudela_header mudela_header_body
 %type <box>    box
 %type <c>      open_request_parens close_request_parens
@@ -192,26 +193,26 @@ yylex(YYSTYPE *s,  void * v_l)
 %type <i>      int
 %type <i>      script_dir
 %type <id>     identifier_init
-%type <duration> explicit_steno_duration notemode_duration 
+%type <duration> explicit_steno_duration notemode_duration
 %type <duration> entered_notemode_duration explicit_duration
 %type <interval>       dinterval
 %type <intvec> intastint_list
 %type <lookup> symtables symtables_body
 %type <melreq> melodic_request steno_melodic_req
 %type <notereq>        steno_note_req
-%type <melreqvec>      pitch_list 
+%type <melreqvec>      pitch_list
 %type <midi>   midi_block midi_body
 %type <moment> duration_length
 
 %type <music>  Music transposed_music
-%type <musiclist> Voice Voice_body 
+%type <musiclist> Voice Voice_body
 %type <chord>  Chord Chord_body
 %type <paper>  paper_block paper_body
 %type <real>   dim real
 %type <real>   unit
-%type <request>        post_request pre_request command_req verbose_command_req 
+%type <request>        post_request pre_request command_req verbose_command_req
 %type <request> abbrev_command_req
-%type <request>        script_req  dynamic_req 
+%type <request>        script_req  dynamic_req
 %type <score>  score_block score_body
 %type <script> script_definition script_body mudela_script gen_script_def
 %type <textdef> text_def
@@ -232,11 +233,11 @@ mudela:   /* empty */
                THIS->default_header_p_ = $2;
        }
        | mudela score_block {
-               add_score($2);          
+               add_score($2);
        }
        | mudela add_declaration { }
        | mudela error
-       | mudela check_version { } 
+       | mudela check_version { }
        | mudela add_notenames { }
        ;
 
@@ -283,7 +284,7 @@ mudela_header:
        HEADER  {
                THIS->lexer_p_->push_header_state();
        }
-       
+
        '{' mudela_header_body '}'      {
                $$ = $4;
                THIS->lexer_p_->pop_state();
@@ -318,43 +319,43 @@ add_declaration:
 identifier_init:
        score_block {
                $$ = new Score_id($1, SCORE_IDENTIFIER);
-               
+
        }
        | paper_block {
                $$ = new Paper_def_id($1, PAPER_IDENTIFIER);
-               
+
        }
        | midi_block {
                $$ = new Midi_def_id($1, MIDI_IDENTIFIER);
-               
+
        }
        | script_definition {
                $$ = new Script_id($1, SCRIPT_IDENTIFIER);
-               
+
        }
        | Music  {
                $$ = new Music_id($1, MUSIC_IDENTIFIER);
-               
+
        }
        | symtables {
                $$ = new Lookup_id($1, IDENTIFIER);
-               
+
        }
        | real  {
                $$ = new Real_id(new Real($1), REAL_IDENTIFIER);
-               
+
        }
        | int   {
                $$ = new Int_id(new int($1), INT_IDENTIFIER);
-               
+
        }
        | post_request {
                $$ = new Request_id($1, POST_REQUEST_IDENTIFIER);
-               
+
        }
        | melodic_request {
                $$ = new Request_id($1, MELODIC_REQUEST_IDENTIFIER);
-               
+
        }
        | input_translator_spec {
                $$ = new Input_translator_id ( $1, INPUT_TRANS_IDENTIFIER);
@@ -376,8 +377,8 @@ input_translator_spec_body:
                $$ = $1->input_translator();
                $$-> set_spot( THIS->here_input() );
        }
-       | STRING STRING { 
-               $$ = new Input_translator; 
+       | STRING STRING {
+               $$ = new Input_translator;
                $$->base_str_ = *$1;
                $$->type_str_ =*$2;
                $$->set_spot ( THIS->here_input() );
@@ -411,8 +412,8 @@ score_block:
        /*cont*/ '{' score_body '}'     {
                $$ = $4;
                $$->set_spot(THIS->pop_spot());
-               if (!$$->paper_p_ && ! $$->midi_p_)
-                       $$->paper_p_ = THIS->default_paper();
+               if (!$$->def_p_arr_.size ())
+                       $$->add ( THIS->default_paper());
 
                /* handle error levels. */
                $$->errorlevel_i_ = THIS->error_level_i_;
@@ -422,8 +423,8 @@ score_block:
        }
        ;
 
-score_body:            { 
-               $$ = new Score; 
+score_body:            {
+               $$ = new Score;
        }
        | SCORE_IDENTIFIER {
                $$ = $1->score();
@@ -434,17 +435,23 @@ score_body:               {
        | score_body Music      {
                $$->music_p_ = $2;
        }
-       | score_body paper_block                {
-               $$->paper_p_ = $2;      
-       }
-       | score_body midi_block         { 
-               $$->midi_p_ = $2;
+       | score_body output_def {
+               $$->add( $2);
        }
        | score_body error {
 
        }
        ;
 
+output_def:
+       paper_block {
+               $$ = $1;
+       }
+       |  midi_block           {
+               $$= $1;
+       }
+       ;
+
 intastint_list:
        /* */   { $$ =new Array<int>; }
        | intastint_list int '*' int    {
@@ -468,11 +475,12 @@ paper_body:
        | PAPER_IDENTIFIER      {
                $$ = $1->paperdef();
        }
-       | paper_body OUTPUT STRING ';'  { $$->outfile_str_ = *$3;
+       | paper_body OUTPUT STRING ';'  { 
+               $$->outfile_str_ = *$3;
                delete $3;
        }
        | paper_body symtables          { $$->set($2); }
-       | paper_body STRING '=' dim ';'         { 
+       | paper_body STRING '=' dim ';'         {
                $$->set_var(*$2, $4);
        }
        | paper_body STRING '=' real ';' {
@@ -498,9 +506,9 @@ midi_block:
 midi_body: /* empty */                 {
                $$ = THIS->default_midi();
        }
-       | midi_body OUTPUT STRING ';'   { 
-               $$->outfile_str_ = *$3; 
-               delete $3; 
+       | midi_body OUTPUT STRING ';'   {
+               $$->outfile_str_ = *$3;
+               delete $3;
        }
        | midi_body tempo_request ';' {
                $$->set_tempo( $2->dur_.length(), $2->metronome_i_ );
@@ -539,7 +547,7 @@ Voice_body:
        }
        | Voice_body ID STRING STRING ';'       {
                $$ = new Voice;
-               $$->type_str_ = *$3;    
+               $$->type_str_ = *$3;
                $$->id_str_ = *$4;
                delete $3;
                delete $4;
@@ -555,16 +563,16 @@ Music:
        | Chord                 { $$ = $1; }
        | transposed_music      { $$ = $1; }
        | MUSIC_IDENTIFIER      { $$ = $1->music(); }
-       | MELODIC 
-               { THIS->lexer_p_->push_note_state(); } 
+       | MELODIC
+               { THIS->lexer_p_->push_note_state(); }
        Music
                { $$=$3; THIS->lexer_p_->pop_state(); }
 
-       | LYRIC 
-               { THIS->lexer_p_->push_lyric_state(); } 
+       | LYRIC
+               { THIS->lexer_p_->push_lyric_state(); }
        Music
                { $$ = $3; THIS->lexer_p_->pop_state(); }
-       ; 
+       ;
 
 Chord:
        '<' Chord_body '>'      { $$  = $2; }
@@ -579,9 +587,9 @@ Chord_body:
                $$->multi_level_i_=$3;
        }
        | Chord_body ID STRING STRING ';'       {
-               $$->type_str_ = *$3;    
+               $$->type_str_ = *$3;
                $$->id_str_ = *$4;
-               delete $4; 
+               delete $4;
                delete $3;
        }
        | Chord_body Music {
@@ -608,10 +616,10 @@ full_element:
        }
        | command_elt
        | voice_command ';'     { $$ = 0; }
-       ;       
+       ;
 
 simple_element:
-       music_elt 
+       music_elt
        | lyrics_elt
        ;
 
@@ -626,12 +634,12 @@ command_elt:
        ;
 
 command_req:
-       abbrev_command_req      
+       abbrev_command_req
        | verbose_command_req ';'       { $$ = $1; }
        ;
 
 abbrev_command_req:
-        '|'                            { 
+        '|'                            {
                $$ = new Barcheck_req;
        }
        | COMMAND_IDENTIFIER    {
@@ -650,16 +658,16 @@ verbose_command_req:
                // sorry hw, i need meter at output of track,
                // but don-t know where to get it... statics should go.
                // HW : default: 4/4, meterchange reqs may change it.
-               
+
                Midi_def::num_i_s = $2;
                Midi_def::den_i_s = $4;
                $$ = m;
        }
        | SKIP duration_length {
                Skip_req * skip_p = new Skip_req;
-               skip_p->duration_.set_plet($2->numerator().as_long(), 
+               skip_p->duration_.set_plet($2->numerator().as_long(),
                        $2->denominator().as_long());
-               
+
                delete $2;
                $$ = skip_p;
        }
@@ -683,7 +691,7 @@ verbose_command_req:
                $$ = new Clef_change_req(*$2);
                delete $2;
        }
-       | KEY pitch_list        {       
+       | KEY pitch_list        {
                Key_change_req *key_p= new Key_change_req;
                key_p->melodic_p_arr_ = *$2;
                $$ = key_p;
@@ -709,8 +717,8 @@ post_request:
        POST_REQUEST_IDENTIFIER {
                $$ = (Request*)$1->request();
        }
-       |close_request_parens   { 
-               $$ = THIS->get_parens_request($1); 
+       |close_request_parens   {
+               $$ = THIS->get_parens_request($1);
        }
        | script_req
        | dynamic_req
@@ -726,10 +734,10 @@ steno_melodic_req:
                $$ = $1->clone()->musical()->melodic();
                $$->octave_i_ += THIS->default_octave_i_;
        }
-       | steno_melodic_req POST_QUOTES         {  
+       | steno_melodic_req POST_QUOTES         {
                $$-> octave_i_ += $2;
        }
-       | PRE_QUOTES steno_melodic_req   {  
+       | PRE_QUOTES steno_melodic_req   {
                $$ = $2;
                $2-> octave_i_ -= $1;
        }
@@ -743,7 +751,7 @@ steno_note_req:
        }
        | steno_note_req   '!'          {
                $$->forceacc_b_ = ! $$->forceacc_b_;
-       } 
+       }
        /* have to duration here. */
        ;
 
@@ -773,7 +781,7 @@ dynamic_req:
        | SPANDYNAMIC '{' int int '}' {
                Span_dynamic_req * sp_p = new Span_dynamic_req;
                sp_p->spantype = $4;
-               sp_p-> dynamic_dir_i_  = $3;
+               sp_p-> dynamic_dir_  = $3;
                $$ = sp_p;
        }
        ;
@@ -790,10 +798,10 @@ close_request_parens:
        '~'     {
                $$ = '~';
        }
-       | '('   { 
+       | '('   {
                $$='(';
        }
-       | ']'   { 
+       | ']'   {
                $$ = ']';
        }
        | close_plet_parens {
@@ -819,7 +827,7 @@ open_request_parens:
        E_EXCLAMATION   {
                $$ = '!';
        }
-       | ')'   { 
+       | ')'   {
                $$=')';
        }
        | '['   {
@@ -841,31 +849,31 @@ script_body:
                s->set_from_input(*$1,$2, $3,$4,$5, $6);
                $$  = s;
                delete $1;
-       }       
+       }
        ;
 
 script_req:
-       script_dir gen_script_def               { 
+       script_dir gen_script_def               {
                Musical_script_req *m = new Musical_script_req;
-               $$ = m; 
+               $$ = m;
                m-> scriptdef_p_ = $2;
                m-> set_spot ( THIS->here_input() );
-               m-> dir_i_  = $1;
+               m-> dir_  = $1;
        }
        ;
 
 gen_script_def:
        text_def        { $$ = $1; }
-       | mudela_script { $$ = $1; 
+       | mudela_script { $$ = $1;
                $$-> set_spot( THIS->here_input() );
        }
        ;
 
 text_def:
-       STRING { 
+       STRING {
                Text_def *t  = new Text_def;
                $$ = t;
-               t->text_str_ = *$1; 
+               t->text_str_ = *$1;
                delete $1;
                t->style_str_ = THIS->textstyle_str_;
                $$->set_spot( THIS->here_input() );
@@ -883,11 +891,11 @@ script_abbreviation:
                $$ = get_scriptdef('.');
        }
        ;
-       
+
 mudela_script:
        SCRIPT_IDENTIFIER               { $$ = $1->script(); }
        | script_definition             { $$ = $1; }
-       | script_abbreviation           { 
+       | script_abbreviation           {
                $$ = THIS->lexer_p_->lookup_identifier(*$1)->script();
                delete $1;
        }
@@ -906,9 +914,9 @@ pre_requests:
        }
        ;
 
-pre_request: 
-       open_request_parens     { 
-               $$ = THIS->get_parens_request($1); 
+pre_request:
+       open_request_parens     {
+               $$ = THIS->get_parens_request($1);
        }
        ;
 
@@ -924,7 +932,7 @@ voice_command:
                THIS->set_default_duration($2);
                delete $2;
        }
-       | OCTAVE { 
+       | OCTAVE {
                /*
                        This is weird, but default_octave_i_
                        is used in steno_note_req too
@@ -944,11 +952,11 @@ voice_command:
        }
        ;
 
-duration_length:       
+duration_length:
        {
                $$ = new Moment(0,1);
        }
-       | duration_length explicit_steno_duration               {       
+       | duration_length explicit_steno_duration               {
                *$$ += $2->length();
        }
        ;
@@ -959,11 +967,11 @@ dots:
        ;
 
 entered_notemode_duration:
-       /* */           { 
+       /* */           {
                $$ = new Duration(THIS->default_duration_);
        }
        | dots          {
-               $$ = new Duration(THIS->default_duration_);             
+               $$ = new Duration(THIS->default_duration_);
                $$->dots_i_  = $1;
        }
        | explicit_steno_duration       {
@@ -996,10 +1004,10 @@ explicit_steno_duration:
                $$->dots_i_ ++;
        }
        | explicit_steno_duration '*' int  {
-               $$->plet_.iso_i_ *= $3; 
+               $$->plet_.iso_i_ *= $3;
        }
        | explicit_steno_duration '/' int {
-               $$->plet_.type_i_ *= $3; 
+               $$->plet_.type_i_ *= $3;
        }
        ;
 
@@ -1059,7 +1067,7 @@ real:
                delete r_p;
        }
        ;
-       
+
 
 
 dim:
@@ -1072,7 +1080,7 @@ unit:     CM_T            { $$ = 1 CM; }
        |MM_T           { $$ = 1 MM; }
        |PT_T           { $$ = 1 PT; }
        ;
-       
+
 /*
        symbol tables
 */
@@ -1132,13 +1140,13 @@ box:
        ;
 
 dinterval: dim dim             {
-               $$ = new Interval($1, $2);      
+               $$ = new Interval($1, $2);
        }
        ;
 
 %%
 
-void 
+void
 My_lily_parser::set_yydebug(bool b )
 {
 #ifdef YYDEBUG
diff --git a/lily/stem-grav.cc b/lily/stem-grav.cc
new file mode 100644 (file)
index 0000000..c5d825c
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+  stem-grav.cc -- implement Stem_engraver
+
+  source file of the GNU LilyPond music typesetter
+
+  (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+
+#include "stem-grav.hh"
+#include "note-head.hh"
+#include "stem.hh"
+#include "musical-request.hh"
+#include "duration-convert.hh"
+
+Stem_engraver::Stem_engraver()
+{
+  stem_p_ =0;
+  dir_ =CENTER;
+}
+
+void
+Stem_engraver::acknowledge_element(Score_elem_info i)
+{
+  if (i.elem_l_->is_type_b (Note_head::static_name()))
+    {
+      Note_head *h  = (Note_head*) i.elem_l_->item();
+      if (!stem_p_) 
+       {
+         Rhythmic_req * r = i.req_l_->musical()->rhythmic();
+         stem_p_ = new Stem;
+         stem_p_->flag_i_ = Duration_convert::type2_i(r->duration_.durlog_i_);
+         announce_element (Score_elem_info (stem_p_, r));
+       }
+      stem_p_->add (h);
+    }
+}
+
+void
+Stem_engraver::do_pre_move_processing()
+{
+  if (stem_p_)
+    {
+      if (dir_)
+       stem_p_->dir_ = dir_;
+      
+      typeset_element(stem_p_);
+      stem_p_ =0;
+    }
+}
+
+void
+Stem_engraver::set_feature (Feature i)
+{
+  if (i.type_ == "vdir")       
+    dir_ = (Direction) int(i.value_);
+}
+
+IMPLEMENT_IS_TYPE_B1(Stem_engraver, Engraver);
+ADD_THIS_ENGRAVER(Stem_engraver);
index a2ce8730cfcc34fe19622133413892cb05ad65d0..ead696b073629faacfc3b4c783bcbcdc5a743d00 100644 (file)
@@ -16,7 +16,7 @@
 Interval
 Text_def::width (Paper_def * p) const
 {
-  Atom a = get_atom (p,0);
+  Atom a = get_atom (p,CENTER);
 
   Real guess_width_f = text_str_.length_i() * a.sym_.dim.x ().length (); // ugh
   Interval i (0, guess_width_f);
@@ -47,7 +47,7 @@ Text_def::do_equal_b (General_script_def const *gdef) const
 }
 
 Atom
-Text_def::get_atom (Paper_def *p, int) const
+Text_def::get_atom (Paper_def *p, Direction) const
 {
   return p->lookup_l()->text (style_str_, text_str_, -align_i_);
 }
index db87a8d152c7fc6e6365df5382ab9fa8ee4ff03d..876acfde39f0b0133970dd94aedf4fbb8fbc94fc 100644 (file)
@@ -14,9 +14,9 @@
 #include "molecule.hh"
 #include "lookup.hh"
 
-Text_item::Text_item (General_script_def*tdef_l, int d)
+Text_item::Text_item (General_script_def*tdef_l, Direction d) 
 {
-  dir_i_ = d;
+  dir_ = d;
   fat_b_ = false;
   tdef_p_ = tdef_l->clone();
 }
@@ -29,29 +29,29 @@ Text_item::~Text_item()
 void
 Text_item::do_pre_processing()
 {
-  if (!dir_i_)
-       dir_i_ = -1;
+  if (!dir_)
+    dir_ = DOWN;
 }
 
 Interval
-Text_item::symbol_height()const
+Text_item::symbol_height() const
 {
-  return tdef_p_->get_atom (paper(), dir_i_).sym_.dim.y ();
+  return tdef_p_->get_atom (paper(), dir_).sym_.dim.y ();
 }
   
 Molecule*
 Text_item::brew_molecule_p() const
 {
-  Atom a (tdef_p_->get_atom (paper(), dir_i_));
+  Atom a (tdef_p_->get_atom (paper(), dir_));
 
-/*
-  if ( fat_b_)
-       a.sym.dim.x = tdef_p_->width (paper());
-       */
+  /*
+    if (fat_b_)
+    a.sym.dim.x = tdef_p_->width (paper());
+    */
   Molecule* mol_p = new Molecule (a);
 
-  if (dir_i_<0)                // should do something better anyway.
-       mol_p->translate (-mol_p->extent().y ().left , Y_AXIS);
+  if (dir_<0)          // should do something better anyway.
+    mol_p->translate (-mol_p->extent().y ().left , Y_AXIS);
   mol_p->translate (pos_i_ * paper()->internote_f (), Y_AXIS);
   
   return mol_p;
index 1ab46bbb62936350febad8e53f16cf1b31d872e8..edf430aa139de4973efeb92a00908e31fcb32566 100644 (file)
@@ -44,13 +44,13 @@ void
 Text_spanner::do_post_processing()
 {
   text_off_ = support_span_l_->center() +
-       Offset (0,support_span_l_->dir_i_ * paper()->internote_f () * 4); // todo
+       Offset (0,support_span_l_->dir_ * paper()->internote_f () * 4); // todo
 }
 
 Molecule*
 Text_spanner::brew_molecule_p() const
 {
-  Atom tsym (spec_p_->get_atom (paper(),0));
+  Atom tsym (spec_p_->get_atom (paper(),CENTER));
   tsym.translate (text_off_);
 
   Molecule*output = new Molecule;
@@ -61,13 +61,11 @@ Text_spanner::brew_molecule_p() const
 void
 Text_spanner::do_pre_processing()
 {
-  right_col_l_ = support_span_l_->right_col_l_;
-  left_col_l_ = support_span_l_->left_col_l_;
-  assert (left_col_l_ && right_col_l_);
+  spanned_drul_ = support_span_l_->spanned_drul_;
 }
 
 Interval
-Text_spanner::height()const
+Text_spanner::height() const
 {
   return brew_molecule_p()->extent ().y ();
 }
index ba7d75a3b8fcc523428a61eec775e122f1152bff..190618869bdfcb7f9fdfbeb2606c08253c554061 100644 (file)
 
 
 void
-Tie::set_head (int x_pos, Note_head * head_l)
+Tie::set_head (Direction d, Note_head * head_l)
 {
-  if (x_pos >0) 
-    {
-       assert (!right_head_l_);
-       right_head_l_ = head_l;
-    }
-  else 
-    {
-       assert (!left_head_l_);
-       left_head_l_ = head_l;
-    }
+  assert (!head_l_drul_[d]);
+  head_l_drul_[d] = head_l;
+
   add_dependency (head_l);
 }
 
 Tie::Tie()
 {
-  right_head_l_ =0;
-  left_head_l_ =0;
+  head_l_drul_[RIGHT] =0;
+  head_l_drul_[LEFT] =0;
   same_pitch_b_ =false;
 }
 
 void
 Tie::set_default_dir()
 {
-  int m= (left_head_l_->position_i_ + right_head_l_->position_i_) /2 ;
-  dir_i_ =  (m < 5)? -1:1;                     // ugh
+  int m= (head_l_drul_[LEFT]->position_i_ + head_l_drul_[RIGHT]->position_i_) /2 ;
+  dir_ =  (m < 5)? DOWN : UP;  // UGH
 }
   
 
 void
 Tie::do_add_processing()
 {
-  assert (left_head_l_ && right_head_l_);
-  left_col_l_ = left_head_l_ -> pcol_l_;
-  right_col_l_ = right_head_l_ -> pcol_l_;
+  assert (head_l_drul_[LEFT] && head_l_drul_[RIGHT]);
+  set_bounds(LEFT,head_l_drul_[LEFT]);
+  set_bounds(RIGHT,head_l_drul_[RIGHT]);
 }
 
-/**
-  This is already getting hairy. Should use Note_head *heads[2]
- */
 void
 Tie::do_post_processing()
 {
-  assert (left_head_l_ || right_head_l_);
-  left_pos_i_ =  (left_head_l_)? 
-       left_head_l_->position_i_ : right_head_l_->position_i_;
-  right_pos_i_ = (right_head_l_) ? 
-       right_head_l_->position_i_ : left_head_l_->position_i_;
-  if ( right_head_l_ && right_head_l_->extremal_i_) 
+  assert (head_l_drul_[LEFT] || head_l_drul_[RIGHT]);
+
+  Direction d = LEFT;
+  do 
     {
-       right_pos_i_ += 2*dir_i_;
-       right_dx_f_ -= 0.25;
+      pos_i_drul_[d] =  (head_l_drul_[d])? 
+       head_l_drul_[d]->position_i_ : head_l_drul_[(Direction)-d]->position_i_;
     }
-  else
-       right_dx_f_ -= 0.5;
+  while ((d *= -1) != LEFT);
 
-  if (left_head_l_ && left_head_l_->extremal_i_) 
+  do 
     {
-       left_pos_i_ += 2*dir_i_;
-       left_dx_f_ += 0.25;
+      if (head_l_drul_[d] && head_l_drul_[d]->extremal_i_) 
+       {
+         pos_i_drul_[d] += 2*dir_;
+         dx_f_drul_[d] += d * 0.25;
+       }
+      else
+       dx_f_drul_[d] += d*0.5;
     }
-  else
-       left_dx_f_ += 0.5;
-  
-  if (!right_head_l_)
-       right_pos_i_ = left_pos_i_;
-  if (! left_head_l_)
-       left_pos_i_ = right_pos_i_;
+  while ((d *= -1) != LEFT);
+
+  do 
+    {
+      if (!head_l_drul_[d])
+       pos_i_drul_[d] = pos_i_drul_[(Direction)-d];
+    } 
+  while ((d *= -1) != LEFT);
 }
 
 
@@ -91,10 +83,10 @@ void
 Tie::do_substitute_dependency (Score_elem*o, Score_elem*n)
 {
   Note_head *new_l =n?(Note_head*)n->item():0;
-  if (o->item() == left_head_l_)
-       left_head_l_ = new_l;
-  else if (o->item() == right_head_l_)
-       right_head_l_ = new_l;
+  if (o->item() == head_l_drul_[LEFT])
+    head_l_drul_[LEFT] = new_l;
+  else if (o->item() == head_l_drul_[RIGHT])
+    head_l_drul_[RIGHT] = new_l;
 }
 
 
index 66235afb14c13dcaf43796fc4d610cf9faef2981..927d9983e791c77ee94e7f9c37d217cd202a933a 100644 (file)
@@ -16,7 +16,7 @@
 
 Voice_group_engravers::Voice_group_engravers()
 {
-  dir_i_ =0;
+  dir_ =CENTER;
 }
 
 bool
@@ -25,11 +25,11 @@ Voice_group_engravers::do_try_request (Request*r_l)
   Command_req* c_l = r_l->command();
   if (c_l&& c_l->groupfeature()) 
     {
-       Feature f;
-       f.type_ = c_l->groupfeature()->type_str_;
-       f.value_ = c_l->groupfeature()->value_str_;
-       set_feature (f);
-       return true;
+      Feature f;
+      f.type_ = c_l->groupfeature()->type_str_;
+      f.value_ = c_l->groupfeature()->value_str_;
+      set_feature (f);
+      return true;
     }
   return Engraver_group_engraver::do_try_request (r_l);
 }
@@ -52,7 +52,7 @@ Scalar
 Voice_group_engravers::get_feature (String f)
 {
   if (f == "vdir")
-       return dir_i_;
+    return dir_;
   Engraver_group_engraver::get_feature (f);
 }