fortran-src 0.6.0 → 0.6.1
raw patch · 38 files changed
+310/−33 lines, 38 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- CHANGELOG.md +4/−0
- LICENSE +2/−2
- README.md +63/−21
- fortran-src.cabal +31/−1
- src/Language/Fortran/Analysis/Types.hs +3/−3
- test-data/f77-include/foo.f +1/−0
- test-data/rewriter/replacementsmap-columnlimit/001_foo.f +5/−0
- test-data/rewriter/replacementsmap-columnlimit/001_foo.f.expected +6/−0
- test-data/rewriter/replacementsmap-columnlimit/002_other.f +6/−0
- test-data/rewriter/replacementsmap-columnlimit/002_other.f.expected +7/−0
- test-data/rewriter/replacementsmap-columnlimit/003_multiline.f +6/−0
- test-data/rewriter/replacementsmap-columnlimit/003_multiline.f.expected +8/−0
- test-data/rewriter/replacementsmap-columnlimit/004_comment.f +11/−0
- test-data/rewriter/replacementsmap-columnlimit/004_comment.f.expected +12/−0
- test-data/rewriter/replacementsmap-columnlimit/005_removals.f +18/−0
- test-data/rewriter/replacementsmap-columnlimit/005_removals.f.expected +18/−0
- test-data/rewriter/replacementsmap-columnlimit/006_linewrap_heuristic.f +16/−0
- test-data/rewriter/replacementsmap-columnlimit/006_linewrap_heuristic.f.expected +21/−0
- test-data/rewriter/replacementsmap-insertion/001_foo.f +3/−0
- test-data/rewriter/replacementsmap-insertion/001_foo.f.expected +4/−0
- test-data/rewriter/replacementsmap-overlapping-filtered/001_foo.f +3/−0
- test-data/rewriter/replacementsmap-overlapping-filtered/001_foo.f.expected +3/−0
- test-data/rewriter/replacementsmap-overlapping/001_foo.f +3/−0
- test-data/rewriter/replacementsmap-overlapping/001_foo.f.expected +3/−0
- test-data/rewriter/replacementsmap-simple/001_foo.f +4/−0
- test-data/rewriter/replacementsmap-simple/001_foo.f.expected +4/−0
- test-data/rewriter/replacementsmap-simple/002_foo.f +4/−0
- test-data/rewriter/replacementsmap-simple/002_foo.f.expected +4/−0
- test-data/rewriter/replacementsmap-simple/003_foo.f +6/−0
- test-data/rewriter/replacementsmap-simple/003_foo.f.expected +6/−0
- test-data/rewriter/replacementsmap-simple/004_unicode.f +5/−0
- test-data/rewriter/replacementsmap-simple/004_unicode.f.expected +5/−0
- test-data/rewriter/replacementsmap-simple/005_unicode.f +5/−0
- test-data/rewriter/replacementsmap-simple/005_unicode.f.expected +5/−0
- test-data/rewriter/temp-failure/fail.f +3/−0
- test/Language/Fortran/Parser/Fortran77/IncludeSpec.hs +1/−1
- test/Language/Fortran/PrettyPrintSpec.hs +0/−4
- test/Language/Fortran/RewriterSpec.hs +1/−1
CHANGELOG.md view
@@ -1,3 +1,7 @@+### 0.6.1 (Sep 17, 2021)+ * Properly include test data in package dist (in preparation for placing on+ Stackage)+ ### 0.6.0 (Sep 03, 2021) * IF and CASE block constructs are now parsed as blocks at parsing instead of as a post-parse transformation (no intermediate statement representation)
LICENSE view
@@ -1,6 +1,6 @@-Copyright (c) 2015-2019: Mistral Contrastin, Matthew Danish, Dominic Orchard and Andrew Rice+Copyright (c) 2015-2021: Mistral Contrastin, Matthew Danish, Dominic Orchard and Andrew Rice -Additional thanks for contributions from: Anthony Burzillo, Azeem Bande-Ali, Ben Moon, Bradley Hardy, Eric Seidel, Harry Clarke, Jason Xu, Lukasz Kolodziejczyk, Raoul Charman, TravelTissues and Vaibhav Yenamandra+Additional thanks for contributions from: Anthony Burzillo, Azeem Bande-Ali, Ben Moon, Bradley Hardy, Eric Seidel, Harry Clarke, Jason Xu, Lukasz Kolodziejczyk, Raoul Charman, TravelTissues, Vaibhav Yenamandra and Ben Orchard Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
README.md view
@@ -21,16 +21,73 @@ --show-flows-to=AST-BLOCK-ID dump a graph showing flows-to information from the given AST-block ID; prefix with 's' for supergraph --show-flows-from=AST-BLOCK-ID dump a graph showing flows-from information from the given AST-block ID; prefix with 's' for supergraph -## Usage/Installation-fortran-src is available on Hackage. Stackage has a very old version and is-definitely not what you want, but you can specify a newer Hackage version in-`stack.yaml`.+## Building+fortran-src supports building with Stack or Cabal. You should be able to build+and use without any dependencies other than GHC itself. +As of 2021-04-28, fortran-src supports and is regularly tested on **GHC 8.6,+8.8, 8.10 and 9.0**. Releases prior to/newer than those may have issues. We+welcome fixes that would let us support a wider range of compilers.++You will likely need **at least 3 GiBs of memory** to build fortran-src.++For installing GHC and build tools, we strongly recommend+[ghcup](https://www.haskell.org/ghcup/).++When **latest recommended** is used, it means the latest version of the tool+that ghcup tags with `recommended`. This sometimes lags behind the+`latest`-tagged version. With ghcup installed, run `ghcup list` for a better+understanding.++Following are general guides for any OS that provides the relevant tools. If you+have trouble, consider checking the CI workflow files in `.github/workflows`.++### Stack+We support the latest recommended version of Stack (as of 2021-09-17, Stack+2.7). Generally, any Stack 2.x should work. *(Stack 1.x may work with minor+alternations -- you may have to download the resolver manually.)*++```+stack build+```++For an interactive shell:++```+stack build+stack ghci+```++Note that running `stack ghci` before running `stack build` won't work properly,+due to `stack ghci` not running build tools like Alex and Happy. So parser+modules will not be built, and you'll receive an error after building the other+modules. You can cheat a bit and run `stack build` until you see `Building+library for [...]` (= preprocessing has finished), then hit `<Ctrl-C>` to stop+the build and run `stack ghci` as usual.++### Cabal+We support the latest recommended version of Cabal (as of 2021-09-17, Cabal 3.4)++```+cabal build+```++## Usage ### As a dependency-Reference `fortran-src` in your (Stack/Cabal) project dependencies. If you're-using Stack, you can stuff a Hackage reference into `stack.yaml` using+fortran-src is available on Hackage, so add `fortran-src` to your project+dependencies. That's all.++If you're using Stack, note that Stackage retains an old version watch out,+because TODO++TODO you can stuff a Hackage reference into `stack.yaml` using `extra-deps`, like: +fortran-src is available on Hackage. Stackage has a very old version and is+definitely not what you want, but you can specify a newer Hackage version in+`stack.yaml` to use it conveniently with Stack-based projects.++ ```yaml resolver: ... ...@@ -50,18 +107,3 @@ Otherwise, we suggest building from source if you want to use the fortran-src CLI tool. See [#Build from source](#build-from-source) for details.--## Development-As of 2021-04-28, fortran-src supports and is regularly tested on **GHC 8.6,-8.8, 8.10 and 9.0**. Releases prior to/newer than those may have issues. We-welcome fixes that would let us support a wider range of compilers.--### Build from source-#### Stack-Stack 2.x is required. *(Stack 1.x may work with minor alternations--- you may have to download the resolver manually.)*--```-stack setup-stack build-```
fortran-src.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack name: fortran-src-version: 0.6.0+version: 0.6.1 synopsis: Parsers and analyses for Fortran standards 66, 77, 90 and 95. description: Provides lexing, parsing, and basic analyses of Fortran code covering standards: FORTRAN 66, FORTRAN 77, Fortran 90, and Fortran 95 and some legacy extensions. Includes data flow and basic block analysis, a renamer, and type analysis. For example usage, see the 'camfort' project, which uses fortran-src as its front end. category: Language@@ -19,6 +19,36 @@ extra-source-files: README.md CHANGELOG.md+ test-data/f77-include/foo.f+ 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+ test-data/rewriter/replacementsmap-columnlimit/002_other.f.expected+ test-data/rewriter/replacementsmap-columnlimit/003_multiline.f+ test-data/rewriter/replacementsmap-columnlimit/003_multiline.f.expected+ test-data/rewriter/replacementsmap-columnlimit/004_comment.f+ test-data/rewriter/replacementsmap-columnlimit/004_comment.f.expected+ test-data/rewriter/replacementsmap-columnlimit/005_removals.f+ test-data/rewriter/replacementsmap-columnlimit/005_removals.f.expected+ test-data/rewriter/replacementsmap-columnlimit/006_linewrap_heuristic.f+ test-data/rewriter/replacementsmap-columnlimit/006_linewrap_heuristic.f.expected+ test-data/rewriter/replacementsmap-insertion/001_foo.f+ test-data/rewriter/replacementsmap-insertion/001_foo.f.expected+ test-data/rewriter/replacementsmap-overlapping-filtered/001_foo.f+ test-data/rewriter/replacementsmap-overlapping-filtered/001_foo.f.expected+ test-data/rewriter/replacementsmap-overlapping/001_foo.f+ test-data/rewriter/replacementsmap-overlapping/001_foo.f.expected+ test-data/rewriter/replacementsmap-simple/001_foo.f+ test-data/rewriter/replacementsmap-simple/001_foo.f.expected+ test-data/rewriter/replacementsmap-simple/002_foo.f+ test-data/rewriter/replacementsmap-simple/002_foo.f.expected+ test-data/rewriter/replacementsmap-simple/003_foo.f+ test-data/rewriter/replacementsmap-simple/003_foo.f.expected+ test-data/rewriter/replacementsmap-simple/004_unicode.f+ test-data/rewriter/replacementsmap-simple/004_unicode.f.expected+ test-data/rewriter/replacementsmap-simple/005_unicode.f+ test-data/rewriter/replacementsmap-simple/005_unicode.f.expected+ test-data/rewriter/temp-failure/fail.f source-repository head type: git
src/Language/Fortran/Analysis/Types.hs view
@@ -509,9 +509,9 @@ -- Set the idType annotation setIDType :: Annotated f => IDType -> f (Analysis a) -> f (Analysis a)-setIDType ty x- | a@Analysis {} <- getAnnotation x = setAnnotation (a { idType = Just ty }) x- | otherwise = x+setIDType ty x =+ let a = getAnnotation x+ in setAnnotation (a { idType = Just ty }) x -- Get the idType annotation getIDType :: (Annotated f, Data a) => f (Analysis a) -> Maybe IDType
+ test-data/f77-include/foo.f view
@@ -0,0 +1,1 @@+ integer a
+ test-data/rewriter/replacementsmap-columnlimit/001_foo.f view
@@ -0,0 +1,5 @@+ subroutine foo+ integer xxxxxxxxxxxxxxxxxxxxxxxxxx+ xxxxxxxxxxxxxxxxxxxxxxxxxx = 10+ if (xxxxxxxxxxxxxxxxxxxxxxxxxx .eq. 9) call bar+ end
+ test-data/rewriter/replacementsmap-columnlimit/001_foo.f.expected view
@@ -0,0 +1,6 @@+ subroutine foo+ integer xxxxxxxxxxxxxxxxxxxxxxxxxx+ xxxxxxxxxxxxxxxxxxxxxxxxxx = 10+ if (xxxxxxxxxxxxxxxxxxxxxxxxxx .eq. 999999999999999999999)+ + call bar+ end
+ test-data/rewriter/replacementsmap-columnlimit/002_other.f view
@@ -0,0 +1,6 @@+ subroutine foo+ integer aaaaa = 10+ integer xxxxxxxxxxxxxxxxxxxxxxxxxx+ xxxxxxxxxxxxxxxxxxxxxxxxxx = 10+ if (aaaaa .eq. 0 .and. xxxxxxxxxxxxxxxxxxxxxxxxxx .eq. 9) call bar+ end
+ test-data/rewriter/replacementsmap-columnlimit/002_other.f.expected view
@@ -0,0 +1,7 @@+ subroutine foo+ integer aaaaa = 10+ integer xxxxxxxxxxxxxxxxxxxxxxxxxx+ xxxxxxxxxxxxxxxxxxxxxxxxxx = 10+ if (aaaaa .eq. 0 .and. xxxxxxxxxxxxxxxxxxxxxxxxxx .eq. + +999999999999) call bar+ end
+ test-data/rewriter/replacementsmap-columnlimit/003_multiline.f view
@@ -0,0 +1,6 @@+ subroutine foo+ integer aaaaa = 10+ integer xxxxxxxxxxxxxxxxxxxxxxxxxx+ xxxxxxxxxxxxxxxxxxxxxxxxxx = 10+ if (aaaaa .eq. 0 .and. xxxxxxxxxxxxxxxxxxxxxxxxxx .eq. 9) call bar+ end
+ test-data/rewriter/replacementsmap-columnlimit/003_multiline.f.expected view
@@ -0,0 +1,8 @@+ subroutine foo+ integer aaaaa = 10+ integer xxxxxxxxxxxxxxxxxxxxxxxxxx+ xxxxxxxxxxxxxxxxxxxxxxxxxx = 10+ if (aaaaa .eq. 0 .and. xxxxxxxxxxxxxxxxxxxxxxxxxx .eq. 9 .and. + + 4 .lt. 4+ + .or. .true.) call bar+ end
+ test-data/rewriter/replacementsmap-columnlimit/004_comment.f view
@@ -0,0 +1,11 @@+c This is the API for foo subroutine. We take in some inputs, apply some cool things and return other things.+ subroutine foo+ integer*2 a ! This is my variable 'a' ... it stores numbers both larger and small+ CHARACTER*2 some_string(15)++ some_string = "some_string"++ if (foo) then+ IF (some_string(0).eq.'s') foo=9 Text after col 72 are comments and should remain+ endif+ end
+ test-data/rewriter/replacementsmap-columnlimit/004_comment.f.expected view
@@ -0,0 +1,12 @@+c This is the API for foo subroutine. We take in some inputs, apply some cool things and return other things.+ subroutine foo+ integer*2 foobar ! This is my variable 'a' ... it stores numbers both larger and small+ CHARACTER*2 some_string(15)++ some_string = "some_string"++ if (foo) then+ IF (xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx+ +(0).eq.'s') foo=9 Text after col 72 are comments and should remain+ endif+ end
+ test-data/rewriter/replacementsmap-columnlimit/005_removals.f view
@@ -0,0 +1,18 @@+ REAL*8 FUNCTION foo_removals ()++ real*8 sec_rate(31),cur_rate(31),day_value,+ . month_rec_values(5,31),in_values(5),+ . blank(31)++ integer*4 somevalue1, somevalue2++ if (my_fn_call(1) .or. deadcode(2)+ . .and. my_fn_call2(somevalue1) .and. my_fn_call3(10))+ . then+ call process_things(1,2,3)+ endif++ foo_removals = 0++ return+ end
+ test-data/rewriter/replacementsmap-columnlimit/005_removals.f.expected view
@@ -0,0 +1,18 @@+ REAL*8 FUNCTION foo_removals ()++ real*8 sec_rate(31),cur_rate(31),+ +month_rec_values(5,31),in_values(5),+ . blank(31)++ integer*4 somevalue1, somevalue2++ if (my_fn_call(1) .or. + + my_fn_call2(somevalue1) .and. my_fn_call3(10))+ . then+ call process_things(1,2,3)+ endif++ foo_removals = 0++ return+ end
+ test-data/rewriter/replacementsmap-columnlimit/006_linewrap_heuristic.f view
@@ -0,0 +1,16 @@+ subroutine foo+ integer word, wrap_after_comma, wrap_after_right_paren+ logical accessor, TEST, LOGICAL2VAR+ if (accessor(word, wrap_after_comma)) call bar+ if (accessor(int(word), wrap_after_comma)) call bar+ if (accessor(int(int2(word)), wrap_after_comma)) call bar+ if (accessor(int(int2(word)))) call wrap_after_right_paren+ if (accessor(word)) call foo(bar)!don't wrap inline comment+ accessor(1) = TEST!inline comment not to be wrapped++ if(1) then+ LOGICAL2VAR = l2!other comment that shouldn't be wrapped+ !comments after 0! char replacements don't wrap!+ L!comments after replacements >0 chars don't wrap+ endif+ end
+ test-data/rewriter/replacementsmap-columnlimit/006_linewrap_heuristic.f.expected view
@@ -0,0 +1,21 @@+ subroutine foo+ integer word, wrap_after_comma, wrap_after_right_paren+ logical accessor, TEST, LOGICAL2VAR+ if (accessor(xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx,+ + wrap_after_comma)) call bar+ if (accessor(int(xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx),+ + wrap_after_comma)) call bar+ if (accessor(int(int2(xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx)),+ + wrap_after_comma)) call bar+ if (accessor(int(int2(xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx))))+ + call wrap_after_right_paren+ if (accessor(xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx))+ + call foo(bar)!don't wrap inline comment+ call testcommons_logarray_settori_findex(logical_1_to_4(test), 1)!inline comment not to be wrapped++ if(1) then+ call testcommons_set_logical2var(logical_2_to_4(l2))!other comment that shouldn't be wrapped+ call testcommons_set_logical2var(logical_2_to_4(l2))!comments after 0! char replacements don't wrap!+ call testcommons_set_logical2var(logical_2_to_4(l2))!comments after replacements >0 chars don't wrap+ endif+ end
+ test-data/rewriter/replacementsmap-insertion/001_foo.f view
@@ -0,0 +1,3 @@+ subroutine aaaa()+ end+
+ test-data/rewriter/replacementsmap-insertion/001_foo.f.expected view
@@ -0,0 +1,4 @@+ subroutine aaaa()+ call bbbb+ end+
+ test-data/rewriter/replacementsmap-overlapping-filtered/001_foo.f view
@@ -0,0 +1,3 @@+ subroutine aaaa()+ call bbbb+ end
+ test-data/rewriter/replacementsmap-overlapping-filtered/001_foo.f.expected view
@@ -0,0 +1,3 @@+ subroutine aaaa()+ call cccc+ end
+ test-data/rewriter/replacementsmap-overlapping/001_foo.f view
@@ -0,0 +1,3 @@+ subroutine aaaa()+ call bbbb+ end
+ test-data/rewriter/replacementsmap-overlapping/001_foo.f.expected view
@@ -0,0 +1,3 @@+ subroutine aaaa()+ call bbbb+ end
+ test-data/rewriter/replacementsmap-simple/001_foo.f view
@@ -0,0 +1,4 @@+ subroutine aaaa()+ call bbbb+ end+
+ test-data/rewriter/replacementsmap-simple/001_foo.f.expected view
@@ -0,0 +1,4 @@+ subroutine aaaa()+ call cccc+ end+
+ test-data/rewriter/replacementsmap-simple/002_foo.f view
@@ -0,0 +1,4 @@+ subroutine aaaa()+ call bbbb+ end+
+ test-data/rewriter/replacementsmap-simple/002_foo.f.expected view
@@ -0,0 +1,4 @@+ subroutine aaaa()+ + end+
+ test-data/rewriter/replacementsmap-simple/003_foo.f view
@@ -0,0 +1,6 @@+ subroutine aaaa()+ call bbbb1++ call bbbb2+ end+
+ test-data/rewriter/replacementsmap-simple/003_foo.f.expected view
@@ -0,0 +1,6 @@+ subroutine aaaa()+ call cccc1++ call cccc2+ end+
+ test-data/rewriter/replacementsmap-simple/004_unicode.f view
@@ -0,0 +1,5 @@+ program main+ character*(*) CH33+ parameter(CH33 = 'LIFFE Euro S? FUTURES ANALYSIS')+ print *, z'deadbeef'+ end program main
+ test-data/rewriter/replacementsmap-simple/004_unicode.f.expected view
@@ -0,0 +1,5 @@+ program main+ character*(*) CH33+ parameter(CH33 = 'LIFFE Euro S? FUTURES ANALYSIS')+ print *, int(z'deadbeef')+ end program main
+ test-data/rewriter/replacementsmap-simple/005_unicode.f view
@@ -0,0 +1,5 @@+ subroutine a()+c BREG 314095: CONVERT SU12,13,15,17·+c BREG 314095: CONVERT SU12,13,15,17·+ print *, "check"+ end subroutine a
+ test-data/rewriter/replacementsmap-simple/005_unicode.f.expected view
@@ -0,0 +1,5 @@+ subroutine a()+c BREG 314095: CONVERT SU12,13,15,17·+c BREG 314095: CONVERT SU12,13,15,17·+ print *, "check"+ end subroutine a
+ test-data/rewriter/temp-failure/fail.f view
@@ -0,0 +1,3 @@+ subroutine foo+ print *, 'FAIL'+ end
test/Language/Fortran/Parser/Fortran77/IncludeSpec.hs view
@@ -24,7 +24,7 @@ " include 'foo.f'", " end" ]- inc = "./test/Language/Fortran/Parser"+ inc = "./test-data/f77-include" name = "bar" pf = ProgramFile mi77 [pu] puSpan = makeSrcR (6,7,1,"<unknown>") (48,9,3,"<unknown>")
test/Language/Fortran/PrettyPrintSpec.hs view
@@ -14,7 +14,6 @@ import Language.Fortran.ParserMonad import Language.Fortran.PrettyPrint -import System.FilePath import Text.PrettyPrint hiding ((<>)) import Text.PrettyPrint.GenericPretty @@ -28,9 +27,6 @@ $ mapM_ check inputs where inputs = catMaybes [ restrict b | b <- universeBi t :: [b] ]--samplesBase :: FilePath-samplesBase = "test" </> "Language" </> "Fortran" </> "samples" spec :: Spec spec =
test/Language/Fortran/RewriterSpec.hs view
@@ -429,7 +429,7 @@ -> [String] -> IO (String, String, Either ReplacementError ()) wrapReplacementsMapInvocationTestHelper_ invocation baseDir ctx files = do- let inputContextDir = baseDir ++ "/test/Language/Fortran/samples/rewriter/" ++ ctx+ let inputContextDir = baseDir ++ "/test-data/rewriter/" ++ ctx outputDir = baseDir ++ "/test/rewriter-test-output" outputContextDir = outputDir ++ "/" ++ ctx doesDirectoryExist outputDir