2 input.cc -- implement Input
4 source file of the LilyPond music typesetter
6 (c) 1997--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
14 #include "international.hh"
15 #include "source-file.hh"
19 Input::Input (Input const &i)
21 source_file_ = i.source_file_;
40 Input::set_spot (Input const &i)
46 Input::step_forward ()
54 Input::set_location (Input const &i_start, Input const &i_end)
56 source_file_ = i_start.source_file_;
57 start_ = i_start.start_;
62 Produce GNU-compliant error message. Correcting lilypond source is
63 such a breeze if you ('re edidor) know (s) the error column too
67 [file:line:column:][warning:]message
70 Input::message (string s) const
73 s = location_string () + ": " + s + "\n"
74 + source_file_->quote_input (start_);
79 Input::warning (string s) const
81 message (_f ("warning: %s", s));
85 Input::error (string s) const
87 message (_f ("error: %s", s));
88 // UGH, fix naming or usage
93 Input::non_fatal_error (string s) const
95 message (_f ("error: %s", s));
99 Input::location_string () const
102 return source_file_->file_line_column_string (start_);
103 return " (" + _ ("position unknown") + ")";
107 Input::line_number_string () const
110 return to_string (source_file_->get_line (start_));
115 Input::file_string () const
118 return source_file_->name_string ();
123 Input::line_number () const
126 return source_file_->get_line (start_);
131 Input::column_number () const
133 int line, chr, col = 0;
134 source_file_->get_counts (start_, &line, &chr, &col);
140 Input::end_line_number () const
143 return source_file_->get_line (end_);
148 Input::end_column_number () const
150 int line, chr, col = 0;
151 source_file_->get_counts (end_, &line, &chr, &col);
157 Input::get_counts (int *line, int *chr, int *col) const
159 source_file_->get_counts (start_, line, chr, col);
163 Input::set (Source_file *sf, char const *start, char const *end)
171 Input::get_source_file () const
177 Input::start () const