Allow optional comma after last entry in enum

This commit is contained in:
Michael Singer 2021-08-05 21:02:35 +02:00 committed by Zachary Snow
parent f368e2c7e6
commit 681a1c07e5
1 changed files with 12 additions and 11 deletions

View File

@ -1624,17 +1624,18 @@ enum_type: TOK_ENUM {
// create the template for the names // create the template for the names
astbuf1 = new AstNode(AST_ENUM_ITEM); astbuf1 = new AstNode(AST_ENUM_ITEM);
astbuf1->children.push_back(AstNode::mkconst_int(0, true)); astbuf1->children.push_back(AstNode::mkconst_int(0, true));
} enum_base_type '{' enum_name_list '}' { // create template for the enum vars } enum_base_type '{' enum_name_list optional_comma '}' {
auto tnode = astbuf1->clone(); // create template for the enum vars
delete astbuf1; auto tnode = astbuf1->clone();
astbuf1 = tnode; delete astbuf1;
tnode->type = AST_WIRE; astbuf1 = tnode;
tnode->attributes[ID::enum_type] = AstNode::mkconst_str(astbuf2->str); tnode->type = AST_WIRE;
// drop constant but keep any range tnode->attributes[ID::enum_type] = AstNode::mkconst_str(astbuf2->str);
delete tnode->children[0]; // drop constant but keep any range
tnode->children.erase(tnode->children.begin()); delete tnode->children[0];
$$ = astbuf1; } tnode->children.erase(tnode->children.begin());
; $$ = astbuf1;
};
enum_base_type: type_atom type_signing enum_base_type: type_atom type_signing
| type_vec type_signing range { if ($3) astbuf1->children.push_back($3); } | type_vec type_signing range { if ($3) astbuf1->children.push_back($3); }