lilypond-1.5.9
[lilypond.git] / src / warn.cc
blobb1a03579429bd96295a9096f368878f07ef697c3
1 #include "debug.hh"
2 #include "lexer.hh"
3 #include "moment.hh"
4 #include "time-description.hh"
5 #include "proto.hh"
6 #include "plist.hh"
7 #include "source-file.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_l_g->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 // since when exits error again?
76 // i-d say: error: errorlevel |= 1; -> no output upon error
77 // warning: recovery -> output (possibly wrong)
78 if ( lexer )
79 lexer->errorlevel_i_ |= 1;
80 // exit( 1 );