fortran-src 0.16.6 → 0.16.7
raw patch · 5 files changed
+28/−6 lines, 5 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- CHANGELOG.md +1/−1
- app/Main.hs +1/−1
- fortran-src.cabal +1/−1
- src/Language/Fortran/Parser/Free/Lexer.x +12/−3
- test/Language/Fortran/Parser/Free/Fortran2003Spec.hs +13/−0
CHANGELOG.md view
@@ -1,4 +1,4 @@-### 0.16.6+### 0.16.7 * Added mention of Fortran 2003 version support in the help message * Improved parsing of `allocate` statements
app/Main.hs view
@@ -51,7 +51,7 @@ programName = "fortran-src" showVersion :: String-showVersion = "0.16.6"+showVersion = "0.16.7" main :: IO () main = do
fortran-src.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack name: fortran-src-version: 0.16.6+version: 0.16.7 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
src/Language/Fortran/Parser/Free/Lexer.x view
@@ -450,11 +450,20 @@ | fillConstr TRightPar == toConstr tok = n - 1 | otherwise = n +-- Detect whether the current line is part of an allocate statement+-- (which may be prepended with other tokens, e.g., if this is an `if` statement+-- with aan allocate statement inside on a single line).+allocateStatement :: [Token] -> Maybe [Token]+allocateStatement (hd1:hd2:rest)+ | toConstr hd1 `elem` [fillConstr TAllocate, fillConstr TDeallocate]+ , toConstr hd2 == fillConstr TLeftPar+ = Just rest+ | otherwise = allocateStatement (hd2:rest)+allocateStatement _ = Nothing+ allocateP :: User -> AlexInput -> Int -> AlexInput -> Bool allocateP _ _ _ ai- | alloc:lpar:rest <- prevTokens- , toConstr alloc `elem` [fillConstr TAllocate, fillConstr TDeallocate]- , fillConstr TLeftPar == toConstr lpar+ | Just rest <- allocateStatement (prevTokens) = null rest || (followsComma && parenLevel prevTokens == 1) | otherwise = False where
test/Language/Fortran/Parser/Free/Fortran2003Spec.hs view
@@ -180,4 +180,17 @@ expBinVars op x1 x2 = ExpBinary () u op (expValVar x1) (expValVar x2) bParser text `shouldBe'` expected + describe "allocate statement" $ do+ it "parses allocated nested in another statement" $ do+ let text = "if(y) allocate(x,stat=ierr_allocate)"+ let expected = StIfLogical () u+ (ExpValue () u (ValVariable "y")) (StAllocate () u Nothing+ (AList {alistAnno = (),+ alistSpan = u,+ alistList = [ExpValue () u (ValVariable "x")]})+ (Just AList {alistAnno = (),+ alistSpan = u,+ alistList = [AOStat () u (ExpValue () u (ValVariable "ierr_allocate"))]}))+ sParser text `shouldBe'` expected+ specFreeCommon bParser sParser eParser