From 512d4b1a7f55d8f016432255f7bb29f72bc24a01 Mon Sep 17 00:00:00 2001 From: Zachary Snow Date: Tue, 17 Sep 2019 19:48:08 -0400 Subject: [PATCH] support module "list of param assignments" shorthand --- src/Language/SystemVerilog/Parser/Parse.y | 10 ++++++++-- test/basic/param_shorthand.sv | 9 +++++++++ test/basic/param_shorthand.v | 9 +++++++++ 3 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 test/basic/param_shorthand.sv create mode 100644 test/basic/param_shorthand.v diff --git a/src/Language/SystemVerilog/Parser/Parse.y b/src/Language/SystemVerilog/Parser/Parse.y index b1d5c85..62a742e 100644 --- a/src/Language/SystemVerilog/Parser/Parse.y +++ b/src/Language/SystemVerilog/Parser/Parse.y @@ -528,8 +528,14 @@ Params :: { [ModuleItem] } : {- empty -} { [] } | "#" "(" ParamsFollow { map (MIPackageItem . Decl) $3 } ParamsFollow :: { [Decl] } - : ParameterDecl(")") { $1 } - | ParameterDecl(",") ParamsFollow { $1 ++ $2 } + : ParamAsgn ")" { [$1] } + | ParamAsgn "," ParamsFollow { $1 : $3 } + | ParamsDecl { $1 } +ParamsDecl :: { [Decl] } + : ParameterDecl(")") { $1 } + | ParameterDecl(",") ParamsDecl { $1 ++ $2 } +ParamAsgn :: { Decl } + : Identifier "=" Expr { Param Parameter (Implicit Unspecified []) $1 $3 } PortDecls :: { ([Identifier], [ModuleItem]) } : "(" DeclTokens(")") { parseDTsAsPortDecls $2 } diff --git a/test/basic/param_shorthand.sv b/test/basic/param_shorthand.sv new file mode 100644 index 0000000..69f4caa --- /dev/null +++ b/test/basic/param_shorthand.sv @@ -0,0 +1,9 @@ +module top #(FOO = 10); + initial $display(FOO); +endmodule +module top2 #(FOO = 10, BAR = 11); + initial $display(FOO, BAR); +endmodule +module top3 #(FOO = 10, BAR = 11, parameter BAZ = 12); + initial $display(FOO, BAR, BAZ); +endmodule diff --git a/test/basic/param_shorthand.v b/test/basic/param_shorthand.v new file mode 100644 index 0000000..2741a65 --- /dev/null +++ b/test/basic/param_shorthand.v @@ -0,0 +1,9 @@ +module top #(parameter FOO = 10); + initial $display(FOO); +endmodule +module top2 #(parameter FOO = 10, parameter BAR = 11); + initial $display(FOO, BAR); +endmodule +module top3 #(parameter FOO = 10, parameter BAR = 11, parameter BAZ = 12); + initial $display(FOO, BAR, BAZ); +endmodule