From 8cb30d94ead6e20897680eab10357efb439194e1 Mon Sep 17 00:00:00 2001 From: fred Date: Sun, 24 Mar 2002 19:38:05 +0000 Subject: [PATCH] lilypond-0.0.47 --- TODO | 8 ++--- lib/include/debug.hh | 5 --- lib/include/input.hh | 14 +++++--- lib/input.cc | 74 +++++++++++++++++++++++++++++++++++++++++++ lily/my-lily-lexer.cc | 14 ++++---- lily/warn.cc | 42 ++---------------------- 6 files changed, 97 insertions(+), 60 deletions(-) create mode 100644 lib/input.cc diff --git a/TODO b/TODO index 522f9cafbe..6e3d3f5c93 100644 --- a/TODO +++ b/TODO @@ -1,9 +1,7 @@ before 0.1 - * update 20 pt table - - * remove spurious/outdated comments in .ly, debug .ly + * fix mi2mu - * pushgroup, popgroup. + * update 20 pt table * decent TeX page layout @@ -75,6 +73,8 @@ SMALLISH PROJECTS * bugreport to doc++ devel: struct not in class hier; public virtual baseclasses + * rpm package buildroot + * indentable stream for TeX stream, lily stream, Dstream. * key transposition diff --git a/lib/include/debug.hh b/lib/include/debug.hh index 7870a0da03..b3b786172d 100644 --- a/lib/include/debug.hh +++ b/lib/include/debug.hh @@ -11,13 +11,8 @@ #include "real.hh" #include "proto.hh" -void message( String message_str, char const* context_ch_c_l ); -void warning( String message_str, char const* context_ch_c_l ); void warning( String message_str ); -void error( String message_str, char const* context_ch_c_l ); - void error( String message_str); -void error(String s); // errors void error_t(const String& s, Time_description const & t_tdes); void error_t(String const &s, const Moment &when); // warnings diff --git a/lib/include/input.hh b/lib/include/input.hh index 80ab11a1bb..180baf170b 100644 --- a/lib/include/input.hh +++ b/lib/include/input.hh @@ -15,11 +15,17 @@ */ class Input { char const *defined_ch_C_ ; - + Source_file * source_file_l_; public: - set_spot(char const *); - Input(char const *); - Input(Input const &); + + void warning(String)const; // should use member func? + void error(String)const; + void message(String)const; + void set_spot(Input const &); + + String location_str()const; + Input(Source_file*, char const*); + Input(); }; #endif // INPUT_HH diff --git a/lib/input.cc b/lib/input.cc new file mode 100644 index 0000000000..de341811bf --- /dev/null +++ b/lib/input.cc @@ -0,0 +1,74 @@ +/* + input.cc -- implement Input + + source file of the LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys +*/ +#include "proto.hh" +#include "input.hh" +#include "string.hh" +#include "source.hh" +#include "source-file.hh" + +Input::Input(Source_file*s, char const *cl) +{ + source_file_l_=s; + defined_ch_C_=cl; +} + +Input::Input() +{ + source_file_l_ = 0; + defined_ch_C_ = 0; +} + +Input::Input(Input const &s) +{ + source_file_l_ = s.source_file_l_; + defined_ch_C_ = s.defined_ch_C_; +} + +void +Input::set_spot(Input const &i) +{ + *this = i; +} + +void +Input::message(String message_str)const +{ + String str = ""; + + if ( source_file_l_ ) { + str += source_file_l_->file_line_no_str(defined_ch_C_) + String(": "); + } + + str += message_str; + if ( source_file_l_ ) { + str += ":\n"; + str += source_file_l_->error_str( defined_ch_C_); + } + cerr << str << endl; +} + +void +Input::warning( String message_str)const +{ + message( "warning: " + message_str); +} +void +Input::error(String s)const +{ + message("error: "+ s); + exit (1); +} + +String +Input::location_str()const +{ + if (source_file_l_) + return source_file_l_->file_line_no_str(defined_ch_C_); + else + return "(location unknown)"; +} diff --git a/lily/my-lily-lexer.cc b/lily/my-lily-lexer.cc index 2bb88b7448..6ff46f282c 100644 --- a/lily/my-lily-lexer.cc +++ b/lily/my-lily-lexer.cc @@ -128,15 +128,13 @@ My_lily_lexer::LexerError(char const *s) if (include_stack_.empty()) { *mlog << "error at EOF" << s << '\n'; } else { - char const* ch_C = here_ch_C(); - if ( ch_C ) { - ch_C--; - while (isspace(*ch_C == ' ' )) - ch_C--; - ch_C++; - } errorlevel_i_ |= 1; - error( s, ch_C ); + error(String(s)); + // FIXME. +/*Input spot(source_l_g = here_spot(); + + spot.error( s ); + */ } } diff --git a/lily/warn.cc b/lily/warn.cc index 4240aa04b5..08c8b52696 100644 --- a/lily/warn.cc +++ b/lily/warn.cc @@ -44,51 +44,15 @@ error_t(String const & s, Time_description const &t_tdes) error(e); } -void -message( String message_str, char const* context_ch_C ) -{ - String str = ""; - Source_file* sourcefile_l = source_l_g->sourcefile_l( context_ch_C ); - if ( sourcefile_l ) { - str += sourcefile_l->file_line_no_str(context_ch_C) + String(": "); - } - str += message_str; - if ( sourcefile_l ) { - str += ":\n"; - str += sourcefile_l->error_str( context_ch_C ); - } - if ( busy_parsing() ) - cerr << endl; - cerr << str << endl; -} - -void -warning( String message_str, char const* context_ch_C ) -{ - message( "warning: " + message_str, context_ch_C ); -} - -void -error( String message_str, char const* context_ch_C ) -{ - message( message_str, context_ch_C ); - // since when exits error again? - // i-d say: error: errorlevel |= 1; -> no output upon error - // warning: recovery -> output (possibly wrong) -/* if ( lexer ) - lexer->errorlevel_i_ |= 1;*/ -// exit( 1 ); -} - - void warning(String m) { - warning(m, (char*)0); + cerr << "warning" <