Skip to content

Add support for parsing "floating" code#25

Merged
alvrogd merged 2 commits into
codeefrom
feature/ParseFloatingCode
Jan 28, 2026
Merged

Add support for parsing "floating" code#25
alvrogd merged 2 commits into
codeefrom
feature/ParseFloatingCode

Conversation

@alvrogd

@alvrogd alvrogd commented Jan 28, 2026

Copy link
Copy Markdown

This PR updates the grammar to allow specification parts and executable statements at top-level, in addition to the usually allowed Fortran items. This is particularly useful for parsing include files, which typically contain fragments of code rather than complete Fortran translation units.

Note: I've tested the updated grammar in the SIESTA project. No parsing regressions were introduced.

@alvrogd alvrogd self-assigned this Jan 28, 2026
Comment thread grammar.js Outdated
@alvrogd alvrogd force-pushed the feature/ParseFloatingCode branch from 9464798 to 6f3d78c Compare January 28, 2026 13:08
@alvrogd alvrogd marked this pull request as ready for review January 28, 2026 13:13
@alvrogd alvrogd requested review from a team, d-alonso and jgonzac and removed request for a team January 28, 2026 13:14

@d-alonso d-alonso left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks very nice

Comment thread grammar.js Outdated

@inaki-amatria inaki-amatria left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment thread test/corpus/line_continuations.txt
Comment thread test/corpus/floating.txt
Comment thread grammar.js
Comment thread test/corpus/statements.txt
@alvrogd alvrogd force-pushed the feature/ParseFloatingCode branch from 6f3d78c to 348768f Compare January 28, 2026 15:34
It seems that there was a slip in the previous merge point, and the test
was left as is in upstream, without applying to the expected output the
modifications from the patches in this fork.
@alvrogd alvrogd force-pushed the feature/ParseFloatingCode branch from 348768f to 169c985 Compare January 28, 2026 16:31
The goal is to allow specification parts and executable statements at
top-level, in addition to the usually allowed Fortran items. This is
particularly useful for parsing include files, which typically contain
fragments of code rather than complete Fortran translation units.

Incomplete blocks of code, such as partial derived type declarations or
do loops, will still trigger parsing errors.
@alvrogd alvrogd force-pushed the feature/ParseFloatingCode branch from 169c985 to d0c100a Compare January 28, 2026 16:31
@alvrogd alvrogd merged commit d0c100a into codee Jan 28, 2026
1 check passed
@inaki-amatria inaki-amatria deleted the feature/ParseFloatingCode branch January 29, 2026 08:06
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

Successfully merging this pull request may close these issues.

3 participants