]> git.donarmstrong.com Git - lilypond.git/blobdiff - src/warn.cc
release: 0.0.33
[lilypond.git] / src / warn.cc
index 82a004875aaa91b17cfed0f40c566c317aca6da1..63490de581077299168faf69b39d54a2bccf2f11 100644 (file)
@@ -2,16 +2,21 @@
 #include "lexer.hh"
 #include "moment.hh"
 #include "timedescription.hh"
+#include "proto.hh"
+#include "plist.hh"
+#include "sourcefile.hh"
+#include "source.hh"
+#include "main.hh"
 
 ostream &warnout (cerr);
 ostream *mlog(&cerr);
-
+/*
 void
 warning(String s)
 {
     WARN << s;
 }
-
+*/
 
 void
 error(String s)
@@ -19,7 +24,7 @@ error(String s)
     if (busy_parsing())
        yyerror(s);
     else
-       cerr <<  "\nerror: " << s << "\n";
+       cerr <<  "error: " << s << "\n";
        
     exit(1);
 }
@@ -27,15 +32,50 @@ error(String s)
 void
 error_t(const String& s, const Moment& r)
 {
-    String t_mom = String(trunc(r)) +  (r - Moment(trunc(r)));
-    String e=s+ "(t = " +  t_mom + ")";
+    String t_mom = String(trunc(r)) + String(r - Moment(trunc(r)));
+    String e=s+ " (t = " +  t_mom + ")";
     error(e);
 }
 
-
 void
 error_t(const String& s, Time_description const &t_tdes)
 {
-    String e=s+ "(at " + t_tdes.bars + ": " + t_tdes.whole_in_measure + ")\n";
+    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_global_l->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 )
+{
+    message( "warning: " + message_str, context_ch_c_l );
+}
+
+void
+error( String message_str, char const* context_ch_c_l )
+{
+    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 );
+}