2 input.cc -- implement Input
4 source file of the LilyPond music typesetter
6 (c) 1997--2009 Han-Wen Nienhuys <hanwen@xs4all.nl>
14 #include "international.hh"
15 #include "program-option.hh"
16 #include "source-file.hh"
20 Input::Input (Input
const &i
)
22 source_file_
= i
.source_file_
;
41 Input::set_spot (Input
const &i
)
47 Input::step_forward ()
55 Input::set_location (Input
const &i_start
, Input
const &i_end
)
57 source_file_
= i_start
.source_file_
;
58 start_
= i_start
.start_
;
63 Produce GNU-compliant error message. Correcting lilypond source is
64 such a breeze if you ('re edidor) know (s) the error column too
68 [file:line:column:][warning:]message
71 Input::message (string s
) const
74 s
= location_string () + ": " + s
+ "\n"
75 + source_file_
->quote_input (start_
) + "\n";
81 Input::programming_error (string s
) const
83 if (get_program_option ("warning-as-error"))
86 message (_f ("programming error: %s", s
.c_str ()));
87 message (_ ("continuing, cross fingers") + "\n");
93 Input::warning (string s
) const
95 if (get_program_option ("warning-as-error"))
98 message (_f ("warning: %s", s
));
102 Input::error (string s
) const
104 message (_f ("error: %s", s
));
105 // UGH, fix naming or usage
110 Input::non_fatal_error (string s
) const
112 message (_f ("error: %s", s
));
116 Input::location_string () const
119 return source_file_
->file_line_column_string (start_
);
120 return " (" + _ ("position unknown") + ")";
124 Input::line_number_string () const
127 return to_string (source_file_
->get_line (start_
));
132 Input::file_string () const
135 return source_file_
->name_string ();
140 Input::line_number () const
143 return source_file_
->get_line (start_
);
148 Input::column_number () const
150 int line
, chr
, col
= 0;
151 source_file_
->get_counts (start_
, &line
, &chr
, &col
);
157 Input::end_line_number () const
160 return source_file_
->get_line (end_
);
165 Input::end_column_number () const
167 int line
, chr
, col
= 0;
168 source_file_
->get_counts (end_
, &line
, &chr
, &col
);
174 Input::get_counts (int *line
, int *chr
, int *col
) const
176 source_file_
->get_counts (start_
, line
, chr
, col
);
180 Input::set (Source_file
*sf
, char const *start
, char const *end
)
188 Input::get_source_file () const
194 Input::start () const