aboutsummaryrefslogtreecommitdiff
path: root/src/makefile/token.rs
diff options
context:
space:
mode:
authorMelody Horn <melody@boringcactus.com>2024-11-11 17:15:08 -0700
committerMelody Horn <melody@boringcactus.com>2024-11-11 17:15:08 -0700
commit4f9299b4639802e05e1cb27d8eb40305ff8e110e (patch)
tree0da5529c68c82e97aed67d842e50f6285e79e6c2 /src/makefile/token.rs
parentfbbcf325b8bbe72f924da6a7cdb128d973ef0026 (diff)
downloadmakers-4f9299b4639802e05e1cb27d8eb40305ff8e110e.tar.gz
makers-4f9299b4639802e05e1cb27d8eb40305ff8e110e.zip
implement rule-specific macros for targets
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 {