]> git.donarmstrong.com Git - lilypond.git/blob - lily/input.cc
release: 0.0.46.jcn1
[lilypond.git] / lily / input.cc
1 /*
2   input.cc -- implement Input
3
4   source file of the LilyPond music typesetter
5
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"
13
14 Input::Input(Sources*s, char const *cl)
15 {
16     sources_l_=s;
17     defined_ch_C_=cl;
18 }
19
20 Input::Input()
21 {
22     sources_l_ = 0;
23     defined_ch_C_ = 0;
24 }
25
26 Input::Input(Input const &s)
27 {
28     sources_l_ = s.sources_l_;
29     defined_ch_C_ = s.defined_ch_C_;
30 }
31
32 void
33 Input::set_spot(Input const &i)
34 {
35     *this  = i;
36 }
37
38 void
39 Input::message(String message_str)const
40 {
41     String str = "";
42     Source_file* sourcefile_l=0;
43     
44     if (sources_l_) 
45         sourcefile_l = sources_l_->sourcefile_l( defined_ch_C_ );
46     
47     if ( sourcefile_l ) {
48         str += sourcefile_l->file_line_no_str(defined_ch_C_) + String(": ");
49     }
50     
51     str += message_str;
52     if ( sourcefile_l ) {
53         str += ":\n";
54         str += sourcefile_l->error_str( defined_ch_C_);
55     }
56     /*
57     if ( busy_parsing() )
58         cerr << endl;
59         */
60     cerr << str << endl;
61 }
62
63 void
64 Input::warning( String message_str)const
65 {
66     message( "warning: " + message_str);
67 }
68 void
69 Input::error(String s)const
70 {
71     message("error: "+ s);
72     exit (1);
73 }
74
75 String
76 Input::location_str()const
77 {
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)";
85 }