diff --git a/grammar.js b/grammar.js index e111c25d..51753333 100644 --- a/grammar.js +++ b/grammar.js @@ -4531,7 +4531,11 @@ const rules = { list_of_actual_arguments: $ => list_of_args($, 'list_of_arguments', $.actual_argument), - actual_argument: $ => $.param_expression, // Out of LRM, needed to support parameterized data types as macro args (common in the UVM) + actual_argument: $ => choice( + // Out of LRM, needed to support parameterized data types and constraints as macro args (common in the UVM) + $.param_expression, // e.g: `uvm_component_utils_param + $.constraint_block // e.g: `uvm_do_with + ), undefine_compiler_directive: $ => seq(directive('undef'), $.text_macro_identifier), @@ -6029,6 +6033,11 @@ module.exports = grammar({ [$.sequence_instance, $.tf_call, $.constant_primary, $.hierarchical_identifier], [$.sequence_instance, $.tf_call, $.hierarchical_identifier], [$.sequence_instance, $.tf_call], + + + // Allow constraint blocks on text_macro_usage + [$.constraint_block, $.empty_unpacked_array_concatenation], + ], }); diff --git a/test/corpus/core/directives/uvm_do_with.txt b/test/corpus/core/directives/uvm_do_with.txt new file mode 100644 index 00000000..57c5adb4 --- /dev/null +++ b/test/corpus/core/directives/uvm_do_with.txt @@ -0,0 +1,49 @@ +============================================ +core/directives/uvm_do_with +============================================ + +`uvm_do_with(arg, { x == 1; y == 2; }); + +---- + +(source_file + (text_macro_usage + (simple_identifier) + (list_of_actual_arguments + (actual_argument + (param_expression + (mintypmax_expression + (expression + (primary + (hierarchical_identifier + (simple_identifier))))))) + (actual_argument + (constraint_block + (constraint_block_item + (constraint_expression + (expression_or_dist + (expression + left: (expression + (primary + (hierarchical_identifier + (simple_identifier)))) + right: (expression + (primary + (primary_literal + (integral_number + (decimal_number + (unsigned_number)))))))))) + (constraint_block_item + (constraint_expression + (expression_or_dist + (expression + left: (expression + (primary + (hierarchical_identifier + (simple_identifier)))) + right: (expression + (primary + (primary_literal + (integral_number + (decimal_number + (unsigned_number))))))))))))))) diff --git a/test/files/core/directives/uvm_do_with.sv b/test/files/core/directives/uvm_do_with.sv new file mode 100644 index 00000000..51a0052b --- /dev/null +++ b/test/files/core/directives/uvm_do_with.sv @@ -0,0 +1 @@ +`uvm_do_with(arg, { x == 1; y == 2; });