diff options
Diffstat (limited to 'src/macro_rules/parse.cpp')
-rw-r--r-- | src/macro_rules/parse.cpp | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/macro_rules/parse.cpp b/src/macro_rules/parse.cpp index f8ec73cc..e382573a 100644 --- a/src/macro_rules/parse.cpp +++ b/src/macro_rules/parse.cpp @@ -70,14 +70,18 @@ public: ret.push_back( MacroPatEnt(name, idx, MacroPatEnt::PAT_PATH) ); else if( type == "expr" ) ret.push_back( MacroPatEnt(name, idx, MacroPatEnt::PAT_EXPR) ); + else if( type == "stmt" ) + ret.push_back( MacroPatEnt(name, idx, MacroPatEnt::PAT_STMT) ); else if( type == "ty" ) ret.push_back( MacroPatEnt(name, idx, MacroPatEnt::PAT_TYPE) ); else if( type == "meta" ) ret.push_back( MacroPatEnt(name, idx, MacroPatEnt::PAT_META) ); else if( type == "block" ) ret.push_back( MacroPatEnt(name, idx, MacroPatEnt::PAT_BLOCK) ); + else if( type == "item" ) + ret.push_back( MacroPatEnt(name, idx, MacroPatEnt::PAT_ITEM) ); else - throw ParseError::Generic(lex, FMT("Unknown fragment type '" << type << "'")); + ERROR(lex.getPosition(), E0000, "Unknown fragment type '" << type << "'"); break; } case TOK_PAREN_OPEN: { auto subpat = Parse_MacroRules_Pat(lex, TOK_PAREN_OPEN, TOK_PAREN_CLOSE, names); @@ -397,6 +401,19 @@ bool patterns_are_same(const Span& sp, const MacroPatEnt& left, const MacroPatEn default: ERROR(sp, E0000, "Incompatible macro fragments " << right << " used with " << left); } + // Matches items + case MacroPatEnt::PAT_ITEM: + switch(left.type) + { + case MacroPatEnt::PAT_TOKEN: + if( is_token_item(left.tok.type()) ) + ERROR(sp, E0000, "Incompatible macro fragments"); + return false; + case MacroPatEnt::PAT_ITEM: + return true; + default: + ERROR(sp, E0000, "Incompatible macro fragments " << right << " used with " << left); + } } throw ""; } |