Alternative Fortran parsing implementation #560
Replies: 1 comment 6 replies
-
I think this is a great idea and worth exploring (again). When I first started working on capgen (more than 6 years ago (!)) I wanted to just grab a parser and start from there. I don't remember if I looked at Rose but did look at some LLVM-based projects. In the end, I did not want to have to build something just to run the CCPP Framework. I also looked at a Python-based Fortran parser but it was written by someone who did not support it at all and I found that code too hard to work with. I did not know about the fparser project but it was really new back then anyway and probably not ready for prime time. I still think it is important to not up the requirements for running the framework so to me, a Python-based tool seems best. |
Beta Was this translation helpful? Give feedback.
-
Description
Currently there are several chunks of regular expressions in
parse_fortran_file.py
andparse_checkers.py
that work with our current input files that parse key details of the Fortran code without being a full fledged parser that generates an AST.There are currently several comments documenting cases the regular expressions don't support and I suspect as we open up the CCPP to the greater community, there will either be more modifications/additions that we will need to added and without any restrictions on the Fortran code being parsed, these will get very complicated fairly quickly.
Solution
This may not be an issue or a priority today but I would like to open the discussion on our options and whether we begin discussing/documenting the Fortran code format that the CCPP will support with our regular expressions or we start evaluating third party libraries such as https://github.com/stfc/fparser/tree/master which is maintained by the UK Science and Technology Facilities Council (https://www.scd.stfc.ac.uk/Pages/About-Us.aspx) or https://github.com/rose-compiler/rose from LLNL (albeit this is a little more heavy handed considering it does far more than just parsing). We have reached out the
fortls
team to see if they support this as well and will update when we hear back if they have this functionality as well.Alternatives (optional)
There is also the option to dump the internal syntax tree from
gfortran
directlyusing https://gcc.gnu.org/onlinedocs/gfortran/Developer-Options.html#index-fdump-fortran-original (example :https://godbolt.org/z/TjrKzj9Wz):
and calling
gfortran
produces:But then we need to have a parser of GNUs internal AST printed to stdout which brings us back to square one unfortunately.
Related to (optional)
N\A
Beta Was this translation helpful? Give feedback.
All reactions