X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fwarn.cc;h=532d2e3fb89809227264adfcfd3a3595778d9c92;hb=ad4297de0246935caa4c51f4e152e20009a6f64e;hp=ad548c6f588cace06c11ba7f775bd4bb76b9c9b3;hpb=daee8243ff1c66bc714455a2d265ab02f03546ec;p=lilypond.git diff --git a/lily/warn.cc b/lily/warn.cc index ad548c6f58..532d2e3fb8 100644 --- a/lily/warn.cc +++ b/lily/warn.cc @@ -1,81 +1,37 @@ +/* + warn.cc -- implement warning and error messages. Needs cleanup. + + source file of the GNU LilyPond music typesetter + + (c) 1997--1999 Han-Wen Nienhuys +*/ + #include "proto.hh" -#include "plist.hh" #include "debug.hh" -#include "lexer.hh" +#include "my-lily-lexer.hh" #include "moment.hh" #include "time-description.hh" #include "source-file.hh" #include "source.hh" #include "main.hh" +#include "input.hh" ostream &warnout (cerr); -ostream *mlog(&cerr); -/* -void -warning(String s) -{ - WARN << s; -} -*/ - -void -error(String s) -{ - if (busy_parsing()) - yyerror(s); - else - cerr << "error: " << s << "\n"; - - exit(1); -} - -void -error_t(const String& s, const Moment& r) -{ - String t_mom = String(trunc(r)) + String(r - Moment(trunc(r))); - String e=s+ " (t = " + t_mom + ")"; - error(e); -} +ostream *mlog (&cerr); -void -error_t(const String& s, Time_description const &t_tdes) -{ - String e=s+ " (at t=" + String(t_tdes.bars_i_) + ": " + String(t_tdes.whole_in_measure_) + ")\n"; - error(e); -} -void -message( String message_str, char const* context_ch_c_l ) -{ - String str = "lilypond: "; - Source_file* sourcefile_l = source_l_g->sourcefile_l( context_ch_c_l ); - if ( sourcefile_l ) { - str += sourcefile_l->file_line_no_str(context_ch_c_l) + String(": "); - } - str += message_str; - if ( sourcefile_l ) { - str += ":\n"; - str += sourcefile_l->error_str( context_ch_c_l ); - } - if ( busy_parsing() ) - cerr << endl; - cerr << str << endl; -} void -warning( String message_str, char const* context_ch_c_l ) +error_t (String const & s, Moment const & r) { - message( "warning: " + message_str, context_ch_c_l ); + String t_mom = r.trunc_rat ().str () + (r - r.trunc_rat ()).str (); + String e=s+ " (t = " + t_mom + ")"; + error (e); } void -error( String message_str, char const* context_ch_c_l ) +error_t (String const & s, Time_description const &t_tdes) { - message( message_str, context_ch_c_l ); - // 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 ); + String e=s+ " (at t=" + to_str (t_tdes.bars_i_) + ": " + (t_tdes.whole_in_measure_).str () + ")\n"; + error (e); }