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();
|
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;
|
use crate::useflag::UseFlag;
|
||||||
|
|
||||||
pub fn useflag<'a>() -> impl Parser<&'a str, Output = UseFlag> {
|
pub fn useflag<'a>() -> impl Parser<&'a str, Output = UseFlag> {
|
||||||
alpha1()
|
let start = r#if(|c: &char| c.is_ascii_alphanumeric());
|
||||||
.and(alphanumeric().or(take_while(one_of("+_@-".chars()))))
|
let rest = take_while(r#if(|c: &char| {
|
||||||
|
c.is_ascii_alphanumeric() || "+_@-".contains(*c)
|
||||||
|
}));
|
||||||
|
|
||||||
|
start
|
||||||
|
.and(rest)
|
||||||
.recognize()
|
.recognize()
|
||||||
.map(|output: &str| UseFlag(output.to_string()))
|
.map(|output: &str| UseFlag(output.to_string()))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user