Lines Matching refs:input

17   /// Creates an error from the input position and an [ErrorKind]
18 fn from_error_kind(input: I, kind: ErrorKind) -> Self;
20 /// Combines an existing error with a new one created from the input
23 fn append(input: I, kind: ErrorKind, other: Self) -> Self;
25 /// Creates an error from an input position and an expected character
26 fn from_char(input: I, _: char) -> Self {
27 Self::from_error_kind(input, ErrorKind::Char)
40 /// Creates a new error from an input position, a static string and an existing error.
51 /// Creates a new error from an input position, an [ErrorKind] indicating the
53 fn from_external_error(input: I, kind: ErrorKind, e: E) -> Self;
59 /// position of the error in the input data
60 pub input: I,
67 pub fn new(input: I, code: ErrorKind) -> Error<I> {
68 Error { input, code }
73 fn from_error_kind(input: I, kind: ErrorKind) -> Self {
74 Error { input, code: kind }
85 /// Create a new error from an input position and an external error
86 fn from_external_error(input: I, kind: ErrorKind, _e: E) -> Self {
87 Error { input, code: kind }
94 write!(f, "error {:?} at: {}", self.code, self.input)
104 fn from_error_kind(input: I, kind: ErrorKind) -> Self {
105 (input, kind)
116 fn from_external_error(input: I, kind: ErrorKind, _e: E) -> Self {
117 (input, kind)
133 /// Creates an error from the input position and an [ErrorKind]
134 pub fn make_error<I, E: ParseError<I>>(input: I, kind: ErrorKind) -> E {
135 E::from_error_kind(input, kind)
138 /// Combines an existing error with a new one created from the input
141 pub fn append_error<I, E: ParseError<I>>(input: I, kind: ErrorKind, other: E) -> E {
142 E::append(input, kind, other)
153 /// part of input data, and some context
173 fn from_error_kind(input: I, kind: ErrorKind) -> Self {
175 errors: vec![(input, VerboseErrorKind::Nom(kind))],
179 fn append(input: I, kind: ErrorKind, mut other: Self) -> Self {
180 other.errors.push((input, VerboseErrorKind::Nom(kind)));
184 fn from_char(input: I, c: char) -> Self {
186 errors: vec![(input, VerboseErrorKind::Char(c))],
194 fn add_context(input: I, ctx: &'static str, mut other: Self) -> Self {
195 other.errors.push((input, VerboseErrorKind::Context(ctx)));
203 /// Create a new error from an input position and an external error
204 fn from_external_error(input: I, kind: ErrorKind, _e: E) -> Self {
205 Self::from_error_kind(input, kind)
213 for (input, error) in &self.errors {
215 VerboseErrorKind::Nom(e) => writeln!(f, "{:?} at: {}", e, input)?,
216 VerboseErrorKind::Char(c) => writeln!(f, "expected '{}' at: {}", c, input)?,
217 VerboseErrorKind::Context(s) => writeln!(f, "in section '{}', at: {}", s, input)?,
230 /// Create a new error from an input position, a static string and an existing error.
248 /// Transforms a `VerboseError` into a trace with input position information
252 input: I,
261 let offset = input.offset(substring);
263 if input.is_empty() {
266 write!(&mut result, "{}: expected '{}', got empty input\n\n", i, c)
268 VerboseErrorKind::Context(s) => write!(&mut result, "{}: in {}, got empty input\n\n", i, s),
269 VerboseErrorKind::Nom(e) => write!(&mut result, "{}: in {:?}, got empty input\n\n", i, e),
272 let prefix = &input.as_bytes()[..offset];
274 // Count the number of newlines in the first `offset` bytes of input
287 let line = input[line_begin..]
290 .unwrap_or(&input[line_begin..])
319 expected '{expected}', got end of input\n\n",
547 /// and the position in the input
551 ($input:expr, $code:expr) => ({
552 $crate::error::make_error($input, $code)
557 /// the position in the input and the next error in
562 ($input:expr, $code:expr, $next:expr) => ({
563 $crate::error::append_error($input, $code, $next)
567 /// Prints a message and the input if the parser fails.
572 /// It also displays the input in hexdump format
615 let input = "";
617 let _result: IResult<_, _, VerboseError<&str>> = char('x')(input);
638 pub fn slice_to_offsets(input: &[u8], s: &[u8]) -> (usize, usize) {
639 let start = input.as_ptr();
646 pub fn prepare_errors<O, E: Clone>(input: &[u8], e: VerboseError<&[u8]>) -> Option<Vec<(ErrorKind, usize, usize)>> {
650 let (o1, o2) = slice_to_offsets(input, p);
659 pub fn print_error<O, E: Clone>(input: &[u8], res: VerboseError<&[u8]>) {
660 if let Some(v) = prepare_errors(input, res) {
663 println!("{}", print_offsets(input, 0, &v));
747 pub fn print_offsets(input: &[u8], from: usize, offsets: &[(ErrorKind, usize, usize)]) -> String {
748 let mut v = Vec::with_capacity(input.len() * 3);
756 for chunk in input.chunks(chunk_size) {