aboutsummaryrefslogtreecommitdiff
path: root/src/makefile/token.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/makefile/token.rs')
-rw-r--r--src/makefile/token.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/makefile/token.rs b/src/makefile/token.rs
index 396380b..dad4694 100644
--- a/src/makefile/token.rs
+++ b/src/makefile/token.rs
@@ -17,6 +17,7 @@ use nom::{
character::complete::{space0, space1},
multi::separated_list1,
};
+use regex::Regex;
trait Err<'a>: 'a + ParseError<&'a str> + ContextError<&'a str> {}
impl<'a, T: 'a + ParseError<&'a str> + ContextError<&'a str>> Err<'a> for T {}
@@ -144,6 +145,16 @@ impl TokenString {
}
})
}
+
+ pub fn matches_regex(&self, regex: &Regex) -> bool {
+ self.0.iter().any(|x| {
+ if let Token::Text(x) = x {
+ regex.is_match(x)
+ } else {
+ false
+ }
+ })
+ }
}
impl fmt::Display for TokenString {