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"
17 Input::Input (Input
const &i
)
19 source_file_
= i
.source_file_
;
38 Input::set_spot (Input
const &i
)
44 Input::step_forward ()
52 Input::set_location (Input
const &i_start
, Input
const &i_end
)
54 source_file_
= i_start
.source_file_
;
55 start_
= i_start
.start_
;
60 Produce GNU-compliant error message. Correcting lilypond source is
61 such a breeze if you ('re edidor) know (s) the error column too
65 [file:line:column:][warning:]message
68 Input::message (String s
) const
71 s
= location_string () + ": " + s
+ "\n"
72 + source_file_
->quote_input (start_
);
77 Input::warning (String s
) const
79 message (_f ("warning: %s", s
));
83 Input::error (String s
) const
85 message (_f ("error: %s", s
));
86 // UGH, fix naming or usage
91 Input::non_fatal_error (String s
) const
93 message (_f ("error: %s", s
));
97 Input::location_string () const
100 return source_file_
->file_line_column_string (start_
);
101 return " (" + _ ("position unknown") + ")";
105 Input::line_number_string () const
108 return to_string (source_file_
->get_line (start_
));
113 Input::file_string () const
116 return source_file_
->name_string ();
121 Input::line_number () const
124 return source_file_
->get_line (start_
);
129 Input::column_number () const
131 int line
, chr
, col
= 0;
132 source_file_
->get_counts (start_
, &line
, &chr
, &col
);
138 Input::end_line_number () const
141 return source_file_
->get_line (end_
);
146 Input::end_column_number () const
148 int line
, chr
, col
= 0;
149 source_file_
->get_counts (end_
, &line
, &chr
, &col
);
155 Input::get_counts (int *line
, int *chr
, int*col
) const
157 source_file_
->get_counts (start_
, line
, chr
, col
);
161 Input::set (Source_file
*sf
, char const *start
, char const *end
)
169 Input::get_source_file () const
176 Input::start () const