Skip to content

Commit

Permalink
refactor DoSpec to not use Statement
Browse files Browse the repository at this point in the history
This removes `Expression`'s mutual recursion with `Statement`.
  • Loading branch information
raehik committed May 10, 2022
1 parent 3bee475 commit e2a4ebe
Show file tree
Hide file tree
Showing 16 changed files with 94 additions and 117 deletions.
2 changes: 1 addition & 1 deletion src/Language/Fortran/AST.hs
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ data FlushSpec a =
deriving (Eq, Show, Data, Typeable, Generic, Functor)

data DoSpecification a =
DoSpecification a SrcSpan (Statement a) (Expression a) (Maybe (Expression a))
DoSpecification a SrcSpan (Expression a) (Expression a) (Expression a) (Maybe (Expression a))
deriving (Eq, Show, Data, Typeable, Generic, Functor)

data Expression a =
Expand Down
20 changes: 15 additions & 5 deletions src/Language/Fortran/Analysis.hs
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ lhsExprs x = concatMap lhsOfStmt (universeBi x)
lhsOfStmt (StExpressionAssign _ _ e e') = e : onExprs e'
lhsOfStmt (StCall _ _ _ (Just aexps)) = filter isLExpr argExps ++ concatMap onExprs argExps
where argExps = map argExtractExpr . aStrip $ aexps
lhsOfStmt (StDo _ _ _ _ (Just dospec)) = lhsOfStmt $ dospecAsStmt dospec
lhsOfStmt s = onExprs s

onExprs :: (Data a, Data (c a)) => c a -> [Expression a]
Expand Down Expand Up @@ -285,10 +286,17 @@ allLhsVars :: Data a => Block (Analysis a) -> [Name]
allLhsVars = allLhsVarsAnn . getAnnotation

allLhsVarsDoSpec :: Data a => DoSpecification (Analysis a) -> [Name]
allLhsVarsDoSpec = computeAllLhsVars
allLhsVarsDoSpec = computeAllLhsVars . dospecAsStmt

dospecAsStmt :: DoSpecification a -> Statement a
dospecAsStmt (DoSpecification a ss lhs rhs _e1 _me2) =
StExpressionAssign a ss lhs rhs

-- | Set of names found in the parts of an AST that are the target of
-- an assignment statement.
--
-- TODO now that dospecs don't store a Statement explicitly, they won't get
-- caught here. urgh
computeAllLhsVars :: forall a b . (Data a, Data (b (Analysis a))) => b (Analysis a) -> [Name]
computeAllLhsVars = concatMap lhsOfStmt . universeBi
where
Expand All @@ -298,6 +306,7 @@ computeAllLhsVars = concatMap lhsOfStmt . universeBi
lhsOfStmt (StCall _ _ f@(ExpValue _ _ (ValIntrinsic _)) _)
| Just defs <- intrinsicDefs f = defs
lhsOfStmt (StCall _ _ _ (Just aexps)) = concatMap (match'' . argExtractExpr) (aStrip aexps)
lhsOfStmt (StDo _ _ _ _ (Just dospec)) = lhsOfStmt $ dospecAsStmt dospec
lhsOfStmt s = onExprs s

lhsOfDecls (Declarator _ _ e _ _ (Just e')) = match' e : onExprs e'
Expand All @@ -308,6 +317,7 @@ computeAllLhsVars = concatMap lhsOfStmt . universeBi

lhsOfExp :: Expression (Analysis a) -> [Name]
lhsOfExp (ExpFunctionCall _ _ _ (Just aexps)) = concatMap (match . argExtractExpr) (aStrip aexps)
-- TODO do I need to handle ExpImpliedDo here? (shouldn't do, right)
lhsOfExp _ = []

-- Match and give the varname for LHS of statement
Expand All @@ -331,7 +341,7 @@ computeAllLhsVars = concatMap lhsOfStmt . universeBi
-- | Set of expressions used -- not defined -- by an AST-block.
blockRhsExprs :: Data a => Block a -> [Expression a]
blockRhsExprs (BlStatement _ _ _ s) = statementRhsExprs s
blockRhsExprs (BlDo _ _ _ _ _ (Just (DoSpecification _ _ (StExpressionAssign _ _ lhs rhs) e1 e2)) _ _)
blockRhsExprs (BlDo _ _ _ _ _ (Just (DoSpecification _ _ lhs rhs e1 e2)) _ _)
| ExpSubscript _ _ _ subs <- lhs = universeBi (rhs, e1, e2) ++ universeBi subs
| otherwise = universeBi (rhs, e1, e2)
blockRhsExprs (BlDoWhile _ _ e1 _ _ e2 _ _) = universeBi (e1, e2)
Expand All @@ -346,8 +356,8 @@ statementRhsExprs (StExpressionAssign _ _ lhs rhs)
statementRhsExprs StDeclaration{} = []
statementRhsExprs (StIfLogical _ _ _ s) = statementRhsExprs s
statementRhsExprs (StDo _ _ _ l s') = universeBi l ++ doSpecRhsExprs s'
where doSpecRhsExprs (Just (DoSpecification _ _ s e1 e2)) =
(e1 : universeBi e2) ++ statementRhsExprs s
where doSpecRhsExprs (Just dospec@(DoSpecification _ _ _lhs _rhs e1 e2)) =
(e1 : universeBi e2) ++ statementRhsExprs (dospecAsStmt dospec)
doSpecRhsExprs Nothing = []
statementRhsExprs s = universeBi s

Expand All @@ -356,7 +366,7 @@ blockVarUses :: forall a. Data a => Block (Analysis a) -> [Name]
blockVarUses (BlStatement _ _ _ (StExpressionAssign _ _ lhs rhs))
| ExpSubscript _ _ _ subs <- lhs = allVars rhs ++ concatMap allVars (aStrip subs)
| otherwise = allVars rhs
blockVarUses (BlDo _ _ _ _ _ (Just (DoSpecification _ _ (StExpressionAssign _ _ lhs rhs) e1 e2)) _ _)
blockVarUses (BlDo _ _ _ _ _ (Just (DoSpecification _ _ lhs rhs e1 e2)) _ _)
| ExpSubscript _ _ _ subs <- lhs = allVars rhs ++ allVars e1 ++ maybe [] allVars e2 ++ concatMap allVars (aStrip subs)
| otherwise = allVars rhs ++ allVars e1 ++ maybe [] allVars e2
blockVarUses (BlStatement _ _ _ st@StDeclaration{}) = concat [ rhsOfDecls d | d <- universeBi st ]
Expand Down
4 changes: 2 additions & 2 deletions src/Language/Fortran/Analysis/BBlocks.hs
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ perBlock b@(BlStatement _ _ _ StIfArithmetic{}) =
-- Treat an arithmetic if similarly to a goto
processLabel b >> addToBBlock b >> closeBBlock_
perBlock b@(BlDo _ _ _ _ _ (Just spec) bs _) = do
let DoSpecification _ _ (StExpressionAssign _ _ _ e1) e2 me3 = spec
let DoSpecification _ _ _ e1 e2 me3 = spec
_ <- processFunctionCalls e1
_ <- processFunctionCalls e2
_ <- case me3 of Just e3 -> Just `fmap` processFunctionCalls e3; Nothing -> return Nothing
Expand Down Expand Up @@ -791,7 +791,7 @@ showBlock (BlDo _ _ mlab _ _ (Just spec) _ _) =
showExpr e2 ++ ", " ++
showExpr e3 ++ ", " ++
maybe "1" showExpr me4 ++ "\\l"
where DoSpecification _ _ (StExpressionAssign _ _ e1 e2) e3 me4 = spec
where DoSpecification _ _ e1 e2 e3 me4 = spec
showBlock (BlDo _ _ _ _ _ Nothing _ _) = "do"
showBlock (BlComment{}) = ""
showBlock b = "<unhandled block: " ++ show (toConstr (fmap (const ()) b)) ++ ">"
Expand Down
8 changes: 4 additions & 4 deletions src/Language/Fortran/Parser/Fixed/Fortran66.y
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,10 @@ DO_STATEMENT :: { Statement A0 }
{ StDo () (getTransSpan $1 $3) Nothing (Just $2) (Just $3) }

DO_SPECIFICATION :: { DoSpecification A0 }
: EXPRESSION_ASSIGNMENT_STATEMENT ',' INT_OR_VAR ',' INT_OR_VAR
{ DoSpecification () (getTransSpan $1 $5) $1 $3 (Just $5) }
| EXPRESSION_ASSIGNMENT_STATEMENT ',' INT_OR_VAR
{ DoSpecification () (getTransSpan $1 $3) $1 $3 Nothing }
: ELEMENT '=' EXPRESSION ',' INT_OR_VAR ',' INT_OR_VAR
{ DoSpecification () (getTransSpan $1 $7) $1 $3 $5 (Just $7) }
| ELEMENT '=' EXPRESSION ',' INT_OR_VAR
{ DoSpecification () (getTransSpan $1 $5) $1 $3 $5 Nothing }

INT_OR_VAR :: { Expression A0 }
: INTEGER_LITERAL { $1 }
Expand Down
6 changes: 4 additions & 2 deletions src/Language/Fortran/Parser/Fixed/Fortran77.y
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,10 @@ DO_STATEMENT :: { Statement A0 }
| do { StDo () (getSpan $1) Nothing Nothing Nothing }

DO_SPECIFICATION :: { DoSpecification A0 }
: EXPRESSION_ASSIGNMENT_STATEMENT ',' EXPRESSION ',' EXPRESSION { DoSpecification () (getTransSpan $1 $5) $1 $3 (Just $5) }
| EXPRESSION_ASSIGNMENT_STATEMENT ',' EXPRESSION { DoSpecification () (getTransSpan $1 $3) $1 $3 Nothing }
: ELEMENT '=' EXPRESSION ',' EXPRESSION ',' EXPRESSION
{ DoSpecification () (getTransSpan $1 $7) $1 $3 $5 (Just $7) }
| ELEMENT '=' EXPRESSION ',' EXPRESSION
{ DoSpecification () (getTransSpan $1 $5) $1 $3 $5 Nothing }

EXECUTABLE_STATEMENT :: { Statement A0 }
: EXPRESSION_ASSIGNMENT_STATEMENT { $1 }
Expand Down
8 changes: 4 additions & 4 deletions src/Language/Fortran/Parser/Free/Fortran2003.y
Original file line number Diff line number Diff line change
Expand Up @@ -1287,10 +1287,10 @@ RANGE :: { Index A0 }
{ IxRange () (getTransSpan $1 $3) (Just $1) (Just $3) Nothing }

DO_SPECIFICATION :: { DoSpecification A0 }
: EXPRESSION_ASSIGNMENT_STATEMENT ',' EXPRESSION ',' EXPRESSION
{ DoSpecification () (getTransSpan $1 $5) $1 $3 (Just $5) }
| EXPRESSION_ASSIGNMENT_STATEMENT ',' EXPRESSION
{ DoSpecification () (getTransSpan $1 $3) $1 $3 Nothing }
: DATA_REF '=' EXPRESSION ',' EXPRESSION ',' EXPRESSION
{ DoSpecification () (getTransSpan $1 $7) $1 $3 $5 (Just $7) }
| DATA_REF '=' EXPRESSION ',' EXPRESSION
{ DoSpecification () (getTransSpan $1 $5) $1 $3 $5 Nothing }

IMPLIED_DO :: { Expression A0 }
: '(' EXPRESSION ',' DO_SPECIFICATION ')'
Expand Down
8 changes: 4 additions & 4 deletions src/Language/Fortran/Parser/Free/Fortran90.y
Original file line number Diff line number Diff line change
Expand Up @@ -1079,10 +1079,10 @@ RANGE :: { Index A0 }
{ IxRange () (getTransSpan $1 $3) (Just $1) (Just $3) Nothing }

DO_SPECIFICATION :: { DoSpecification A0 }
: EXPRESSION_ASSIGNMENT_STATEMENT ',' EXPRESSION ',' EXPRESSION
{ DoSpecification () (getTransSpan $1 $5) $1 $3 (Just $5) }
| EXPRESSION_ASSIGNMENT_STATEMENT ',' EXPRESSION
{ DoSpecification () (getTransSpan $1 $3) $1 $3 Nothing }
: DATA_REF '=' EXPRESSION ',' EXPRESSION ',' EXPRESSION
{ DoSpecification () (getTransSpan $1 $7) $1 $3 $5 (Just $7) }
| DATA_REF '=' EXPRESSION ',' EXPRESSION
{ DoSpecification () (getTransSpan $1 $5) $1 $3 $5 Nothing }

IMPLIED_DO :: { Expression A0 }
: '(' EXPRESSION ',' DO_SPECIFICATION ')'
Expand Down
8 changes: 4 additions & 4 deletions src/Language/Fortran/Parser/Free/Fortran95.y
Original file line number Diff line number Diff line change
Expand Up @@ -1094,10 +1094,10 @@ RANGE :: { Index A0 }
{ IxRange () (getTransSpan $1 $3) (Just $1) (Just $3) Nothing }

DO_SPECIFICATION :: { DoSpecification A0 }
: EXPRESSION_ASSIGNMENT_STATEMENT ',' EXPRESSION ',' EXPRESSION
{ DoSpecification () (getTransSpan $1 $5) $1 $3 (Just $5) }
| EXPRESSION_ASSIGNMENT_STATEMENT ',' EXPRESSION
{ DoSpecification () (getTransSpan $1 $3) $1 $3 Nothing }
: DATA_REF '=' EXPRESSION ',' EXPRESSION ',' EXPRESSION
{ DoSpecification () (getTransSpan $1 $7) $1 $3 $5 (Just $7) }
| DATA_REF '=' EXPRESSION ',' EXPRESSION
{ DoSpecification () (getTransSpan $1 $5) $1 $3 $5 Nothing }

IMPLIED_DO :: { Expression A0 }
: '(' EXPRESSION ',' DO_SPECIFICATION ')'
Expand Down
11 changes: 3 additions & 8 deletions src/Language/Fortran/PrettyPrint.hs
Original file line number Diff line number Diff line change
Expand Up @@ -870,16 +870,11 @@ instance Pretty (FlushSpec a) where
pprint' v (FSErr _ _ e) = "err=" <> pprint' v e

instance Pretty (DoSpecification a) where
pprint' v (DoSpecification _ _ s@StExpressionAssign{} limit mStride) =
pprint' v s <> comma
<+> pprint' v limit
pprint' v (DoSpecification _ _ lhs rhs limit mStride) =
(pprint' v lhs <+> equals <+> pprint' v rhs)
<> comma <+> pprint' v limit
<> comma <?+> pprint' v mStride

-- Given DoSpec. has a single constructor, the only way for pattern
-- match above to fail is to have the wrong type of statement embedded
-- in it.
pprint' _ _ = error "Incorrect initialisation in DO specification."

instance Pretty (ControlPair a) where
pprint' v (ControlPair _ _ mStr exp)
| v >= Fortran77
Expand Down
3 changes: 1 addition & 2 deletions test/Language/Fortran/Parser/Fixed/Fortran66Spec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ spec =
sParser " f = a(1,2)" `shouldBe'` expectedSt

it "parses 'do 42 i = 10, 1, 1'" $ do
let st = StExpressionAssign () u (varGen "i") (intGen 10)
let doSpec = DoSpecification () u st (intGen 1) (Just $ intGen 1)
let doSpec = DoSpecification () u (varGen "i") (intGen 10) (intGen 1) (Just $ intGen 1)
let expectedSt = StDo () u Nothing (Just $ labelGen 42) (Just doSpec)
sParser " do 42 i = 10, 1, 1" `shouldBe'` expectedSt
6 changes: 2 additions & 4 deletions test/Language/Fortran/Parser/Fixed/Fortran77/ParserSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,15 @@ spec =
sParser " endfile i" `shouldBe'` StEndfile2 () u (varGen "i")

it "parses 'read *, (x, y(i), i = 1, 10, 2)'" $ do
let stAssign = StExpressionAssign () u (varGen "i") (intGen 1)
doSpec = DoSpecification () u stAssign (intGen 10) (Just $ intGen 2)
let doSpec = DoSpecification () u (varGen "i") (intGen 1) (intGen 10) (Just $ intGen 2)
impliedDoVars = AList () u [ varGen "x", ExpSubscript () u (varGen "y") (AList () u [ IxSingle () u Nothing $ varGen "i" ])]
impliedDo = ExpImpliedDo () u impliedDoVars doSpec
iolist = AList () u [ impliedDo ]
expectedSt = StRead2 () u starVal (Just iolist)
sParser " read *, (x, y(i), i = 1, 10, 2)" `shouldBe'` expectedSt

it "parses '(x, y(i), i = 1, 10, 2)'" $ do
let stAssign = StExpressionAssign () u (varGen "i") (intGen 1)
doSpec = DoSpecification () u stAssign (intGen 10) (Just $ intGen 2)
let doSpec = DoSpecification () u (varGen "i") (intGen 1) (intGen 10) (Just $ intGen 2)
impliedDoVars = AList () u [ varGen "x", ExpSubscript () u (varGen "y") (AList () u [ IxSingle () u Nothing $ varGen "i" ])]
impliedDo = ExpImpliedDo () u impliedDoVars doSpec
eParser "(x, y(i), i = 1, 10, 2)" `shouldBe'` impliedDo
Expand Down
44 changes: 44 additions & 0 deletions test/Language/Fortran/Parser/Free/Common.hs
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,47 @@ specFreeCommon sParser eParser =
, genArg (ArgExpr (varGen "i")) ]
genArg = Argument () u Nothing
sParser stStr `shouldBe'` expected

describe "Do" $ do
it "parses do statement with label" $ do
let doSpec = DoSpecification () u (varGen "i") (intGen 0) (intGen 42) Nothing
st = StDo () u Nothing (Just $ intGen 24) (Just doSpec)
sParser "do 24, i = 0, 42" `shouldBe'` st

it "parses do statement without label" $ do
let doSpec = DoSpecification () u (varGen "i") (intGen 0) (intGen 42) Nothing
st = StDo () u Nothing Nothing (Just doSpec)
sParser "do i = 0, 42" `shouldBe'` st

it "parses infinite do" $ do
let st = StDo () u Nothing Nothing Nothing
sParser "do" `shouldBe'` st

it "parses end do statement" $ do
let st = StEnddo () u (Just "constructor")
sParser "end do constructor" `shouldBe'` st

describe "DO WHILE" $ do
it "parses unnamed do while statement" $ do
let st = StDoWhile () u Nothing Nothing valTrue
sParser "do while (.true.)" `shouldBe'` st

it "parses named do while statement" $ do
let st = StDoWhile () u (Just "name") Nothing valTrue
sParser "name: do while (.true.)" `shouldBe'` st

it "parses unnamed labelled do while statement" $ do
let st = StDoWhile () u Nothing (Just (intGen 999)) valTrue
sParser "do 999 while (.true.)" `shouldBe'` st

describe "Expression" $ do
describe "Implied DO loop" $ do
it "parses write with implied do" $ do
let cp1 = ControlPair () u Nothing (intGen 10)
cp2 = ControlPair () u (Just "format") (varGen "x")
ciList = fromList () [ cp1, cp2 ]
doSpec = DoSpecification () u (varGen "i") (intGen 1) (intGen 42) (Just $ intGen 2)
alist = fromList () [ varGen "i", varGen "j" ]
outList = fromList () [ ExpImpliedDo () u alist doSpec ]
st = StWrite () u ciList (Just outList)
sParser "write (10, FORMAT = x) (i, j, i = 1, 42, 2)" `shouldBe'` st
37 changes: 1 addition & 36 deletions test/Language/Fortran/Parser/Free/Fortran90Spec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -493,40 +493,6 @@ spec =
(Just $ intGen 80)
bParser src `shouldBe'` block

describe "Do" $ do
it "parses do statement with label" $ do
let assign = StExpressionAssign () u (varGen "i") (intGen 0)
doSpec = DoSpecification () u assign (intGen 42) Nothing
st = StDo () u Nothing (Just $ intGen 24) (Just doSpec)
sParser "do 24, i = 0, 42" `shouldBe'` st

it "parses do statement without label" $ do
let assign = StExpressionAssign () u (varGen "i") (intGen 0)
doSpec = DoSpecification () u assign (intGen 42) Nothing
st = StDo () u Nothing Nothing (Just doSpec)
sParser "do i = 0, 42" `shouldBe'` st

it "parses infinite do" $ do
let st = StDo () u Nothing Nothing Nothing
sParser "do" `shouldBe'` st

it "parses end do statement" $ do
let st = StEnddo () u (Just "constructor")
sParser "end do constructor" `shouldBe'` st

describe "DO WHILE" $ do
it "parses unnamed do while statement" $ do
let st = StDoWhile () u Nothing Nothing valTrue
sParser "do while (.true.)" `shouldBe'` st

it "parses named do while statement" $ do
let st = StDoWhile () u (Just "name") Nothing valTrue
sParser "name: do while (.true.)" `shouldBe'` st

it "parses unnamed labelled do while statement" $ do
let st = StDoWhile () u Nothing (Just (intGen 999)) valTrue
sParser "do 999 while (.true.)" `shouldBe'` st

describe "Goto" $ do
it "parses vanilla goto" $ do
let st = StGotoUnconditional () u (intGen 999)
Expand Down Expand Up @@ -555,8 +521,7 @@ spec =
let cp1 = ControlPair () u Nothing (intGen 10)
cp2 = ControlPair () u (Just "format") (varGen "x")
ciList = fromList () [ cp1, cp2 ]
assign = StExpressionAssign () u (varGen "i") (intGen 1)
doSpec = DoSpecification () u assign (intGen 42) (Just $ intGen 2)
doSpec = DoSpecification () u (varGen "i") (intGen 1) (intGen 42) (Just $ intGen 2)
alist = fromList () [ varGen "i", varGen "j" ]
outList = fromList () [ ExpImpliedDo () u alist doSpec ]
st = StWrite () u ciList (Just outList)
Expand Down
37 changes: 1 addition & 36 deletions test/Language/Fortran/Parser/Free/Fortran95Spec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -548,40 +548,6 @@ spec =
(Just $ intGen 80)
bParser src `shouldBe'` block

describe "Do" $ do
it "parses do statement with label" $ do
let assign = StExpressionAssign () u (varGen "i") (intGen 0)
doSpec = DoSpecification () u assign (intGen 42) Nothing
st = StDo () u Nothing (Just $ intGen 24) (Just doSpec)
sParser "do 24, i = 0, 42" `shouldBe'` st

it "parses do statement without label" $ do
let assign = StExpressionAssign () u (varGen "i") (intGen 0)
doSpec = DoSpecification () u assign (intGen 42) Nothing
st = StDo () u Nothing Nothing (Just doSpec)
sParser "do i = 0, 42" `shouldBe'` st

it "parses infinite do" $ do
let st = StDo () u Nothing Nothing Nothing
sParser "do" `shouldBe'` st

it "parses end do statement" $ do
let st = StEnddo () u (Just "constructor")
sParser "end do constructor" `shouldBe'` st

describe "DO WHILE" $ do
it "parses unnamed do while statement" $ do
let st = StDoWhile () u Nothing Nothing valTrue
sParser "do while (.true.)" `shouldBe'` st

it "parses named do while statement" $ do
let st = StDoWhile () u (Just "name") Nothing valTrue
sParser "name: do while (.true.)" `shouldBe'` st

it "parses unnamed labelled do while statement" $ do
let st = StDoWhile () u Nothing (Just (intGen 999)) valTrue
sParser "do 999 while (.true.)" `shouldBe'` st

describe "Goto" $ do
it "parses vanilla goto" $ do
let st = StGotoUnconditional () u (intGen 999)
Expand All @@ -607,8 +573,7 @@ spec =
let cp1 = ControlPair () u Nothing (intGen 10)
cp2 = ControlPair () u (Just "format") (varGen "x")
ciList = fromList () [ cp1, cp2 ]
assign = StExpressionAssign () u (varGen "i") (intGen 1)
doSpec = DoSpecification () u assign (intGen 42) (Just $ intGen 2)
doSpec = DoSpecification () u (varGen "i") (intGen 1) (intGen 42) (Just $ intGen 2)
alist = fromList () [ varGen "i", varGen "j" ]
outList = fromList () [ ExpImpliedDo () u alist doSpec ]
st = StWrite () u ciList (Just outList)
Expand Down
6 changes: 2 additions & 4 deletions test/Language/Fortran/PrettyPrintSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,7 @@ spec =
let stDo = StDo () u Nothing Nothing Nothing
pprint Fortran90 stDo Nothing `shouldBe` "do"

let doInit = StExpressionAssign () u (varGen "i") (intGen (-1))
let doSpec = DoSpecification () u doInit (intGen 5) Nothing
let doSpec = DoSpecification () u (varGen "i") (intGen (-1)) (intGen 5) Nothing

it "prints labeled do" $ do
let stDo = StDo () u Nothing (Just $ intGen 42) (Just doSpec)
Expand Down Expand Up @@ -338,8 +337,7 @@ spec =
pprint Fortran90 bl Nothing `shouldBe` text expect

describe "Do" $ do
let iAssign = StExpressionAssign () u (varGen "i") (intGen 1)
let doSpec = DoSpecification () u iAssign (intGen 9) (Just (intGen 2))
let doSpec = DoSpecification () u (varGen "i") (intGen 1) (intGen 9) (Just (intGen 2))

it "prints 90 style do loop" $ do
let bl = BlDo () u Nothing Nothing Nothing (Just doSpec) body Nothing
Expand Down
Loading

0 comments on commit e2a4ebe

Please sign in to comment.