summaryrefslogtreecommitdiff
path: root/src/Main.hs
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2023-02-20 19:50:36 +0100
committerRoman Smrž <roman.smrz@seznam.cz>2023-02-20 19:50:36 +0100
commit82e4bdcaaefa88913a0dacf3496747251909219f (patch)
treeb649928867f520681491b3488a17a8f52f681550 /src/Main.hs
parentf8c6706d5eefb8e4ebcdee7c963e8fe22fd9efab (diff)
For statement
Diffstat (limited to 'src/Main.hs')
-rw-r--r--src/Main.hs11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/Main.hs b/src/Main.hs
index 81fb04f..404ecec 100644
--- a/src/Main.hs
+++ b/src/Main.hs
@@ -172,7 +172,7 @@ testStepGuard sline expr = do
evalSteps :: [TestStep] -> TestRun ()
evalSteps = mapM_ $ \case
- Let (SourceLine sline) name expr inner -> do
+ Let (SourceLine sline) (TypedVarName name) expr inner -> do
cur <- asks (lookup name . tsVars . snd)
when (isJust cur) $ do
outLine OutputError Nothing $ T.pack "variable '" `T.append` textVarName name `T.append` T.pack "' already exists on " `T.append` sline
@@ -180,6 +180,15 @@ evalSteps = mapM_ $ \case
value <- eval expr
withVar name value $ evalSteps inner
+ For (SourceLine sline) (TypedVarName name) expr inner -> do
+ cur <- asks (lookup name . tsVars . snd)
+ when (isJust cur) $ do
+ outLine OutputError Nothing $ T.pack "variable '" `T.append` textVarName name `T.append` T.pack "' already exists on " `T.append` sline
+ throwError Failed
+ value <- eval expr
+ forM_ value $ \i -> do
+ withVar name i $ evalSteps inner
+
DeclNode name@(TypedVarName vname) net inner -> do
createNode net (Left name) $ \node -> do
withVar vname node $ evalSteps inner