From 173f591c06e2c77603b3db8be74e78cb6502b85c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Lanzend=C3=B6rfer?= Date: Mon, 19 Aug 2024 20:59:38 +0100 Subject: [PATCH] Fixing coverage of packed assignments A list can either start with '{ or {, this commit fixes this --- frontends/verilog/verilog_lexer.l | 4 ++++ frontends/verilog/verilog_parser.y | 20 +++++++++++++++----- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/frontends/verilog/verilog_lexer.l b/frontends/verilog/verilog_lexer.l index 8a3734302..effed5ffc 100644 --- a/frontends/verilog/verilog_lexer.l +++ b/frontends/verilog/verilog_lexer.l @@ -524,6 +524,10 @@ import[ \t\r\n]+\"(DPI|DPI-C)\"[ \t\r\n]+function[ \t\r\n]+ { "{*" { return DEFATTR_BEGIN; } "*}" { return DEFATTR_END; } +"'{" { return LIST_SIZED_BEGIN; } +"{" { return LIST_BEGIN; } +"}" { return LIST_END; } + "**" { return OP_POW; } "||" { return OP_LOR; } "&&" { return OP_LAND; } diff --git a/frontends/verilog/verilog_parser.y b/frontends/verilog/verilog_parser.y index 15a04eb28..884295ce2 100644 --- a/frontends/verilog/verilog_parser.y +++ b/frontends/verilog/verilog_parser.y @@ -417,6 +417,7 @@ static const AstNode *addAsgnBinopStmt(dict *attr, AstNode * %token TOK_SUB_ASSIGN TOK_DIV_ASSIGN TOK_MOD_ASSIGN TOK_MUL_ASSIGN %token TOK_SHL_ASSIGN TOK_SHR_ASSIGN TOK_SSHL_ASSIGN TOK_SSHR_ASSIGN %token TOK_BIND TOK_TIME_SCALE +%token LIST_SIZED_BEGIN LIST_BEGIN LIST_END %type range range_or_multirange non_opt_range non_opt_multirange %type wire_type expr basic_expr concat_list rvalue lvalue lvalue_concat_list non_io_wire_type io_wire_type @@ -903,6 +904,9 @@ wire_type_token: TOK_VAR logic_type { astbuf3->is_logic = true; } | + TOK_AUTOMATIC logic_type { + astbuf3->is_logic = true; + } | logic_type { astbuf3->is_logic = true; } | @@ -1763,7 +1767,7 @@ enum_type: TOK_ENUM { // create the template for the names astbuf1 = new AstNode(AST_ENUM_ITEM); astbuf1->children.push_back(AstNode::mkconst_int(0, true)); - } enum_base_type '{' enum_name_list optional_comma '}' { + } enum_base_type LIST_BEGIN enum_name_list optional_comma LIST_END { // create template for the enum vars auto tnode = astbuf1->clone(); delete astbuf1; @@ -1862,7 +1866,7 @@ struct_union: | TOK_UNION { $$ = new AstNode(AST_UNION); } ; -struct_body: opt_packed '{' struct_member_list '}' +struct_body: opt_packed LIST_BEGIN struct_member_list LIST_END ; opt_packed: @@ -3051,7 +3055,7 @@ lvalue: rvalue { $$ = $1; } | - '{' lvalue_concat_list '}' { + LIST_BEGIN lvalue_concat_list LIST_END { $$ = $2; }; @@ -3299,10 +3303,16 @@ basic_expr: $$ = $4; delete $6; } | - '{' concat_list '}' { + LIST_SIZED_BEGIN concat_list LIST_END { $$ = $2; } | - '{' expr '{' concat_list '}' '}' { + LIST_BEGIN concat_list LIST_END { + $$ = $2; + } | + LIST_BEGIN expr LIST_BEGIN concat_list LIST_END LIST_END { + $$ = new AstNode(AST_REPLICATE, $2, $4); + } | + LIST_SIZED_BEGIN expr LIST_BEGIN concat_list LIST_END LIST_END { $$ = new AstNode(AST_REPLICATE, $2, $4); } | '~' attr basic_expr %prec UNARY_OPS {