The following section will provide details on command line arguments supported by FortranAS
Print help
List available lexers and exit
List all available Antlr4 lexers detected by FortranAS.
This flag specifies the lexer to use with -p,--parse-fortran-files
.
The default is specified by the default_lexer
configuration
parameter in FortranAS.conf. This will be used if none
is supplied with -L,--lexer <arg>
. Any lexer provided by
grammars-v4 🔗.
Use -l,--list-lexers
to see what lexers FortranAS is able to use.
Parse FORTRAN files
All FORTRAN files provided by the input source code directory
(-i,--input-source-code-directory <arg>
) will be recursively parsed.
Any file extension specified by the fortran_file_extensions
configuration
parameter in FortranAS.conf. Each discovered
FORTRAN file will be parsed and serialized with several artifacts generated for
each FORTRAN file. For a detail of all the artifacts generated by FortranAS
please review the FortranAS Artifacts 🔗
documentation.
The Antlr4 grammars cannot parse FORTRAN source code that uses non-standard language
features such as preprocessor directives. In order to process
these files with FortranAS the preprocessor directives must be removed.
There is no perfect way to do this. FortranAS provides a shell script that
uses the command line tool unifdef in the
tools directory called unifdef.sh
. This shell script will strip all
preprocessor directives from the FORTRAN source code in the ./source
directory.
To run it place fortran ./source
and run the provide script:
bash tools/unifdef.sh
When the -p,--parse-fortran-files
flag is supplied to FortranAS a database
is generated in the current working directory of FortranAS with the default
file name: FortranAS.sqlite3
. If the database already exists then it is used.
All nodes
and subtrees
from every parsed FORTRAN file will placed in this
database. A summary of every parsed FORTRAN file will be placed in the
fortran_files
table.
The FortranAS database is specified by the database_file
configuration
parameter in FortranAS.conf (Default database file:
FortranAS.sqlite3
).
Subtrees can be bounded and selectively inserted into the subtree
table by
modifying the subtree bounding parameters in the FortranAS.conf.
Any subtree not within the minimum and maximun depth and size will not be
inserted into the subtree
table. Modify the following parameters to change the
subtree bounding:
...
minimum_subtree_depth = 0
maximum_subtree_depth = 25
minimum_subtree_size = 0
maximum_subtree_size = 150
...
Reducing the number of subtrees in the subtree
table will reduce the clone
calculation time.
Calculate code clones for all subtrees in the provided database
This flag operates on the FortranAS database (default database file name:
FortranAS.sqlite3
) and the subtree
table. Every subtree in the subtree
table will be used to calculate a
code clone pair using a number of natural language processing (NLP) algorithms.
Code clone pair calculations are parallelized and divided amongst the number of
available cores. All clone pair calculation results are placed in the clones
table.
To enable or disable a given NLP algorithm modify the appropriate section in the FortranAS.conf:
...
bleu_score_enabled = true
jaro_winkler_similarity_enabled = true
sorensen_dice_coefficient_enabled = false
cosine_similarity_enabled = false
...
All subtrees will be compared with all other subtrees in the database resulting O(n^(2)) complexity. Total clone calculation time can be reduced by disabling NLP algorithms. Alternatively, clone calculation time can be also reduced by bounding the number of subtrees in the subtree table (See the Subtree Bounding paragraph for more information).
Code clone pair calculations can be filtered from insertion to the database by
modifying the minimum_bleu_score
configuration
parameter in FortranAS.conf. Any clone pair with a blue
score less then the minimum specified will not be inserted into the database.
Print discovered FORTRAN files and exit
This flag will print all FORTRAN files in the supplied source code directory
(specified by -i,--input-source-code-directory <arg>
). The
fortran_file_extensions
configuration parameter in
FortranAS.conf dictates what file extensions to include.
Example output:
Printing FORTRAN files...
source file #1: /tmp/FortranAS/source/fortran_code_samples/249.f90
source file #2: /tmp/FortranAS/source/fortran_code_samples/273.f90
source file #3: /tmp/FortranAS/source/fortran_code_samples/273_print.f90
source file #4: /tmp/FortranAS/source/fortran_code_samples/273_result.f90
source file #5: /tmp/FortranAS/source/fortran_code_samples/274.f90
...
This is a helper flag that prints a summary of all tables the provided database
specified by the database_file
configuration parameter in
FortranAS.conf (Default database file: FortranAS.sqlite3
).
Example output:
Printing FortranAS database summary...
Database Summary for: FortranAS.sqlite3
File Size: 3.95 MB
Table: clones, Records: 639
Table: fortran_files, Records: 25
Table: nodes, Records: 7950
Table: subtrees, Records: 566
This flag defines what input FORTRAN source code directory to use when parsing
the default is ./source
.
This flag defines what output directory to use for all FortranAS generated
artifacts; the default output directory is ./output
.