]> git.donarmstrong.com Git - lilypond.git/blob - src/warn.cc
release: 0.0.27
[lilypond.git] / src / warn.cc
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"
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 <<  "\nerror: " << 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) + ": " + 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->sourcefile_l( context_ch_c_l );
52     if ( sourcefile_l ) {
53         str += sourcefile_l->name_str() + ": ";
54         str += String( sourcefile_l->line_i( context_ch_c_l ) ) + ": ";
55     }
56     str += message_str;
57     if ( sourcefile_l ) {
58         str += "\n";
59         str += sourcefile_l->error_str( context_ch_c_l );
60     }
61     cerr << endl << str << endl;
62 }
63
64 void
65 warning( String message_str, char const* context_ch_c_l )
66 {
67     message( "warning: " + message_str, context_ch_c_l );
68 }
69
70 void
71 error( String message_str, char const* context_ch_c_l )
72 {
73     message( message_str, context_ch_c_l );
74     exit( 1 );
75 }