Closed AntoineGautier closed 1 month ago
@JayHuLBL Can you look into that?
@AntoineGautier
With the extra level of element_sections
, we would potentially keep the element orders. As in the code, we may have sections like:
[element]
[element]
protected
[element]
[element]
public
[element]
[element]
When parsing it, we can have
[element-list]
element_sections: [
{
"protected_element_list": ...
},
{
"public_element_list": ...
}
]
Overall, the major intention is to keep the element order, as it appears in the code. The same reason for the equation sections.
Since public element-list
, protected element-list
, etc. are sections of composition
that:
{ }
in the grammar), andelement-list
in the grammar,the best option is probably:
{
"composition": [
{ "element_list": [ ] },
{ "public_element_list": [ ] },
{ "protected_element_list": [ ] }
{ "equation_section": [ ] }
]
}
But maybe the refactoring effort is too much.
An option minimizing the refactoring effort would be to rename element_sections
into optional_sections
(short for "sections of composition that may be repeated zero or more times").
The main issue with the current structure is that fundamentally equations and algorithms are not elements of the class, see https://specification.modelica.org/maint/3.6/class-predefined-types-and-declarations.html#S5.p6
So it is uncanny to find these sections under element_sections
.
Discussing with @JayHuLBL on 8/9 we agree that the structure proposed above (https://github.com/lbl-srg/modelica-json/issues/237#issuecomment-2275196719) would be the best fit to the Modelica grammar. However, the refactoring appears significant. We'll close this issue for now as it isn't a development priority.
Parsing a block from MBL using commit
648b390
of modelica-json creates a JSON file with the following structure.In contrast, the MLS defines
composition
as follows:And
element
as follows:This brings the following observations.
element_sections
does not exist in the grammar: why is it used in the schema?equation_section
should not be nested underelement_sections
but directly undercomposition
(an equation is not an element). The same observation holds foralgorithm_section
when it is present.protected_element_list
at a deeper level thanelement-list
? Both should be directly nested undercomposition
. The same observation holds forpublic_element_list
when it is present.