I am using the below ANTLR grammar for parsing my code.
https://github.com/antlr/grammars-v4/tree/master/cpp
But I am getting a parsing error in the below part of my code
const GstTensorsInfo info_in = {
.num_tensors = 1U,
.info = {{ .name = NULL, .type = _NNS_UINT8, .dimension = { 1, 10, 1, 1}}},
};
I am using the below input for the CPP parser:
TEST(tensor_filter_custom_easy, in_code_func_01)
{
int ret;
const guint num_buffers = 10;
TestOption option = { num_buffers, TEST_CUSTOM_EASY_ICF_01 };
guint timeout_id;
const GstTensorsInfo info_in = {
.num_tensors = 1U,
.info = {{ .name = NULL, .type = _NNS_UINT8, .dimension = { 1, 10, 1, 1}}},
};
ret = NNS_custom_easy_register ("safe_memcpy_10x10", cef_func_safe_memcpy,
NULL, &info_in, &info_out);
ASSERT_EQ(ret, 0);
}
What modification is needed in parser/lexer to parse the input correctly? Any help on this is highly appreciated. Thanks in advance.
The designated initializer syntax (.num_tensors = 1U
) was only added to C++ in C++20. The grammar you are trying to use is named "CPP14", which I suppose means that it is a C++14 grammar. In that case, it's not surprising that it doesn't accept the syntax.
You might be able to find something useful in a C grammar, since designated initializers have been part of C since C99.