better Pos
This commit is contained in:
parent
bcefb1b68f
commit
651ccb9cba
11 changed files with 268 additions and 318 deletions
|
|
@ -1,7 +1,7 @@
|
|||
use nom::{
|
||||
branch::alt,
|
||||
bytes::complete::tag,
|
||||
character::complete::{line_ending, space0, space1},
|
||||
character::complete::{line_ending, space0, space1, u32},
|
||||
combinator::{eof, opt, value},
|
||||
error::ParseError,
|
||||
multi::many0,
|
||||
|
|
@ -34,6 +34,10 @@ where
|
|||
terminated(line, alt((line_ending, eof)))
|
||||
}
|
||||
|
||||
pub fn usize<'a, E: ParseError<&'a str>>(input: &'a str) -> IResult<&'a str, usize, E> {
|
||||
u32.map(|v| v as usize).parse(input)
|
||||
}
|
||||
|
||||
pub fn true_false<'a, E: ParseError<&'a str>>(input: &'a str) -> IResult<&'a str, bool, E> {
|
||||
alt((value(true, tag("true")), value(false, tag("false"))))(input)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue