From d74dbba609780131c4488f8e2eb56462ccb90c0b Mon Sep 17 00:00:00 2001 From: fred Date: Sun, 24 Mar 2002 19:31:09 +0000 Subject: [PATCH] lilypond-0.0.30 --- input/error.ly | 4 +++ src/lexer.l | 4 ++- src/note.cc | 8 +++--- src/parser.y | 18 +++++++------ src/scriptdef.cc | 2 +- src/scriptreg.cc | 69 +++++++++++++++++++++++++++++++++++++++++++++++ src/sourcefile.cc | 23 ++++++++++------ src/wordwrap.cc | 6 ++--- 8 files changed, 110 insertions(+), 24 deletions(-) create mode 100644 src/scriptreg.cc diff --git a/input/error.ly b/input/error.ly index 9aa92d0710..82e5d190c6 100644 --- a/input/error.ly +++ b/input/error.ly @@ -13,6 +13,7 @@ mwa = music { a b ,c a b c-* a b c& + { a-. b-. } $ } @@ -22,6 +23,9 @@ bla = music { @ } + +include "this-is-hopefully-a-nonexisting-file" + score { staff { lyric music { bla } diff --git a/src/lexer.l b/src/lexer.l index 0771cafcde..f0652ac6c7 100644 --- a/src/lexer.l +++ b/src/lexer.l @@ -9,6 +9,7 @@ #include "parser.hh" #include "debug.hh" #include "inputscore.hh" +#include "parseconstruct.hh" #include "main.hh" %} @@ -220,7 +221,8 @@ include { [ \t]* { /* eat the whitespace */ } \"[^"]*\"+ { /* got the include file name */ String s (YYText()+1); - s = s.left(s.len()-1); + s = s.left(s.len()-1); + defined_ch_c_l = here_ch_c_l() - String( YYText() ).len() - 1; new_input(s); yy_pop_state(); } diff --git a/src/note.cc b/src/note.cc index 226b10a601..5c9daee9fd 100644 --- a/src/note.cc +++ b/src/note.cc @@ -1,7 +1,7 @@ /* could use cleanup */ - #include +#include #include "lexer.hh" #include "string.hh" #include "real.hh" @@ -121,7 +121,7 @@ get_note_element(String pitch, int * notename, int * duration ) parse_pitchmod(pitch, i, oct, forceacc); rq->notename =notename[0]; rq->accidental = notename[1]; - rq->octave = oct; + rq->octave = oct + notename[2]; rq->forceacc = forceacc; rq->balltype = dur; rq->dots = dots; @@ -289,7 +289,9 @@ Request* get_script_req(int d , Script_def*def) { Script_req* script_req_p = new Script_req(d, def); - script_req_p->defined_ch_c_l_m = defined_ch_c_l; +// script_req_p->defined_ch_c_l_m = req_defined_ch_c_l; + // all terminal symbols, rather set directly here: + script_req_p->defined_ch_c_l_m = lexer->here_ch_c_l(); return script_req_p; } diff --git a/src/parser.y b/src/parser.y index 09e4bd310a..71926f60ca 100644 --- a/src/parser.y +++ b/src/parser.y @@ -64,7 +64,7 @@ int fatal_error_i = 0; } %token VOICE STAFF SCORE TITLE BAR OUTPUT MULTIVOICE -%token CM IN PT MM PAPER WIDTH METER UNITSPACE SKIP COMMANDS COMMAND +%token CM_T IN_T PT_T MM_T PAPER WIDTH METER UNITSPACE SKIP COMMANDS COMMAND %token GEOMETRIC START_T DURATIONCOMMAND OCTAVECOMMAND %token KEY CLEF TABLE VOICES STEM %token PARTIAL MUSIC GROUPING CADENZA @@ -78,7 +78,7 @@ int fatal_error_i = 0; %token STRING %token DOTS INT -%type unit +%type unit %type pitch_list %type open_request_parens close_request_parens %type declaration @@ -517,7 +517,9 @@ mudela_text: ; script_req: - script_dir mudela_script { $$ = get_script_req($1, $2); } + script_dir mudela_script { + $$ = get_script_req($1, $2); + } ; mudela_script: @@ -704,14 +706,14 @@ int_list: { dim: - real unit { $$ = convert_dimen($1,$2); } + real unit { $$ = $1*$2; } ; -unit: CM { $$ = "cm"; } - |IN { $$ = "in"; } - |MM { $$ = "mm"; } - |PT { $$ = "pt"; } +unit: CM_T { $$ = 1 CM; } + |IN_T { $$ = 1 INCH; } + |MM_T { $$ = 1 MM; } + |PT_T { $$ = 1 PT; } ; /* diff --git a/src/scriptdef.cc b/src/scriptdef.cc index 1e11de72c2..508ae6a24b 100644 --- a/src/scriptdef.cc +++ b/src/scriptdef.cc @@ -17,7 +17,7 @@ Script_def::print() const int Script_def::compare(Script_def const & c) { - return (symidx == c.symidx && + return !(symidx == c.symidx && stemdir == c.stemdir&& staffdir == c.staffdir&& invertsym == c.invertsym); diff --git a/src/scriptreg.cc b/src/scriptreg.cc new file mode 100644 index 0000000000..88375db8fe --- /dev/null +++ b/src/scriptreg.cc @@ -0,0 +1,69 @@ +/* + scriptreg.cc -- implement Script_register + + (c) 1997 Han-Wen Nienhuys +*/ + +#include "scriptreg.hh" +#include "script.hh" +#include "request.hh" +#include "complexwalker.hh" + +Script_register::Script_register(Complex_walker*w) + : Request_register(w) +{ + script_p_ = 0; +} + +bool +Script_register::try_request(Request *r_l) +{ + if (!r_l->script()) + return false ; + + if (accepted_req_arr_.size() + && Script_req::compare(*accepted_req_arr_[0]->script(), *r_l->script())) + + return false; + + accepted_req_arr_.push(r_l); + + return true; +} + +void +Script_register::process_request() +{ + if (accepted_req_arr_.size() ) { + script_p_ = new Script(accepted_req_arr_[0]->script(), 10); + announce_element( + Staff_elem_info(script_p_, accepted_req_arr_[0], this)); + } +} + +void +Script_register::acknowledge_element(Staff_elem_info info) +{ + if (!script_p_) + return; + if (info.elem_p_->name() == String("Stem")) + script_p_->set_stem((Stem*)info.elem_p_); + else if (info.req_l_->rhythmic()) + script_p_->set_support(info.elem_p_->item()); +} + +void +Script_register::do_pre_move_process() +{ + if (script_p_){ + script_p_->dir = dir_i_; + typeset_element(script_p_); + script_p_ = 0; + } +} + +void +Script_register::set_dir(int i) +{ + dir_i_ = i; +} diff --git a/src/sourcefile.cc b/src/sourcefile.cc index 1fe2aa3d53..ac164fd94a 100644 --- a/src/sourcefile.cc +++ b/src/sourcefile.cc @@ -17,6 +17,9 @@ #include "string.hh" #include "proto.hh" #include "plist.hh" +#include "lexer.hh" +#include "debug.hh" +#include "parseconstruct.hh" #include "main.hh" // find_file #include "sourcefile.hh" @@ -143,12 +146,13 @@ Source_file::line_i( char const* pos_ch_c_l ) void Source_file::map() { + if ( fildes_i_m == -1 ) + return; + data_caddr_m = (caddr_t)mmap( (void*)0, size_off_m, PROT_READ, MAP_SHARED, fildes_i_m, 0 ); - if ( (int)data_caddr_m == -1 ) { - cerr << "lilypond: can't map: " << name_str_m << ": " << strerror( errno ) << endl; - assert( 0 ); - } + if ( (int)data_caddr_m == -1 ) + warning( String( "can't map: " ) + name_str_m + String( ": " ) + strerror( errno ), defined_ch_c_l ); //lexer->here_ch_c_l() ); } String @@ -160,12 +164,15 @@ Source_file::name_str() void Source_file::open() { - name_str_m = find_file( name_str_m ); + String name_str = find_file( name_str_m ); + if ( name_str != "" ) + name_str_m = name_str; + fildes_i_m = ::open( name_str_m, O_RDONLY ); - + if ( fildes_i_m == -1 ) { - cerr << "lilypond: can't open: " << name_str_m << ": " << strerror( errno ) << endl; - assert( 0 ); + warning( String( "can't open: " ) + name_str_m + String( ": " ) + strerror( errno ), defined_ch_c_l ); // lexer->here_ch_c_l() ); + return; } struct stat file_stat; diff --git a/src/wordwrap.cc b/src/wordwrap.cc index 469d2d1d29..90d4d542dc 100644 --- a/src/wordwrap.cc +++ b/src/wordwrap.cc @@ -2,13 +2,12 @@ #include "pscore.hh" #include "debug.hh" -/* el stupido. This should be done more accurately: +/** el stupido. This should be done more accurately: It would be nice to have a Dynamic Programming type of algorithm similar to TeX's */ - Array Word_wrap::solve() { @@ -64,7 +63,8 @@ Word_wrap::solve() curcol ++; break_idx_i++; } - mtor << "Adding cols~, next breakpoint " << break_idx_i << '\n'; + + *mlog << "[" <