summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Hodge <tpg@ucc.asn.au>2018-02-24 09:20:42 +0800
committerJohn Hodge <tpg@ucc.asn.au>2018-02-24 09:20:42 +0800
commitc254e048393c4fdcf3122e6f52f925577399b390 (patch)
treed37a6aa63ddf747484ed4cf079c37e245739ae38 /src
parent301de6f2baadbc78f270f85d488a85f75d6caacd (diff)
downloadmrust-c254e048393c4fdcf3122e6f52f925577399b390.tar.gz
macro_rules - Fix #59 and add tests for various macro quirks
Diffstat (limited to 'src')
-rw-r--r--src/macro_rules/eval.cpp5
1 files changed, 4 insertions, 1 deletions
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);