diff options
author | John Hodge <tpg@ucc.asn.au> | 2017-07-17 12:57:29 +0800 |
---|---|---|
committer | John Hodge <tpg@ucc.asn.au> | 2017-07-17 12:57:29 +0800 |
commit | 8ac5b10b954c6a9f33e1ed200e737682c7e89dfc (patch) | |
tree | 110f126b195f9ceb3bf59e9f1cb25fe78a1f2542 | |
parent | 9fe26bb83dcee67be874e57c439ea2e1ee984306 (diff) | |
download | mrust-8ac5b10b954c6a9f33e1ed200e737682c7e89dfc.tar.gz |
Parse - Allow :expr in attributes
-rw-r--r-- | src/parse/root.cpp | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/parse/root.cpp b/src/parse/root.cpp index cdb36345..33087724 100644 --- a/src/parse/root.cpp +++ b/src/parse/root.cpp @@ -18,6 +18,7 @@ #include <expand/cfg.hpp> // check_cfg - for `mod nonexistant;` #include <fstream> // Used by directory path #include "lex.hpp" // New file lexer +#include <ast/expr.hpp> template<typename T> Spanned<T> get_spanned(TokenStream& lex, ::std::function<T()> f) { @@ -981,8 +982,25 @@ AST::MetaItem Parse_MetaItem(TokenStream& lex) switch(GET_TOK(tok, lex)) { case TOK_EQUAL: - GET_CHECK_TOK(tok, lex, TOK_STRING); - return AST::MetaItem(name, tok.str()); + switch(GET_TOK(tok, lex)) + { + case TOK_STRING: + return AST::MetaItem(name, tok.str()); + case TOK_INTERPOLATED_EXPR: { + auto n = tok.take_frag_node(); + if( auto* v = dynamic_cast<::AST::ExprNode_String*>(&*n) ) + { + return AST::MetaItem(name, mv$(v->m_value)); + } + else + { + CHECK_TOK(tok, TOK_STRING); + } + break; } + default: + CHECK_TOK(tok, TOK_STRING); + } + throw ""; case TOK_PAREN_OPEN: { ::std::vector<AST::MetaItem> items; do { |