23-24 September 2021
Europe/Zurich timezone

Finish AST generation in LFortran

24 Sep 2021, 17:20
ZOOM (Virtual)



Fortran-lang Communications Minisymposium


Thirumalai Shaktivel (KS Institute Of Technology)


LFortran has a Bison based parser implemented in the parser.yy file that can parse most of Fortran source code. The main objective of my GSoC project was to make sure that all the grammar rules defined are exposed to AST (Abstract Syntax Tree) level i.e., one has to systematically go over the parser file and make sure AST is always generated for all the grammar rules defined, resulting in Completion of the AST generation. AST.asdl contains a list of AST nodes that have already been implemented, this project aims at adding the missing node into the AST.asdl.
The steps for implementation are:
Add missing AST nodes.
Define macros, use them in the parser file to expose these nodes to the AST level.
Add tests to make sure things work as expected.
The fmt sub-command(format) is used to convert AST back to Fortran source code. There were certain issues related to fmt and parser, this project solved those issues. As a result, LFortran would be able to convert every grammar rule defined into AST for further manipulation and if required back to Fortran source code.

Primary author

Thirumalai Shaktivel (KS Institute Of Technology)


Ondřej Čertík (Los Alamos National Laboratory)

Presentation Materials