From 3dc689e92a87044ec6123b14099529150a89860d Mon Sep 17 00:00:00 2001 From: fred Date: Sun, 24 Mar 2002 19:57:44 +0000 Subject: [PATCH] lilypond-0.1.14 --- lily/boxes.cc | 8 +++++++ lily/include/my-lily-parser.hh | 2 -- lily/include/stem-grav.hh | 2 ++ lily/my-lily-parser.cc | 21 +++++----------- lily/parser.y | 44 ++++++++++++++++++++-------------- lily/stem-grav.cc | 25 ++++++++++++++++--- lily/translator.cc | 19 ++++++++++++--- 7 files changed, 80 insertions(+), 41 deletions(-) diff --git a/lily/boxes.cc b/lily/boxes.cc index 4a219a4864..1bf7177336 100644 --- a/lily/boxes.cc +++ b/lily/boxes.cc @@ -1,3 +1,11 @@ +/* + boxes.cc -- implement Box + + source file of the GNU LilyPond music typesetter + + (c) 1996,1997 Han-Wen Nienhuys +*/ + #include "boxes.hh" #include "varray.hh" diff --git a/lily/include/my-lily-parser.hh b/lily/include/my-lily-parser.hh index d1a4b77914..b0666e160a 100644 --- a/lily/include/my-lily-parser.hh +++ b/lily/include/my-lily-parser.hh @@ -33,14 +33,12 @@ class My_lily_parser { void set_last_duration (Duration const *); void set_default_duration (Duration const *); - void set_last_abbrev (int type_i); void set_abbrev_beam (int type_i); void set_duration_mode (String s); friend int yyparse (void*); public: int abbrev_beam_type_i_; - int default_abbrev_type_i_; int default_octave_i_; Duration default_duration_; Plet plet_; diff --git a/lily/include/stem-grav.hh b/lily/include/stem-grav.hh index 136e6e5095..b5a77589ec 100644 --- a/lily/include/stem-grav.hh +++ b/lily/include/stem-grav.hh @@ -18,10 +18,12 @@ class Stem_engraver : public Engraver { Direction dir_; + int default_abbrev_i_; Stem *stem_p_; Rhythmic_req *rhythmic_req_l_; Abbreviation_req* abbrev_req_l_; protected: + virtual void do_creation_processing (); virtual void acknowledge_element (Score_elem_info); virtual void do_pre_move_processing (); virtual bool do_try_request (Request*); diff --git a/lily/my-lily-parser.cc b/lily/my-lily-parser.cc index d03e29ffec..bfa78512da 100644 --- a/lily/my-lily-parser.cc +++ b/lily/my-lily-parser.cc @@ -23,7 +23,6 @@ My_lily_parser::My_lily_parser (Sources * source_l) source_l_ = source_l; lexer_p_ = 0; abbrev_beam_type_i_ = 0; - default_abbrev_type_i_ = 0; default_duration_.durlog_i_ = 2; default_octave_i_ = 0; textstyle_str_="roman"; // in lexer? @@ -145,18 +144,11 @@ My_lily_parser::set_abbrev_beam (int type_i) abbrev_beam_type_i_ = type_i; } -void -My_lily_parser::set_last_abbrev (int type_i) -{ - default_abbrev_type_i_ = type_i; -} - void My_lily_parser::set_default_duration (Duration const *d) { last_duration_mode_b_ = false; default_duration_ = *d; - set_last_abbrev (0); } @@ -165,7 +157,6 @@ My_lily_parser::set_last_duration (Duration const *d) { if (last_duration_mode_b_) default_duration_ = *d; - set_last_abbrev (0); } @@ -193,11 +184,11 @@ My_lily_parser::get_rest_element (String s, Duration * duration_p) if (s=="s") { /* Space */ - Skip_req * skip_p = new Skip_req; - skip_p->duration_ = *duration_p; + 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 { @@ -216,7 +207,7 @@ Chord * My_lily_parser::get_note_element (Note_req *rq, Duration * duration_p) { Chord*v = new Request_chord; - v->set_spot (here_input()); + v->set_spot (here_input ()); v->add (rq); @@ -228,7 +219,7 @@ My_lily_parser::get_note_element (Note_req *rq, Duration * duration_p) duration_p->set_plet (1, 2); } rq->set_duration (*duration_p); - rq->set_spot (here_input()); + rq->set_spot (here_input ()); delete duration_p ; return v; } diff --git a/lily/parser.y b/lily/parser.y index ed9a28aceb..d7b2a0d4fa 100644 --- a/lily/parser.y +++ b/lily/parser.y @@ -12,7 +12,7 @@ #include // mmm -#define MUDELA_VERSION "0.1.5" +#define MUDELA_VERSION "0.1.6" #include "scalar.hh" #include "translation-property.hh" @@ -38,6 +38,7 @@ #include "music-list.hh" #include "header.hh" #include "duration-convert.hh" +#include "change-translator.hh" #ifndef NDEBUG #define YYDEBUG 1 @@ -210,7 +211,7 @@ yylex (YYSTYPE *s, void * v_l) %type scalar %type Music transposed_music -%type propertydef +%type property_def translator_change %type Voice Voice_body %type Chord Chord_body %type paper_block paper_body @@ -472,7 +473,7 @@ paper_block: paper_body: /* empty */ { - $$ = THIS->default_paper (); // paper / video / engrave + $$ = THIS->default_paper (); } | PAPER_IDENTIFIER { $$ = $1->paperdef (); @@ -581,20 +582,24 @@ Music: { THIS->lexer_p_->push_lyric_state (); } Music { $$ = $3; THIS->lexer_p_->pop_state (); } - | propertydef + | property_def + | translator_change ; -propertydef: +translator_change: TRANSLATOR STRING '=' STRING { - /* kluge. Could use Music just as well */ - Translation_property * t = new Translation_property; - t-> translator_type_str_ = *$2; - t-> translator_id_str_ = *$4; + Change_translator * t = new Change_translator; + t-> change_to_type_str_ = *$2; + t-> change_to_id_str_ = *$4; + $$ = t; delete $2; delete $4; } - | PROPERTY STRING '.' STRING '=' scalar { + ; + +property_def: + PROPERTY STRING '.' STRING '=' scalar { Translation_property *t = new Translation_property; t-> translator_type_str_ = *$2; t-> var_str_ = *$4; @@ -614,6 +619,10 @@ scalar: Chord: '<' Chord_body '>' { $$ = $2; } + | MULTI INT Chord { + $$ = $3; + $$->multi_level_i_=$2; + } ; Chord_body: @@ -621,9 +630,6 @@ Chord_body: $$ = new Chord; $$-> multi_level_i_ = 1; } - | Chord_body MULTI INT ';' { - $$->multi_level_i_=$3; - } | Chord_body Music { $$->add ($2); } @@ -978,7 +984,7 @@ voice_command: c' -> default_octave_i_ == 1 */ - /* why can't we have \oct{0} iso \oct{c'}*/ + /* why can't we have \oct 0 iso \oct{c'}*/ THIS->default_octave_i_ = 1; } /* cont */ steno_melodic_req { @@ -1052,15 +1058,17 @@ explicit_steno_duration: abbrev_type: - ':' int { + ':' { + $$ =0; + } + | ':' int { if (!Duration::duration_type_b ($2)) THIS->parser_error ("Not a duration"); else if ($2 < 8) THIS->parser_error ("Can't abbreviate"); - else - THIS->set_last_abbrev ($2); - $$ = THIS->default_abbrev_type_i_; + $$ = $2; } + ; music_elt: diff --git a/lily/stem-grav.cc b/lily/stem-grav.cc index 2d81cc58f2..c2114bf972 100644 --- a/lily/stem-grav.cc +++ b/lily/stem-grav.cc @@ -17,9 +17,20 @@ Stem_engraver::Stem_engraver() { abbrev_req_l_ = 0; stem_p_ = 0; + default_abbrev_i_ = 16; dir_ = CENTER; } +void +Stem_engraver::do_creation_processing () +{ + Scalar prop = get_property ("abbrev"); + if (prop && prop.isnum ()) + { + default_abbrev_i_ = prop; + } +} + void Stem_engraver::acknowledge_element(Score_elem_info i) { @@ -31,10 +42,18 @@ Stem_engraver::acknowledge_element(Score_elem_info i) Rhythmic_req * r = i.req_l_->musical()->rhythmic(); stem_p_ = new Stem; int durlog_i = r->duration_.durlog_i_; - stem_p_->flag_i_ = Duration_convert::type2_i(durlog_i); + stem_p_->flag_i_ = durlog_i; + + if (abbrev_req_l_) - stem_p_->abbrev_flag_i_ = intlog2 (abbrev_req_l_->type_i_) - - (durlog_i>? 2); + { + int t = abbrev_req_l_->type_i_; + if (!t) + t = default_abbrev_i_; + else + default_abbrev_i_ = t; + stem_p_->abbrev_flag_i_ = intlog2 (t) - (durlog_i>? 2); + } announce_element (Score_elem_info (stem_p_, r)); } stem_p_->add (h); diff --git a/lily/translator.cc b/lily/translator.cc index 636123a950..58b4c58917 100644 --- a/lily/translator.cc +++ b/lily/translator.cc @@ -24,6 +24,7 @@ Translator::Translator () } Translator::Translator (Translator const &s) + : Input (s) { status = ORPHAN; daddy_trans_l_ =0; @@ -55,8 +56,16 @@ Translator::now_moment () const void Translator::add_processing () { - if (status == ORPHAN) - status = VIRGIN; + if (status > ORPHAN) + return; + + do_add_processing (); + status = VIRGIN; +} + +void +Translator::do_add_processing () +{ } void @@ -65,7 +74,7 @@ Translator::print () const #ifndef NPRINT DOUT << name () << " {"; if (name () != type_str_) - DOUT << "type= " << type_str_; + DOUT << "type = " << type_str_; for (Dictionary_iter i (properties_dict_); i.ok (); i++) { DOUT << i.key () << "=" << i.val () <<"\n"; @@ -107,8 +116,12 @@ Translator::post_move_processing() void Translator::removal_processing() { + if (status == ORPHAN) + return; creation_processing(); do_removal_processing(); + // elegancy ... + // status = ORPHAN; } -- 2.39.5