summaryrefslogtreecommitdiff
path: root/src/parse
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2016-03-08 11:41:47 +0800
committerJohn Hodge <tpg@mutabah.net>2016-03-08 11:41:47 +0800
commitd631637ae467843ffd969c6003b6c187f498ef5c (patch)
tree71a1908002656186152f8421e6c3a52aca846e31 /src/parse
parent8438c45edf9ee1b561ccfec304d2a36b0671e311 (diff)
downloadmrust-d631637ae467843ffd969c6003b6c187f498ef5c.tar.gz
Spans on MacroInvocation, re-enable span in ERROR reporting
Diffstat (limited to 'src/parse')
-rw-r--r--src/parse/common.hpp2
-rw-r--r--src/parse/pattern.cpp3
-rw-r--r--src/parse/root.cpp10
-rw-r--r--src/parse/types.cpp3
4 files changed, 11 insertions, 7 deletions
diff --git a/src/parse/common.hpp b/src/parse/common.hpp
index 4b6ceb54..ed052a33 100644
--- a/src/parse/common.hpp
+++ b/src/parse/common.hpp
@@ -39,7 +39,7 @@ extern ::std::vector<TypeRef> Parse_Path_GenericList(TokenStream& lex);
extern AST::MetaItem Parse_MetaItem(TokenStream& lex);
-extern ::AST::MacroInvocation Parse_MacroInvocation(::AST::MetaItems meta_items, ::std::string name, TokenStream& lex);
+extern ::AST::MacroInvocation Parse_MacroInvocation(ProtoSpan ps, ::AST::MetaItems meta_items, ::std::string name, TokenStream& lex);
extern TypeRef Parse_Type(TokenStream& lex);
extern AST::Pattern Parse_Pattern(TokenStream& lex, bool is_refutable);
diff --git a/src/parse/pattern.cpp b/src/parse/pattern.cpp
index e8ccd962..dcbc8c5d 100644
--- a/src/parse/pattern.cpp
+++ b/src/parse/pattern.cpp
@@ -37,13 +37,14 @@ AST::Pattern Parse_PatternReal1(TokenStream& lex, bool is_refutable);
AST::Pattern Parse_Pattern(TokenStream& lex, bool is_refutable)
{
TRACE_FUNCTION;
+ auto ps = lex.start_span();
Token tok;
tok = lex.getToken();
if( tok.type() == TOK_MACRO )
{
- return AST::Pattern( AST::Pattern::TagMacro(), box$(Parse_MacroInvocation(AST::MetaItems(), tok.str(), lex)));
+ return AST::Pattern( AST::Pattern::TagMacro(), box$(Parse_MacroInvocation(ps, AST::MetaItems(), tok.str(), lex)));
}
bool expect_bind = false;
diff --git a/src/parse/root.cpp b/src/parse/root.cpp
index faa2b9bb..0860a008 100644
--- a/src/parse/root.cpp
+++ b/src/parse/root.cpp
@@ -917,9 +917,10 @@ void Parse_Impl(TokenStream& lex, AST::Module& mod, AST::MetaItems attrs, bool i
// A sequence of method implementations
while( GET_TOK(tok, lex) != TOK_BRACE_CLOSE )
{
+ auto ps = lex.start_span();
if( tok.type() == TOK_MACRO )
{
- impl.add_macro_invocation( Parse_MacroInvocation( AST::MetaItems(), mv$(tok.str()), lex ) );
+ impl.add_macro_invocation( Parse_MacroInvocation( ps, AST::MetaItems(), mv$(tok.str()), lex ) );
// - Silently consume ';' after the macro
if( GET_TOK(tok, lex) != TOK_SEMICOLON )
lex.putback(tok);
@@ -1206,7 +1207,7 @@ void Parse_Use(TokenStream& lex, ::std::function<void(AST::Path, ::std::string)>
}
-::AST::MacroInvocation Parse_MacroInvocation(::AST::MetaItems meta_items, ::std::string name, TokenStream& lex)
+::AST::MacroInvocation Parse_MacroInvocation(ProtoSpan span_start, ::AST::MetaItems meta_items, ::std::string name, TokenStream& lex)
{
Token tok;
::std::string ident;
@@ -1217,7 +1218,7 @@ void Parse_Use(TokenStream& lex, ::std::function<void(AST::Path, ::std::string)>
lex.putback(tok);
}
TokenTree tt = Parse_TT(lex, true);
- return ::AST::MacroInvocation( mv$(meta_items), mv$(name), mv$(ident), mv$(tt));
+ return ::AST::MacroInvocation( lex.end_span(span_start), mv$(meta_items), mv$(name), mv$(ident), mv$(tt));
}
void Parse_ExternCrate(TokenStream& lex, AST::Module& mod, AST::MetaItems meta_items)
@@ -1598,10 +1599,11 @@ void Parse_ModRoot_Items(TokenStream& lex, AST::Module& mod, LList<AST::Module*>
DEBUG("meta_items = " << meta_items);
// root-level macros
+ auto ps = lex.start_span();
if( GET_TOK(tok, lex) == TOK_MACRO )
{
::std::string name = mv$(tok.str());
- mod.add_macro_invocation( Parse_MacroInvocation( mv$(meta_items), mv$(name), lex ) );
+ mod.add_macro_invocation( Parse_MacroInvocation( ps, mv$(meta_items), mv$(name), lex ) );
// - Silently consume ';' after the macro
// TODO: Check the tt next token before parsing to tell if this is needed
if( GET_TOK(tok, lex) != TOK_SEMICOLON )
diff --git a/src/parse/types.cpp b/src/parse/types.cpp
index e6aadbbe..16e95f6d 100644
--- a/src/parse/types.cpp
+++ b/src/parse/types.cpp
@@ -28,13 +28,14 @@ TypeRef Parse_Type(TokenStream& lex)
TypeRef Parse_Type_Int(TokenStream& lex)
{
//TRACE_FUNCTION;
+ auto ps = lex.start_span();
Token tok;
switch( GET_TOK(tok, lex) )
{
case TOK_MACRO:
- return TypeRef(TypeRef::TagMacro(), Parse_MacroInvocation(AST::MetaItems(), mv$(tok.str()), lex));
+ return TypeRef(TypeRef::TagMacro(), Parse_MacroInvocation(ps, AST::MetaItems(), mv$(tok.str()), lex));
// '!' - Only ever used as part of function prototypes, but is kinda a type... not allowed here though
case TOK_EXCLAM:
throw ParseError::Generic(lex, "! is not a real type");