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_);
80 Input::programming_error (string s) const
82 message (_f ("programming error: %s", s.c_str ()));
83 message (_ ("continuing, cross fingers") + "\n");
88 Input::warning (string s) const
90 message (_f ("warning: %s", s));
94 Input::error (string s) const
96 message (_f ("error: %s", s));
97 // UGH, fix naming or usage
102 Input::non_fatal_error (string s) const
104 message (_f ("error: %s", s));
108 Input::location_string () const
111 return source_file_->file_line_column_string (start_);
112 return " (" + _ ("position unknown") + ")";
116 Input::line_number_string () const
119 return to_string (source_file_->get_line (start_));
124 Input::file_string () const
127 return source_file_->name_string ();
132 Input::line_number () const
135 return source_file_->get_line (start_);
140 Input::column_number () const
142 int line, chr, col = 0;
143 source_file_->get_counts (start_, &line, &chr, &col);
149 Input::end_line_number () const
152 return source_file_->get_line (end_);
157 Input::end_column_number () const
159 int line, chr, col = 0;
160 source_file_->get_counts (end_, &line, &chr, &col);
166 Input::get_counts (int *line, int *chr, int *col) const
168 source_file_->get_counts (start_, line, chr, col);
172 Input::set (Source_file *sf, char const *start, char const *end)
180 Input::get_source_file () const
186 Input::start () const