fortran-src 0.16.5 → 0.16.6
raw patch · 11 files changed
+546/−6 lines, 11 filesbinary-addedPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- CHANGELOG.md +5/−1
- README.md +1/−1
- app/Main.hs +2/−2
- fortran-src.cabal +9/−2
- test-data/module/leaf.mod binary
- test-data/pragma.f90 +30/−0
- test-data/pragma.f90.expected +292/−0
- test-data/small.f90 +17/−0
- test-data/small.f90.expected +175/−0
- test-data/st.expected +10/−0
- test-data/st2.expected +5/−0
CHANGELOG.md view
@@ -1,4 +1,8 @@-### 0.16.5 [in preparation]+### 0.16.6+ * Added mention of Fortran 2003 version support in the help message+ * Improved parsing of `allocate` statements++### 0.16.5 * Small fix to Fortran 2003 parsing around `procedure` statements. ### 0.16.4 (Feb 07, 2025)
README.md view
@@ -59,7 +59,7 @@ ``` Usage: fortran-src [OPTION...] <file> --version show fortran-src version- -v VERSION, -F VERSION --fortranVersion=VERSION Fortran version to use, format: Fortran[66/77/77Legacy/77Extended/90]+ -v VERSION, -F VERSION --fortranVersion=VERSION Fortran version to use, format: Fortran[66/77/77Legacy/77Extended/90/2003] -a ACTION --action=ACTION choose the action, possible values: lex|parse -t --typecheck parse and run typechecker -R --rename parse and rename variables
app/Main.hs view
@@ -51,7 +51,7 @@ programName = "fortran-src" showVersion :: String-showVersion = "0.16.5"+showVersion = "0.16.6" main :: IO () main = do@@ -348,7 +348,7 @@ , Option ['v','F'] ["fortranVersion"] (ReqArg (\v opts -> opts { fortranVersion = selectFortranVersion v }) "VERSION")- "Fortran version to use, format: Fortran[66/77/77Legacy/77Extended/90]"+ "Fortran version to use, format: Fortran[66/77/77Legacy/77Extended/90/2003]" , Option ['a'] ["action"] (ReqArg (\a opts -> opts { action = read a }) "ACTION")
fortran-src.cabal view
@@ -1,11 +1,11 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.36.0.+-- This file has been generated from package.yaml by hpack version 0.38.0. -- -- see: https://github.com/sol/hpack name: fortran-src-version: 0.16.5+version: 0.16.6 synopsis: Parsers and analyses for Fortran standards 66, 77, 90, 95 and 2003 (partial). description: Provides lexing, parsing, and basic analyses of Fortran code covering standards: FORTRAN 66, FORTRAN 77, Fortran 90, Fortran 95, Fortran 2003 (partial) and some legacy extensions. Includes data flow and basic block analysis, a renamer, and type analysis. For example usage, see the @<https://hackage.haskell.org/package/camfort CamFort>@ project, which uses fortran-src as its front end. category: Language@@ -27,9 +27,12 @@ test-data/f77-include/foo.f test-data/f77-include/no-newline/foo.f test-data/module/leaf.f90+ test-data/module/leaf.mod test-data/module/mid1.f90 test-data/module/mid2.f90 test-data/module/top.f90+ test-data/pragma.f90+ test-data/pragma.f90.expected test-data/rewriter/replacementsmap-columnlimit/001_foo.f test-data/rewriter/replacementsmap-columnlimit/001_foo.f.expected test-data/rewriter/replacementsmap-columnlimit/002_other.f@@ -61,6 +64,10 @@ test-data/rewriter/replacementsmap-simple/005_unicode.f test-data/rewriter/replacementsmap-simple/005_unicode.f.expected test-data/rewriter/temp-failure/fail.f+ test-data/small.f90+ test-data/small.f90.expected+ test-data/st.expected+ test-data/st2.expected source-repository head type: git
+ test-data/module/leaf.mod view
binary file changed (absent → 215 bytes)
+ test-data/pragma.f90 view
@@ -0,0 +1,30 @@+module foo+ implicit none+ != unit s :: j+ integer :: j+#ifdef PRAGMALAND+ use iso_c_binding+#endif+ != unit t :: k+ integer :: k++!! Example with a CPP ifdef+ contains+ subroutine main()+ integer :: x+ x = simple(k) + simple(1)+ x = simple(j)+ end subroutine+ function simple(x) result(i)+ integer :: x+ integer :: i+ i = x * x+ ! thest+#ifdef CAM_PROFILE+ print *, "Hello from simple"+ i = i + 0+#endif+ ! thingummy+ print *, "Hello from simple"+ end function+end module
+ test-data/pragma.f90.expected view
@@ -0,0 +1,292 @@+ProgramFile {programFileMeta = MetaInfo {miVersion = Fortran90,+ miFilename = "test-data/pragma.f90"},+ programFileProgramUnits = [PUModule ()+ (1:0)-(30:9)+ "foo"+ [BlStatement ()+ (2:2)-(2:14)+ Nothing+ (StImplicit ()+ (2:2)-(2:14)+ Nothing),+ BlComment ()+ (3:2)-(3:15)+ (Comment "= unit s :: j"),+ BlStatement ()+ (4:2)-(4:13)+ Nothing+ (StDeclaration ()+ (4:2)-(4:13)+ (TypeSpec+ {typeSpecAnno = (),+ typeSpecSpan = (4:2)-(4:8),+ typeSpecBaseType = TypeInteger,+ typeSpecSelector = Nothing})+ Nothing+ (AList+ {alistAnno = (),+ alistSpan = (4:13)-(4:13),+ alistList = [Declarator {declaratorAnno = (),+ declaratorSpan = (4:13)-(4:13),+ declaratorVariable = ExpValue ()+ (4:13)-(4:13)+ (ValVariable "j"),+ declaratorType = ScalarDecl,+ declaratorLength = Nothing,+ declaratorInitial = Nothing}]})),+ BlStatement ()+ (6:2)-(6:18)+ Nothing+ (StUse ()+ (6:2)-(6:18)+ (ExpValue ()+ (6:6)-(6:18)+ (ValVariable "iso_c_binding"))+ Nothing+ Permissive+ Nothing),+ BlComment ()+ (8:2)-(8:15)+ (Comment "= unit t :: k"),+ BlStatement ()+ (9:2)-(9:13)+ Nothing+ (StDeclaration ()+ (9:2)-(9:13)+ (TypeSpec+ {typeSpecAnno = (),+ typeSpecSpan = (9:2)-(9:8),+ typeSpecBaseType = TypeInteger,+ typeSpecSelector = Nothing})+ Nothing+ (AList+ {alistAnno = (),+ alistSpan = (9:13)-(9:13),+ alistList = [Declarator {declaratorAnno = (),+ declaratorSpan = (9:13)-(9:13),+ declaratorVariable = ExpValue ()+ (9:13)-(9:13)+ (ValVariable "k"),+ declaratorType = ScalarDecl,+ declaratorLength = Nothing,+ declaratorInitial = Nothing}]})),+ BlComment ()+ (11:0)-(11:26)+ (Comment "! example with a cpp ifdef")]+ (Just [PUSubroutine ()+ (13:4)-(17:17)+ (Nothing,+ Nothing)+ "main"+ Nothing+ [BlStatement ()+ (14:6)-(14:17)+ Nothing+ (StDeclaration ()+ (14:6)-(14:17)+ (TypeSpec+ {typeSpecAnno = (),+ typeSpecSpan = (14:6)-(14:12),+ typeSpecBaseType = TypeInteger,+ typeSpecSelector = Nothing})+ Nothing+ (AList+ {alistAnno = (),+ alistSpan = (14:17)-(14:17),+ alistList = [Declarator {declaratorAnno = (),+ declaratorSpan = (14:17)-(14:17),+ declaratorVariable = ExpValue ()+ (14:17)-(14:17)+ (ValVariable "x"),+ declaratorType = ScalarDecl,+ declaratorLength = Nothing,+ declaratorInitial = Nothing}]})),+ BlStatement ()+ (15:6)-(15:30)+ Nothing+ (StExpressionAssign ()+ (15:6)-(15:30)+ (ExpValue ()+ (15:6)-(15:6)+ (ValVariable "x"))+ (ExpBinary ()+ (15:10)-(15:30)+ Addition+ (ExpFunctionCall ()+ (15:10)-(15:18)+ (ExpValue ()+ (15:10)-(15:15)+ (ValVariable "simple"))+ (AList+ {alistAnno = (),+ alistSpan = (15:17)-(15:17),+ alistList = [Argument {argumentAnno = (),+ argumentSpan = (15:17)-(15:17),+ argumentName = Nothing,+ argumentExpr = ArgExpr (ExpValue ()+ (15:17)-(15:17)+ (ValVariable "k"))}]}))+ (ExpFunctionCall ()+ (15:22)-(15:30)+ (ExpValue ()+ (15:22)-(15:27)+ (ValVariable "simple"))+ (AList+ {alistAnno = (),+ alistSpan = (15:29)-(15:29),+ alistList = [Argument {argumentAnno = (),+ argumentSpan = (15:29)-(15:29),+ argumentName = Nothing,+ argumentExpr = ArgExpr (ExpValue ()+ (15:29)-(15:29)+ (ValInteger "1"+ Nothing))}]})))),+ BlStatement ()+ (16:6)-(16:18)+ Nothing+ (StExpressionAssign ()+ (16:6)-(16:18)+ (ExpValue ()+ (16:6)-(16:6)+ (ValVariable "x"))+ (ExpFunctionCall ()+ (16:10)-(16:18)+ (ExpValue ()+ (16:10)-(16:15)+ (ValVariable "simple"))+ (AList+ {alistAnno = (),+ alistSpan = (16:17)-(16:17),+ alistList = [Argument {argumentAnno = (),+ argumentSpan = (16:17)-(16:17),+ argumentName = Nothing,+ argumentExpr = ArgExpr (ExpValue ()+ (16:17)-(16:17)+ (ValVariable "j"))}]})))]+ Nothing,+ PUFunction ()+ (18:4)-(29:15)+ Nothing+ (Nothing,+ Nothing)+ "simple"+ (Just AList {alistAnno = (),+ alistSpan = (18:20)-(18:20),+ alistList = [ExpValue ()+ (18:20)-(18:20)+ (ValVariable "x")]})+ (Just ExpValue ()+ (18:30)-(18:30)+ (ValVariable "i"))+ [BlStatement ()+ (19:8)-(19:19)+ Nothing+ (StDeclaration ()+ (19:8)-(19:19)+ (TypeSpec+ {typeSpecAnno = (),+ typeSpecSpan = (19:8)-(19:14),+ typeSpecBaseType = TypeInteger,+ typeSpecSelector = Nothing})+ Nothing+ (AList+ {alistAnno = (),+ alistSpan = (19:19)-(19:19),+ alistList = [Declarator {declaratorAnno = (),+ declaratorSpan = (19:19)-(19:19),+ declaratorVariable = ExpValue ()+ (19:19)-(19:19)+ (ValVariable "x"),+ declaratorType = ScalarDecl,+ declaratorLength = Nothing,+ declaratorInitial = Nothing}]})),+ BlStatement ()+ (20:8)-(20:19)+ Nothing+ (StDeclaration ()+ (20:8)-(20:19)+ (TypeSpec+ {typeSpecAnno = (),+ typeSpecSpan = (20:8)-(20:14),+ typeSpecBaseType = TypeInteger,+ typeSpecSelector = Nothing})+ Nothing+ (AList+ {alistAnno = (),+ alistSpan = (20:19)-(20:19),+ alistList = [Declarator {declaratorAnno = (),+ declaratorSpan = (20:19)-(20:19),+ declaratorVariable = ExpValue ()+ (20:19)-(20:19)+ (ValVariable "i"),+ declaratorType = ScalarDecl,+ declaratorLength = Nothing,+ declaratorInitial = Nothing}]})),+ BlStatement ()+ (21:8)-(21:16)+ Nothing+ (StExpressionAssign ()+ (21:8)-(21:16)+ (ExpValue ()+ (21:8)-(21:8)+ (ValVariable "i"))+ (ExpBinary ()+ (21:12)-(21:16)+ Multiplication+ (ExpValue ()+ (21:12)-(21:12)+ (ValVariable "x"))+ (ExpValue ()+ (21:16)-(21:16)+ (ValVariable "x")))),+ BlComment ()+ (22:8)-(22:14)+ (Comment " thest"),+ BlStatement ()+ (24:8)-(24:35)+ Nothing+ (StPrint ()+ (24:8)-(24:35)+ (ExpValue ()+ (24:14)-(24:14)+ ValStar)+ (Just AList {alistAnno = (),+ alistSpan = (24:17)-(24:35),+ alistList = [ExpValue ()+ (24:17)-(24:35)+ (ValString "Hello from simple")]})),+ BlStatement ()+ (25:8)-(25:16)+ Nothing+ (StExpressionAssign ()+ (25:8)-(25:16)+ (ExpValue ()+ (25:8)-(25:8)+ (ValVariable "i"))+ (ExpBinary ()+ (25:12)-(25:16)+ Addition+ (ExpValue ()+ (25:12)-(25:12)+ (ValVariable "i"))+ (ExpValue ()+ (25:16)-(25:16)+ (ValInteger "0"+ Nothing)))),+ BlComment ()+ (27:8)-(27:18)+ (Comment " thingummy"),+ BlStatement ()+ (28:8)-(28:35)+ Nothing+ (StPrint ()+ (28:8)-(28:35)+ (ExpValue ()+ (28:14)-(28:14)+ ValStar)+ (Just AList {alistAnno = (),+ alistSpan = (28:17)-(28:35),+ alistList = [ExpValue ()+ (28:17)-(28:35)+ (ValString "Hello from simple")]}))]+ Nothing])]}
+ test-data/small.f90 view
@@ -0,0 +1,17 @@+module foo+ implicit none+ ! comment+ integer :: i+ #ifdef PRAGMALAND+ use iso_c_binding+#endif+contains+subroutine main()+ integer :: x+ x = simple(k) + simple(1)+ x = simple(j)+end subroutine+function simple(x) result(i)+ integer :: x+end function+end module
+ test-data/small.f90.expected view
@@ -0,0 +1,175 @@+ProgramFile {programFileMeta = MetaInfo {miVersion = Fortran90,+ miFilename = "test-data/small.f90"},+ programFileProgramUnits = [PUModule ()+ (1:0)-(17:9)+ "foo"+ [BlStatement ()+ (2:2)-(2:14)+ Nothing+ (StImplicit ()+ (2:2)-(2:14)+ Nothing),+ BlComment ()+ (3:2)-(3:10)+ (Comment " comment"),+ BlStatement ()+ (4:2)-(4:13)+ Nothing+ (StDeclaration ()+ (4:2)-(4:13)+ (TypeSpec+ {typeSpecAnno = (),+ typeSpecSpan = (4:2)-(4:8),+ typeSpecBaseType = TypeInteger,+ typeSpecSelector = Nothing})+ Nothing+ (AList+ {alistAnno = (),+ alistSpan = (4:13)-(4:13),+ alistList = [Declarator {declaratorAnno = (),+ declaratorSpan = (4:13)-(4:13),+ declaratorVariable = ExpValue ()+ (4:13)-(4:13)+ (ValVariable "i"),+ declaratorType = ScalarDecl,+ declaratorLength = Nothing,+ declaratorInitial = Nothing}]})),+ BlStatement ()+ (6:2)-(6:18)+ Nothing+ (StUse ()+ (6:2)-(6:18)+ (ExpValue ()+ (6:6)-(6:18)+ (ValVariable "iso_c_binding"))+ Nothing+ Permissive+ Nothing)]+ (Just [PUSubroutine ()+ (9:0)-(13:13)+ (Nothing,+ Nothing)+ "main"+ Nothing+ [BlStatement ()+ (10:2)-(10:13)+ Nothing+ (StDeclaration ()+ (10:2)-(10:13)+ (TypeSpec+ {typeSpecAnno = (),+ typeSpecSpan = (10:2)-(10:8),+ typeSpecBaseType = TypeInteger,+ typeSpecSelector = Nothing})+ Nothing+ (AList+ {alistAnno = (),+ alistSpan = (10:13)-(10:13),+ alistList = [Declarator {declaratorAnno = (),+ declaratorSpan = (10:13)-(10:13),+ declaratorVariable = ExpValue ()+ (10:13)-(10:13)+ (ValVariable "x"),+ declaratorType = ScalarDecl,+ declaratorLength = Nothing,+ declaratorInitial = Nothing}]})),+ BlStatement ()+ (11:2)-(11:26)+ Nothing+ (StExpressionAssign ()+ (11:2)-(11:26)+ (ExpValue ()+ (11:2)-(11:2)+ (ValVariable "x"))+ (ExpBinary ()+ (11:6)-(11:26)+ Addition+ (ExpFunctionCall ()+ (11:6)-(11:14)+ (ExpValue ()+ (11:6)-(11:11)+ (ValVariable "simple"))+ (AList+ {alistAnno = (),+ alistSpan = (11:13)-(11:13),+ alistList = [Argument {argumentAnno = (),+ argumentSpan = (11:13)-(11:13),+ argumentName = Nothing,+ argumentExpr = ArgExpr (ExpValue ()+ (11:13)-(11:13)+ (ValVariable "k"))}]}))+ (ExpFunctionCall ()+ (11:18)-(11:26)+ (ExpValue ()+ (11:18)-(11:23)+ (ValVariable "simple"))+ (AList+ {alistAnno = (),+ alistSpan = (11:25)-(11:25),+ alistList = [Argument {argumentAnno = (),+ argumentSpan = (11:25)-(11:25),+ argumentName = Nothing,+ argumentExpr = ArgExpr (ExpValue ()+ (11:25)-(11:25)+ (ValInteger "1"+ Nothing))}]})))),+ BlStatement ()+ (12:2)-(12:14)+ Nothing+ (StExpressionAssign ()+ (12:2)-(12:14)+ (ExpValue ()+ (12:2)-(12:2)+ (ValVariable "x"))+ (ExpFunctionCall ()+ (12:6)-(12:14)+ (ExpValue ()+ (12:6)-(12:11)+ (ValVariable "simple"))+ (AList+ {alistAnno = (),+ alistSpan = (12:13)-(12:13),+ alistList = [Argument {argumentAnno = (),+ argumentSpan = (12:13)-(12:13),+ argumentName = Nothing,+ argumentExpr = ArgExpr (ExpValue ()+ (12:13)-(12:13)+ (ValVariable "j"))}]})))]+ Nothing,+ PUFunction ()+ (14:0)-(16:11)+ Nothing+ (Nothing,+ Nothing)+ "simple"+ (Just AList {alistAnno = (),+ alistSpan = (14:16)-(14:16),+ alistList = [ExpValue ()+ (14:16)-(14:16)+ (ValVariable "x")]})+ (Just ExpValue ()+ (14:26)-(14:26)+ (ValVariable "i"))+ [BlStatement ()+ (15:2)-(15:13)+ Nothing+ (StDeclaration ()+ (15:2)-(15:13)+ (TypeSpec+ {typeSpecAnno = (),+ typeSpecSpan = (15:2)-(15:8),+ typeSpecBaseType = TypeInteger,+ typeSpecSelector = Nothing})+ Nothing+ (AList+ {alistAnno = (),+ alistSpan = (15:13)-(15:13),+ alistList = [Declarator {declaratorAnno = (),+ declaratorSpan = (15:13)-(15:13),+ declaratorVariable = ExpValue ()+ (15:13)-(15:13)+ (ValVariable "x"),+ declaratorType = ScalarDecl,+ declaratorLength = Nothing,+ declaratorInitial = Nothing}]}))]+ Nothing])]}
+ test-data/st.expected view
@@ -0,0 +1,10 @@+(StPrint ()+ (24:8)-(24:35)+ (ExpValue ()+ (24:14)-(24:14)+ ValStar)+ (Just AList {alistAnno = (),+ alistSpan = (24:17)-(24:35),+ alistList = [ExpValue ()+ (24:17)-(24:35)+ (ValString "Hello from simple")]}))
+ test-data/st2.expected view
@@ -0,0 +1,5 @@+TypeSpec+ {typeSpecAnno = (),+ typeSpecSpan = (4:2)-(4:8),+ typeSpecBaseType = TypeInteger,+ typeSpecSelector = Nothing}