forked from gentoo-utils/gentoo-utils
fix useflag parser
This commit is contained in:
@@ -280,4 +280,11 @@ mod test {
|
||||
|
||||
atom().check_finished(it).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_usedep_with_underscore() {
|
||||
let it = InputIter::new("foo/bar-1.0.0[use_dep]");
|
||||
|
||||
atom().check_finished(it).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
use mon::{Parser, alpha1, alphanumeric, one_of, take_while};
|
||||
use mon::{Parser, r#if, take_while};
|
||||
|
||||
use crate::useflag::UseFlag;
|
||||
|
||||
pub fn useflag<'a>() -> impl Parser<&'a str, Output = UseFlag> {
|
||||
alpha1()
|
||||
.and(alphanumeric().or(take_while(one_of("+_@-".chars()))))
|
||||
let start = r#if(|c: &char| c.is_ascii_alphanumeric());
|
||||
let rest = take_while(r#if(|c: &char| {
|
||||
c.is_ascii_alphanumeric() || "+_@-".contains(*c)
|
||||
}));
|
||||
|
||||
start
|
||||
.and(rest)
|
||||
.recognize()
|
||||
.map(|output: &str| UseFlag(output.to_string()))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user