2 input.cc -- implement Input
4 source file of the LilyPond music typesetter
6 (c) 1997--2004 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
68 Input::message (String message_string) const
73 marked "Work in prgress" in GNU iostream
77 why not just return always -1 (unknown),
78 iso breaking the interface?
80 int col = cerr.rdbuf ()->column ();
84 // well, we don't want to loose first warning...
90 str += location_string () + String (": ");
92 str += message_string;
96 str += source_file_->error_string (start_);
98 fprintf (stderr, "%s\n", str.to_str0 ());
103 Input::warning (String message_string) const
105 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);
119 Input::location_string () const
122 return source_file_->file_line_column_string (start_);
124 return " (" + _ ("position unknown") + ")";
128 Input::line_number_string () const
131 return to_string (source_file_->get_line (start_));
137 Input::file_string () const
140 return source_file_->name_string ();
147 Input::line_number () const
150 return source_file_->get_line (start_);
157 Input::column_number () const
160 return source_file_->get_column (start_);
167 Input::end_line_number () const
170 return source_file_->get_line (end_);
177 Input::end_column_number () const
180 return source_file_->get_column (end_);