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
56
57
58
59
60
61
62
63
64
#[macro_use]
extern crate nom as nom_crate;
pub mod nom {
    
    pub use nom_crate::{IResult,Needed,Err,ErrorKind};
}
pub mod literal;
pub mod expr;
pub mod token;
use nom::*;
#[derive(Debug)]
pub enum Error {
    
	ExactToken(token::Kind,&'static [u8]),
    
	ExactTokens(token::Kind,&'static [&'static str]),
    
	TypedToken(token::Kind),
    
	UnknownIdentifier,
    
    
    
    
	InvalidLiteral,
    
    Partial,
}
impl From<u32> for Error {
	fn from(_: u32) -> Self {
		Error::InvalidLiteral
	}
}
macro_rules! identity (
    ($i:expr,$e:expr) => ($e);
);
pub fn assert_full_parse<I,O,E>(result: IResult<&[I],O,E>) -> IResult<&[I],O,::Error>
  where Error: From<E> {
	match fix_error!((),::Error,identity!(result)) {
		Ok((rem,output)) => if rem.len()==0 {
			Ok((rem, output))
		} else {
			Err(Err::Error(error_position!(rem, ErrorKind::Custom(::Error::Partial))))
		},
		r => r,
	}
}