Open kaby76 opened 3 weeks ago
In practice include is handled by the preprocessor (after the C-like preprocessor has been applied). See for instance here: https://flang.llvm.org/docs/Preprocessing.html#in-short-a-fortran-preprocessor-should-work-as-if
Saving files with a capitalized extension, e.g. .F
or .F90
, will automatically invoke the C-like Fortran preprocessor that responds to statements like #include
, #define
and others. On the other hand include
always get processed, because it is a Fortran-specific mechanism.
The FortranLexer.g4 was copied from https://github.com/AkhilAkkapelli/Fortran2023Grammar/blob/553123a023f70e9a524e2a4036be128978834c42/Fortran2023Lexer.g4. But, it contains many problems.
Comments
The 2023 Spec clearly states:
INCLUDE
include
statements, but it is missing. (It is in the old Fortran90 grammar.)An INCLUDE line is not a Fortran statement.
However, the grammar needs rules for this, otherwise inputs may not parse. E.g., https://github.com/antlr/grammars-v4/blob/9d19a6d1a5a5819d809a7a940be39774675f3503/fortran/fortran90/examples/flang/test/f90_correct/src/ac02.f90#L7=>