Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Appetite for common Fortran parsing library? #205

Open
ZedThree opened this issue Sep 3, 2021 · 3 comments
Open

Appetite for common Fortran parsing library? #205

ZedThree opened this issue Sep 3, 2021 · 3 comments

Comments

@ZedThree
Copy link

ZedThree commented Sep 3, 2021

Along with the original developer @cmacmackin, I'm one of the maintainers on FORD, a Fortran documentation generator, and our parsing module is starting to get a bit old and creaky.

Is there any appetite among the fortls developers to work on a common parsing library that both our tools could use? There are a few other tools such as fprettify that might also benefit from having such a library.

@cmacmackin
Copy link

cmacmackin commented Sep 3, 2021 via email

@michaelkonecny
Copy link
Contributor

michaelkonecny commented Sep 3, 2021

Are you guys aware of LFortran?
It says it can now parse any Fortran 2018 syntax to an Abstract Syntax Tree and format it back.
Maybe it could be useful somehow.

I didn't have a chance to test it yet, but I'm a big fan of the author's (Ondřej Čertík's) efforts (also fortran-lang.org).

@cmacmackin
Copy link

I've examined the source code for both LFortran and Flang. My conclusion is that, while LFortran is quicker and easier to build the code looks much harder to understand and develop. Parts of it appear to be written more like C than C++. Flang has some slightly unintuitive bits but is very much written according to modern C++ conventions, making it much easier to follow. It also already seems to have quite a good ability to extract information on all of the symbols defined in the code. Another advantage of Flang is that it provides much better information about locations in source files, properly accounting for included files, line continuations, etc (whereas Lfortran just normalises everything to be like a single file without line continuations and gives line numbers based on this). The main downside of Flang is that the contribution process looks more difficult, should any modification to the main library be required (discussion occurs via mailing lists, contributors send in patches, etc.). The biggest thing that would need changing would be pulling out comments from source code (Flang doesn't do this but there is an approach we could borrow from Clang) and to do this efficiently I'm pretty sure would require modifying Flang itself (or else doing some sort of monkey-patching by hacking include and link paths at build-time).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants