From e584ea9876b53304880733ca3928dbad334c0c0d Mon Sep 17 00:00:00 2001 From: John Hodge Date: Mon, 26 Sep 2016 14:12:01 +0800 Subject: Parse - Handle attributes directly on items (for :item capture) --- src/macro_rules/mod.cpp | 2 ++ src/parse/root.cpp | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) (limited to 'src') diff --git a/src/macro_rules/mod.cpp b/src/macro_rules/mod.cpp index 3d1f04c5..effa03cb 100644 --- a/src/macro_rules/mod.cpp +++ b/src/macro_rules/mod.cpp @@ -111,6 +111,8 @@ bool is_token_stmt(eTokenType tt) { bool is_token_item(eTokenType tt) { switch( tt ) { + case TOK_ATTR_OPEN: + case TOK_RWORD_PUB: case TOK_RWORD_UNSAFE: case TOK_RWORD_TYPE: diff --git a/src/parse/root.cpp b/src/parse/root.cpp index 43c89a36..14a3d3ef 100644 --- a/src/parse/root.cpp +++ b/src/parse/root.cpp @@ -26,6 +26,9 @@ Spanned get_spanned(TokenStream& lex, ::std::function f) { } #define GET_SPANNED(type, lex, val) get_spanned< type >(lex, [&](){ return val; }) +// Check the next two tokens +#define LOOKAHEAD2(lex, tok1, tok2) ((lex).lookahead(0) == (tok1) && (lex).lookahead(1) == (tok2)) + ::std::string dirname(::std::string input) { while( input.size() > 0 && input.back() != '/' ) { input.pop_back(); @@ -1289,6 +1292,14 @@ void Parse_Use(TokenStream& lex, ::std::function