Minres / CoreDSL

Xtext project to parse CoreDSL files
Apache License 2.0
16 stars 3 forks source link

Add support for arrays of constants #114

Open eyck opened 7 months ago

eyck commented 7 months ago

CoreDSL shall support arrays of constants ether as: const unsigned int arr[] = {3,4,5}; which inferes the size or const unsigned int arr[3] = {3,4,5}; where size has to be specified explicitly.

AtomCrafty commented 7 months ago

Question: do we need to be able to evaluate arr[1] as a constant expression as well?

const unsigned int arr[] = {16, 32, 64};
unsigned int XLEN = arr[1];
eyck commented 7 months ago

For the usecases I have in mind: no. Does the frontend support

const unsigned int c = 32;
unsigned int XLEN = c;
AtomCrafty commented 7 months ago

It does, yes. I'm specifically asking about the array accesses.

AtomCrafty commented 7 months ago

Another question: Should this support multi-dimensional arrays with nested array initializers?

const int a[][] = { {1, 2}, {3, 4} };
eyck commented 7 months ago

I guess in the long run we need to, I can imagine there are algorithms which need this. So we should start with a 1-dimensional array documenting the limitation.