From b9ebee54da296f99ceab32c3db31ae38fe8709a1 Mon Sep 17 00:00:00 2001 From: Melody Horn Date: Fri, 2 Apr 2021 19:16:28 -0600 Subject: try expanding an unknown line first --- src/makefile/mod.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/makefile') diff --git a/src/makefile/mod.rs b/src/makefile/mod.rs index 9038150..9c4967a 100644 --- a/src/makefile/mod.rs +++ b/src/makefile/mod.rs @@ -225,12 +225,21 @@ impl<'a> Makefile<'a> { let line_type = LineType::of(&line_tokens); + // before we actually test it, see if it's only visible after expanding macros + let (line_tokens, line_type) = if let LineType::Unknown = line_type { + let line_tokens = TokenString::text(self.expand_macros(&line_tokens, None)?); + let line_type = LineType::of(&line_tokens); + (line_tokens, line_type) + } else { + (line_tokens, line_type) + }; + match line_type { LineType::Rule => self.read_rule(&line_tokens, line_number, &mut lines_iter)?, LineType::Macro => self.read_macro(&line_tokens, line_number)?, LineType::Unknown => { bail!( - "error: line {}: unknown line {:?}", + "error: line {}: unknown line \"{}\"", line_number, line_tokens ); -- cgit v1.2.3