Can I use LLVM to parse Fortran?

I am new to LLVM. My primary need is to parse Fortran codes. Studying the LLVM website, it seems that LLVM can be used as a library for parsing codes. Can I use it to parse Fortran codes and retrieve code information (AST?)?

+6
source share
3 answers

LLVM is the compiler backend. The only thing he can analyze is LLVM IR, an intermediate language designed to exit programming language interfaces. The official interface for LLVM is Clang, which can handle C, C ++, and ObjC. If you are interested in other languages, there is also DragonEgg , which is the LLVM plugin for gcc. It uses gcc front-end and LLVM as a backend, so it can analyze everything that gcc knows how to understand. I know that work is being done to create the right code from Ada and Fortran. Here is an excerpt from his page:

Current status

  • Works best with gcc-4.6.
  • Fortran works very well. Ada, C, and C ++ also work well. Ada does not work well with gcc-4.7.
  • It can compile a reasonable amount of Obj-C, Obj-C ++ and Go.
  • It can compile simple Java programs, but they do not execute properly (this is due to the fact that the java interface does not support GCC LTO).
  • Debugging information is small.
+10
source

No, LLVM is not a Fortran parsing library. LLVM is a library for implementing the compiler backend. You will need to write your own Fortran interface.

+2
source

By adding an Eli Bendersky comment, you can use the -fdump-parse-tree parameter in gfortran to display the internal syntax tree before starting the code generation.

0
source

All Articles