Could I use LLVM for parsing Fortran?
LLVM is a compiler backend. The only thing it knows how to parse is LLVM IR - an intermediate language designed to be emitted from programing language frontends. The official frontend for LLVM is Clang, which can handle C, C++ and ObjC. If you're interested in other languages, there's also DragonEgg, which is a LLVM plugin for gcc. It uses gcc's front-end and LLVM as a backend, so it can parse anything gcc knows how to parse. I know that work is being done on making it generate correct code from Ada and Fortran. Here's an excerpt from its page:
Current Status
- Works best with gcc-4.6.
- Fortran works very well. Ada, C and C++ also work well. Ada works poorly 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 don't execute properly (this is a consequence of the java front-end not supporting GCC's LTO).
- Debug info is poor.
No, LLVM is not a library for parsing Fortran. LLVM is a library for implementing the backend of a compiler. You would need to write the Fortran frontend yourself.