summaryrefslogtreecommitdiff
path: root/src/parse/root.cpp
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2015-03-17 12:44:16 +0800
committerJohn Hodge <tpg@mutabah.net>2015-03-17 12:44:16 +0800
commit80e44173b4abef7238304fbaf1182862144b62b1 (patch)
treed468ce61ffa2c3ed5a5ceaffb909fb0798bf5161 /src/parse/root.cpp
parent6c571b2d3f99f5e209986dc00710d3fb86caafad (diff)
downloadmrust-80e44173b4abef7238304fbaf1182862144b62b1.tar.gz
Clean up handling of TokenTrees, allowing empty but valid TTs
Diffstat (limited to 'src/parse/root.cpp')
-rw-r--r--src/parse/root.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/parse/root.cpp b/src/parse/root.cpp
index f84b11f6..55f6f21c 100644
--- a/src/parse/root.cpp
+++ b/src/parse/root.cpp
@@ -173,6 +173,8 @@ TypeRef Parse_Type(TokenStream& lex)
switch( GET_TOK(tok, lex) )
{
+ case TOK_UNDERSCORE:
+ return TypeRef();
case TOK_RWORD_EXTERN: {
GET_CHECK_TOK(tok, lex, TOK_STRING);
::std::string abi = tok.str();
@@ -211,6 +213,10 @@ TypeRef Parse_Type(TokenStream& lex)
case TOK_DOUBLE_COLON:
// Path with generics
return TypeRef(TypeRef::TagPath(), Parse_Path(lex, true, PATH_GENERIC_TYPE));
+
+ // HACK! Convert && into & &
+ case TOK_DOUBLE_AMP:
+ lex.putback(Token(TOK_AMP));
case TOK_AMP: {
::std::string lifetime;
// Reference
@@ -1424,8 +1430,10 @@ void Parse_ModRoot_Items(TokenStream& lex, AST::Crate& crate, AST::Module& mod,
}
else
{
+ DEBUG("Invoke macro '"<<tok.str()<<"'");
TokenTree tt = Parse_TT(lex, true);
- if( tt.size() == 0 ) {
+ if( tt.is_token() ) {
+ DEBUG("TT was a single token (not a sub-tree)");
throw ParseError::Unexpected(lex, tt.tok());
}
::std::string name = tok.str();