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);
107 Input::error (String s) const
109 message (_ ("error: ")+ s);
113 Input::non_fatal_error (String s) const
115 message (_ ("non fatal error: ") + s);
118 Input::location_string () const
121 return source_file_->file_line_column_string (start_);
123 return " (" + _ ("position unknown") + ")";
127 Input::line_number_string () const
130 return to_string (source_file_->get_line (start_));
136 Input::file_string () const
139 return source_file_->name_string ();
145 Input::line_number () const
148 return source_file_->get_line (start_);
154 Input::column_number () const
157 return source_file_->get_column (start_);
163 Input::end_line_number () const
166 return source_file_->get_line (end_);
172 Input::end_column_number () const
175 return source_file_->get_column (end_);