2 input.cc -- implement Input
4 source file of the LilyPond music typesetter
6 (c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
14 #include "source-file.hh"
16 Input::Input (Input const &i)
18 source_file_ = i.source_file_;
37 Input::set_spot (Input const &i)
43 Input::step_forward ()
51 Input::set_location (Input const &i_start, Input const &i_end)
53 source_file_ = i_start.source_file_;
54 start_ = i_start.start_;
59 Produce GNU-compliant error message. Correcting lilypond source is
60 such a breeze if you ('re edidor) know (s) the error column too
64 [file:line:column:][warning:]message
67 Input::message (String message_string) const
72 marked "Work in prgress" in GNU iostream
76 why not just return always -1 (unknown),
77 iso breaking the interface?
79 int col = cerr.rdbuf ()->column ();
83 // well, we don't want to loose first warning...
89 str += location_string () + String (": ");
91 str += message_string;
95 str += source_file_->error_string (start_);
97 fprintf (stderr, "%s\n", str.to_str0 ());
102 Input::warning (String message_string) const
104 message (_ ("warning: ") + message_string);
108 Input::error (String s) const
110 message (_ ("error: ")+ s);
114 Input::non_fatal_error (String s) const
116 message (_ ("non fatal error: ") + s);
120 Input::location_string () const
123 return source_file_->file_line_column_string (start_);
125 return " (" + _ ("position unknown") + ")";
129 Input::line_number_string () const
132 return to_string (source_file_->get_line (start_));
138 Input::file_string () const
141 return source_file_->name_string ();
147 Input::line_number () const
150 return source_file_->get_line (start_);
156 Input::column_number () const
159 return source_file_->get_column (start_);
165 Input::end_line_number () const
168 return source_file_->get_line (end_);
174 Input::end_column_number () const
177 return source_file_->get_column (end_);