Skip to content

Commit

Permalink
Add support for parsing enum class declarations
Browse files Browse the repository at this point in the history
  • Loading branch information
YuriUfimtsev authored and mrbean-bremen committed Oct 28, 2023
1 parent 6f75669 commit 5b91c50
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion generator/parser/parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1389,9 +1389,25 @@ bool Parser::parseEnumSpecifier(TypeSpecifierAST *&node)

CHECK(Token_enum);

if (token_stream.lookAhead() == Token_class)
{
token_stream.nextToken();
}

NameAST *name = 0;
parseName(name);

if(token_stream.lookAhead() == ':')
{
token_stream.nextToken();
TypeSpecifierAST *ast = 0;
if (!parseSimpleTypeSpecifier(ast))
{
token_stream.rewind((int) start);
return false;
}
}

if (token_stream.lookAhead() != '{')
{
token_stream.rewind((int) start);
Expand Down Expand Up @@ -1796,12 +1812,17 @@ bool Parser::parseForwardDeclarationSpecifier(TypeSpecifierAST *&node)
std::size_t start = token_stream.cursor();

int kind = token_stream.lookAhead();
if (kind != Token_class && kind != Token_struct && kind != Token_union)
if (kind != Token_class && kind != Token_struct && kind != Token_union && kind != Token_enum)
return false;

std::size_t class_key = token_stream.cursor();
token_stream.nextToken();

if (kind == Token_enum && token_stream.lookAhead() == Token_class)
{
token_stream.nextToken();
}

NameAST *name = 0;
if (!parseName(name, false)) {
token_stream.rewind((int) start);
Expand Down

0 comments on commit 5b91c50

Please sign in to comment.