Syntax Proposals / Arrays
Is your feature request related to a problem? Please describe. Currently GBOML can only receive data in the form of single-line CSV files. This imposes most modelers (me included) to preprocess other file formats, such as JSON, to transform them to CSV, losing valuable information ("what is config[4]? ah yeah it's "capex" in that JSON file") and costing dev time. Some data is given in the form of matrices (aka multi-line csvs...)...
Describe the solution you'd like Before implementing solution to allow the importation of these files, we need a way to represent in GBOML array composed of mostly anything, from integers and floats to other arrays and even strings.
I propose a simple extension of the language, where an array can be composed like this:
array: "{" _separated_list{_array_entry, ","} "}"
_array_entry: expression | STRING | array
i.e. an array can be composed of any "expression" (i.e. operations on the parameters/variables/nodes/...), of strings, and of other arrays, in an interleaved fashion.
This would be a valid array:
{"hello", 22, {2.2, 22}, X.a}
Note that this implicitly allows a Node or an HyperEdge to be a value inside the array, allowing to do fun things:
#PARAMETERS
subnodes = {A, B, C, D}
#NODE A
//...
#NODE B
//...
#NODE C
//...
#NODE D
//...
#HYPEREDGE E
#CONSTRAINTS
sum(subnodes[i].x for i in [0:3]) == 0
This behavior would be very useful, but we may decide to forbid it if there is a technical reason to do so. Forbidden it would be done in the semantic check rather than while parsing.