nasa / fpp

F Prime Prime: A modeling language for F Prime
https://fprime.jpl.nasa.gov
Apache License 2.0
46 stars 31 forks source link

Add FPP JSON Dictionary #395

Closed jwest115 closed 4 months ago

jwest115 commented 6 months ago

This PR adds:

thomas-bc commented 5 months ago

Currently, using a type defined in FPP looks like this:

{
    "name": "MyModule.MyType",
    "kind": "qualifiedIdentifier",
}

To figure out what MyType actually is (enum, struct, array) one has to go find the type MyType defined in one of those 3 sub-dictionary which isn't ideal, both for a machine and for human-readability. What if we added an entry to have something like this

{
    "name": "MyModule.MyType",
    "kind": "qualifiedIdentifier",
    "kind_type": "array"
}

Probably this following would be sufficient too (since we know any of those 3 has to be looked up at a qualified identifier):

{
    "name": "MyModule.MyType",
    "kind": "array|struct|enum"
}

Thoughts? @jwest115 @bocchino @LeStarch

bocchino commented 5 months ago

To figure out what MyType actually is (enum, struct, array) one has to go find the type MyType defined in one of those 3 sub-dictionary

I think we got rid of those sub-dictionaries, so you just look up the name in a single dictionary of type definitions.

bocchino commented 5 months ago

Confirmed, there are no sub-dictionaries. See here: https://github.com/nasa/fprime/blob/a771b3540bcfa58c507b9d368fc91a3f0debaf2e/docs/Design/fpp-json-dict.md#dictionary-content.

thomas-bc commented 5 months ago

Ok that helps. Still - do we not think it's relevant to add a field saying which of the three it is? It would help for both human readability and parsing. Probably just need an extra field there ?

bocchino commented 5 months ago

I don't think we need that extra field repeating partial info about the type. The qualified type name points to the type definition, which has all the info, e.g., not just whether it's an array but the entire shape of the array. This is also how it works in FPP source.

bocchino commented 5 months ago

Also, the JSON dictionary is not primarily designed for human readability. When generating human-readable dictionaries, we can inline the entire type definition at every type name, if we think that is useful. It's a tradeoff -- lookup vs. verbosity. I think this is a concern for a downstream tool, not the dictionary spec.

bocchino commented 5 months ago

Recording the array/struct/enum info does not help with machine processing. It's just a name lookup in a table.