cppparser icon indicating copy to clipboard operation
cppparser copied to clipboard

Static arrays initialization causes parse errors

Open litdarya opened this issue 2 years ago • 3 comments

There are some cases with initializing static arrays in sequences which the parser fails to process.

Example 1:

int main()
{
  int variable, array_one[100], array_two[500];
  return 0;
}

produces:

./cppparsertest -p failed_testcases/many_arrays.cpp 
Error: Unexpected '[', while in context=ctxGeneral(1), found at line#2
	int variable, array_one[100], array_two[

Example 2:

int main()
{
  int variable = 0, array[100];
  return 0;
}

produces:

./cppparsertest -p failed_testcases/one_array.cpp 
Error: Unexpected '[', while in context=ctxGeneral(1), found at line#2
	int variable=0, array[

At the same time it parses these examples:

int main()
{
  int variable_one = 0, variable_two = 1;
  return 0;
}
int main()
{
  int array_one[500], array_two[500];
  return 0;
}

litdarya avatar May 24 '23 08:05 litdarya

Thanks for reporting. I see the problem and can be fixed. I will tackle it soon after completion of the major refactoring I am doing as of now.

satya-das avatar May 25 '23 09:05 satya-das

Hello, @satya-das! Looks like I've fixed it, can I create MR?

litdarya avatar May 31 '23 13:05 litdarya

Hello, @satya-das! Looks like I've fixed it, can I create MR?

Please go ahead. And thanks for taking initiative. :)

satya-das avatar May 31 '23 14:05 satya-das

The issue is fixed with 07e43111

satya-das avatar Oct 16 '24 17:10 satya-das