From 931e96838a433b3634ae7ab3347f7650cd78003d Mon Sep 17 00:00:00 2001 From: Lefteris Karapetsas Date: Wed, 11 Feb 2015 17:23:13 +0100 Subject: [PATCH] Disallow trailing comma in Enum Declaration --- Parser.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Parser.cpp b/Parser.cpp index a26713a73..e59e698f1 100644 --- a/Parser.cpp +++ b/Parser.cpp @@ -282,12 +282,15 @@ ASTPointer Parser::parseEnumDefinition() vector> members; expectToken(Token::LBrace); - while (m_scanner->getCurrentToken() == Token::Identifier) + while (m_scanner->getCurrentToken() != Token::RBrace) { members.push_back(parseEnumDeclaration()); if (m_scanner->getCurrentToken() == Token::RBrace) break; expectToken(Token::Comma); + if (m_scanner->getCurrentToken() != Token::Identifier) { + BOOST_THROW_EXCEPTION(createParserError("Expected Identifier after ,")); + } } nodeFactory.markEndPosition();