summaryrefslogtreecommitdiff
path: root/src/Parser
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2024-09-28 19:53:42 +0200
committerRoman Smrž <roman.smrz@seznam.cz>2024-09-28 20:08:00 +0200
commit9b947899eea2852e9855fa30595e7a3176b70875 (patch)
tree5af0eb8659c9c6694126e2ad5b30a21b6458dd7c /src/Parser
parentf91ff15b9551cd0d325dbd03f066d48dfd70ed25 (diff)
Optional arguments and "flush" as a builtin
Diffstat (limited to 'src/Parser')
-rw-r--r--src/Parser/Core.hs9
-rw-r--r--src/Parser/Statement.hs6
2 files changed, 5 insertions, 10 deletions
diff --git a/src/Parser/Core.hs b/src/Parser/Core.hs
index f40889a..cb66529 100644
--- a/src/Parser/Core.hs
+++ b/src/Parser/Core.hs
@@ -139,13 +139,14 @@ unifyExpr off pa expr = if
showType ( Just (ArgumentKeyword kw), SomeArgumentType atype ) = "`" <> kw <> " <" <> textExprType atype <> ">'"
err = parseError . FancyError off . S.singleton . ErrorFail . T.unpack
- defaults <- forM (M.toAscList remaining) $ \case
- arg@(_, SomeArgumentType NoDefault) -> err $ "missing " <> showType arg <> " argument"
- (kw, SomeArgumentType (ExprDefault def)) -> return (kw, SomeExpr def)
+ defaults <- fmap catMaybes $ forM (M.toAscList remaining) $ \case
+ arg@(_, SomeArgumentType RequiredArgument) -> err $ "missing " <> showType arg <> " argument"
+ (_, SomeArgumentType OptionalArgument) -> return Nothing
+ (kw, SomeArgumentType (ExprDefault def)) -> return $ Just ( kw, SomeExpr def )
(kw, SomeArgumentType atype@ContextDefault) -> do
SomeExpr context <- gets testContext
context' <- unifyExpr off atype context
- return (kw, SomeExpr context')
+ return $ Just ( kw, SomeExpr context' )
return (FunctionEval $ ArgsApp (FunctionArguments $ M.fromAscList defaults) expr)
| Just (Refl :: DynamicType :~: b) <- eqT
diff --git a/src/Parser/Statement.hs b/src/Parser/Statement.hs
index 67ffd76..c7cdf5a 100644
--- a/src/Parser/Statement.hs
+++ b/src/Parser/Statement.hs
@@ -320,11 +320,6 @@ testExpect = command "expect" $ Expect
<*> param "capture"
<*> innerBlock
-testFlush :: TestParser [TestStep]
-testFlush = command "flush" $ Flush
- <$> paramOrContext "from"
- <*> param ""
-
testDisconnectNode :: TestParser [TestStep]
testDisconnectNode = command "disconnect_node" $ DisconnectNode
<$> paramOrContext ""
@@ -372,7 +367,6 @@ testStep = choice
, testNode
, testSpawn
, testExpect
- , testFlush
, testDisconnectNode
, testDisconnectNodes
, testDisconnectUpstream