From 95985061ddff891f9cb80c495585d575e35005e4 Mon Sep 17 00:00:00 2001 From: Daniel Kroening Date: Fri, 24 Jan 2025 16:29:03 -0800 Subject: [PATCH] Verilog: allow task invocations without parentheses --- .../verilog/tasks/task_invocation1.desc | 3 +-- src/verilog/parser.y | 24 +++++++++++++++++-- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/regression/verilog/tasks/task_invocation1.desc b/regression/verilog/tasks/task_invocation1.desc index e15030bc..e7d3968e 100644 --- a/regression/verilog/tasks/task_invocation1.desc +++ b/regression/verilog/tasks/task_invocation1.desc @@ -1,4 +1,4 @@ -KNOWNBUG +CORE task_invocation1.sv ^EXIT=0$ @@ -6,4 +6,3 @@ task_invocation1.sv -- ^warning: ignoring -- -The parser rejects invocations without (). diff --git a/src/verilog/parser.y b/src/verilog/parser.y index a041d68f..7144c6ed 100644 --- a/src/verilog/parser.y +++ b/src/verilog/parser.y @@ -4007,7 +4007,7 @@ unsigned_number: TOK_NUMBER // A.8.2 Subroutine calls tf_call: - hierarchical_tf_identifier list_of_arguments_paren + hierarchical_identifier list_of_arguments_paren_opt { init($$, ID_function_call); stack_expr($$).operands().reserve(2); mto($$, $1); mto($$, $2); } @@ -4020,6 +4020,7 @@ list_of_arguments_paren: list_of_arguments_paren_opt: /* Optional */ + { init($$); } | list_of_arguments_paren ; @@ -4054,7 +4055,26 @@ subroutine_call: | system_tf_call ; -function_subroutine_call: subroutine_call +function_subroutine_call: + hierarchical_tf_identifier list_of_arguments_paren + { init($$, ID_function_call); + stack_expr($$).operands().reserve(2); + mto($$, $1); mto($$, $2); } + | system_task_name list_of_arguments_paren + { init($$, ID_function_call); + stack_expr($$).operands().reserve(2); + mto($$, $1); mto($$, $2); } + | system_task_name '(' data_type ')' + { init($$, ID_function_call); + stack_expr($$).operands().reserve(2); + mto($$, $1); + unary_exprt arguments(ID_arguments, exprt(ID_type, stack_type($3))); + stack_expr($$).add_to_operands(arguments); } + | system_task_name + { init($$, ID_function_call); + stack_expr($$).operands().reserve(2); + mto($$, $1); + } ; event_trigger: TOK_MINUSGREATER hierarchical_event_identifier ';'