From c254e048393c4fdcf3122e6f52f925577399b390 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Sat, 24 Feb 2018 09:20:42 +0800 Subject: macro_rules - Fix #59 and add tests for various macro quirks --- src/macro_rules/eval.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/macro_rules/eval.cpp b/src/macro_rules/eval.cpp index 705addb3..24adac3e 100644 --- a/src/macro_rules/eval.cpp +++ b/src/macro_rules/eval.cpp @@ -616,6 +616,8 @@ namespace { } } +// TODO: This shouldn't exist, and can false-positives +// - Ideally, this would use consume_from_frag (which takes a clone-able input) bool Macro_TryPatternCap(TokenStream& lex, MacroPatEnt::Type type) { switch(type) @@ -652,7 +654,7 @@ bool Macro_TryPatternCap(TokenStream& lex, MacroPatEnt::Type type) case MacroPatEnt::PAT_META: return LOOK_AHEAD(lex) == TOK_IDENT || LOOK_AHEAD(lex) == TOK_INTERPOLATED_META; case MacroPatEnt::PAT_ITEM: - return is_token_item( LOOK_AHEAD(lex) ); + return is_token_item( LOOK_AHEAD(lex) ) || LOOK_AHEAD(lex) == TOK_IDENT; } BUG(lex.point_span(), "Fell through"); } @@ -1978,6 +1980,7 @@ unsigned int Macro_InvokeRules_MatchPattern(const Span& sp, const MacroRules& ru // NOTE: There can be multiple arms active, take the first. auto i = matches[0]; + DEBUG("Evalulating arm " << i); auto lex = TTStreamO(sp, mv$(input)); SET_MODULE(lex, mod); -- cgit v1.2.3