Lines Matching refs:Error

18 /// It will return `Err(Err::Error((_, ErrorKind::Tag)))` if the input doesn't match the pattern
21 /// # use nom::{Err, error::{Error, ErrorKind}, Needed, IResult};
29 /// assert_eq!(parser("Something"), Err(Err::Error(Error::new("Something", ErrorKind::Tag))));
30 /// assert_eq!(parser(""), Err(Err::Error(Error::new("", ErrorKind::Tag))));
32 pub fn tag<T, Input, Error: ParseError<Input>>(
34 ) -> impl Fn(Input) -> IResult<Input, Input, Error>
42 let res: IResult<_, _, Error> = match i.compare(t) {
46 Err(Err::Error(Error::from_error_kind(i, e)))
58 /// It will return `Err(Err::Error((_, ErrorKind::Tag)))` if the input doesn't match the pattern.
61 /// # use nom::{Err, error::{Error, ErrorKind}, Needed, IResult};
71 /// assert_eq!(parser("Something"), Err(Err::Error(Error::new("Something", ErrorKind::Tag))));
72 /// assert_eq!(parser(""), Err(Err::Error(Error::new("", ErrorKind::Tag))));
74 pub fn tag_no_case<T, Input, Error: ParseError<Input>>(
76 ) -> impl Fn(Input) -> IResult<Input, Input, Error>
85 let res: IResult<_, _, Error> = match (i).compare_no_case(t) {
89 Err(Err::Error(Error::from_error_kind(i, e)))
102 /// It will return a `Err::Error(("", ErrorKind::IsNot))` if the pattern wasn't met.
105 /// # use nom::{Err, error::{Error, ErrorKind}, Needed, IResult};
115 /// assert_eq!(not_space(""), Err(Err::Error(Error::new("", ErrorKind::IsNot))));
117 pub fn is_not<T, Input, Error: ParseError<Input>>(
119 ) -> impl Fn(Input) -> IResult<Input, Input, Error>
135 /// It will return a `Err(Err::Error((_, ErrorKind::IsA)))` if the pattern wasn't met.
138 /// # use nom::{Err, error::{Error, ErrorKind}, Needed, IResult};
149 /// assert_eq!(hex(""), Err(Err::Error(Error::new("", ErrorKind::IsA))));
151 pub fn is_a<T, Input, Error: ParseError<Input>>(
153 ) -> impl Fn(Input) -> IResult<Input, Input, Error>
183 pub fn take_while<F, Input, Error: ParseError<Input>>(
185 ) -> impl Fn(Input) -> IResult<Input, Input, Error>
198 /// It will return an `Err(Err::Error((_, ErrorKind::TakeWhile1)))` if the pattern wasn't met.
201 /// # use nom::{Err, error::{Error, ErrorKind}, Needed, IResult};
211 /// assert_eq!(alpha(b"12345"), Err(Err::Error(Error::new(&b"12345"[..], ErrorKind::TakeWhile1))));
213 pub fn take_while1<F, Input, Error: ParseError<Input>>(
215 ) -> impl Fn(Input) -> IResult<Input, Input, Error>
231 /// It will return an `Err::Error((_, ErrorKind::TakeWhileMN))` if the pattern wasn't met or is out
235 /// # use nom::{Err, error::{Error, ErrorKind}, Needed, IResult};
246 /// assert_eq!(short_alpha(b"ed"), Err(Err::Error(Error::new(&b"ed"[..], ErrorKind::TakeWhileMN))));
247 /// assert_eq!(short_alpha(b"12345"), Err(Err::Error(Error::new(&b"12345"[..], ErrorKind::TakeWhileMN))));
249 pub fn take_while_m_n<F, Input, Error: ParseError<Input>>(
253 ) -> impl Fn(Input) -> IResult<Input, Input, Error>
265 let res: IResult<_, _, Error> = if let Ok(index) = input.slice_index(idx) {
268 Err(Err::Error(Error::from_error_kind(
275 let res: IResult<_, _, Error> = if let Ok(index) = input.slice_index(n) {
278 Err(Err::Error(Error::from_error_kind(
287 Err(Err::Error(Error::from_error_kind(input, e)))
295 Err(_needed) => Err(Err::Error(Error::from_error_kind(
301 let res: IResult<_, _, Error> = Ok((input.slice(len..), input));
305 Err(Err::Error(Error::from_error_kind(input, e)))
330 pub fn take_till<F, Input, Error: ParseError<Input>>(
332 ) -> impl Fn(Input) -> IResult<Input, Input, Error>
345 /// It will return `Err(Err::Error((_, ErrorKind::TakeTill1)))` if the input is empty or the
349 /// # use nom::{Err, error::{Error, ErrorKind}, Needed, IResult};
357 /// assert_eq!(till_colon(":empty matched"), Err(Err::Error(Error::new(":empty matched", ErrorKind::TakeTill1))));
359 /// assert_eq!(till_colon(""), Err(Err::Error(Error::new("", ErrorKind::TakeTill1))));
361 pub fn take_till1<F, Input, Error: ParseError<Input>>(
363 ) -> impl Fn(Input) -> IResult<Input, Input, Error>
376 /// It will return `Err(Err::Error((_, ErrorKind::Eof)))` if the input is shorter than the argument.
379 /// # use nom::{Err, error::{Error, ErrorKind}, Needed, IResult};
388 /// assert_eq!(take6("short"), Err(Err::Error(Error::new("short", ErrorKind::Eof))));
389 /// assert_eq!(take6(""), Err(Err::Error(Error::new("", ErrorKind::Eof))));
397 /// use nom::error::Error;
400 /// assert_eq!(take::<_, _, Error<_>>(1usize)("?"), Ok(("", "?")));
401 /// assert_eq!(take::<_, _, Error<_>>(1usize)("?".as_bytes()), Ok((b"\x9F\x92\x99".as_ref(), b"\xF0".as_ref())));
403 pub fn take<C, Input, Error: ParseError<Input>>(
405 ) -> impl Fn(Input) -> IResult<Input, Input, Error>
412 Err(_needed) => Err(Err::Error(Error::from_error_kind(i, ErrorKind::Eof))),
419 /// It doesn't consume the pattern. It will return `Err(Err::Error((_, ErrorKind::TakeUntil)))`
423 /// # use nom::{Err, error::{Error, ErrorKind}, Needed, IResult};
431 /// assert_eq!(until_eof("hello, world"), Err(Err::Error(Error::new("hello, world", ErrorKind::TakeUntil))));
432 /// assert_eq!(until_eof(""), Err(Err::Error(Error::new("", ErrorKind::TakeUntil))));
435 pub fn take_until<T, Input, Error: ParseError<Input>>(
437 ) -> impl Fn(Input) -> IResult<Input, Input, Error>
444 let res: IResult<_, _, Error> = match i.find_substring(t) {
445 None => Err(Err::Error(Error::from_error_kind(i, ErrorKind::TakeUntil))),
454 /// It doesn't consume the pattern. It will return `Err(Err::Error((_, ErrorKind::TakeUntil)))`
458 /// # use nom::{Err, error::{Error, ErrorKind}, Needed, IResult};
466 /// assert_eq!(until_eof("hello, world"), Err(Err::Error(Error::new("hello, world", ErrorKind::TakeUntil))));
467 /// assert_eq!(until_eof(""), Err(Err::Error(Error::new("", ErrorKind::TakeUntil))));
469 /// assert_eq!(until_eof("eof"), Err(Err::Error(Error::new("eof", ErrorKind::TakeUntil))));
471 pub fn take_until1<T, Input, Error: ParseError<Input>>(
473 ) -> impl Fn(Input) -> IResult<Input, Input, Error>
480 let res: IResult<_, _, Error> = match i.find_substring(t) {
481 None => Err(Err::Error(Error::from_error_kind(i, ErrorKind::TakeUntil))),
482 Some(0) => Err(Err::Error(Error::from_error_kind(i, ErrorKind::TakeUntil))),
509 pub fn escaped<'a, Input: 'a, Error, F, G, O1, O2>(
513 ) -> impl FnMut(Input) -> IResult<Input, Input, Error>
523 F: Parser<Input, O1, Error>,
524 G: Parser<Input, O2, Error>,
525 Error: ParseError<Input>,
548 Err(Err::Error(_)) => {
553 return Err(Err::Error(Error::from_error_kind(
572 return Err(Err::Error(Error::from_error_kind(
623 pub fn escaped_transform<Input, Error, F, G, O1, O2, ExtendItem, Output>(
627 ) -> impl FnMut(Input) -> IResult<Input, Output, Error>
640 F: Parser<Input, O1, Error>,
641 G: Parser<Input, O2, Error>,
642 Error: ParseError<Input>,
666 Err(Err::Error(_)) => {
673 return Err(Err::Error(Error::from_error_kind(
692 return Err(Err::Error(Error::from_error_kind(