Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fpp to json

Ali Mosallaei edited this page Jul 2, 2024 · 1 revision

This tool parses an FPP model, performs semantic checking on it, and writes out the model in JavaScript Object Notation (JSON) format.

Options:

  1. -d dir: Set the output directory to dir. If this option is not present, then the output directory is the current directory.

  2. -s: Emit syntax only (location map and abstract syntax tree).

Input:

  1. A list fl of files to translate: either the single file stdin or a list of files specified on the command line.

Output:

Fpp-to-json generates the following files:

  1. A file fpp-ast.json containing a JSON representation of the abstract syntax tree (AST).

  2. A file fpp-loc.json containing a JSON representation of the location map.

  3. If the flag -s is not present, then a file fpp-analysis.json containing a JSON representation of the Analysis Data Structure.

Procedure:

  1. Parse each of the files in fl, generating a list tul of translation units. When parsing, recursively resolve include specifiers.

  2. Convert the abstract syntax tree (AST) and the location map to JSON objects.

  3. If -s is not present, then

    1. Perform semantic checking on tul.

    2. Convert the Analysis Data Structure to a JSON object.

  4. Write the JSON objects to files.

JSON AST Parser

The fpp-ast.json output from this tool can be quite tedious to parse, but is a very useful source for programatically interpreting the fpp model files. As such, a barebones Python-based JSON AST parser is provided as a utility of [fprime-tools](https://github.com/nasa/fprime-tools/pull/207), as well as an fpp syntax writer.

Examples for utilizing both tools are provided in the fprime-tools utility folder.

Clone this wiki locally