2 input.cc -- implement Input
4 source file of the LilyPond music typesetter
6 (c) 1997--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
15 #include "source-file.hh"
18 Input::Input (Input const &i)
20 source_file_ = i.source_file_;
39 Input::set_spot (Input const &i)
45 Input::step_forward ()
53 Input::set_location (Input const &i_start, Input const &i_end)
55 source_file_ = i_start.source_file_;
56 start_ = i_start.start_;
61 Produce GNU-compliant error message. Correcting lilypond source is
62 such a breeze if you ('re edidor) know (s) the error column too
66 [file:line:column:][warning:]message
69 Input::message (String s) const
72 s = location_string () + ": " + s + "\n"
73 + source_file_->quote_input (start_);
78 Input::warning (String s) const
80 message (_f ("warning: %s", s));
84 Input::error (String s) const
86 message (_f ("error: %s", s));
87 // UGH, fix naming or usage
92 Input::non_fatal_error (String s) const
94 message (_f ("error: %s", s));
98 Input::location_string () const
101 return source_file_->file_line_column_string (start_);
102 return " (" + _ ("position unknown") + ")";
106 Input::line_number_string () const
109 return to_string (source_file_->get_line (start_));
114 Input::file_string () const
117 return source_file_->name_string ();
122 Input::line_number () const
125 return source_file_->get_line (start_);
130 Input::column_number () const
132 int line, chr, col = 0;
133 source_file_->get_counts (start_, &line, &chr, &col);
139 Input::end_line_number () const
142 return source_file_->get_line (end_);
147 Input::end_column_number () const
149 int line, chr, col = 0;
150 source_file_->get_counts (end_, &line, &chr, &col);
156 Input::get_counts (int *line, int *chr, int *col) const
158 source_file_->get_counts (start_, line, chr, col);
162 Input::set (Source_file *sf, char const *start, char const *end)
170 Input::get_source_file () const
176 Input::start () const