You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+8Lines changed: 8 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -453,6 +453,14 @@ The parser exposes stable file/project entrypoints:
453
453
-`parse_fortran_project(...)` for many sources returning `FortranProject`.
454
454
-`assess_wrap_readiness(...)` for wrappability diagnostics.
455
455
456
+
Internally, `FortranParser.visit_file` uses a recursive source-unit parser:
457
+
the file is sliced into direct modules/submodules/programs/procedures/block
458
+
data/interfaces/types, then each unit visitor parses only its own substring and
459
+
recurses into direct children. Shared declaration helpers parse variables,
460
+
procedure arguments/results, and type fields, then push them into the active
461
+
scope. Procedure execution bodies and internal subprograms are ignored for
462
+
wrapper metadata; procedure-local interfaces are retained for callback typing.
463
+
456
464
The semantics layer consumes `FortranFile`/`FortranModule` objects and projects them into language-independent semantic IR (`SemanticModule`, `SemanticFunction`, `SemanticClass`, `SemanticType`). This keeps the semantic API model independent from parser internals, matching the project goal that parser output is a helper and the semantic interface/IR is the source of truth.
457
465
458
466
For Fortran `use` imports, the parser stores each explicit imported symbol as a
- The parser does **not** run a full C preprocessor stage before parsing.
494
-
- While scanning signatures, simple directive structure is tracked for `#ifdef`, `#ifndef`, `#elif`, `#else`, and `#endif` to model mutually-exclusive branches.
495
-
-`visit_file(..., macro_defines=...)` can provide macro decisions; inactive conditional branches are skipped during signature extraction so the active code path is selected. The module-level `parse_fortran_file(...)` convenience function delegates to this visitor.
508
+
- While slicing source units, simple directive structure is tracked for
509
+
`#ifdef`, `#ifndef`, `#elif`, `#else`, and `#endif` to model
510
+
mutually-exclusive branches.
511
+
-`visit_file(..., macro_defines=...)` can provide macro decisions; inactive conditional branches are skipped before unit parsing so the active code path is selected. The module-level `parse_fortran_file(...)` convenience function delegates to this visitor.
496
512
- accepted forms: `set[str]` or `dict[str, int|bool|str]`
497
513
- dictionary values are truthy/falsey (`0`, `False`, `"0"`, `"false"` treated as undefined/disabled)
498
514
- Basic `#if` expressions are supported for branch selection (`defined(X)`, `!`, `&&`, `||`, parentheses, `0`/`1`).
499
-
- Duplicate procedure-name checks in a module/global scope are evaluated against this branch context:
515
+
- Duplicate procedure-name checks in a module/global scope are evaluated
516
+
against same-level sliced units and this branch context:
500
517
- if two same-name procedure headers are reachable in an overlapping branch context, raise `FortranParseError` (duplicate procedure name).
501
518
- if they are only present in mutually-exclusive branches of the same conditional group, allow both signatures.
502
519
- This is a structural exclusivity model (branch groups), not semantic evaluation of macro expressions. In other words, branch mutual exclusivity is honored without requiring expression truth evaluation.
0 commit comments