better Pos

This commit is contained in:
Rüdiger Ludwig 2023-08-07 05:50:26 +02:00
parent bcefb1b68f
commit 651ccb9cba
11 changed files with 268 additions and 318 deletions

View file

@ -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)
}