Improve error reporting of trailing commas

This commit is contained in:
Federico Bond 2017-06-15 13:10:08 -03:00
parent 54e97d1c34
commit 60bfae75e5

View File

@ -1335,13 +1335,19 @@ pair<vector<ASTPointer<Expression>>, vector<ASTPointer<ASTString>>> Parser::pars
if (!first)
expectToken(Token::Comma);
if (m_scanner->currentToken() == Token::RBrace)
fatalParserError("Unexpected trailing comma.");
ret.second.push_back(expectIdentifierToken());
expectToken(Token::Colon);
ret.first.push_back(parseExpression());
if (
m_scanner->currentToken() == Token::Comma &&
m_scanner->peekNextToken() == Token::RBrace
)
{
parserError("Unexpected trailing comma.");
m_scanner->next();
}
first = false;
}
expectToken(Token::RBrace);