summaryrefslogtreecommitdiff
path: root/src/parse
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2015-04-04 16:25:14 +0800
committerJohn Hodge <tpg@mutabah.net>2015-04-04 16:25:14 +0800
commitc744ebf392209f1dc7dda8900d1e0b16823b55bd (patch)
tree145599928895c06bc9e317623a3f312e660111a9 /src/parse
parent18c2dbbaa330157006b56d3afc97b89379120ddd (diff)
downloadmrust-c744ebf392209f1dc7dda8900d1e0b16823b55bd.tar.gz
Hacked in parsing of HRLs
Diffstat (limited to 'src/parse')
-rw-r--r--src/parse/root.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/parse/root.cpp b/src/parse/root.cpp
index 89843f34..15268ce9 100644
--- a/src/parse/root.cpp
+++ b/src/parse/root.cpp
@@ -109,6 +109,31 @@ void Parse_WhereClause(TokenStream& lex, AST::TypeParams& params)
{
throw ParseError::Todo(lex, "Lifetime bounds in 'where' clauses");
}
+ // Higher-ranked types/lifetimes
+ else if( tok.type() == TOK_RWORD_FOR )
+ {
+ ::std::vector< ::std::string> lifetimes;
+ GET_CHECK_TOK(tok, lex, TOK_LT);
+ do {
+ switch(GET_TOK(tok, lex))
+ {
+ case TOK_LIFETIME:
+ lifetimes.push_back(tok.str());
+ break;
+ default:
+ throw ParseError::Unexpected(lex, tok, Token(TOK_LIFETIME));
+ }
+ } while( GET_TOK(tok, lex) == TOK_COMMA );
+ CHECK_TOK(tok, TOK_GT);
+
+ // Parse a bound as normal
+ TypeRef type = Parse_Type(lex);
+ GET_CHECK_TOK(tok, lex, TOK_COLON);
+ Parse_TypeBound(lex, params, type);
+
+ // And store the higher-ranked lifetime list
+ params.bounds().back().set_higherrank( mv$(lifetimes) );
+ }
else
{
lex.putback(tok);