lilypond-0.0.32
[lilypond.git] / src / warn.cc
blob46d779e10f511cf8495f8c2506b7e19f6aa3188e
1 #include "debug.hh"
2 #include "lexer.hh"
3 #include "moment.hh"
4 #include "timedescription.hh"
5 #include "proto.hh"
6 #include "plist.hh"
7 #include "sourcefile.hh"
8 #include "source.hh"
9 #include "main.hh"
11 ostream &warnout (cerr);
12 ostream *mlog(&cerr);
14 void
15 warning(String s)
17 WARN << s;
21 void
22 error(String s)
24 if (busy_parsing())
25 yyerror(s);
26 else
27 cerr << "error: " << s << "\n";
29 exit(1);
32 void
33 error_t(const String& s, const Moment& r)
35 String t_mom = String(trunc(r)) + String(r - Moment(trunc(r)));
36 String e=s+ " (t = " + t_mom + ")";
37 error(e);
40 void
41 error_t(const String& s, Time_description const &t_tdes)
43 String e=s+ " (at t=" + String(t_tdes.bars_i_) + ": " + String(t_tdes.whole_in_measure_) + ")\n";
44 error(e);
47 void
48 message( String message_str, char const* context_ch_c_l )
50 String str = "lilypond: ";
51 Source_file* sourcefile_l = source_global_l->sourcefile_l( context_ch_c_l );
52 if ( sourcefile_l ) {
53 str += sourcefile_l->file_line_no_str(context_ch_c_l) + String(": ");
55 str += message_str;
56 if ( sourcefile_l ) {
57 str += ":\n";
58 str += sourcefile_l->error_str( context_ch_c_l );
60 if ( busy_parsing() )
61 cerr << endl;
62 cerr << str << endl;
65 void
66 warning( String message_str, char const* context_ch_c_l )
68 message( "warning: " + message_str, context_ch_c_l );
71 void
72 error( String message_str, char const* context_ch_c_l )
74 message( message_str, context_ch_c_l );
75 exit( 1 );