tree-sitter Fortran preprocessor

Command line options

Required

  • source_path (str) - The path to the Fortran source file that the preprocessor will be run on
  • out_path (str) - The path to the directory where intermediate products will be stored

Optional

  • overwrite (bool) - If True, overwrite the files in the directory specified by out_path
  • out_missing_includes (bool) - If True, output report of missing included files
  • out_gcc (bool) - If True, output intermediate product generated by GCC
  • out_unsupported (bool) - If True, output report of unsupported idioms contained in the source
  • out_corrected (bool) - If True, output the final source that will be sent to tree-sitter.
  • out_parse (bool) - If True, output the tree-sitter parse tree in sexp format

Preprocessing #include directives

To handle the include directive, the preprocessor requires a directory containing any additional files that a source file includes.

This directory should be located in the same directory as the source at source_path and follow the naming structure include_filename.

For example, in the source file: cons.F

#include <defs.h>

The directory structure should look like the following:

TIE_GCM   cons.F   include_cons    defs.h

Running as library

from skema.program_analysis.TS2CAST.preprocessor.preprocess import preprocess

parse_tree = preprocess("skema/data/TIE_GCM/cons.F", "skema/data/TIE_GCM/intermediate_products_cons/", out_parse=True) 

Running as script

python preproces.py skema/data/TIE_GCM/cons.F skema/data/TIE_GCM/intermediate_prodcuts_cons/ --out_parse