]> git.donarmstrong.com Git - lilypond.git/blob - lily/warn.cc
ad548c6f588cace06c11ba7f775bd4bb76b9c9b3
[lilypond.git] / lily / warn.cc
1 #include "proto.hh"
2 #include "plist.hh"
3 #include "debug.hh"
4 #include "lexer.hh"
5 #include "moment.hh"
6 #include "time-description.hh"
7 #include "source-file.hh"
8 #include "source.hh"
9 #include "main.hh"
10
11 ostream &warnout (cerr);
12 ostream *mlog(&cerr);
13 /*
14 void
15 warning(String s)
16 {
17     WARN << s;
18 }
19 */
20
21 void
22 error(String s)
23 {
24     if (busy_parsing())
25         yyerror(s);
26     else
27         cerr <<  "error: " << s << "\n";
28         
29     exit(1);
30 }
31
32 void
33 error_t(const String& s, const Moment& r)
34 {
35     String t_mom = String(trunc(r)) + String(r - Moment(trunc(r)));
36     String e=s+ " (t = " +  t_mom + ")";
37     error(e);
38 }
39
40 void
41 error_t(const String& s, Time_description const &t_tdes)
42 {
43     String e=s+ " (at t=" + String(t_tdes.bars_i_) + ": " + String(t_tdes.whole_in_measure_) + ")\n";
44     error(e);
45 }
46
47 void
48 message( String message_str, char const* context_ch_c_l )
49 {
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(": ");
54     }
55     str += message_str;
56     if ( sourcefile_l ) {
57         str += ":\n";
58         str += sourcefile_l->error_str( context_ch_c_l );
59     }
60     if ( busy_parsing() )
61         cerr << endl;
62     cerr << str << endl;
63 }
64
65 void
66 warning( String message_str, char const* context_ch_c_l )
67 {
68     message( "warning: " + message_str, context_ch_c_l );
69 }
70
71 void
72 error( String message_str, char const* context_ch_c_l )
73 {
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 );
81 }