diff options
author | John Hodge <tpg@mutabah.net> | 2015-04-04 16:25:14 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2015-04-04 16:25:14 +0800 |
commit | c744ebf392209f1dc7dda8900d1e0b16823b55bd (patch) | |
tree | 145599928895c06bc9e317623a3f312e660111a9 /src/parse | |
parent | 18c2dbbaa330157006b56d3afc97b89379120ddd (diff) | |
download | mrust-c744ebf392209f1dc7dda8900d1e0b16823b55bd.tar.gz |
Hacked in parsing of HRLs
Diffstat (limited to 'src/parse')
-rw-r--r-- | src/parse/root.cpp | 25 |
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);
|