diff options
author | John Hodge (bugs) <tpg@mutabah.net> | 2017-05-14 12:39:31 +0800 |
---|---|---|
committer | John Hodge (bugs) <tpg@mutabah.net> | 2017-05-14 12:39:31 +0800 |
commit | 39ccbcf7e5596ca791d8616b678d1a13ebbb1af4 (patch) | |
tree | 7d05b59afda9dca6c741275ab3d27e13c39ff561 /src/macro_rules | |
parent | 1d2fe7681219700998c8ecbdb8ed5acab66578df (diff) | |
parent | 699dbed9dca998b0df8418fde68235d230a726eb (diff) | |
download | mrust-39ccbcf7e5596ca791d8616b678d1a13ebbb1af4.tar.gz |
Merge branch 'master' of https://github.com/thepowersgang/mrustc
Diffstat (limited to 'src/macro_rules')
-rw-r--r-- | src/macro_rules/mod.cpp | 1 | ||||
-rw-r--r-- | src/macro_rules/parse.cpp | 7 |
2 files changed, 4 insertions, 4 deletions
diff --git a/src/macro_rules/mod.cpp b/src/macro_rules/mod.cpp index f685f6dc..eb0f9be0 100644 --- a/src/macro_rules/mod.cpp +++ b/src/macro_rules/mod.cpp @@ -76,7 +76,6 @@ bool is_token_expr(eTokenType tt) { case TOK_EXCLAM: // Invert case TOK_RWORD_BOX: // Box // Composite values - case TOK_MACRO: case TOK_PAREN_OPEN: // Parenthesised case TOK_SQUARE_OPEN: // Array diff --git a/src/macro_rules/parse.cpp b/src/macro_rules/parse.cpp index fa82e0e0..8264180f 100644 --- a/src/macro_rules/parse.cpp +++ b/src/macro_rules/parse.cpp @@ -48,8 +48,9 @@ public: case TOK_DOLLAR: switch( GET_TOK(tok, lex) ) { + case TOK_RWORD_TYPE: case TOK_IDENT: { - ::std::string name = mv$(tok.str()); + ::std::string name = tok.type() == TOK_IDENT ? mv$(tok.str()) : FMT(tok); GET_CHECK_TOK(tok, lex, TOK_COLON); GET_CHECK_TOK(tok, lex, TOK_IDENT); ::std::string type = mv$(tok.str()); @@ -199,10 +200,10 @@ public: } } - else if( tok.type() == TOK_IDENT ) + else if( tok.type() == TOK_IDENT || tok.type() == TOK_RWORD_TYPE ) { // Look up the named parameter in the list of param names for this arm - const auto& name = tok.str(); + auto name = tok.type() == TOK_IDENT ? tok.str() : FMT(tok); unsigned int idx = ::std::find(var_names.begin(), var_names.end(), name) - var_names.begin(); if( idx == var_names.size() ) ERROR(lex.getPosition(), E0000, "Macro variable $" << name << " not found"); |