lilypond-1.3.130
[lilypond.git] / lily / input.cc
blob1ff4e8624431809cb2092c3b175a54af61ac75b7
1 /*
2 input.cc -- implement Input
4 source file of the LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
8 #include "proto.hh"
9 #include "input.hh"
10 #include "string.hh"
11 #include "source.hh"
12 #include "source-file.hh"
14 Input::Input(Sources*s, char const *cl)
16 sources_l_=s;
17 defined_ch_C_=cl;
20 Input::Input()
22 sources_l_ = 0;
23 defined_ch_C_ = 0;
26 Input::Input(Input const &s)
28 sources_l_ = s.sources_l_;
29 defined_ch_C_ = s.defined_ch_C_;
32 void
33 Input::set_spot(Input const &i)
35 *this = i;
38 void
39 Input::message(String message_str)const
41 String str = "";
42 Source_file* sourcefile_l=0;
44 if (sources_l_)
45 sourcefile_l = sources_l_->sourcefile_l( defined_ch_C_ );
47 if ( sourcefile_l ) {
48 str += sourcefile_l->file_line_no_str(defined_ch_C_) + String(": ");
51 str += message_str;
52 if ( sourcefile_l ) {
53 str += ":\n";
54 str += sourcefile_l->error_str( defined_ch_C_);
57 if ( busy_parsing() )
58 cerr << endl;
60 cerr << str << endl;
63 void
64 Input::warning( String message_str)const
66 message( "warning: " + message_str);
68 void
69 Input::error(String s)const
71 message("error: "+ s);
72 exit (1);
75 String
76 Input::location_str()const
78 Source_file * sourcefile_l=0;
79 if (sources_l_)
80 sourcefile_l = sources_l_->sourcefile_l (defined_ch_C_);
81 if (sourcefile_l)
82 return sourcefile_l->file_line_no_str(defined_ch_C_);
83 else
84 return "(location unknown)";