Skip to content

fpp to cpp

Rob Bocchino edited this page Sep 27, 2023 · 21 revisions

This tool parses FPP models, performs semantic checking on them, and writes out C++ files.

Options:

  1. -a: Enable automatic setup of unit tests.

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

  3. -i files: Import files. These files are read in for their symbols, but their definitions do not cause any code to be generated.

  4. -g prefix: Specify a prefix for include guards that have no associated namespace.

  5. -n file: Write the names of the generated files to file. This is useful for collecting build dependencies.

  6. -p files: Specify local prefixes to delete when generating include guards and include paths.

  7. -s string size: Specify the default string size. If this option is present, the argument must be a decimal integer value between 1 and 1024. If this option is not present, the default string size is 80.

  8. -u: Generate unit test code.

  9. -t: Generate component implementation templates.

Input:

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

  2. A list fl_i of files to import, specified as arguments to the -i option.

Output:

  1. A set of C++ files, written to the output directory.

    1. By default these are the autocoded F Prime C++ files for constants, types, ports, components, and topologies.

    2. If the -u option is present and the -t option is not present, then

      1. These are the autocoded files for unit testing.

      2. If the -a option is present, then these files include code for setting up unit tests.

    3. If the -t option is present, then

      1. By default these are the template files for handwritten component implementations.

      2. If the -u option is also present, then

        1. These are the template files for handwritten component unit test implementations.

        2. If the -a option is not present, then these files include code for setting up unit tests.

  2. If the -n option is present, then the names of the generated C++ files.

Procedure:

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

  2. Do the same for fl_i, generating a list tul_i.

  3. Perform semantic checking on the concatenation of tul_fl and tul_i.

  4. Check that no two definitions in tul_tr will generate a C++ file with the same name. If so, halt with an error message.

  5. Generate the output for the definitions in tul_tr.

Clone this wiki locally