aboutsummaryrefslogtreecommitdiff
path: root/src/makefile/token.rs
diff options
context:
space:
mode:
authorMelody Horn <melody@boringcactus.com>2024-11-13 00:27:03 -0700
committerMelody Horn <melody@boringcactus.com>2024-11-13 00:27:03 -0700
commit44b3ea4dac1cc60eeda54ae7b53facbb025c6f68 (patch)
tree48ea916afa45aaad161042efdaa771e6f7b5c1b6 /src/makefile/token.rs
parentdfb51bfebd0d5c22e82d2a73412a19c3e0599524 (diff)
downloadmakers-44b3ea4dac1cc60eeda54ae7b53facbb025c6f68.tar.gz
makers-44b3ea4dac1cc60eeda54ae7b53facbb025c6f68.zip
fix rule macro detection when macro expansion in macro name
Diffstat (limited to 'src/makefile/token.rs')
-rw-r--r--src/makefile/token.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/makefile/token.rs b/src/makefile/token.rs
index dad4694..7b88823 100644
--- a/src/makefile/token.rs
+++ b/src/makefile/token.rs
@@ -155,6 +155,19 @@ impl TokenString {
}
})
}
+
+ /// Returns (token index within string, pattern index within token).
+ pub fn find(&self, pattern: &str) -> Option<(usize, usize)> {
+ self.0
+ .iter()
+ .enumerate()
+ .find_map(|(token_index, token)| match token {
+ Token::Text(text) => text
+ .find(pattern)
+ .map(|pattern_index| (token_index, pattern_index)),
+ _ => None,
+ })
+ }
}
impl fmt::Display for TokenString {