Skip to content

Latest commit

 

History

History
67 lines (44 loc) · 2.15 KB

File metadata and controls

67 lines (44 loc) · 2.15 KB

Analysis and Translation

Analysis

Analysis is the process of checking a source model. It usually involves the following steps:

  1. Lexing and parsing to generate an abstract syntax tree (AST).

  2. If step (1), succeeded, analysis and expansion of templates to generate a new AST.

  3. If step (2) succeeded, semantic analysis of the AST generated in step (2).

Analysis Tools

An analysis tool is a tool that reads in and analyzes FPP source files, but does not generate any code. Source files for analysis are provided in one of two ways:

  1. Via command-line arguments; or

  2. On standard input, if there are no arguments.

For example, the command analyze file1.fpp file2.fpp says to read in the translation units file1.fpp and file2.fpp and perform analysis on the model consisting of these two translation units. The command cat file1.fpp file2.fpp | analyze is functionally equivalent.

Translation

Translation is the process of performing analysis and generating code.

Translation usually involves the following steps:

  1. Analysis.

  2. If step (1) succeeded, code generation.

FPP is intended to support a variety of translation strategies. For example, we need to generate (1) C++ code for FSW and (2) JSON or other code to export to ground tools.

Translation Tools

A translation tool is a tool that translates FPP source files. A translation tool typically accepts the following two kinds of input:

  1. Source files to be translated.

  2. Source files that are imported for their symbol definitions, but are not translated.

For example, when translating a component C, a tool may read in files containing the definitions of the ports used in C, but not translate those files.

Source files for translation are provided as for analysis tools. Imported source files are specified as arguments to a -i flag.

For example, the command translate -i file1.fpp,file2.fpp file3.fpp says to import file1.fpp and file2.fpp and translate file3.fpp. The command translate -i file1.fpp,file2.fpp < file3.fpp is functionally equivalent.