1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
use Borrow;
use crate;
use CombinatorError;
/// Verifies the output of a parser. If verification fails, the returned error
/// is a semantic error.
///
/// # Examples
///
/// ```rust
/// # use kamo::{Position, parser::{prelude::*, code, CombinatorError, CharacterError, Input}};
/// let digit = literal::Radix::Decimal.one_digit();
/// let mut parser = verify(digit, |d| *d == 0);
///
/// assert_eq!(parser.parse("0".into()), Ok((0, Input::from(""))));
/// assert_eq!(parser.parse("1".into()), Err(ParseError::new(
/// Position::new(0, 1, 1),
/// code::ERR_VERIFY,
/// CombinatorError::Verify
/// )));
/// assert_eq!(parser.parse("a".into()), Err(ParseError::new(
/// Position::new(0, 1, 1),
/// code::ERR_DIGIT,
/// CharacterError::Digit
/// )));
///
/// let error = parser.parse("".into()).expect_err("error output");
///
/// assert!(error.is_eof());
/// assert_eq!(error, ParseError::new(
/// Position::new(0, 1, 1),
/// code::ERR_DIGIT,
/// CharacterError::Digit,
/// ));
/// ```