diff options
author | John Hodge <tpg@ucc.asn.au> | 2019-01-20 20:35:26 +0800 |
---|---|---|
committer | John Hodge <tpg@ucc.asn.au> | 2019-01-20 20:35:26 +0800 |
commit | e4437d90f3839e5731d29bb56202a800d78c7d18 (patch) | |
tree | f7c236d5305f852f99370ec4523c8d7ff1429066 /src | |
parent | 71be0e9e2cd81ef9c0482ae258e82bcdc8fb6e5c (diff) | |
download | mrust-e4437d90f3839e5731d29bb56202a800d78c7d18.tar.gz |
Parse - Trailing commas in Fn(...) handling
Diffstat (limited to 'src')
-rw-r--r-- | src/parse/paths.cpp | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/src/parse/paths.cpp b/src/parse/paths.cpp index 2a2437ca..cb704f85 100644 --- a/src/parse/paths.cpp +++ b/src/parse/paths.cpp @@ -142,18 +142,14 @@ AST::Path Parse_Path(TokenStream& lex, bool is_abs, eParsePathGenericMode generi auto ps = lex.start_span(); DEBUG("Fn() hack"); ::std::vector<TypeRef> args; - if( GET_TOK(tok, lex) == TOK_PAREN_CLOSE ) - { - // Empty list - } - else - { - PUTBACK(tok, lex); - do { - // TODO: Trailing commas - args.push_back( Parse_Type(lex) ); - } while( GET_TOK(tok, lex) == TOK_COMMA ); - } + do { + // Trailing comma or empty list support + if( lex.lookahead(0) == TOK_PAREN_CLOSE ) { + GET_TOK(tok, lex); + break; + } + args.push_back( Parse_Type(lex) ); + } while( GET_TOK(tok, lex) == TOK_COMMA ); CHECK_TOK(tok, TOK_PAREN_CLOSE); TypeRef ret_type = TypeRef( TypeRef::TagUnit(), Span(tok.get_pos()) ); |